From b59623572921d99fafd894350efb34e97dce6ff9 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Wed, 12 Sep 2018 13:50:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B8=D0=B7=D0=B4=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=B9=D1=88=D0=B5=D0=B5=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20"Settings"=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications/Settings/Icon.pic | Bin 0 -> 293 bytes .../Settings/Localizations/English.lang | 89 ++++ .../Settings/Localizations/French.lang | 89 ++++ .../Settings/Localizations/Russian.lang | 89 ++++ Applications/Settings/Main.lua | 148 ++++++ .../Settings/Modules/0_Screen/Icon.pic | Bin 0 -> 147 bytes .../Settings/Modules/0_Screen/Main.lua | 96 ++++ .../Settings/Modules/1_Wallpaper/Icon.pic | Bin 0 -> 219 bytes .../Settings/Modules/1_Wallpaper/Main.lua | 88 ++++ .../Settings/Modules/2_Icons/Icon.pic | Bin 0 -> 113 bytes .../Settings/Modules/2_Icons/Main.lua | 91 ++++ .../Settings/Modules/3_Tasks/Icon.pic | Bin 0 -> 87 bytes .../Settings/Modules/3_Tasks/Main.lua | 95 ++++ .../Settings/Modules/4_Disks/Icon.pic | Bin 0 -> 205 bytes .../Settings/Modules/4_Disks/Main.lua | 114 +++++ .../Settings/Modules/5_Network/Icon.pic | Bin 0 -> 202 bytes .../Settings/Modules/5_Network/Main.lua | 110 +++++ .../Settings/Modules/6_Localizations/Icon.pic | Bin 0 -> 184 bytes .../Settings/Modules/6_Localizations/Main.lua | 44 ++ Applications/Settings/Modules/7_Time/Icon.pic | Bin 0 -> 162 bytes Applications/Settings/Modules/7_Time/Main.lua | 52 ++ .../Settings/Modules/8_System/Icon.pic | Bin 0 -> 79 bytes .../Settings/Modules/8_System/Main.lua | 78 +++ OS.lua | 451 ++---------------- lib/MineOSCore.lua | 2 + lib/MineOSNetwork.lua | 105 ++-- 26 files changed, 1264 insertions(+), 477 deletions(-) create mode 100644 Applications/Settings/Icon.pic create mode 100644 Applications/Settings/Localizations/English.lang create mode 100644 Applications/Settings/Localizations/French.lang create mode 100755 Applications/Settings/Localizations/Russian.lang create mode 100644 Applications/Settings/Main.lua create mode 100755 Applications/Settings/Modules/0_Screen/Icon.pic create mode 100644 Applications/Settings/Modules/0_Screen/Main.lua create mode 100755 Applications/Settings/Modules/1_Wallpaper/Icon.pic create mode 100644 Applications/Settings/Modules/1_Wallpaper/Main.lua create mode 100644 Applications/Settings/Modules/2_Icons/Icon.pic create mode 100644 Applications/Settings/Modules/2_Icons/Main.lua create mode 100644 Applications/Settings/Modules/3_Tasks/Icon.pic create mode 100644 Applications/Settings/Modules/3_Tasks/Main.lua create mode 100644 Applications/Settings/Modules/4_Disks/Icon.pic create mode 100644 Applications/Settings/Modules/4_Disks/Main.lua create mode 100644 Applications/Settings/Modules/5_Network/Icon.pic create mode 100644 Applications/Settings/Modules/5_Network/Main.lua create mode 100644 Applications/Settings/Modules/6_Localizations/Icon.pic create mode 100644 Applications/Settings/Modules/6_Localizations/Main.lua create mode 100644 Applications/Settings/Modules/7_Time/Icon.pic create mode 100644 Applications/Settings/Modules/7_Time/Main.lua create mode 100644 Applications/Settings/Modules/8_System/Icon.pic create mode 100644 Applications/Settings/Modules/8_System/Main.lua diff --git a/Applications/Settings/Icon.pic b/Applications/Settings/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..6add2e9dafbde5e0ec6cdd9b6f4eeb0ffae40adb GIT binary patch literal 293 zcmXw!F$%&!5JfYSO|nO@wDlZ 0 and scrollSpeed or -scrollSpeed) + if cell.verticalMargin > object.module.margin then + cell.verticalMargin = object.module.margin + elseif cell.verticalMargin < to then + cell.verticalMargin = to + end + + mainContainer:drawOnScreen() + end + end + + object.module.onTouch() + mainContainer:drawOnScreen() +end + +local function selectModule(object) + local child + for i = 1, #modulesLayout.children do + child = modulesLayout.children[i] + child.pressed = object == child + end + + runModule(object) +end + +local function moduleEventHandler(mainContainer, object, e1) + if e1 == "touch" then + selectModule(object) + end +end + +local modules = {} +for file in filesystem.list(modulesPath) do + table.insert(modules, file) +end +table.sort(modules, function(a, b) return a < b end) + +for i = 1, #modules do + local result, reason = loadfile(modulesPath .. modules[i] .. "Main.lua") + if result then + local success, result = pcall(result, mainContainer, window, localization) + if success then + local object = modulesLayout:addChild(GUI.object(1, 1, modulesLayout.width, 3)) + + object.icon = image.load(modulesPath .. modules[i] .. "Icon.pic") + object.module = result + object.pressed = false + object.draw = moduleDraw + object.eventHandler = moduleEventHandler + else + error("Failed to execute module " .. modules[i] .. ": " .. tostring(result)) + end + else + error("Failed to load module " .. modules[i] .. ": " .. tostring(reason)) + end +end + +modulesLayout.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) + if e1 == "scroll" then + local cell = modulesLayout.cells[1][1] + local to = -(#modulesLayout.children - 1) * 4 + 1 + + cell.verticalMargin = cell.verticalMargin + (e5 > 0 and scrollSpeed or -scrollSpeed) + if cell.verticalMargin > 1 then + cell.verticalMargin = 1 + elseif cell.verticalMargin < to then + cell.verticalMargin = to + end + + mainContainer:drawOnScreen() + end +end + +window.onResize = function(width, height) + modulesLayout:setMargin(1, 1, 0, 1) + + window.backgroundPanel.width, window.backgroundPanel.height = width - leftPanel.width, height + window.contentLayout.width, window.contentLayout.height = window.backgroundPanel.width, window.backgroundPanel.height + leftPanel.height = height + modulesLayout.height = height - 2 + + for i = 1, #modulesLayout.children do + if modulesLayout.children[i].pressed then + runModule(modulesLayout.children[i]) + break + end + end +end + +window:resize(window.width, window.height) +selectModule(modulesLayout.children[1]) \ No newline at end of file diff --git a/Applications/Settings/Modules/0_Screen/Icon.pic b/Applications/Settings/Modules/0_Screen/Icon.pic new file mode 100755 index 0000000000000000000000000000000000000000..0defb00c65999b1aacb5b701fd6a45c0130de486 GIT binary patch literal 147 zcmeZw_H<+8U}j`s;CZyTfiakofsvVwiJ66!jokpqt7BwhVqrCeuo#(Dp$xW1i*|t3 zGBI*ITHFq1GBYwhTG$U}G6I>4AqtooITV0m*MR0Qu|HbS36Y1|@Ms}KD-%%tqMcB! F8~`3u8OQ(t literal 0 HcmV?d00001 diff --git a/Applications/Settings/Modules/0_Screen/Main.lua b/Applications/Settings/Modules/0_Screen/Main.lua new file mode 100644 index 00000000..d7e56c13 --- /dev/null +++ b/Applications/Settings/Modules/0_Screen/Main.lua @@ -0,0 +1,96 @@ + +local GUI = require("GUI") +local component = require("component") +local buffer = require("doubleBuffering") +local MineOSInterface = require("MineOSInterface") +local MineOSPaths = require("MineOSPaths") +local MineOSCore = require("MineOSCore") +local scale = require("scale") + +local module = {} + +local mainContainer, window, localization = table.unpack({...}) + +-------------------------------------------------------------------------------- + +module.name = localization.screen +module.margin = 0 +module.onTouch = function() + -- Screen proxy + window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.screenPreferredMonitor)) + + local monitorComboBox = window.contentLayout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5)) + for address in component.list("screen") do + monitorComboBox:addItem(address).onTouch = function() + buffer.clear(0x0) + buffer.drawChanges() + + buffer.bindScreen(address, false) + MineOSInterface.changeResolution() + MineOSInterface.changeWallpaper() + MineOSInterface.updateFileListAndDraw() + MineOSCore.saveProperties() + end + end + + -- Resolution + window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.screenResolution)) + local resolutionComboBox = window.contentLayout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5)) + + local function setResolution(width, height) + MineOSCore.properties.resolution = {width, height} + MineOSInterface.changeResolution() + MineOSInterface.changeWallpaper() + MineOSInterface.updateFileListAndDraw() + + MineOSCore.saveProperties() + end + + local step = 1 / 6 + for i = 1, step, -step do + local width, height = scale.getResolution(i) + resolutionComboBox:addItem(width .. "x" .. height).onTouch = function() + setResolution(width, height) + end + end + + local layout = window.contentLayout:addChild(GUI.layout(1, 1, 36, 3, 1, 1)) + layout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL) + + local widthInput = layout:addChild(GUI.input(1, 1, 16, 3, 0xE1E1E1, 0x696969, 0xA5A5A5, 0xE1E1E1, 0x2D2D2D, "", localization.screenWidth)) + layout:addChild(GUI.text(1, 1, 0x2D2D2D, "x")) + local heightInput = layout:addChild(GUI.input(1, 1, 17, 3, 0xE1E1E1, 0x696969, 0xA5A5A5, 0xE1E1E1, 0x2D2D2D, "", localization.screenHeight)) + + local switch = window.contentLayout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, localization.screenAutoScale .. ":", MineOSCore.properties.screenAutoScale)).switch + + window.contentLayout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0xA5A5A5, {localization.screenScaleInfo}, 1, 0, 0, true, true)) + + local function updateSwitch() + widthInput.text, heightInput.text = tostring(buffer.getWidth()), tostring(buffer.getHeight()) + resolutionComboBox.hidden = not switch.state + layout.hidden = switch.state + MineOSInterface.mainContainer:drawOnScreen() + end + + switch.onStateChanged = function() + updateSwitch() + + MineOSCore.properties.screenAutoScale = switch.state + MineOSCore.saveProperties() + end + + widthInput.onInputFinished = function() + local width, height = tonumber(widthInput.text), tonumber(heightInput.text) + if width and height then + setResolution(width, height) + end + end + heightInput.onInputFinished = widthInput.onInputFinished + + updateSwitch() +end + +-------------------------------------------------------------------------------- + +return module + diff --git a/Applications/Settings/Modules/1_Wallpaper/Icon.pic b/Applications/Settings/Modules/1_Wallpaper/Icon.pic new file mode 100755 index 0000000000000000000000000000000000000000..224d0978ca63acb4adc0ffd1786017cc3f3d3bf9 GIT binary patch literal 219 zcmXAjEe^s^5QLe1uRo4!G`K1bKth5-KqaOpp{5N%7K3~3YtV=)1Q-k#-~f9PrjHey z$!6x8-L5w4I5n8f=IU#dXaOYZ&dBhAL8R_Vd7-r0HQ1w|Ayt1wPB$RxNBPI>6JH1; zU5zTpSo?;=iq}NDk=Yj|(+&%wIO+!}LTOyGMab*#vI}U_;?0XycS2?ld?9JMXfz@w U=blhElrlXXJ?J&s4_F2eezJQsNB{r; literal 0 HcmV?d00001 diff --git a/Applications/Settings/Modules/1_Wallpaper/Main.lua b/Applications/Settings/Modules/1_Wallpaper/Main.lua new file mode 100644 index 00000000..b04ce810 --- /dev/null +++ b/Applications/Settings/Modules/1_Wallpaper/Main.lua @@ -0,0 +1,88 @@ + +local GUI = require("GUI") +local MineOSInterface = require("MineOSInterface") +local MineOSPaths = require("MineOSPaths") +local MineOSCore = require("MineOSCore") + +local module = {} + +local mainContainer, window, localization = table.unpack({...}) + +-------------------------------------------------------------------------------- + +module.name = localization.wallpaper +module.margin = 5 +module.onTouch = function() + window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.wallpaperWallpaper)) + + local wallpaperChooser = window.contentLayout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5, MineOSCore.properties.wallpaper, localization.open, localization.cancel, localization.wallpaperPath, "/")) + wallpaperChooser:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) + wallpaperChooser:addExtensionFilter(".pic") + wallpaperChooser.onSubmit = function(path) + MineOSCore.properties.wallpaper = path + MineOSInterface.changeWallpaper() + MineOSInterface.mainContainer:drawOnScreen() + + MineOSCore.saveProperties() + end + + local comboBox = window.contentLayout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5)) + comboBox.selectedItem = MineOSCore.properties.wallpaperMode or 1 + comboBox:addItem(localization.wallpaperStretch) + comboBox:addItem(localization.wallpaperCenter) + + local wallpaperSwitch = window.contentLayout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, localization.wallpaperEnabled .. ":", MineOSCore.properties.wallpaperEnabled)).switch + wallpaperSwitch.onStateChanged = function() + MineOSCore.properties.wallpaperEnabled = wallpaperSwitch.state + MineOSInterface.changeWallpaper() + MineOSInterface.mainContainer:drawOnScreen() + + MineOSCore.saveProperties() + end + + window.contentLayout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0xA5A5A5, {localization.wallpaperInfo}, 1, 0, 0, true, true)) + + local wallpaperSlider = window.contentLayout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, 0, 100, MineOSCore.properties.wallpaperBrightness * 100, false, localization.wallpaperBrightness .. ": ", "%")) + wallpaperSlider.height = 2 + wallpaperSlider.roundValues = true + wallpaperSlider.onValueChanged = function() + MineOSCore.properties.wallpaperBrightness = wallpaperSlider.value / 100 + MineOSInterface.changeWallpaper() + MineOSInterface.mainContainer:drawOnScreen() + + MineOSCore.saveProperties() + end + + comboBox.onItemSelected = function() + MineOSCore.properties.wallpaperMode = comboBox.selectedItem + MineOSInterface.changeWallpaper() + MineOSInterface.mainContainer:drawOnScreen() + + MineOSCore.saveProperties() + end + + window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.wallpaperScreensaver)) + + local screensaverChooser = window.contentLayout:addChild(GUI.filesystemChooser(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5, MineOSCore.properties.screensaver, localization.open, localization.cancel, localization.wallpaperScreensaverPath, "/")) + screensaverChooser:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) + screensaverChooser:addExtensionFilter(".lua") + + local screensaverSwitch = window.contentLayout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, localization.wallpaperScreensaverEnabled .. ":", MineOSCore.properties.screensaverEnabled)).switch + + local screensaverSlider = window.contentLayout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, 1, 100, MineOSCore.properties.screensaverDelay, false, localization.wallpaperScreensaverDelay .. ": ", " s")) + + local function save() + MineOSCore.properties.screensaverEnabled = screensaverSwitch.state + MineOSCore.properties.screensaver = screensaverChooser.path + MineOSCore.properties.screensaverDelay = screensaverSlider.value + + MineOSCore.saveProperties() + end + + screensaverChooser.onSubmit, screensaverSwitch.onStateChanged, screensaverSlider.onValueChanged = save, save, save +end + +-------------------------------------------------------------------------------- + +return module + diff --git a/Applications/Settings/Modules/2_Icons/Icon.pic b/Applications/Settings/Modules/2_Icons/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..303d38f313951ed526951a18bfd3a67c8fdc0355 GIT binary patch literal 113 zcmXYos||oK6h(XA>u(Hv#~>kqVJQS`(WE#AszY=GJc65mIl14Zp9UWl#`sn;5>6f$=({79%4oGYcyly8?*A%*e#Z!34z29E?n0VU9 0 then + MineOSCore.properties.tasks[tasksComboBox.selectedItem].mode = modeComboBox.selectedItem + MineOSCore.saveProperties() + end + end + + switchAndLabel.switch.onStateChanged = function() + if #MineOSCore.properties.tasks > 0 then + MineOSCore.properties.tasks[tasksComboBox.selectedItem].enabled = switchAndLabel.switch.state + MineOSCore.saveProperties() + end + end + + window.contentLayout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0xA5A5A5, {localization.tasksInfo}, 1, 0, 0, true, true)) + + fill() +end + +-------------------------------------------------------------------------------- + +return module + diff --git a/Applications/Settings/Modules/4_Disks/Icon.pic b/Applications/Settings/Modules/4_Disks/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..7cd48ea3378ad0d7fbd399f647d4df8d23cd2015 GIT binary patch literal 205 zcmXX=u@S;R42$gWNy!Mbum*SBQKev^a1_u%PxJ7U)Eud@1p{~z^!|5aS+*n(+x;%| zil$kvWQ`vnq1&(vdW$DyN(s})Aw*kyoKY@<#UtqhSoRz%+gZF-U9j}3I$2n}7g~tZ m>}diiR@}~ItJ>1x!Xf)I`HHvyqn4%$`NQZ3nuEVC6yOi7fHQgk literal 0 HcmV?d00001 diff --git a/Applications/Settings/Modules/4_Disks/Main.lua b/Applications/Settings/Modules/4_Disks/Main.lua new file mode 100644 index 00000000..39dc6a64 --- /dev/null +++ b/Applications/Settings/Modules/4_Disks/Main.lua @@ -0,0 +1,114 @@ + +local computer = require("computer") +local component = require("component") +local GUI = require("GUI") +local MineOSInterface = require("MineOSInterface") +local MineOSPaths = require("MineOSPaths") +local MineOSCore = require("MineOSCore") +local filesystem = require("filesystem") + +local module = {} + +local mainContainer, window, localization = table.unpack({...}) + +-------------------------------------------------------------------------------- + +module.name = localization.disks +module.margin = 6 +module.onTouch = function() + local currentAddress = computer.getBootAddress() + + window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.disksControl)) + + local comboBox = window.contentLayout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5)) + + local input = window.contentLayout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xA5A5A5, 0xE1E1E1, 0x2D2D2D, "", localization.disksRename)) + + local button = window.contentLayout:addChild(GUI.button(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, localization.disksFormat)) + + window.contentLayout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0xA5A5A5, {localization.disksInfo}, 1, 0, 0, true, true)) + + window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.disksStatistics)) + + local progressBar = window.contentLayout:addChild(GUI.progressBar(1, 1, 36, 0x66DB80, 0xE1E1E1, 0xA5A5A5, 100, true, true, "", "%")) + progressBar.height = 2 + + local layout = window.contentLayout:addChild(GUI.layout(1, 1, 36, 1, 1, 1)) + layout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_LEFT, GUI.ALIGNMENT_VERTICAL_TOP) + + local permissionsKV = layout:addChild(GUI.keyAndValue(1, 1, 0x696969, 0xA5A5A5, localization.disksPermissions, "")) + local spaceTotalKV = layout:addChild(GUI.keyAndValue(1, 1, 0x696969, 0xA5A5A5, localization.disksSpaceTotal, "")) + local spaceUsedKV = layout:addChild(GUI.keyAndValue(1, 1, 0x696969, 0xA5A5A5, localization.disksSpaceUsed, "")) + local spaceFreeKV = layout:addChild(GUI.keyAndValue(1, 1, 0x696969, 0xA5A5A5, localization.disksSpaceFree, "")) + + layout.height = (#layout.children * 2) - 1 + + local function getProxy() + return comboBox:getItem(comboBox.selectedItem).proxy + end + + local function update() + local proxy = getProxy() + local used, total = proxy.spaceUsed(), proxy.spaceTotal() + local free = total - used + + progressBar.value = math.ceil(used / total * 100) + permissionsKV.value = ": " .. (proxy.isReadOnly() and localization.disksReadOnly or localization.disksReadAndWrite) + spaceTotalKV.value = ": " .. string.format("%.2f", total / 1024 / 1024) .. " MB" + spaceUsedKV.value = ": " .. string.format("%.2f", used / 1024 / 1024) .. " MB" + spaceFreeKV.value = ": " .. string.format("%.2f", free / 1024 / 1024) .. " MB" + end + + local function fill() + comboBox:clear() + + for address in component.list("filesystem") do + local proxy = component.proxy(address) + local label = proxy.getLabel() + local item = comboBox:addItem(label and label .. " (" .. address .. ")" or address) + item.proxy = proxy + + if address == currentAddress then + comboBox.selectedItem = comboBox:count() + end + end + + update() + end + + comboBox.onItemSelected = function() + currentAddress = getProxy().address + update() + mainContainer:drawOnScreen() + end + + input.onInputFinished = function() + local success, reason = pcall(getProxy().setLabel, input.text) + input.text = "" + + if success then + fill() + else + GUI.alert(reason) + end + + mainContainer:drawOnScreen() + end + + button.onTouch = function() + local list = getProxy().list("/") + for i = 1, #list do + -- filesystem.remove(list[i]) + end + + fill() + mainContainer:drawOnScreen() + end + + fill() +end + +-------------------------------------------------------------------------------- + +return module + diff --git a/Applications/Settings/Modules/5_Network/Icon.pic b/Applications/Settings/Modules/5_Network/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..d2c7a2a89720ff57dc835cfcfaf9da8cfc1aa386 GIT binary patch literal 202 zcmXYrEe--f3`XZ`=VuLfKywWe0&1_cC_oU*2xNC13JZeE^axx4CY`FjyuPFzw})LG zn0{fUazwxegt#_f!k}_?nRIy>0!iiJHfz227)9mkmbFgZMvkd9)f-azc+>FG(atkZtu-E*c$i)rT-`C literal 0 HcmV?d00001 diff --git a/Applications/Settings/Modules/5_Network/Main.lua b/Applications/Settings/Modules/5_Network/Main.lua new file mode 100644 index 00000000..c4885fb3 --- /dev/null +++ b/Applications/Settings/Modules/5_Network/Main.lua @@ -0,0 +1,110 @@ + +local GUI = require("GUI") +local MineOSInterface = require("MineOSInterface") +local MineOSPaths = require("MineOSPaths") +local MineOSCore = require("MineOSCore") +local MineOSNetwork = require("MineOSNetwork") +local filesystem = require("filesystem") + +local module = {} + +local mainContainer, window, localization = table.unpack({...}) + +-------------------------------------------------------------------------------- + +module.name = localization.network +module.margin = 0 +module.onTouch = function() + local emptyObject = window.contentLayout:addChild(GUI.object(1, 1, 0, 0)) + local insertModemText = window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.networkNoModem)) + local ebloText = window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.networkThis)) + local networkNameInput = window.contentLayout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xA5A5A5, 0xE1E1E1, 0x2D2D2D, MineOSCore.properties.network.name or "", localization.networkName)) + local stateSwitchAndLabel = window.contentLayout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, localization.networkEnabled .. ":", MineOSCore.properties.network.enabled)) + local remoteComputersText = window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.networkRemote)) + local remoteComputersComboBox = window.contentLayout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5)) + local allowReadAndWriteSwitchAndLabel = window.contentLayout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, localization.networkFileAccess .. ":", false)) + + local signalStrengthSlider = window.contentLayout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, 0, 512, MineOSCore.properties.network.signalStrength, false, localization.networkRadius ..": ", "")) + signalStrengthSlider.roundValues = true + + local function check() + insertModemText.hidden = MineOSNetwork.modemProxy + + for i = 3, #window.contentLayout.children do + window.contentLayout.children[i].hidden = not MineOSNetwork.modemProxy + end + + if MineOSNetwork.modemProxy then + for i = 6, #window.contentLayout.children do + window.contentLayout.children[i].hidden = not stateSwitchAndLabel.switch.state + end + + if stateSwitchAndLabel.switch.state then + signalStrengthSlider.hidden = not MineOSNetwork.modemProxy.isWireless() + + remoteComputersComboBox:clear() + for proxy, path in filesystem.mounts() do + if proxy.MineOSNetworkModem then + local item = remoteComputersComboBox:addItem(MineOSNetwork.getModemProxyName(proxy)) + item.proxyAddress = proxy.address + item.onTouch = function() + allowReadAndWriteSwitchAndLabel.switch:setState(MineOSCore.properties.network.users[item.proxyAddress].allowReadAndWrite) + end + end + end + + remoteComputersText.hidden = remoteComputersComboBox:count() < 1 + remoteComputersComboBox.hidden = remoteComputersText.hidden + allowReadAndWriteSwitchAndLabel.hidden = remoteComputersText.hidden + + if not remoteComputersText.hidden then + remoteComputersComboBox:getItem(remoteComputersComboBox.selectedItem).onTouch() + end + end + end + + mainContainer:drawOnScreen() + end + + networkNameInput.onInputFinished = function() + MineOSCore.properties.network.name = #networkNameInput.text > 0 and networkNameInput.text or nil + MineOSCore.saveProperties() + MineOSNetwork.broadcastComputerState(MineOSCore.properties.network.enabled) + end + + signalStrengthSlider.onValueChanged = function() + MineOSCore.properties.network.signalStrength = math.floor(signalStrengthSlider.value) + MineOSCore.saveProperties() + end + + stateSwitchAndLabel.switch.onStateChanged = function() + if stateSwitchAndLabel.switch.state then + MineOSNetwork.enable() + else + MineOSNetwork.disable() + end + + check() + end + + allowReadAndWriteSwitchAndLabel.switch.onStateChanged = function() + MineOSCore.properties.network.users[remoteComputersComboBox:getItem(remoteComputersComboBox.selectedItem).proxyAddress].allowReadAndWrite = allowReadAndWriteSwitchAndLabel.switch.state + MineOSCore.saveProperties() + end + + -- Empty object-listener + emptyObject.eventHandler = function(mainContainer, object, e1, e2, e3, ...) + if (e1 == "component_added" or e1 == "component_removed") and e3 == "modem" then + check() + elseif e1 == "MineOSNetwork" and e2 == "updateProxyList" then + check() + end + end + + check() +end + +-------------------------------------------------------------------------------- + +return module + diff --git a/Applications/Settings/Modules/6_Localizations/Icon.pic b/Applications/Settings/Modules/6_Localizations/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..0c83247fc281317fa1b2b24329e68d17683aafb5 GIT binary patch literal 184 zcmXxe%?ScQ30 W^i?f!9!BMBW1Ma*^d-viA?y!aHY(u& literal 0 HcmV?d00001 diff --git a/Applications/Settings/Modules/6_Localizations/Main.lua b/Applications/Settings/Modules/6_Localizations/Main.lua new file mode 100644 index 00000000..7f1b8944 --- /dev/null +++ b/Applications/Settings/Modules/6_Localizations/Main.lua @@ -0,0 +1,44 @@ + +local GUI = require("GUI") +local MineOSInterface = require("MineOSInterface") +local MineOSPaths = require("MineOSPaths") +local MineOSCore = require("MineOSCore") +local filesystem = require("filesystem") + +local module = {} + +local mainContainer, window, localization = table.unpack({...}) + +-------------------------------------------------------------------------------- + +module.name = localization.localizations +module.margin = 0 +module.onTouch = function() + local comboBox = window.contentLayout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5)) + window.contentLayout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0xA5A5A5, {localization.localizationsInfo}, 1, 0, 0, true, true)) + + for file in filesystem.list(MineOSPaths.localizationFiles) do + local name = filesystem.hideExtension(file) + comboBox:addItem(name).onTouch = function() + MineOSCore.properties.language = name + MineOSCore.localization = MineOSCore.getLocalization(MineOSPaths.localizationFiles) + + MineOSInterface.createWidgets() + MineOSInterface.changeResolution() + MineOSInterface.changeWallpaper() + MineOSCore.updateTime() + MineOSInterface.updateFileListAndDraw() + + MineOSCore.saveProperties() + end + + if name == MineOSCore.properties.language then + comboBox.selectedItem = comboBox:count() + end + end +end + +-------------------------------------------------------------------------------- + +return module + diff --git a/Applications/Settings/Modules/7_Time/Icon.pic b/Applications/Settings/Modules/7_Time/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..9e39f28048a9418dd46625b9f35c7eb190fb2762 GIT binary patch literal 162 zcmXZV%MHRn3`BP|^YWI~lG J_ZPha(hsB#Bd!1d literal 0 HcmV?d00001 diff --git a/Applications/Settings/Modules/7_Time/Main.lua b/Applications/Settings/Modules/7_Time/Main.lua new file mode 100644 index 00000000..7bb173ae --- /dev/null +++ b/Applications/Settings/Modules/7_Time/Main.lua @@ -0,0 +1,52 @@ + +local GUI = require("GUI") +local MineOSInterface = require("MineOSInterface") +local MineOSPaths = require("MineOSPaths") +local MineOSCore = require("MineOSCore") + +local module = {} + +local mainContainer, window, localization = table.unpack({...}) + +-------------------------------------------------------------------------------- + +module.name = localization.time +module.margin = 0 +module.onTouch = function() + window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.timeZone)) + + local comboBox = window.contentLayout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xD2D2D2, 0xA5A5A5)) + comboBox.dropDownMenu.itemHeight = 1 + + for i = -12, 12 do + comboBox:addItem("GMT" .. (i >= 0 and "+" or "") .. i) + end + + window.contentLayout:addChild(GUI.text(1, 1, 0x2D2D2D, localization.timeFormat)) + + local input = window.contentLayout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0xA5A5A5, 0xE1E1E1, 0x2D2D2D, MineOSCore.properties.dateFormat or "")) + + local switch = window.contentLayout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, localization.timeUseRealTimestamp .. ":", MineOSCore.properties.timeUseRealTimestamp)).switch + + window.contentLayout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0xA5A5A5, {localization.timeInfo}, 1, 0, 0, true, true)) + + comboBox.selectedItem = (MineOSCore.properties.timezone or 0) + 13 + comboBox.onItemSelected = function() + MineOSCore.properties.timeUseRealTimestamp = switch.state + MineOSCore.properties.timezone = comboBox.selectedItem - 13 + MineOSCore.properties.dateFormat = input.text + + MineOSCore.updateTimezone() + MineOSCore.updateTime() + MineOSInterface.mainContainer:drawOnScreen() + + MineOSCore.saveProperties() + end + + input.onInputFinished, switch.onStateChanged = comboBox.onItemSelected, comboBox.onItemSelected +end + +-------------------------------------------------------------------------------- + +return module + diff --git a/Applications/Settings/Modules/8_System/Icon.pic b/Applications/Settings/Modules/8_System/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..4148c0e1563a61a07ab44e4068686fce802a9cf1 GIT binary patch literal 79 zcmeZw_H<+8U}pT!!18E82O|UHe@13jCT12^wnvK^z+6TMSAmg%=|2-AGb1|(Gl 0 and networkNameInput.text or nil - MineOSCore.saveProperties() - MineOSNetwork.broadcastComputerState(MineOSCore.properties.network.enabled) - end - - signalStrengthSlider.onValueChanged = function() - MineOSCore.properties.network.signalStrength = math.floor(signalStrengthSlider.value) - MineOSCore.saveProperties() - end - - stateSwitchAndLabel.switch.onStateChanged = function() - if stateSwitchAndLabel.switch.state then - MineOSNetwork.enable() - else - MineOSNetwork.disable() - end - - check() - end - - allowReadAndWriteSwitchAndLabel.switch.onStateChanged = function() - MineOSCore.properties.network.users[remoteComputersComboBox:getItem(remoteComputersComboBox.selectedItem).proxyAddress].allowReadAndWrite = allowReadAndWriteSwitchAndLabel.switch.state - MineOSCore.saveProperties() - end - - container.panel.eventHandler = function(mainContainer, object, e1, e2, e3) - if e1 == "touch" then - container:remove() - MineOSInterface.mainContainer:drawOnScreen() - elseif (e1 == "component_added" or e1 == "component_removed") and e3 == "modem" then - check() - elseif e1 == "MineOSNetwork" and e2 == "updateProxyList" then - check() - end - end - - check() - end - - local settingsContextMenu = MineOSInterface.mainContainer.menu:addContextMenu(MineOSCore.localization.settings) - if computer.getArchitectures then - settingsContextMenu: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 - - settingsContextMenu: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)) - comboBox.dropDownMenu.itemHeight = 1 - - local function update() - local libraries = {} - for key, value in pairs(package.loaded) do - if _G[key] ~= value then - table.insert(libraries, key) - end - end - - table.sort(libraries, function(a, b) return unicode.lower(a) < unicode.lower(b) end) - - 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 - - settingsContextMenu: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 - - settingsContextMenu:addSeparator() - - 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.updateTime() - - MineOSInterface.mainContainer.updateFileListAndDraw() - MineOSCore.saveProperties() - end - - if name == MineOSCore.properties.language then - comboBox.selectedItem = comboBox:count() - end - end - end - - settingsContextMenu: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 - - 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 - - MineOSInterface.mainContainer:drawOnScreen() - end - - settingsContextMenu:addItem(MineOSCore.localization.colorScheme).onTouch = function() - local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.colorScheme) - - 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 switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0xE1E1E1, MineOSCore.localization.transparencyEnabled .. ":", MineOSCore.properties.transparencyEnabled)).switch - switch.onStateChanged = function() - MineOSCore.properties.transparencyEnabled = switch.state - - 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 - applyTransparency() - - MineOSInterface.mainContainer:drawOnScreen() - MineOSCore.saveProperties() - end - container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x5A5A5A, {MineOSCore.localization.transparencySwitchInfo}, 1, 0, 0, true, true)) - - backgroundColorSelector.onColorSelected = function() - 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() - end - menuColorSelector.onColorSelected = backgroundColorSelector.onColorSelected - dockColorSelector.onColorSelected = backgroundColorSelector.onColorSelected - - container.panel.eventHandler = function(mainContainer, object, e1) - if e1 == "touch" then - container:remove() - MineOSInterface.mainContainer:drawOnScreen() - - MineOSCore.saveProperties() - end - 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.updateTime() - - MineOSInterface.mainContainer:drawOnScreen() - MineOSCore.saveProperties() - end - - for i = -12, 12 do - comboBox:addItem("GMT" .. (i >= 0 and "+" or "") .. i).onTouch = function() - MineOSCore.properties.timezone = i - MineOSCore.updateTimezone(i) - - MineOSInterface.mainContainer:drawOnScreen() - MineOSCore.saveProperties() - end - end - - MineOSInterface.mainContainer:drawOnScreen() - 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:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL) MineOSInterface.mainContainer.menuLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_RIGHT, GUI.ALIGNMENT_VERTICAL_TOP) @@ -1051,7 +649,7 @@ local function createOSWidgets() MineOSCore.updateTime = function() MineOSCore.time = realTimestamp + computer.uptime() - bootUptime + timezoneCorrection - dateWidgetText = os.date(MineOSCore.properties.dateFormat, MineOSCore.time) + dateWidgetText = os.date(MineOSCore.properties.dateFormat, MineOSCore.properties.timeUseRealTimestamp and MineOSCore.time or nil) dateWidget.width = unicode.len(dateWidgetText) batteryWidgetPercent = computer.energy() / computer.maxEnergy() @@ -1065,12 +663,12 @@ local function createOSWidgets() RAMPercent = (totalMemory - computer.freeMemory()) / totalMemory end - MineOSCore.updateTimezone = function(timezone) - timezoneCorrection = timezone * 3600 + MineOSCore.updateTimezone = function() + timezoneCorrection = MineOSCore.properties.timezone * 3600 MineOSCore.updateTime() end - MineOSInterface.mainContainer.updateFileListAndDraw = function(...) + MineOSInterface.updateFileListAndDraw = function(...) MineOSInterface.mainContainer.iconField:updateFileList() MineOSInterface.mainContainer:drawOnScreen(...) end @@ -1105,11 +703,11 @@ local function createOSWidgets() lastWindowHandled = false elseif e1 == "MineOSCore" then if e2 == "updateFileList" then - MineOSInterface.mainContainer.updateFileListAndDraw() + MineOSInterface.updateFileListAndDraw() elseif e2 == "updateFileListAndBufferTrueRedraw" then - MineOSInterface.mainContainer.updateFileListAndDraw(true) + MineOSInterface.updateFileListAndDraw(true) elseif e2 == "updateWallpaper" then - changeWallpaper() + MineOSInterface.changeWallpaper() MineOSInterface.mainContainer:drawOnScreen() end elseif e1 == "MineOSNetwork" then @@ -1132,8 +730,8 @@ local function createOSWidgets() end if dateUptime - screensaverUptime >= MineOSCore.properties.screensaverDelay then - if fs.exists(screensaversPath .. MineOSCore.properties.screensaver) then - MineOSInterface.safeLaunch(screensaversPath .. MineOSCore.properties.screensaver) + if fs.exists(MineOSCore.properties.screensaver) then + MineOSInterface.safeLaunch(MineOSCore.properties.screensaver) MineOSInterface.mainContainer:drawOnScreen(true) end @@ -1156,22 +754,35 @@ end local function createOSWindow() MineOSInterface.mainContainer = GUI.fullScreenContainer() - createOSWidgets() - changeResolution() - changeWallpaper() - MineOSCore.updateTimezone(MineOSCore.properties.timezone) + MineOSInterface.createWidgets() + MineOSInterface.changeResolution() + MineOSInterface.changeWallpaper() + MineOSCore.updateTimezone() +end + +local function runTasks(mode) + for i = 1, #MineOSCore.properties.tasks do + local task = MineOSCore.properties.tasks[i] + if task.mode == mode and task.enabled then + MineOSInterface.safeLaunch(task.path) + end + end end ---------------------------------------- Сама ОС ---------------------------------------- MineOSCore.localization = MineOSCore.getLocalization(MineOSPaths.localizationFiles) -applyTransparency() +runTasks(2) + +MineOSInterface.applyTransparency() updateCurrentTimestamp() createOSWindow() login() MineOSNetwork.update() +runTasks(1) + while true do local success, path, line, traceback = MineOSCore.call( MineOSInterface.mainContainer.startEventHandling, diff --git a/lib/MineOSCore.lua b/lib/MineOSCore.lua index 57d099a3..a1244e68 100755 --- a/lib/MineOSCore.lua +++ b/lib/MineOSCore.lua @@ -88,6 +88,8 @@ function MineOSCore.loadPropeties() end local defaultValues = { + tasks = {}, + timeUseRealTimestamp = true, dateFormat = "%d %b %Y %H:%M:%S", packageUnloading = true, transparencyEnabled = true, diff --git a/lib/MineOSNetwork.lua b/lib/MineOSNetwork.lua index 1f945667..e20f745e 100755 --- a/lib/MineOSNetwork.lua +++ b/lib/MineOSNetwork.lua @@ -650,12 +650,12 @@ local exceptionMethods = { end, } -local function handleRequest(eventData) - if MineOSCore.properties.network.users[eventData[3]].allowReadAndWrite then - local result = { pcall(exceptionMethods[eventData[8]] or filesystemProxy[eventData[8]], table.unpack(eventData, 9)) } - MineOSNetwork.sendMessage(eventData[3], "MineOSNetwork", "response", eventData[8], table.unpack(result, result[1] and 2 or 1)) +local function handleRequest(e1, e2, e3, e4, e5, e6, e7, e8, ...) + if MineOSCore.properties.network.users[e3].allowReadAndWrite then + local result = { pcall(exceptionMethods[e8] or filesystemProxy[e8], ...) } + MineOSNetwork.sendMessage(e3, "MineOSNetwork", "response", e8, table.unpack(result, result[1] and 2 or 1)) else - MineOSNetwork.sendMessage(eventData[3], "MineOSNetwork", "accessDenied") + MineOSNetwork.sendMessage(e3, "MineOSNetwork", "accessDenied") end end @@ -668,51 +668,13 @@ function MineOSNetwork.update() MineOSNetwork.setSignalStrength(MineOSCore.properties.network.signalStrength) MineOSNetwork.broadcastComputerState(MineOSCore.properties.network.enabled) - if MineOSNetwork.eventHandlerID then - event.removeHandler(MineOSNetwork.eventHandlerID) - end + -- if MineOSNetwork.eventHandlerID then + -- event.removeHandler(MineOSNetwork.eventHandlerID) + -- end - if MineOSCore.properties.network.enabled then - MineOSNetwork.eventHandlerID = event.addHandler(function(...) - local eventData = {...} - - if (eventData[1] == "component_added" or eventData[1] == "component_removed") and (eventData[3] == "modem" or eventData[3] == "internet") then - MineOSNetwork.updateComponents() - elseif eventData[1] == "modem_message" and MineOSCore.properties.network.enabled and eventData[6] == "MineOSNetwork" then - if eventData[7] == "request" then - handleRequest(eventData) - elseif eventData[7] == "computerAvailable" or eventData[7] == "computerAvailableRedirect" then - for proxy in fs.mounts() do - if proxy.MineOSNetworkModem and proxy.address == eventData[3] then - fs.umount(proxy) - end - end - - proxy = newModemProxy(eventData[3]) - proxy.name = eventData[8] - fs.mount(proxy, MineOSNetwork.mountPaths.modem .. eventData[3] .. "/") - - if eventData[7] == "computerAvailable" then - MineOSNetwork.sendMessage(eventData[3], "MineOSNetwork", "computerAvailableRedirect", MineOSCore.properties.network.name) - end - - if not MineOSCore.properties.network.users[eventData[3]] then - MineOSCore.properties.network.users[eventData[3]] = {} - MineOSCore.saveProperties() - end - - computer.pushSignal("MineOSNetwork", "updateProxyList") - elseif eventData[7] == "computerNotAvailable" then - local proxy = MineOSNetwork.getMountedModemProxy(eventData[3]) - if proxy then - fs.umount(proxy) - end - - computer.pushSignal("MineOSNetwork", "updateProxyList") - end - end - end) - end + -- if MineOSCore.properties.network.enabled then + + -- end end function MineOSNetwork.disable() @@ -729,16 +691,45 @@ end ---------------------------------------------------------------------------------------------------------------- --- MineOSNetwork.updateComponents() +event.addHandler(function(e1, e2, e3, e4, e5, e6, e7, e8, ...) + if (e1 == "component_added" or e1 == "component_removed") and (e3 == "modem" or e3 == "internet") then + MineOSNetwork.updateComponents() + MineOSNetwork.broadcastComputerState(MineOSCore.properties.network.enabled) + elseif MineOSCore.properties.network.enabled and e1 == "modem_message" and e6 == "MineOSNetwork" then + if e7 == "request" then + handleRequest(e1, e2, e3, e4, e5, e6, e7, e8, ...) + elseif e7 == "computerAvailable" or e7 == "computerAvailableRedirect" then + for proxy in fs.mounts() do + if proxy.MineOSNetworkModem and proxy.address == e3 then + fs.umount(proxy) + end + end --- local proxy, reason = MineOSNetwork.FTPProxy("localhost", 8888, "root", "1234") --- print(proxy, reason) + proxy = newModemProxy(e3) + proxy.name = e8 + fs.mount(proxy, MineOSNetwork.mountPaths.modem .. e3 .. "/") + + if e7 == "computerAvailable" then + MineOSNetwork.sendMessage(e3, "MineOSNetwork", "computerAvailableRedirect", MineOSCore.properties.network.name) + end + + if not MineOSCore.properties.network.users[e3] then + MineOSCore.properties.network.users[e3] = {} + MineOSCore.saveProperties() + end + + computer.pushSignal("MineOSNetwork", "updateProxyList") + elseif e7 == "computerNotAvailable" then + local proxy = MineOSNetwork.getMountedModemProxy(e3) + if proxy then + fs.umount(proxy) + end + + computer.pushSignal("MineOSNetwork", "updateProxyList") + end + end +end) ---------------------------------------------------------------------------------------------------------------- return MineOSNetwork - - - - -