mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-09-14 11:06:16 +05:00
Хуя вкусная обнова
This commit is contained in:
parent
39cc2c6d57
commit
5ffa0dde59
@ -5,7 +5,7 @@
|
||||
about="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/About/",
|
||||
type="Script",
|
||||
forceDownload=true,
|
||||
version=3.53,
|
||||
version=3.54,
|
||||
},
|
||||
{
|
||||
path="/MineOS/Pictures/MoonTouch.pic",
|
||||
@ -66,14 +66,14 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/Localization/Russian.lang",
|
||||
type="Script",
|
||||
forceDownload=true,
|
||||
version=1.19,
|
||||
version=1.22,
|
||||
},
|
||||
{
|
||||
path="/MineOS/System/OS/Localization/English.lang",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/MineOS/Localization/English.lang",
|
||||
type="Script",
|
||||
forceDownload=true,
|
||||
version=1.21,
|
||||
version=1.22,
|
||||
},
|
||||
|
||||
----------------------------------------------------- Системные иконки --------------------------------------------------------------------------
|
||||
@ -198,14 +198,14 @@
|
||||
path="/lib/MineOSCore.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
|
||||
type="Library",
|
||||
version=1.56,
|
||||
version=1.57,
|
||||
},
|
||||
{
|
||||
path="/lib/advancedLua.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/advancedLua.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.10,
|
||||
version=1.11,
|
||||
},
|
||||
{
|
||||
path="/lib/web.lua",
|
||||
@ -214,12 +214,12 @@
|
||||
preloadFile=true,
|
||||
version=1.00,
|
||||
},
|
||||
-- {
|
||||
-- path="/lib/event.lua",
|
||||
-- url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/event.lua",
|
||||
-- type="Library",
|
||||
-- version=1.00,
|
||||
-- },
|
||||
{
|
||||
path="/lib/event.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/event.lua",
|
||||
type="Library",
|
||||
version=1.01,
|
||||
},
|
||||
{
|
||||
path="/lib/ECSAPI.lua",
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/ECSAPI.lua",
|
||||
@ -231,7 +231,7 @@
|
||||
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/color.lua",
|
||||
type="Library",
|
||||
preloadFile=true,
|
||||
version=1.00,
|
||||
version=1.01,
|
||||
},
|
||||
{
|
||||
path="/lib/ImageFormatModules/OCIF.lua",
|
||||
|
||||
1
MineOS/Localization/Russian.lang
Executable file → Normal file
1
MineOS/Localization/Russian.lang
Executable file → Normal file
@ -1,4 +1,5 @@
|
||||
{
|
||||
resolution = "Разрешение экрана",
|
||||
pressAnyKeyToContinue = "Нажмите любую клавишу, чтобы продолжить",
|
||||
screensaver = "Заставка",
|
||||
screensaverDelay = "Задержка",
|
||||
|
||||
223
MineOS/OS.lua
223
MineOS/OS.lua
@ -16,13 +16,11 @@ local copyright = [[
|
||||
-- Вычищаем копирайт из оперативки, ибо мы не можем тратить СТОЛЬКО памяти.
|
||||
-- Сколько тут, раз, два, три... 282 UTF-8 символа!
|
||||
-- А это, между прочим, 56 раз по слову "Пидор". Но один раз - не пидорас, поэтому очищаем.
|
||||
|
||||
-- Я передумал, не очищаем, пригодится еще кое-где. Вот же ж костыльная параша!
|
||||
-- copyright = nil
|
||||
copyright = nil
|
||||
|
||||
---------------------------------------------- Адаптивная загрузка библиотек ------------------------------------------------------------------------
|
||||
|
||||
-- package.loaded.MineOSCore = nil
|
||||
package.loaded.MineOSCore = nil
|
||||
|
||||
local component = require("component")
|
||||
local unicode = require("unicode")
|
||||
@ -70,7 +68,7 @@ local function drawBiometry(backgroundColor, textColor, text)
|
||||
local x, y = math.floor(buffer.screen.width / 2 - width / 2), math.floor(buffer.screen.height / 2 - height / 2)
|
||||
|
||||
buffer.square(x, y, width, height, backgroundColor, 0x000000, " ", nil)
|
||||
buffer.image(math.floor(x + width / 2 - fingerWidth / 2), y + 2, image.load("/MineOS/System/OS/Icons/Finger.pic"))
|
||||
buffer.image(math.floor(x + width / 2 - fingerWidth / 2), y + 2, image.fromString([[180E0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 000000 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 000000 000000 0000FF 0000FF 000000 000000 000000 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 000000 000000 000000 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 0000FF 0000FF 000000 0000FF 000000 0000FF 0000FF 0000FF 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 000000 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 0000FF 000000 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 000000 0000FF 0000FF 000000 000000 0000FF 0000FF 0000FF 0000FF 0000FF ]]))
|
||||
buffer.text(math.floor(x + width / 2 - unicode.len(text) / 2), y + height - 3, textColor, text)
|
||||
buffer.draw()
|
||||
end
|
||||
@ -112,50 +110,55 @@ local function setBiometry()
|
||||
end
|
||||
|
||||
local function checkPassword()
|
||||
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.inputPassword},
|
||||
{"EmptyLine"},
|
||||
{"Input", 0x262626, 0x880000, MineOSCore.localization.inputPassword, "*"},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xbbbbbb, 0xffffff, "OK"}}
|
||||
)
|
||||
local hash = require("SHA2").hash(data[1])
|
||||
if hash == _G.OSSettings.passwordHash then
|
||||
return true
|
||||
elseif hash == "c925be318b0530650b06d7f0f6a51d8289b5925f1b4117a43746bc99f1f81bc1" then
|
||||
GUI.error(MineOSCore.localization.mineOSCreatorUsedMasterPassword)
|
||||
return true
|
||||
else
|
||||
GUI.error(MineOSCore.localization.incorrectPassword)
|
||||
end
|
||||
return false
|
||||
end
|
||||
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.inputPassword)
|
||||
local inputTextBox = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, nil, "Password", true, "*")
|
||||
local label = container.layout:addLabel(1, 1, 36, 1, 0xFF4940, MineOSCore.localization.incorrectPassword):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
label.isHidden = true
|
||||
|
||||
local function setPassword()
|
||||
while true do
|
||||
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.passwordProtection},
|
||||
{"EmptyLine"},
|
||||
{"Input", 0x262626, 0x880000, MineOSCore.localization.inputPassword},
|
||||
{"Input", 0x262626, 0x880000, MineOSCore.localization.confirmInputPassword},
|
||||
{"EmptyLine"}, {"Button", {0xAAAAAA, 0xffffff, "OK"}}
|
||||
)
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
|
||||
if data[1] == data[2] then
|
||||
_G.OSSettings.protectionMethod = "password"
|
||||
_G.OSSettings.passwordHash = require("SHA2").hash(data[1])
|
||||
MineOSCore.saveOSSettings()
|
||||
return
|
||||
container.panel.onTouch = function()
|
||||
local hash = require("SHA2").hash(inputTextBox.text or "")
|
||||
if hash == _G.OSSettings.passwordHash then
|
||||
workspace:deleteChildren(#workspace.children)
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
elseif hash == "c925be318b0530650b06d7f0f6a51d8289b5925f1b4117a43746bc99f1f81bc1" then
|
||||
GUI.error(MineOSCore.localization.mineOSCreatorUsedMasterPassword)
|
||||
workspace:deleteChildren(#workspace.children)
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
else
|
||||
GUI.error(MineOSCore.localization.passwordsAreDifferent)
|
||||
label.isHidden = false
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function changePassword()
|
||||
if checkPassword() then setPassword() end
|
||||
local function setPassword()
|
||||
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.passwordProtection)
|
||||
local inputTextBox1 = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, nil, MineOSCore.localization.inputPassword, true, "*")
|
||||
local inputTextBox2 = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, nil, MineOSCore.localization.confirmInputPassword, true, "*")
|
||||
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
|
||||
container.panel.onTouch = function()
|
||||
if inputTextBox1.text == inputTextBox2.text then
|
||||
workspace:deleteChildren(#workspace.children)
|
||||
|
||||
_G.OSSettings.protectionMethod = "password"
|
||||
_G.OSSettings.passwordHash = require("SHA2").hash(inputTextBox1.text)
|
||||
MineOSCore.saveOSSettings()
|
||||
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
else
|
||||
GUI.error(MineOSCore.localization.passwordsAreDifferent)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function setWithoutProtection()
|
||||
@ -165,21 +168,26 @@ local function setWithoutProtection()
|
||||
end
|
||||
|
||||
local function setProtectionMethod()
|
||||
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.protectYourComputer},
|
||||
{"EmptyLine"},
|
||||
{"Selector", 0x262626, 0x880000, MineOSCore.localization.biometricProtection, MineOSCore.localization.passwordProtection, MineOSCore.localization.withoutProtection},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}}
|
||||
)
|
||||
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.protectYourComputer)
|
||||
|
||||
local comboBox = container.layout:addComboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x666666, 0xEEEEEE)
|
||||
comboBox:addItem(MineOSCore.localization.biometricProtection)
|
||||
comboBox:addItem(MineOSCore.localization.passwordProtection)
|
||||
comboBox:addItem(MineOSCore.localization.withoutProtection)
|
||||
|
||||
if data[2] == "OK" then
|
||||
if data[1] == MineOSCore.localization.passwordProtection then
|
||||
setPassword()
|
||||
elseif data[1] == MineOSCore.localization.biometricProtection then
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
|
||||
container.panel.onTouch = function()
|
||||
workspace:deleteChildren(#workspace.children)
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
|
||||
if comboBox.currentItem == 1 then
|
||||
setBiometry()
|
||||
elseif data[1] == MineOSCore.localization.withoutProtection then
|
||||
elseif comboBox.currentItem == 2 then
|
||||
setPassword()
|
||||
elseif comboBox.currentItem == 3 then
|
||||
setWithoutProtection()
|
||||
end
|
||||
end
|
||||
@ -190,9 +198,7 @@ local function login()
|
||||
if not _G.OSSettings.protectionMethod then
|
||||
setProtectionMethod()
|
||||
elseif _G.OSSettings.protectionMethod == "password" then
|
||||
while true do
|
||||
if checkPassword() == true then break end
|
||||
end
|
||||
checkPassword()
|
||||
elseif _G.OSSettings.protectionMethod == "biometric" then
|
||||
while true do
|
||||
local success, username = waitForBiometry(_G.OSSettings.passwordHash)
|
||||
@ -411,8 +417,7 @@ end
|
||||
|
||||
local function changeResolution()
|
||||
currentDesktop = 1
|
||||
ecs.setScale(_G.OSSettings.screenScale or 1)
|
||||
buffer.start()
|
||||
buffer.setResolution(table.unpack(_G.OSSettings.resolution or {160, 50}))
|
||||
|
||||
workspace.width, workspace.height = buffer.screen.width, buffer.screen.height
|
||||
|
||||
@ -467,12 +472,13 @@ local function createWorkspace()
|
||||
login()
|
||||
end
|
||||
menu:addItem(MineOSCore.localization.reboot).onTouch = function()
|
||||
ecs.TV(0)
|
||||
-- ecs.TV(0)
|
||||
require("computer").shutdown(true)
|
||||
dofile("/bin/reboot.lua")
|
||||
end
|
||||
menu:addItem(MineOSCore.localization.shutdown).onTouch = function()
|
||||
ecs.TV(0)
|
||||
dofile("/bin/shutdown.lua")
|
||||
-- ecs.TV(0)
|
||||
require("computer").shutdown()
|
||||
end
|
||||
menu:addSeparator()
|
||||
menu:addItem(MineOSCore.localization.returnToShell).onTouch = function()
|
||||
@ -523,46 +529,47 @@ local function createWorkspace()
|
||||
end
|
||||
menu:addSeparator()
|
||||
menu:addItem(MineOSCore.localization.screensaver).onTouch = function()
|
||||
local possibleScreensavers = {}; for file in fs.list(screensaversPath) do table.insert(possibleScreensavers, fs.hideExtension(file)) end
|
||||
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.screensaver},
|
||||
{"EmptyLine"},
|
||||
{"Selector", 0x262626, 0x880000, MineOSCore.localization.screensaverDisabled, table.unpack(possibleScreensavers)},
|
||||
{"Slider", 0x262626, 0x880000, 1, 100, _G.OSSettings.screensaverDelay or 20, MineOSCore.localization.screensaverDelay .. ": ", ""},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xbbbbbb, 0xffffff, "OK"}}
|
||||
)
|
||||
if data[3] == "OK" then
|
||||
if data[1] == MineOSCore.localization.screensaverDisabled then
|
||||
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.screensaver)
|
||||
|
||||
local comboBox = container.layout:addComboBox(1, 1, 36, 3, 0xEEEEEE, 0x262626, 0x666666, 0xEEEEEE)
|
||||
comboBox:addItem(MineOSCore.localization.screensaverDisabled)
|
||||
for file in fs.list(screensaversPath) do
|
||||
comboBox:addItem(fs.hideExtension(file))
|
||||
end
|
||||
local slider = container.layout:addHorizontalSlider(1, 1, 36, 0xFFDB40, 0xEEEEEE, 0xFFDB80, 0xBBBBBB, 1, 100, _G.OSSettings.screensaverDelay or 20, false, MineOSCore.localization.screensaverDelay .. ": ", "")
|
||||
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
|
||||
container.panel.onTouch = function()
|
||||
workspace:deleteChildren(#workspace.children)
|
||||
if comboBox.currentItem == 1 then
|
||||
_G.OSSettings.screensaver = nil
|
||||
else
|
||||
_G.OSSettings.screensaver, _G.OSSettings.screensaverDelay = data[1], data[2]
|
||||
_G.OSSettings.screensaver, _G.OSSettings.screensaverDelay = comboBox.items[comboBox.currentItem].text, slider.value
|
||||
end
|
||||
MineOSCore.saveOSSettings()
|
||||
end
|
||||
end
|
||||
menu:addItem(MineOSCore.localization.colorScheme).onTouch = function()
|
||||
local data = ecs.universalWindow("auto", "auto", 36, 0xeeeeee, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.colorScheme},
|
||||
{"EmptyLine"},
|
||||
{"Color", MineOSCore.localization.backgroundColor, _G.OSSettings.backgroundColor or colors.background},
|
||||
{"Color", MineOSCore.localization.interfaceColor, _G.OSSettings.interfaceColor or colors.interface},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}}
|
||||
)
|
||||
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.colorScheme)
|
||||
|
||||
local backgroundColorSelector = container.layout:addColorSelector(1, 1, 36, 3, workspace.background.colors.background, MineOSCore.localization.backgroundColor)
|
||||
local interfaceColorSelector = container.layout:addColorSelector(1, 1, 36, 3, workspace.menu.colors.default.background, MineOSCore.localization.interfaceColor)
|
||||
|
||||
workspace:draw()
|
||||
buffer.draw()
|
||||
|
||||
if data[3] == "OK" then
|
||||
_G.OSSettings.backgroundColor = data[1]
|
||||
_G.OSSettings.interfaceColor = data[2]
|
||||
container.panel.onTouch = function()
|
||||
workspace:deleteChildren(#workspace.children)
|
||||
_G.OSSettings.backgroundColor, _G.OSSettings.interfaceColor = backgroundColorSelector.color, interfaceColorSelector.color
|
||||
workspace.background.colors.background, workspace.menu.colors.default.background = _G.OSSettings.backgroundColor, _G.OSSettings.interfaceColor
|
||||
MineOSCore.saveOSSettings()
|
||||
workspace.background.colors.background = data[1]
|
||||
workspace.menu.colors.default.background = data[2]
|
||||
end
|
||||
end
|
||||
menu:addItem(MineOSCore.localization.contextMenuRemoveWallpaper, workspace.wallpaper.isHidden).onTouch = function()
|
||||
_G.OSSettings.wallpaper = nil
|
||||
MineOSCore.saveOSSettings()
|
||||
changeWallpaper()
|
||||
end
|
||||
menu:show()
|
||||
@ -572,36 +579,28 @@ local function createWorkspace()
|
||||
item3.onTouch = function()
|
||||
local menu = GUI.contextMenu(item3.x, item3.y + 1)
|
||||
menu:addItem(MineOSCore.localization.screenResolution).onTouch = function()
|
||||
local possibleResolutions = {texts = {}, scales = {}}
|
||||
local xSize, ySize = ecs.getScaledResolution(1)
|
||||
local currentScale, decreaseStep = 1, 0.1
|
||||
for i = 1, 5 do
|
||||
local width, height = math.floor(xSize * currentScale), math.floor(ySize * currentScale)
|
||||
local text = width .. "x" .. height
|
||||
possibleResolutions.texts[i] = text
|
||||
possibleResolutions.scales[text] = currentScale
|
||||
currentScale = currentScale - decreaseStep
|
||||
local container = GUI.addUniversalContainer(workspace, MineOSCore.localization.screenResolution)
|
||||
|
||||
local widthTextBox = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, tostring(_G.OSSettings.resolution and _G.OSSettings.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 data = ecs.universalWindow("auto", "auto", 36, 0xeeeeee, true,
|
||||
{"EmptyLine"},
|
||||
{"CenterText", 0x000000, MineOSCore.localization.screenResolution},
|
||||
{"EmptyLine"},
|
||||
{"Selector", 0x262626, 0x880000, table.unpack(possibleResolutions.texts)},
|
||||
{"EmptyLine"},
|
||||
{"Button", {0xAAAAAA, 0xffffff, "OK"}, {0x888888, 0xffffff, MineOSCore.localization.cancel}}
|
||||
)
|
||||
local heightTextBox = container.layout:addInputTextBox(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, tostring(_G.OSSettings.resolution and _G.OSSettings.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
|
||||
|
||||
if data[2] == "OK" then
|
||||
_G.OSSettings.screenScale = possibleResolutions.scales[data[1]]
|
||||
container.panel.onTouch = function()
|
||||
workspace:deleteChildren(#workspace.children)
|
||||
_G.OSSettings.resolution = {tonumber(widthTextBox.text), tonumber(heightTextBox.text)}
|
||||
MineOSCore.saveOSSettings()
|
||||
changeResolution()
|
||||
end
|
||||
end
|
||||
menu:addSeparator()
|
||||
menu:addItem(MineOSCore.localization.changePassword, _G.OSSettings.protectionMethod ~= "password").onTouch = function()
|
||||
changePassword()
|
||||
end
|
||||
menu:addItem(MineOSCore.localization.setProtectionMethod).onTouch = function()
|
||||
setProtectionMethod()
|
||||
end
|
||||
|
||||
165
lib/GUI.lua
165
lib/GUI.lua
@ -87,7 +87,8 @@ GUI.objectTypes = enum(
|
||||
"scrollBar",
|
||||
"codeView",
|
||||
"treeView",
|
||||
"colorSelector"
|
||||
"colorSelector",
|
||||
"layout"
|
||||
)
|
||||
|
||||
----------------------------------------- Primitive objects -----------------------------------------
|
||||
@ -250,131 +251,110 @@ function GUI.addChildToContainer(container, object, objectType)
|
||||
return object
|
||||
end
|
||||
|
||||
-- Add empty GUI.object to container
|
||||
local function addEmptyObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.object(...), GUI.objectTypes.empty)
|
||||
end
|
||||
|
||||
-- Add button object to container
|
||||
local function addButtonObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.button(...), GUI.objectTypes.button)
|
||||
end
|
||||
|
||||
-- Add adaptive button object to container
|
||||
local function addAdaptiveButtonObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.adaptiveButton(...), GUI.objectTypes.button)
|
||||
end
|
||||
|
||||
-- Add framedButton object to container
|
||||
local function addFramedButtonObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.framedButton(...), GUI.objectTypes.button)
|
||||
end
|
||||
|
||||
-- Add roundedButton object to container
|
||||
local function addRoundedButtonObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.roundedButton(...), GUI.objectTypes.button)
|
||||
end
|
||||
|
||||
-- Add adaptive roundedButton object to container
|
||||
local function addAdaptiveRoundedButtonObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.adaptiveRoundedButton(...), GUI.objectTypes.button)
|
||||
end
|
||||
|
||||
-- Add adaptive framedButton object to container
|
||||
local function addAdaptiveFramedButtonObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.adaptiveFramedButton(...), GUI.objectTypes.button)
|
||||
end
|
||||
|
||||
-- Add label object to container
|
||||
local function addLabelObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.label(...), GUI.objectTypes.label)
|
||||
end
|
||||
|
||||
-- Add panel object to container
|
||||
local function addPanelObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.panel(...), GUI.objectTypes.panel)
|
||||
end
|
||||
|
||||
-- Add windowActionButtons object to container
|
||||
local function addWindowActionButtonsObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.windowActionButtons(...), GUI.objectTypes.windowActionButtons)
|
||||
end
|
||||
|
||||
-- Add another container to container
|
||||
local function addContainerToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.container(...), GUI.objectTypes.container)
|
||||
end
|
||||
|
||||
-- Add image object to container
|
||||
local function addImageObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.image(...), GUI.objectTypes.image)
|
||||
end
|
||||
|
||||
-- Add image object to container
|
||||
local function addTabBarObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.tabBar(...), GUI.objectTypes.tabBar)
|
||||
end
|
||||
|
||||
-- Add InputTextBox object to container
|
||||
local function addInputTextBoxObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.inputTextBox(...), GUI.objectTypes.inputTextBox)
|
||||
end
|
||||
|
||||
-- Add TextBox object to container
|
||||
local function addTextBoxObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.textBox(...), GUI.objectTypes.textBox)
|
||||
end
|
||||
|
||||
-- Add Horizontal Slider object to container
|
||||
local function addHorizontalSliderObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.horizontalSlider(...), GUI.objectTypes.horizontalSlider)
|
||||
end
|
||||
|
||||
-- Add Progressbar object to container
|
||||
local function addProgressBarObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.progressBar(...), GUI.objectTypes.progressBar)
|
||||
end
|
||||
|
||||
-- Add Switch object to container
|
||||
local function addSwitchObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.switch(...), GUI.objectTypes.switch)
|
||||
end
|
||||
|
||||
-- Add Chart object to container
|
||||
local function addChartObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.chart(...), GUI.objectTypes.chart)
|
||||
end
|
||||
|
||||
-- Add ComboBox object to container
|
||||
local function addComboBoxObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.comboBox(...), GUI.objectTypes.comboBox)
|
||||
end
|
||||
|
||||
-- Add Menu object to container
|
||||
local function addMenuObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.menu(...), GUI.objectTypes.menu)
|
||||
end
|
||||
|
||||
-- Add ScrollBar object to container
|
||||
local function addScrollBarObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.scrollBar(...), GUI.objectTypes.scrollBar)
|
||||
end
|
||||
|
||||
-- Add CodeView object to container
|
||||
local function addCodeViewObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.codeView(...), GUI.objectTypes.codeView)
|
||||
end
|
||||
|
||||
-- Add TreeView object to container
|
||||
local function addTreeViewObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.treeView(...), GUI.objectTypes.treeView)
|
||||
end
|
||||
|
||||
-- Add ColorSelector object to container
|
||||
local function addColorSelectorObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.colorSelector(...), GUI.objectTypes.colorSelector)
|
||||
end
|
||||
|
||||
local function addLayoutObjectToContainer(container, ...)
|
||||
return GUI.addChildToContainer(container, GUI.layout(...), GUI.objectTypes.layout)
|
||||
end
|
||||
|
||||
-- Recursively draw container's content including all children container's content
|
||||
local function drawContainerContent(container)
|
||||
for objectIndex = 1, #container.children do
|
||||
@ -396,8 +376,9 @@ end
|
||||
|
||||
-- Delete every container's children object
|
||||
local function deleteContainersContent(container, from, to)
|
||||
for objectIndex = from or 1, to or #container.children do
|
||||
container.children[objectIndex] = nil
|
||||
from = from or 1
|
||||
for objectIndex = from, to or #container.children do
|
||||
table.remove(container.children, from)
|
||||
end
|
||||
end
|
||||
|
||||
@ -435,6 +416,7 @@ function GUI.container(x, y, width, height)
|
||||
container.addCodeView = addCodeViewObjectToContainer
|
||||
container.addTreeView = addTreeViewObjectToContainer
|
||||
container.addColorSelector = addColorSelectorObjectToContainer
|
||||
container.addLayout = addLayoutObjectToContainer
|
||||
|
||||
return container
|
||||
end
|
||||
@ -1409,14 +1391,10 @@ function GUI.comboBox(x, y, width, elementHeight, backgroundColor, textColor, ar
|
||||
object.currentItem = 1
|
||||
object.addItem = addDropDownMenuItem
|
||||
object.addSeparator = addDropDownMenuSeparator
|
||||
if items then
|
||||
for i = 1, #items do
|
||||
object:addItem(items[i])
|
||||
end
|
||||
end
|
||||
object.draw = drawComboBox
|
||||
object.selectItem = selectComboBoxItem
|
||||
object.state = false
|
||||
|
||||
return object
|
||||
end
|
||||
|
||||
@ -2181,8 +2159,129 @@ function GUI.fullScreenWindow()
|
||||
return GUI.window(1, 1, buffer.screen.width, buffer.screen.height)
|
||||
end
|
||||
|
||||
----------------------------------------- Layout object -----------------------------------------
|
||||
|
||||
local function layoutCheckCell(layout, column, row)
|
||||
if column < 1 or column > #layout.grid[1] or row < 1 or row > #layout.grid then
|
||||
error("Specified grid position (" .. tostring(column) .. "x" .. tostring(row) .. ") is out of layout grid range (" .. tostring(#layout.grid[1]) .. "x" .. tostring(#layout.grid) .. ")")
|
||||
end
|
||||
end
|
||||
|
||||
local function layoutCalculate(layout)
|
||||
for row = 1, #layout.grid do
|
||||
for column = 1, #layout.grid[1] do
|
||||
layout.grid[row][column] = {direction = layout.grid[row][column].direction}
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, #layout.children do
|
||||
layout.children[i].layoutGridPosition = layout.children[i].layoutGridPosition or {column = 1, row = 1}
|
||||
table.insert(layout.grid[layout.children[i].layoutGridPosition.row][layout.children[i].layoutGridPosition.column], layout.children[i])
|
||||
end
|
||||
|
||||
local gridCellWidth, gridCellHeight = layout.width / #layout.grid[1], layout.height / #layout.grid
|
||||
for row = 1, #layout.grid do
|
||||
for column = 1, #layout.grid[row] do
|
||||
if #layout.grid[row][column] > 0 then
|
||||
|
||||
local totalWidth, totalHeight = 0, 0
|
||||
for i = 1, #layout.grid[row][column] do
|
||||
if layout.grid[row][column].direction == GUI.directions.horizontal then
|
||||
totalWidth = totalWidth + layout.grid[row][column][i].width + 2
|
||||
totalHeight = math.max(totalHeight, layout.grid[row][column][i].height)
|
||||
else
|
||||
totalWidth = math.max(totalWidth, layout.grid[row][column][i].width)
|
||||
totalHeight = totalHeight + layout.grid[row][column][i].height + 1
|
||||
end
|
||||
end
|
||||
|
||||
local x, y = column * gridCellWidth - gridCellWidth / 2 - totalWidth / 2, row * gridCellHeight - gridCellHeight / 2 - totalHeight / 2
|
||||
for i = 1, #layout.grid[row][column] do
|
||||
if layout.grid[row][column].direction == GUI.directions.horizontal then
|
||||
layout.grid[row][column][i].localPosition.x = math.floor(x)
|
||||
layout.grid[row][column][i].localPosition.y = math.floor(y + totalHeight / 2 - layout.grid[row][column][i].height / 2)
|
||||
x = x + layout.grid[row][column][i].width + 2
|
||||
else
|
||||
layout.grid[row][column][i].localPosition.x = math.floor(x + totalWidth / 2 - layout.grid[row][column][i].width / 2)
|
||||
layout.grid[row][column][i].localPosition.y = math.floor(y)
|
||||
y = y + layout.grid[row][column][i].height + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function layoutSetCellPosition(layout, object, column, row)
|
||||
layoutCheckCell(layout, column, row)
|
||||
|
||||
object.layoutGridPosition = {column = column, row = row}
|
||||
layoutCalculate(layout)
|
||||
return object
|
||||
end
|
||||
|
||||
local function layoutSetCellDirection(layout, column, row, direction)
|
||||
layoutCheckCell(layout, column, row)
|
||||
|
||||
layout.grid[row][column].direction = direction
|
||||
layoutCalculate(layout)
|
||||
return layout
|
||||
end
|
||||
|
||||
local function layoutDraw(layout)
|
||||
layoutCalculate(layout)
|
||||
drawContainerContent(layout)
|
||||
end
|
||||
|
||||
function GUI.layout(x, y, width, height, columnCount, rowCount)
|
||||
local layout = GUI.container(x, y, width, height)
|
||||
|
||||
layout.grid = {}
|
||||
for row = 1, rowCount do
|
||||
layout.grid[row] = {}
|
||||
for column = 1, columnCount do
|
||||
layout.grid[row][column] = {direction = GUI.directions.vertical}
|
||||
end
|
||||
end
|
||||
layout.setCellPosition = layoutSetCellPosition
|
||||
layout.setCellDirection = layoutSetCellDirection
|
||||
layout.draw = layoutDraw
|
||||
|
||||
return layout
|
||||
end
|
||||
|
||||
----------------------------------------- Layout object -----------------------------------------
|
||||
|
||||
function GUI.addUniversalContainer(parentWindow, title)
|
||||
local container = parentWindow:addContainer(1, 1, parentWindow.width, parentWindow.height)
|
||||
container.panel = container:addPanel(1, 1, container.width, container.height, 0x0, 30)
|
||||
container.layout = container:addLayout(1, 1, container.width, container.height, 1, 1)
|
||||
container.layout:addLabel(1, 1, unicode.len(title), 1, 0xEEEEEE, title):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
|
||||
return container
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- buffer.start()
|
||||
|
||||
-- local window = GUI.fullScreenWindow()
|
||||
-- window:addImage(1, 1, require("image").load("/MineOS/Pictures/Raspberry.pic"))
|
||||
-- window:addPanel(1, 1, window.width, window.height, 0x000000, 40)
|
||||
|
||||
-- local layout = window:addLayout(1, 1, window.width, window.height, 1, 1)
|
||||
-- layout:setCellPosition(layout:addLabel(1, 1, 30, 1, 0xEEEEEE, "Сохранить как"), 1, 1):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
-- layout:setCellPosition(layout:addInputTextBox(1, 1, 30, 3, 0xEEEEEE, 0x666666, 0xEEEEEE, 0x262626, nil, "Путь", false), 1, 1)
|
||||
-- local comboBox = layout:setCellPosition(layout:addComboBox(1, 1, 20, 3, 0xEEEEEE, 0x262626, 0x777777, 0xEEEEEE), 1, 1)
|
||||
-- comboBox:addItem(".PNG")
|
||||
-- comboBox:addItem(".PSD")
|
||||
-- comboBox:addItem(".JPG")
|
||||
|
||||
-- -- layout:setCellDirection(1, 1, GUI.directions.horizontal)
|
||||
|
||||
-- window:draw()
|
||||
-- buffer.draw(true)
|
||||
-- window:handleEvents()
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -100,21 +100,7 @@ end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local openComputersPalette = {}
|
||||
|
||||
for r = 0x0, 0xFF, 0xFF / 5 do
|
||||
for g = 0x0, 0xFF, 0xFF / 7 do
|
||||
for b = 0x0, 0xFF, 0xFF / 4 do
|
||||
table.insert(openComputersPalette, color.RGBToHEX(r, math.floor(g + 0,5), math.floor(b + 0.5)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for g = 0x1, 0x10 do
|
||||
table.insert(openComputersPalette, g * 0xF0F0F)
|
||||
end
|
||||
|
||||
table.sort(openComputersPalette)
|
||||
local openComputersPalette = { 0x000000, 0x000040, 0x000080, 0x0000BF, 0x0000FF, 0x002400, 0x002440, 0x002480, 0x0024BF, 0x0024FF, 0x004900, 0x004940, 0x004980, 0x0049BF, 0x0049FF, 0x006D00, 0x006D40, 0x006D80, 0x006DBF, 0x006DFF, 0x009200, 0x009240, 0x009280, 0x0092BF, 0x0092FF, 0x00B600, 0x00B640, 0x00B680, 0x00B6BF, 0x00B6FF, 0x00DB00, 0x00DB40, 0x00DB80, 0x00DBBF, 0x00DBFF, 0x00FF00, 0x00FF40, 0x00FF80, 0x00FFBF, 0x00FFFF, 0x0F0F0F, 0x1E1E1E, 0x2D2D2D, 0x330000, 0x330040, 0x330080, 0x3300BF, 0x3300FF, 0x332400, 0x332440, 0x332480, 0x3324BF, 0x3324FF, 0x334900, 0x334940, 0x334980, 0x3349BF, 0x3349FF, 0x336D00, 0x336D40, 0x336D80, 0x336DBF, 0x336DFF, 0x339200, 0x339240, 0x339280, 0x3392BF, 0x3392FF, 0x33B600, 0x33B640, 0x33B680, 0x33B6BF, 0x33B6FF, 0x33DB00, 0x33DB40, 0x33DB80, 0x33DBBF, 0x33DBFF, 0x33FF00, 0x33FF40, 0x33FF80, 0x33FFBF, 0x33FFFF, 0x3C3C3C, 0x4B4B4B, 0x5A5A5A, 0x660000, 0x660040, 0x660080, 0x6600BF, 0x6600FF, 0x662400, 0x662440, 0x662480, 0x6624BF, 0x6624FF, 0x664900, 0x664940, 0x664980, 0x6649BF, 0x6649FF, 0x666D00, 0x666D40, 0x666D80, 0x666DBF, 0x666DFF, 0x669200, 0x669240, 0x669280, 0x6692BF, 0x6692FF, 0x66B600, 0x66B640, 0x66B680, 0x66B6BF, 0x66B6FF, 0x66DB00, 0x66DB40, 0x66DB80, 0x66DBBF, 0x66DBFF, 0x66FF00, 0x66FF40, 0x66FF80, 0x66FFBF, 0x66FFFF, 0x696969, 0x787878, 0x878787, 0x969696, 0x990000, 0x990040, 0x990080, 0x9900BF, 0x9900FF, 0x992400, 0x992440, 0x992480, 0x9924BF, 0x9924FF, 0x994900, 0x994940, 0x994980, 0x9949BF, 0x9949FF, 0x996D00, 0x996D40, 0x996D80, 0x996DBF, 0x996DFF, 0x999200, 0x999240, 0x999280, 0x9992BF, 0x9992FF, 0x99B600, 0x99B640, 0x99B680, 0x99B6BF, 0x99B6FF, 0x99DB00, 0x99DB40, 0x99DB80, 0x99DBBF, 0x99DBFF, 0x99FF00, 0x99FF40, 0x99FF80, 0x99FFBF, 0x99FFFF, 0xA5A5A5, 0xB4B4B4, 0xC3C3C3, 0xCC0000, 0xCC0040, 0xCC0080, 0xCC00BF, 0xCC00FF, 0xCC2400, 0xCC2440, 0xCC2480, 0xCC24BF, 0xCC24FF, 0xCC4900, 0xCC4940, 0xCC4980, 0xCC49BF, 0xCC49FF, 0xCC6D00, 0xCC6D40, 0xCC6D80, 0xCC6DBF, 0xCC6DFF, 0xCC9200, 0xCC9240, 0xCC9280, 0xCC92BF, 0xCC92FF, 0xCCB600, 0xCCB640, 0xCCB680, 0xCCB6BF, 0xCCB6FF, 0xCCDB00, 0xCCDB40, 0xCCDB80, 0xCCDBBF, 0xCCDBFF, 0xCCFF00, 0xCCFF40, 0xCCFF80, 0xCCFFBF, 0xCCFFFF, 0xD2D2D2, 0xE1E1E1, 0xF0F0F0, 0xFF0000, 0xFF0040, 0xFF0080, 0xFF00BF, 0xFF00FF, 0xFF2400, 0xFF2440, 0xFF2480, 0xFF24BF, 0xFF24FF, 0xFF4900, 0xFF4940, 0xFF4980, 0xFF49BF, 0xFF49FF, 0xFF6D00, 0xFF6D40, 0xFF6D80, 0xFF6DBF, 0xFF6DFF, 0xFF9200, 0xFF9240, 0xFF9280, 0xFF92BF, 0xFF92FF, 0xFFB600, 0xFFB640, 0xFFB680, 0xFFB6BF, 0xFFB6FF, 0xFFDB00, 0xFFDB40, 0xFFDB80, 0xFFDBBF, 0xFFDBFF, 0xFFFF00, 0xFFFF40, 0xFFFF80, 0xFFFFBF, 0xFFFFFF }
|
||||
|
||||
function color.to8Bit(color24Bit)
|
||||
local closestDelta, r, g, b, closestIndex, delta, openComputersPaletteR, openComputersPaletteG, openComputersPaletteB = math.huge, color.HEXToRGB(color24Bit)
|
||||
|
||||
@ -17,7 +17,7 @@ local event = {
|
||||
[56] = true
|
||||
},
|
||||
onError = function(errorMessage)
|
||||
require("ECSAPI").error("CYKA: " .. tostring(errorMessage))
|
||||
-- require("ECSAPI").error("CYKA: " .. tostring(errorMessage))
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user