This commit is contained in:
Igor Timofeev 2018-05-21 03:30:55 +03:00
parent 67d38da1ce
commit 3846eddc61
3 changed files with 552 additions and 599 deletions

View File

@ -1244,9 +1244,7 @@ local function toggleTopToolBar()
calculateSizes() calculateSizes()
end end
local function createEditOrRightClickMenu(x, y) local function createEditOrRightClickMenu(menu)
local menu = GUI.addContextMenu(mainContainer, x, y)
menu:addItem(localization.cut, not codeView.selections[1], "^X").onTouch = function() menu:addItem(localization.cut, not codeView.selections[1], "^X").onTouch = function()
cut() cut()
end end
@ -1311,14 +1309,12 @@ local function createEditOrRightClickMenu(x, y)
menu:addItem(localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function() menu:addItem(localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function()
clearBreakpoints() clearBreakpoints()
end end
mainContainer:drawOnScreen()
end end
codeView.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) codeView.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
if e1 == "touch" then if e1 == "touch" then
if e5 == 1 then if e5 == 1 then
createEditOrRightClickMenu(e3, e4) createEditOrRightClickMenu(GUI.addContextMenu(mainContainer, e3, e4))
else else
setCursorPositionAndClearSelection(convertScreenCoordinatesToTextPosition(e3, e4)) setCursorPositionAndClearSelection(convertScreenCoordinatesToTextPosition(e3, e4))
end end
@ -1531,206 +1527,180 @@ leftTreeView.onItemSelected = function(path)
mainContainer:drawOnScreen() mainContainer:drawOnScreen()
end end
local topMenuMineCode = topMenu:addItem("MineCode", 0x0) local MineCodeContextMenu = topMenu:addContextMenu("MineCode", 0x0)
topMenuMineCode.onTouch = function() MineCodeContextMenu:addItem(localization.about).onTouch = function()
local menu = GUI.addContextMenu(mainContainer, topMenuMineCode.x, topMenuMineCode.y + 1) local container = addBackgroundContainer(localization.about)
menu:addItem(localization.about).onTouch = function() local about = {
local container = addBackgroundContainer(localization.about) "MineCode IDE",
"Copyright © 2014-2018 ECS Inc.",
" ",
"Developers:",
" ",
"Timofeev Igor, vk.com/id7799889",
"Trifonov Gleb, vk.com/id88323331",
" ",
"Testers:",
" ",
"Semyonov Semyon, vk.com/id92656626",
"Prosin Mihail, vk.com/id75667079",
"Shestakov Timofey, vk.com/id113499693",
"Bogushevich Victoria, vk.com/id171497518",
"Vitvitskaya Yana, vk.com/id183425349",
"Golovanova Polina, vk.com/id226251826",
}
local about = { local textBox = container.layout:addChild(GUI.textBox(1, 1, 36, #about, nil, 0xB4B4B4, about, 1, 0, 0, true, false))
"MineCode IDE", textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
"Copyright © 2014-2018 ECS Inc.", textBox.eventHandler = nil
" ",
"Developers:",
" ",
"Timofeev Igor, vk.com/id7799889",
"Trifonov Gleb, vk.com/id88323331",
" ",
"Testers:",
" ",
"Semyonov Semyon, vk.com/id92656626",
"Prosin Mihail, vk.com/id75667079",
"Shestakov Timofey, vk.com/id113499693",
"Bogushevich Victoria, vk.com/id171497518",
"Vitvitskaya Yana, vk.com/id183425349",
"Golovanova Polina, vk.com/id226251826",
}
local textBox = container.layout:addChild(GUI.textBox(1, 1, 36, #about, nil, 0xB4B4B4, about, 1, 0, 0, true, false))
textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
textBox.eventHandler = nil
mainContainer:drawOnScreen()
end
menu:addItem(localization.quit, false, "^W").onTouch = function()
mainContainer:stopEventHandling()
end
mainContainer:drawOnScreen() mainContainer:drawOnScreen()
end end
local topMenuFile = topMenu:addItem(localization.file) MineCodeContextMenu:addItem(localization.quit, false, "^W").onTouch = function()
topMenuFile.onTouch = function() mainContainer:stopEventHandling()
local menu = GUI.addContextMenu(mainContainer, topMenuFile.x, topMenuFile.y + 1) end
menu:addItem(localization.new, false, "^N").onTouch = function()
newFile()
mainContainer:drawOnScreen()
end
menu:addItem(localization.open, false, "^O").onTouch = function()
openFileWindow()
end
if component.isAvailable("internet") then
menu:addItem(localization.getFromWeb, false, "^U").onTouch = function()
downloadFileFromWeb()
end
end
menu:addSeparator()
menu:addItem(localization.save, not leftTreeView.selectedItem, "^S").onTouch = function()
saveFileWindow()
end
menu:addItem(localization.saveAs, false, "^⇧S").onTouch = function()
saveFileAsWindow()
end
menu:addItem(localization.launchWithArguments, false, "^F5").onTouch = function()
launchWithArgumentsWindow()
end
local fileContextMenu = topMenu:addContextMenu(localization.file)
fileContextMenu:addItem(localization.new, false, "^N").onTouch = function()
newFile()
mainContainer:drawOnScreen() mainContainer:drawOnScreen()
end end
local topMenuEdit = topMenu:addItem(localization.edit) fileContextMenu:addItem(localization.open, false, "^O").onTouch = function()
topMenuEdit.onTouch = function() openFileWindow()
createEditOrRightClickMenu(topMenuEdit.x, topMenuEdit.y + 1)
end end
local topMenuGoto = topMenu:addItem(localization.gotoCyka) if component.isAvailable("internet") then
topMenuGoto.onTouch = function() fileContextMenu:addItem(localization.getFromWeb, false, "^U").onTouch = function()
local menu = GUI.addContextMenu(mainContainer, topMenuGoto.x, topMenuGoto.y + 1) downloadFileFromWeb()
menu:addItem(localization.pageUp, false, "PgUp").onTouch = function()
pageUp()
end end
menu:addItem(localization.pageDown, false, "PgDn").onTouch = function()
pageDown()
end
menu:addItem(localization.gotoStart, false, "Home").onTouch = function()
setCursorPositionToHome()
end
menu:addItem(localization.gotoEnd, false, "End").onTouch = function()
setCursorPositionToEnd()
end
menu:addSeparator()
menu:addItem(localization.gotoLine, false, "^L").onTouch = function()
gotoLineWindow()
end
mainContainer:drawOnScreen()
end end
local topMenuProperties = topMenu:addItem(localization.properties) fileContextMenu:addSeparator()
topMenuProperties.onTouch = function()
local menu = GUI.addContextMenu(mainContainer, topMenuProperties.x, topMenuProperties.y + 1)
menu:addItem(localization.colorScheme).onTouch = function() fileContextMenu:addItem(localization.save, not leftTreeView.selectedItem, "^S").onTouch = function()
local container = GUI.addBackgroundContainer(mainContainer, true, false, localization.colorScheme) saveFileWindow()
end
local colorSelectorsCount, colorSelectorCountX = 0, 4; for key in pairs(config.syntaxColorScheme) do colorSelectorsCount = colorSelectorsCount + 1 end fileContextMenu:addItem(localization.saveAs, false, "^⇧S").onTouch = function()
local colorSelectorCountY = math.ceil(colorSelectorsCount / colorSelectorCountX) saveFileAsWindow()
local colorSelectorWidth, colorSelectorHeight, colorSelectorSpaceX, colorSelectorSpaceY = math.floor(container.width / colorSelectorCountX * 0.8), 3, 2, 1 end
local startX, y = math.floor(container.width / 2 - (colorSelectorCountX * (colorSelectorWidth + colorSelectorSpaceX) - colorSelectorSpaceX) / 2), math.floor(container.height / 2 - (colorSelectorCountY * (colorSelectorHeight + colorSelectorSpaceY) - colorSelectorSpaceY + 3) / 2) fileContextMenu:addItem(localization.launchWithArguments, false, "^F5").onTouch = function()
container:addChild(GUI.label(1, y, container.width, 1, 0xFFFFFF, localization.colorScheme)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 3 launchWithArgumentsWindow()
local x, counter = startX, 1 end
local colors = {} local topMenuEdit = topMenu:addContextMenu(localization.edit)
for key in pairs(config.syntaxColorScheme) do createEditOrRightClickMenu(topMenuEdit)
table.insert(colors, {key})
end
aplhabeticalSort(colors) local gotoContextMenu = topMenu:addContextMenu(localization.gotoCyka)
gotoContextMenu:addItem(localization.pageUp, false, "PgUp").onTouch = function()
pageUp()
end
for i = 1, #colors do gotoContextMenu:addItem(localization.pageDown, false, "PgDn").onTouch = function()
local colorSelector = container:addChild(GUI.colorSelector(x, y, colorSelectorWidth, colorSelectorHeight, config.syntaxColorScheme[colors[i][1]], colors[i][1])) pageDown()
colorSelector.onColorSelected = function() end
config.syntaxColorScheme[colors[i][1]] = colorSelector.color
GUI.LUA_SYNTAX_COLOR_SCHEME = config.syntaxColorScheme
saveConfig()
end
x, counter = x + colorSelectorWidth + colorSelectorSpaceX, counter + 1 gotoContextMenu:addItem(localization.gotoStart, false, "Home").onTouch = function()
if counter > colorSelectorCountX then setCursorPositionToHome()
x, y, counter = startX, y + colorSelectorHeight + colorSelectorSpaceY, 1 end
end
end
mainContainer:drawOnScreen() gotoContextMenu:addItem(localization.gotoEnd, false, "End").onTouch = function()
setCursorPositionToEnd()
end
gotoContextMenu:addSeparator()
gotoContextMenu:addItem(localization.gotoLine, false, "^L").onTouch = function()
gotoLineWindow()
end
local propertiesContextMenu = topMenu:addContextMenu(localization.properties)
propertiesContextMenu:addItem(localization.colorScheme).onTouch = function()
local container = GUI.addBackgroundContainer(mainContainer, true, false, localization.colorScheme)
local colorSelectorsCount, colorSelectorCountX = 0, 4; for key in pairs(config.syntaxColorScheme) do colorSelectorsCount = colorSelectorsCount + 1 end
local colorSelectorCountY = math.ceil(colorSelectorsCount / colorSelectorCountX)
local colorSelectorWidth, colorSelectorHeight, colorSelectorSpaceX, colorSelectorSpaceY = math.floor(container.width / colorSelectorCountX * 0.8), 3, 2, 1
local startX, y = math.floor(container.width / 2 - (colorSelectorCountX * (colorSelectorWidth + colorSelectorSpaceX) - colorSelectorSpaceX) / 2), math.floor(container.height / 2 - (colorSelectorCountY * (colorSelectorHeight + colorSelectorSpaceY) - colorSelectorSpaceY + 3) / 2)
container:addChild(GUI.label(1, y, container.width, 1, 0xFFFFFF, localization.colorScheme)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 3
local x, counter = startX, 1
local colors = {}
for key in pairs(config.syntaxColorScheme) do
table.insert(colors, {key})
end end
menu:addItem(localization.cursorProperties).onTouch = function() aplhabeticalSort(colors)
local container = addBackgroundContainer(localization.cursorProperties)
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xC3C3C3, 0x787878, 0x787878, 0xC3C3C3, 0x2D2D2D, config.cursorSymbol, localization.cursorSymbol)) for i = 1, #colors do
input.onInputFinished = function() local colorSelector = container:addChild(GUI.colorSelector(x, y, colorSelectorWidth, colorSelectorHeight, config.syntaxColorScheme[colors[i][1]], colors[i][1]))
if #input.text == 1 then
config.cursorSymbol = input.text
saveConfig()
end
end
local colorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.cursorColor, localization.cursorColor))
colorSelector.onColorSelected = function() colorSelector.onColorSelected = function()
config.cursorColor = colorSelector.color config.syntaxColorScheme[colors[i][1]] = colorSelector.color
GUI.LUA_SYNTAX_COLOR_SCHEME = config.syntaxColorScheme
saveConfig() saveConfig()
end end
local slider = container.layout:addChild(GUI.slider(1, 1, 36, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 1, 1000, config.cursorBlinkDelay * 1000, false, localization.cursorBlinkDelay .. ": ", " ms")) x, counter = x + colorSelectorWidth + colorSelectorSpaceX, counter + 1
slider.onValueChanged = function() if counter > colorSelectorCountX then
config.cursorBlinkDelay = slider.value / 1000 x, y, counter = startX, y + colorSelectorHeight + colorSelectorSpaceY, 1
end
end
mainContainer:drawOnScreen()
end
propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function()
local container = addBackgroundContainer(localization.cursorProperties)
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xC3C3C3, 0x787878, 0x787878, 0xC3C3C3, 0x2D2D2D, config.cursorSymbol, localization.cursorSymbol))
input.onInputFinished = function()
if #input.text == 1 then
config.cursorSymbol = input.text
saveConfig() saveConfig()
end end
mainContainer:drawOnScreen()
end end
if topToolBar.hidden then local colorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.cursorColor, localization.cursorColor))
menu:addItem(localization.toggleTopToolBar).onTouch = function() colorSelector.onColorSelected = function()
toggleTopToolBar() config.cursorColor = colorSelector.color
end
end
menu:addSeparator()
menu:addItem(config.syntaxHighlight and localization.disableSyntaxHighlight or localization.enableSyntaxHighlight).onTouch = function()
syntaxHighlightingButton.pressed = not syntaxHighlightingButton.pressed
syntaxHighlightingButton.onTouch()
end
menu:addItem(config.enableAutoBrackets and localization.disableAutoBrackets or localization.enableAutoBrackets, false, "^]").onTouch = function()
config.enableAutoBrackets = not config.enableAutoBrackets
saveConfig() saveConfig()
end end
menu:addItem(config.enableAutocompletion and localization.disableAutocompletion or localization.enableAutocompletion, false, "^I").onTouch = function() local slider = container.layout:addChild(GUI.slider(1, 1, 36, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 1, 1000, config.cursorBlinkDelay * 1000, false, localization.cursorBlinkDelay .. ": ", " ms"))
toggleEnableAutocompleteDatabase() slider.onValueChanged = function()
config.cursorBlinkDelay = slider.value / 1000
saveConfig()
end end
mainContainer:drawOnScreen() mainContainer:drawOnScreen()
end end
if topToolBar.hidden then
propertiesContextMenu:addItem(localization.toggleTopToolBar).onTouch = function()
toggleTopToolBar()
end
end
propertiesContextMenu:addSeparator()
propertiesContextMenu:addItem(config.syntaxHighlight and localization.disableSyntaxHighlight or localization.enableSyntaxHighlight).onTouch = function()
syntaxHighlightingButton.pressed = not syntaxHighlightingButton.pressed
syntaxHighlightingButton.onTouch()
end
propertiesContextMenu:addItem(config.enableAutoBrackets and localization.disableAutoBrackets or localization.enableAutoBrackets, false, "^]").onTouch = function()
config.enableAutoBrackets = not config.enableAutoBrackets
saveConfig()
end
propertiesContextMenu:addItem(config.enableAutocompletion and localization.disableAutocompletion or localization.enableAutocompletion, false, "^I").onTouch = function()
toggleEnableAutocompleteDatabase()
end
leftTreeViewResizer.onResize = function(dragWidth, dragHeight) leftTreeViewResizer.onResize = function(dragWidth, dragHeight)
leftTreeView.width = leftTreeView.width + dragWidth leftTreeView.width = leftTreeView.width + dragWidth
calculateSizes() calculateSizes()

View File

@ -339,93 +339,87 @@ end
mainContainer.menu:addItem("PE", 0x00B6FF) mainContainer.menu:addItem("PE", 0x00B6FF)
local fileItem = mainContainer.menu:addItem("File") local fileItem = mainContainer.menu:addContextMenu("File")
fileItem.onTouch = function() fileItem:addItem("New").onTouch = new
local menu = GUI.addContextMenu(mainContainer, fileItem.x, fileItem.y + 1)
menu:addItem("New").onTouch = new fileItem:addSeparator()
menu:addSeparator() fileItem:addItem("Open").onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Open", "Cancel", "File name", "/")
menu:addItem("Open").onTouch = function() filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Open", "Cancel", "File name", "/") filesystemDialog:addExtensionFilter(".pic")
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) filesystemDialog:expandPath(MineOSPaths.desktop)
filesystemDialog:addExtensionFilter(".pic") filesystemDialog:show()
filesystemDialog:expandPath(MineOSPaths.desktop)
filesystemDialog:show()
filesystemDialog.onSubmit = function(path)
loadImage(path)
mainContainer:drawOnScreen()
end
end
local subMenu = menu:addSubMenu("Open recent", #config.recentFiles == 0)
for i = 1, #config.recentFiles do
subMenu:addItem(string.limit(config.recentFiles[i], 32, "left")).onTouch = function()
loadImage(config.recentFiles[i])
mainContainer:drawOnScreen()
end
end
menu:addItem("Open from URL").onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Open from URL")
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x969696, 0xE1E1E1, 0x2D2D2D, "", "http://example.com/test.pic"))
input.onInputFinished = function()
if #input.text > 0 then
input:remove()
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, "Downloading file..."):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP))
mainContainer:drawOnScreen()
local temporaryPath = MineOSCore.getTemporaryPath() .. ".pic"
local result, reason = web.download(input.text, temporaryPath)
container:remove()
if result then
loadImage(temporaryPath)
fs.remove(temporaryPath)
savePath = nil
else
GUI.alert(reason)
end
mainContainer:drawOnScreen()
end
end
filesystemDialog.onSubmit = function(path)
loadImage(path)
mainContainer:drawOnScreen() mainContainer:drawOnScreen()
end end
end
menu:addSeparator() local fileItemSubMenu = fileItem:addSubMenu("Open recent", #config.recentFiles == 0)
for i = 1, #config.recentFiles do
menu:addItem("Save", not savePath).onTouch = function() fileItemSubMenu:addItem(string.limit(config.recentFiles[i], 32, "left")).onTouch = function()
saveImage(savePath) loadImage(config.recentFiles[i])
mainContainer:drawOnScreen()
end end
end
menu:addItem("Save as").onTouch = function() fileItem:addItem("Open from URL").onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Save", "Cancel", "File name", "/") local container = MineOSInterface.addBackgroundContainer(mainContainer, "Open from URL")
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".pic")
filesystemDialog:expandPath(MineOSPaths.desktop)
filesystemDialog.filesystemTree.selectedItem = MineOSPaths.desktop
filesystemDialog:show()
filesystemDialog.onSubmit = function(path) local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x969696, 0xE1E1E1, 0x2D2D2D, "", "http://example.com/test.pic"))
saveImage(path) input.onInputFinished = function()
if #input.text > 0 then
input:remove()
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, "Downloading file..."):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP))
mainContainer:drawOnScreen()
local temporaryPath = MineOSCore.getTemporaryPath() .. ".pic"
local result, reason = web.download(input.text, temporaryPath)
container:remove()
if result then
loadImage(temporaryPath)
fs.remove(temporaryPath)
savePath = nil
else
GUI.alert(reason)
end
mainContainer:drawOnScreen()
end end
end end
menu:addSeparator()
menu:addItem("Exit").onTouch = function()
mainContainer:stopEventHandling()
end
mainContainer:drawOnScreen() mainContainer:drawOnScreen()
end end
fileItem:addSeparator()
fileItem:addItem("Save", not savePath).onTouch = function()
saveImage(savePath)
end
fileItem:addItem("Save as").onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Save", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".pic")
filesystemDialog:expandPath(MineOSPaths.desktop)
filesystemDialog.filesystemTree.selectedItem = MineOSPaths.desktop
filesystemDialog:show()
filesystemDialog.onSubmit = function(path)
saveImage(path)
end
end
fileItem:addSeparator()
fileItem:addItem("Exit").onTouch = function()
mainContainer:stopEventHandling()
end
mainContainer.menu:addItem("View").onTouch = function() mainContainer.menu:addItem("View").onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "View") local container = MineOSInterface.addBackgroundContainer(mainContainer, "View")

671
OS.lua
View File

@ -512,87 +512,82 @@ local function createOSWidgets()
MineOSInterface.mainContainer.windowsContainer = MineOSInterface.mainContainer:addChild(GUI.container(1, 2, 1, 1)) MineOSInterface.mainContainer.windowsContainer = MineOSInterface.mainContainer:addChild(GUI.container(1, 2, 1, 1))
MineOSInterface.mainContainer.menu = MineOSInterface.mainContainer:addChild(GUI.menu(1, 1, MineOSInterface.mainContainer.width, MineOSCore.properties.menuColor, 0x696969, 0x3366CC, 0xFFFFFF)) MineOSInterface.mainContainer.menu = MineOSInterface.mainContainer:addChild(GUI.menu(1, 1, MineOSInterface.mainContainer.width, MineOSCore.properties.menuColor, 0x696969, 0x3366CC, 0xFFFFFF))
local item1 = MineOSInterface.mainContainer.menu:addItem("MineOS", 0x000000)
item1.onTouch = function()
local menu = MineOSInterface.addContextMenu(MineOSInterface.mainContainer, item1.x, item1.y + 1)
menu:addItem(MineOSCore.localization.aboutSystem).onTouch = function() local MineOSContextMenu = MineOSInterface.mainContainer.menu:addContextMenu("MineOS", 0x000000)
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.aboutSystem) MineOSContextMenu:addItem(MineOSCore.localization.aboutSystem).onTouch = function()
container.layout:setFitting(2, 1, false, false) local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.aboutSystem)
container.layout:removeChildren() container.layout:setFitting(2, 1, false, false)
container.layout:removeChildren()
local lines = { local lines = {
"MineOS", "MineOS",
"Copyright © 2014-" .. os.date("%Y", realTimestamp), "Copyright © 2014-" .. os.date("%Y", realTimestamp),
" ", " ",
"Developers:", "Developers:",
" ", " ",
"Igor Timofeev, vk.com/id7799889", "Igor Timofeev, vk.com/id7799889",
"Gleb Trifonov, vk.com/id88323331", "Gleb Trifonov, vk.com/id88323331",
"Yakov Verevkin, vk.com/id60991376", "Yakov Verevkin, vk.com/id60991376",
"Alexey Smirnov, vk.com/id23897419", "Alexey Smirnov, vk.com/id23897419",
"Timofey Shestakov, vk.com/id113499693", "Timofey Shestakov, vk.com/id113499693",
" ", " ",
"UX-advisers:", "UX-advisers:",
" ", " ",
"Nikita Yarichev, vk.com/id65873873", "Nikita Yarichev, vk.com/id65873873",
"Vyacheslav Sazonov, vk.com/id21321257", "Vyacheslav Sazonov, vk.com/id21321257",
"Michail Prosin, vk.com/id75667079", "Michail Prosin, vk.com/id75667079",
"Dmitrii Tiunov, vk.com/id151541414", "Dmitrii Tiunov, vk.com/id151541414",
"Egor Paliev, vk.com/id83795932", "Egor Paliev, vk.com/id83795932",
"Maxim Pakin, vk.com/id100687922", "Maxim Pakin, vk.com/id100687922",
"Andrey Kakoito, vk.com/id201043162", "Andrey Kakoito, vk.com/id201043162",
"Maxim Omelaenko, vk.com/id54662296", "Maxim Omelaenko, vk.com/id54662296",
"Konstantin Mayakovskiy, vk.com/id10069748", "Konstantin Mayakovskiy, vk.com/id10069748",
" ", " ",
"Translators:", "Translators:",
" ", " ",
"06Games, github.com/06Games", "06Games, github.com/06Games",
"Ksenia Mazneva, vk.com/id5564402", "Ksenia Mazneva, vk.com/id5564402",
"Yana Dmitrieva, vk.com/id155326634", "Yana Dmitrieva, vk.com/id155326634",
} }
local textBox = container.layout:addChild(GUI.textBox(1, 1, container.layout.width, #lines, nil, 0xB4B4B4, lines, 1, 0, 0)) local textBox = container.layout:addChild(GUI.textBox(1, 1, container.layout.width, #lines, nil, 0xB4B4B4, lines, 1, 0, 0))
textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
textBox.eventHandler = container.panel.eventHandler textBox.eventHandler = container.panel.eventHandler
MineOSInterface.mainContainer:drawOnScreen()
end
menu:addItem(MineOSCore.localization.updates).onTouch = function()
MineOSInterface.safeLaunch(MineOSPaths.applications .. "App Market.app/Main.lua", "updates")
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.logout, MineOSCore.properties.protectionMethod == "withoutProtection").onTouch = function()
login()
end
menu:addItem(MineOSCore.localization.reboot).onTouch = function()
MineOSNetwork.broadcastComputerState(false)
require("computer").shutdown(true)
end
menu:addItem(MineOSCore.localization.shutdown).onTouch = function()
MineOSNetwork.broadcastComputerState(false)
require("computer").shutdown()
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.returnToShell).onTouch = function()
MineOSNetwork.broadcastComputerState(false)
MineOSInterface.mainContainer:stopEventHandling()
MineOSInterface.clearTerminal()
os.exit()
end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.mainContainer:drawOnScreen()
end end
local item2 = MineOSInterface.mainContainer.menu:addItem(MineOSCore.localization.network) MineOSContextMenu:addItem(MineOSCore.localization.updates).onTouch = function()
item2.onTouch = function() MineOSInterface.safeLaunch(MineOSPaths.applications .. "App Market.app/Main.lua", "updates")
end
MineOSContextMenu:addSeparator()
MineOSContextMenu:addItem(MineOSCore.localization.logout, MineOSCore.properties.protectionMethod == "withoutProtection").onTouch = function()
login()
end
MineOSContextMenu:addItem(MineOSCore.localization.reboot).onTouch = function()
MineOSNetwork.broadcastComputerState(false)
require("computer").shutdown(true)
end
MineOSContextMenu:addItem(MineOSCore.localization.shutdown).onTouch = function()
MineOSNetwork.broadcastComputerState(false)
require("computer").shutdown()
end
MineOSContextMenu:addSeparator()
MineOSContextMenu:addItem(MineOSCore.localization.returnToShell).onTouch = function()
MineOSNetwork.broadcastComputerState(false)
MineOSInterface.mainContainer:stopEventHandling()
MineOSInterface.clearTerminal()
os.exit()
end
local networkItem = MineOSInterface.mainContainer.menu:addItem(MineOSCore.localization.network)
networkItem.onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.network) local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.network)
local insertModemTextBox = container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x5A5A5A, {MineOSCore.localization.networkModemNotAvailable}, 1, 0, 0, true, true)) local insertModemTextBox = container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x5A5A5A, {MineOSCore.localization.networkModemNotAvailable}, 1, 0, 0, true, true))
local stateSwitchAndLabel = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.networkState .. ":", MineOSCore.properties.network.enabled)) local stateSwitchAndLabel = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.networkState .. ":", MineOSCore.properties.network.enabled))
@ -682,323 +677,317 @@ local function createOSWidgets()
check() check()
end end
local item3 = MineOSInterface.mainContainer.menu:addItem(MineOSCore.localization.settings) local settingsContextMenu = MineOSInterface.mainContainer.menu:addContextMenu(MineOSCore.localization.settings)
item3.onTouch = function() if computer.getArchitectures then
local menu = MineOSInterface.addContextMenu(MineOSInterface.mainContainer, item3.x, item3.y + 1) settingsContextMenu:addItem(MineOSCore.localization.CPUArchitecture).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.CPUArchitecture)
if computer.getArchitectures then
menu:addItem(MineOSCore.localization.CPUArchitecture).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.CPUArchitecture)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
local architectures, architecture = computer.getArchitectures(), computer.getArchitecture()
for i = 1, #architectures do
comboBox:addItem(architectures[i]).onTouch = function()
computer.setArchitecture(architectures[i])
computer.shutdown(true)
end
if architecture == architectures[i] then
comboBox.selectedItem = i
end
end
MineOSInterface.mainContainer:drawOnScreen()
end
end
menu:addItem(MineOSCore.localization.RAMControl).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.RAMControl)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696)) local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
comboBox.dropDownMenu.itemHeight = 1 local architectures, architecture = computer.getArchitectures(), computer.getArchitecture()
for i = 1, #architectures do
local function update() comboBox:addItem(architectures[i]).onTouch = function()
local libraries = {} computer.setArchitecture(architectures[i])
for key in pairs(package.loaded) do computer.shutdown(true)
if not _G[key] then
table.insert(libraries, key)
end
end end
table.sort(libraries, function(a, b) return a < b end) if architecture == architectures[i] then
comboBox:clear()
for i = 1, #libraries do
comboBox:addItem(libraries[i]).onTouch = function()
package.loaded[libraries[i]] = nil
update()
end
end
MineOSInterface.mainContainer:drawOnScreen()
end
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.packageUnloading .. ":", MineOSCore.properties.packageUnloading)).switch
switch.onStateChanged = function()
MineOSCore.properties.packageUnloading = switch.state
MineOSCore.setPackageUnloading(MineOSCore.properties.packageUnloading)
MineOSCore.saveProperties()
end
update()
end
menu:addItem(MineOSCore.localization.screenResolution).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.screenResolution)
local widthTextBox = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, tostring(MineOSCore.properties.resolution and MineOSCore.properties.resolution[1] or 160), "Width", true))
widthTextBox.validator = function(text)
local number = tonumber(text)
if number then return number >= 1 and number <= 160 end
end
local heightTextBox = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, tostring(MineOSCore.properties.resolution and MineOSCore.properties.resolution[2] or 50), "Height", true))
heightTextBox.validator = function(text)
local number = tonumber(text)
if number then return number >= 1 and number <= 50 end
end
container.panel.eventHandler = function(mainContainer, object, e1)
if e1 == "touch" then
container:remove()
MineOSCore.properties.resolution = {tonumber(widthTextBox.text), tonumber(heightTextBox.text)}
MineOSCore.saveProperties()
changeResolution()
changeWallpaper()
MineOSInterface.mainContainer.updateFileListAndDraw()
end
end
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.systemLanguage).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.systemLanguage)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
for file in fs.list(MineOSPaths.localizationFiles) do
local name = fs.hideExtension(file)
comboBox:addItem(name).onTouch = function()
MineOSCore.properties.language = name
MineOSCore.localization = MineOSCore.getLocalization(MineOSPaths.localizationFiles)
createOSWidgets()
changeResolution()
changeWallpaper()
MineOSCore.OSUpdateDate()
MineOSInterface.mainContainer.updateFileListAndDraw()
MineOSCore.saveProperties()
end
if name == MineOSCore.properties.language then
comboBox.selectedItem = comboBox:count()
end
end
end
menu:addItem(MineOSCore.localization.wallpaper).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.wallpaper)
local filesystemChooser = container.layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696, MineOSCore.properties.wallpaper, MineOSCore.localization.open, MineOSCore.localization.cancel, MineOSCore.localization.wallpaperPath, "/"))
filesystemChooser:addExtensionFilter(".pic")
filesystemChooser.onSubmit = function(path)
MineOSCore.properties.wallpaper = path
MineOSCore.saveProperties()
changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen()
end
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
comboBox.selectedItem = MineOSCore.properties.wallpaperMode or 1
comboBox:addItem(MineOSCore.localization.wallpaperModeStretch)
comboBox:addItem(MineOSCore.localization.wallpaperModeCenter)
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0xE1E1E1, MineOSCore.localization.wallpaperEnabled .. ":", MineOSCore.properties.wallpaperEnabled)).switch
switch.onStateChanged = function()
MineOSCore.properties.wallpaperEnabled = switch.state
MineOSCore.saveProperties()
changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen()
end
container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x5A5A5A, {MineOSCore.localization.wallpaperSwitchInfo}, 1, 0, 0, true, true))
local slider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 0, 100, MineOSCore.properties.wallpaperBrightness * 100, false, MineOSCore.localization.wallpaperBrightness .. ": ", "%"))
slider.roundValues = true
slider.onValueChanged = function()
MineOSCore.properties.wallpaperBrightness = slider.value / 100
MineOSCore.saveProperties()
changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen()
end
container.layout:addChild(GUI.object(1, 1, 1, 1))
comboBox.onItemSelected = function()
MineOSCore.properties.wallpaperMode = comboBox.selectedItem
MineOSCore.saveProperties()
changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen()
end
end
menu:addItem(MineOSCore.localization.screensaver).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.screensaver)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
local fileList = fs.sortedList(screensaversPath, "name", false)
for i = 1, #fileList do
comboBox:addItem(fs.hideExtension(fileList[i]))
if MineOSCore.properties.screensaver == fileList[i] then
comboBox.selectedItem = i comboBox.selectedItem = i
end end
end end
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0xE1E1E1, MineOSCore.localization.screensaverEnabled .. ":", MineOSCore.properties.screensaverEnabled)).switch
local slider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 1, 80, MineOSCore.properties.screensaverDelay, false, MineOSCore.localization.screensaverDelay .. ": ", ""))
container.panel.eventHandler = function(mainContainer, object, e1) MineOSInterface.mainContainer:drawOnScreen()
if e1 == "touch" then end
container:remove() end
MineOSInterface.mainContainer:drawOnScreen()
MineOSCore.properties.screensaverEnabled = switch.state settingsContextMenu:addItem(MineOSCore.localization.RAMControl).onTouch = function()
MineOSCore.properties.screensaver = fileList[comboBox.selectedItem] local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.RAMControl)
MineOSCore.properties.screensaverDelay = slider.value
MineOSCore.saveProperties() local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
comboBox.dropDownMenu.itemHeight = 1
local function update()
local libraries = {}
for key in pairs(package.loaded) do
if not _G[key] then
table.insert(libraries, key)
end
end
table.sort(libraries, function(a, b) return a < b end)
comboBox:clear()
for i = 1, #libraries do
comboBox:addItem(libraries[i]).onTouch = function()
package.loaded[libraries[i]] = nil
update()
end end
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.mainContainer:drawOnScreen()
end end
menu:addItem(MineOSCore.localization.colorScheme).onTouch = function() local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.packageUnloading .. ":", MineOSCore.properties.packageUnloading)).switch
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.colorScheme) switch.onStateChanged = function()
MineOSCore.properties.packageUnloading = switch.state
MineOSCore.setPackageUnloading(MineOSCore.properties.packageUnloading)
MineOSCore.saveProperties()
end
local backgroundColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, MineOSCore.properties.backgroundColor, MineOSCore.localization.backgroundColor)) update()
local menuColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, MineOSCore.properties.menuColor, MineOSCore.localization.menuColor)) end
local dockColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, MineOSCore.properties.dockColor, MineOSCore.localization.dockColor))
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0xE1E1E1, MineOSCore.localization.transparencyEnabled .. ":", MineOSCore.properties.transparencyEnabled)).switch settingsContextMenu:addItem(MineOSCore.localization.screenResolution).onTouch = function()
switch.onStateChanged = function() local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.screenResolution)
MineOSCore.properties.transparencyEnabled = switch.state
local widthTextBox = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, tostring(MineOSCore.properties.resolution and MineOSCore.properties.resolution[1] or 160), "Width", true))
widthTextBox.validator = function(text)
local number = tonumber(text)
if number then return number >= 1 and number <= 160 end
end
local heightTextBox = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, tostring(MineOSCore.properties.resolution and MineOSCore.properties.resolution[2] or 50), "Height", true))
heightTextBox.validator = function(text)
local number = tonumber(text)
if number then return number >= 1 and number <= 50 end
end
container.panel.eventHandler = function(mainContainer, object, e1)
if e1 == "touch" then
container:remove()
MineOSCore.properties.resolution = {tonumber(widthTextBox.text), tonumber(heightTextBox.text)}
MineOSCore.saveProperties() MineOSCore.saveProperties()
MineOSInterface.mainContainer.menu.colors.transparency = MineOSCore.properties.transparencyEnabled and menuTransparency changeResolution()
container.panel.colors.background = switch.state and GUI.BACKGROUND_CONTAINER_PANEL_COLOR or (MineOSCore.properties.backgroundColor) changeWallpaper()
container.panel.colors.transparency = switch.state and GUI.BACKGROUND_CONTAINER_PANEL_TRANSPARENCY MineOSInterface.mainContainer.updateFileListAndDraw()
MineOSInterface.mainContainer:drawOnScreen()
end end
container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x5A5A5A, {MineOSCore.localization.transparencySwitchInfo}, 1, 0, 0, true, true)) end
end
backgroundColorSelector.onColorSelected = function() settingsContextMenu:addSeparator()
MineOSCore.properties.backgroundColor = backgroundColorSelector.color
MineOSCore.properties.menuColor = menuColorSelector.color
MineOSCore.properties.dockColor = dockColorSelector.color
MineOSInterface.mainContainer.menu.colors.default.background = MineOSCore.properties.menuColor
MineOSInterface.mainContainer:drawOnScreen() settingsContextMenu:addItem(MineOSCore.localization.systemLanguage).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.systemLanguage)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
for file in fs.list(MineOSPaths.localizationFiles) do
local name = fs.hideExtension(file)
comboBox:addItem(name).onTouch = function()
MineOSCore.properties.language = name
MineOSCore.localization = MineOSCore.getLocalization(MineOSPaths.localizationFiles)
createOSWidgets()
changeResolution()
changeWallpaper()
MineOSCore.OSUpdateDate()
MineOSInterface.mainContainer.updateFileListAndDraw()
MineOSCore.saveProperties()
end end
menuColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
dockColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
container.panel.eventHandler = function(mainContainer, object, e1) if name == MineOSCore.properties.language then
if e1 == "touch" then comboBox.selectedItem = comboBox:count()
container:remove() end
MineOSInterface.mainContainer:drawOnScreen() end
end
MineOSCore.saveProperties() settingsContextMenu:addItem(MineOSCore.localization.wallpaper).onTouch = function()
end local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.wallpaper)
local filesystemChooser = container.layout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696, MineOSCore.properties.wallpaper, MineOSCore.localization.open, MineOSCore.localization.cancel, MineOSCore.localization.wallpaperPath, "/"))
filesystemChooser:addExtensionFilter(".pic")
filesystemChooser.onSubmit = function(path)
MineOSCore.properties.wallpaper = path
MineOSCore.saveProperties()
changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen()
end
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
comboBox.selectedItem = MineOSCore.properties.wallpaperMode or 1
comboBox:addItem(MineOSCore.localization.wallpaperModeStretch)
comboBox:addItem(MineOSCore.localization.wallpaperModeCenter)
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0xE1E1E1, MineOSCore.localization.wallpaperEnabled .. ":", MineOSCore.properties.wallpaperEnabled)).switch
switch.onStateChanged = function()
MineOSCore.properties.wallpaperEnabled = switch.state
MineOSCore.saveProperties()
changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen()
end
container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x5A5A5A, {MineOSCore.localization.wallpaperSwitchInfo}, 1, 0, 0, true, true))
local slider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 0, 100, MineOSCore.properties.wallpaperBrightness * 100, false, MineOSCore.localization.wallpaperBrightness .. ": ", "%"))
slider.roundValues = true
slider.onValueChanged = function()
MineOSCore.properties.wallpaperBrightness = slider.value / 100
MineOSCore.saveProperties()
changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen()
end
container.layout:addChild(GUI.object(1, 1, 1, 1))
comboBox.onItemSelected = function()
MineOSCore.properties.wallpaperMode = comboBox.selectedItem
MineOSCore.saveProperties()
changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen()
end
end
settingsContextMenu:addItem(MineOSCore.localization.screensaver).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.screensaver)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
local fileList = fs.sortedList(screensaversPath, "name", false)
for i = 1, #fileList do
comboBox:addItem(fs.hideExtension(fileList[i]))
if MineOSCore.properties.screensaver == fileList[i] then
comboBox.selectedItem = i
end
end
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0xE1E1E1, MineOSCore.localization.screensaverEnabled .. ":", MineOSCore.properties.screensaverEnabled)).switch
local slider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 1, 80, MineOSCore.properties.screensaverDelay, false, MineOSCore.localization.screensaverDelay .. ": ", ""))
container.panel.eventHandler = function(mainContainer, object, e1)
if e1 == "touch" then
container:remove()
MineOSInterface.mainContainer:drawOnScreen()
MineOSCore.properties.screensaverEnabled = switch.state
MineOSCore.properties.screensaver = fileList[comboBox.selectedItem]
MineOSCore.properties.screensaverDelay = slider.value
MineOSCore.saveProperties()
end end
end end
menu:addItem(MineOSCore.localization.iconProperties).onTouch = function() MineOSInterface.mainContainer:drawOnScreen()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.iconProperties) end
local showExtensionSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.showExtension .. ":", MineOSCore.properties.showExtension)).switch settingsContextMenu:addItem(MineOSCore.localization.colorScheme).onTouch = function()
local showHiddenFilesSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.showHiddenFiles .. ":", MineOSCore.properties.showHiddenFiles)).switch local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.colorScheme)
local showApplicationIconsSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.showApplicationIcons .. ":", MineOSCore.properties.showApplicationIcons)).switch
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0xE1E1E1, MineOSCore.localization.sizeOfIcons):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)) local backgroundColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, MineOSCore.properties.backgroundColor, MineOSCore.localization.backgroundColor))
local menuColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, MineOSCore.properties.menuColor, MineOSCore.localization.menuColor))
local dockColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, MineOSCore.properties.dockColor, MineOSCore.localization.dockColor))
local iconWidthSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 8, 16, MineOSCore.properties.iconWidth, false, MineOSCore.localization.byHorizontal .. ": ", "")) local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0xE1E1E1, MineOSCore.localization.transparencyEnabled .. ":", MineOSCore.properties.transparencyEnabled)).switch
local iconHeightSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 6, 16, MineOSCore.properties.iconHeight, false, MineOSCore.localization.byVertical .. ": ", "")) switch.onStateChanged = function()
MineOSCore.properties.transparencyEnabled = switch.state
MineOSCore.saveProperties()
MineOSInterface.mainContainer.menu.colors.transparency = MineOSCore.properties.transparencyEnabled and menuTransparency
container.panel.colors.background = switch.state and GUI.BACKGROUND_CONTAINER_PANEL_COLOR or (MineOSCore.properties.backgroundColor)
container.panel.colors.transparency = switch.state and GUI.BACKGROUND_CONTAINER_PANEL_TRANSPARENCY
container.layout:addChild(GUI.object(1, 1, 1, 0)) MineOSInterface.mainContainer:drawOnScreen()
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0xE1E1E1, MineOSCore.localization.spaceBetweenIcons):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)) end
container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x5A5A5A, {MineOSCore.localization.transparencySwitchInfo}, 1, 0, 0, true, true))
local iconHorizontalSpaceBetweenSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 0, 5, MineOSCore.properties.iconHorizontalSpaceBetween, false, MineOSCore.localization.byHorizontal .. ": ", "")) backgroundColorSelector.onColorSelected = function()
local iconVerticalSpaceBetweenSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 0, 5, MineOSCore.properties.iconVerticalSpaceBetween, false, MineOSCore.localization.byVertical .. ": ", "")) MineOSCore.properties.backgroundColor = backgroundColorSelector.color
MineOSCore.properties.menuColor = menuColorSelector.color
MineOSCore.properties.dockColor = dockColorSelector.color
MineOSInterface.mainContainer.menu.colors.default.background = MineOSCore.properties.menuColor
iconHorizontalSpaceBetweenSlider.roundValues, iconVerticalSpaceBetweenSlider.roundValues = true, true MineOSInterface.mainContainer:drawOnScreen()
iconWidthSlider.roundValues, iconHeightSlider.roundValues = true, true end
menuColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
dockColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
iconWidthSlider.onValueChanged = function() container.panel.eventHandler = function(mainContainer, object, e1)
MineOSInterface.setIconProperties(math.floor(iconWidthSlider.value), math.floor(iconHeightSlider.value), MineOSCore.properties.iconHorizontalSpaceBetween, MineOSCore.properties.iconVerticalSpaceBetween) if e1 == "touch" then
end container:remove()
iconHeightSlider.onValueChanged = iconWidthSlider.onValueChanged MineOSInterface.mainContainer:drawOnScreen()
iconHorizontalSpaceBetweenSlider.onValueChanged = function()
MineOSInterface.setIconProperties(MineOSCore.properties.iconWidth, MineOSCore.properties.iconHeight, math.floor(iconHorizontalSpaceBetweenSlider.value), math.floor(iconVerticalSpaceBetweenSlider.value))
end
iconVerticalSpaceBetweenSlider.onValueChanged = iconHorizontalSpaceBetweenSlider.onValueChanged
showExtensionSwitch.onStateChanged = function()
MineOSCore.properties.showExtension = showExtensionSwitch.state
MineOSCore.properties.showHiddenFiles = showHiddenFilesSwitch.state
MineOSCore.properties.showApplicationIcons = showApplicationIconsSwitch.state
MineOSCore.saveProperties() MineOSCore.saveProperties()
computer.pushSignal("MineOSCore", "updateFileList")
end end
showHiddenFilesSwitch.onStateChanged, showApplicationIconsSwitch.onStateChanged = showExtensionSwitch.onStateChanged, showExtensionSwitch.onStateChanged end
end
settingsContextMenu:addItem(MineOSCore.localization.iconProperties).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.iconProperties)
local showExtensionSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.showExtension .. ":", MineOSCore.properties.showExtension)).switch
local showHiddenFilesSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.showHiddenFiles .. ":", MineOSCore.properties.showHiddenFiles)).switch
local showApplicationIconsSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, MineOSCore.localization.showApplicationIcons .. ":", MineOSCore.properties.showApplicationIcons)).switch
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0xE1E1E1, MineOSCore.localization.sizeOfIcons):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP))
local iconWidthSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 8, 16, MineOSCore.properties.iconWidth, false, MineOSCore.localization.byHorizontal .. ": ", ""))
local iconHeightSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 6, 16, MineOSCore.properties.iconHeight, false, MineOSCore.localization.byVertical .. ": ", ""))
container.layout:addChild(GUI.object(1, 1, 1, 0))
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0xE1E1E1, MineOSCore.localization.spaceBetweenIcons):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP))
local iconHorizontalSpaceBetweenSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 0, 5, MineOSCore.properties.iconHorizontalSpaceBetween, false, MineOSCore.localization.byHorizontal .. ": ", ""))
local iconVerticalSpaceBetweenSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, 0, 5, MineOSCore.properties.iconVerticalSpaceBetween, false, MineOSCore.localization.byVertical .. ": ", ""))
iconHorizontalSpaceBetweenSlider.roundValues, iconVerticalSpaceBetweenSlider.roundValues = true, true
iconWidthSlider.roundValues, iconHeightSlider.roundValues = true, true
iconWidthSlider.onValueChanged = function()
MineOSInterface.setIconProperties(math.floor(iconWidthSlider.value), math.floor(iconHeightSlider.value), MineOSCore.properties.iconHorizontalSpaceBetween, MineOSCore.properties.iconVerticalSpaceBetween)
end
iconHeightSlider.onValueChanged = iconWidthSlider.onValueChanged
iconHorizontalSpaceBetweenSlider.onValueChanged = function()
MineOSInterface.setIconProperties(MineOSCore.properties.iconWidth, MineOSCore.properties.iconHeight, math.floor(iconHorizontalSpaceBetweenSlider.value), math.floor(iconVerticalSpaceBetweenSlider.value))
end
iconVerticalSpaceBetweenSlider.onValueChanged = iconHorizontalSpaceBetweenSlider.onValueChanged
showExtensionSwitch.onStateChanged = function()
MineOSCore.properties.showExtension = showExtensionSwitch.state
MineOSCore.properties.showHiddenFiles = showHiddenFilesSwitch.state
MineOSCore.properties.showApplicationIcons = showApplicationIconsSwitch.state
MineOSCore.saveProperties()
computer.pushSignal("MineOSCore", "updateFileList")
end
showHiddenFilesSwitch.onStateChanged, showApplicationIconsSwitch.onStateChanged = showExtensionSwitch.onStateChanged, showExtensionSwitch.onStateChanged
end
settingsContextMenu:addItem(MineOSCore.localization.dateAndTime).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.timezone)
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696))
comboBox.dropDownMenu.itemHeight = 1
local label = container.layout:addChild(GUI.label(1, 1, container.width, 1, 0xE1E1E1, MineOSCore.localization.dateFormat):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP))
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, MineOSCore.properties.dateFormat or ""))
input.onInputFinished = function()
MineOSCore.properties.dateFormat = input.text
MineOSCore.OSUpdateDate()
MineOSInterface.mainContainer:drawOnScreen()
MineOSCore.saveProperties()
end end
menu:addItem(MineOSCore.localization.dateAndTime).onTouch = function() for i = -12, 12 do
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.timezone) comboBox:addItem("GMT" .. (i >= 0 and "+" or "") .. i).onTouch = function()
MineOSCore.properties.timezone = i
local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696)) MineOSCore.OSUpdateTimezone(i)
comboBox.dropDownMenu.itemHeight = 1
local label = container.layout:addChild(GUI.label(1, 1, container.width, 1, 0xE1E1E1, MineOSCore.localization.dateFormat):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP))
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, MineOSCore.properties.dateFormat or ""))
input.onInputFinished = function()
MineOSCore.properties.dateFormat = input.text
MineOSCore.OSUpdateDate() MineOSCore.OSUpdateDate()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.mainContainer:drawOnScreen()
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end
for i = -12, 12 do
comboBox:addItem("GMT" .. (i >= 0 and "+" or "") .. i).onTouch = function()
MineOSCore.properties.timezone = i
MineOSCore.OSUpdateTimezone(i)
MineOSCore.OSUpdateDate()
MineOSInterface.mainContainer:drawOnScreen()
MineOSCore.saveProperties()
end
end
MineOSInterface.mainContainer:drawOnScreen()
end
menu:addSeparator()
menu:addItem(MineOSCore.localization.setProtectionMethod).onTouch = function()
setProtectionMethod()
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.mainContainer:drawOnScreen()
end end
settingsContextMenu:addSeparator()
settingsContextMenu:addItem(MineOSCore.localization.setProtectionMethod).onTouch = function()
setProtectionMethod()
end
MineOSInterface.mainContainer.menuLayout = MineOSInterface.mainContainer:addChild(GUI.layout(1, 1, 1, 1, 1, 1)) MineOSInterface.mainContainer.menuLayout = MineOSInterface.mainContainer:addChild(GUI.layout(1, 1, 1, 1, 1, 1))
MineOSInterface.mainContainer.menuLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL) MineOSInterface.mainContainer.menuLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
MineOSInterface.mainContainer.menuLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_RIGHT, GUI.ALIGNMENT_VERTICAL_TOP) MineOSInterface.mainContainer.menuLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_RIGHT, GUI.ALIGNMENT_VERTICAL_TOP)