mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
112 lines
3.7 KiB
Lua
112 lines
3.7 KiB
Lua
|
|
local GUI = require("GUI")
|
|
local screen = require("Screen")
|
|
local paths = require("Paths")
|
|
local system = require("System")
|
|
|
|
local module = {}
|
|
|
|
local workspace, 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()
|
|
screen.clear(0x0)
|
|
screen.update()
|
|
|
|
screen.bind(address, false)
|
|
|
|
system.updateResolution()
|
|
system.updateWallpaper()
|
|
workspace:draw()
|
|
|
|
system.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)
|
|
system.properties.interfaceScreenWidth = width
|
|
system.properties.interfaceScreenHeight = height
|
|
|
|
system.updateResolution()
|
|
system.updateWallpaper()
|
|
workspace:draw()
|
|
|
|
system.saveProperties()
|
|
end
|
|
|
|
local step = 1 / 6
|
|
for i = 1, step, -step do
|
|
local width, height = screen.getScaledResolution(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 maxWidth, maxHeight = screen.getGPUProxy().maxResolution()
|
|
local limit = maxWidth * maxHeight
|
|
local cykaTextBox = window.contentLayout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x880000, {string.format(localization.screenInvalidResolution, limit)}, 1, 0, 0, true, true))
|
|
|
|
local switch = window.contentLayout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0xE1E1E1, 0xFFFFFF, 0xA5A5A5, localization.screenAutoScale .. ":", system.properties.interfaceScreenAutoScale)).switch
|
|
|
|
window.contentLayout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0xA5A5A5, {localization.screenScaleInfo}, 1, 0, 0, true, true))
|
|
|
|
local function updateSwitch()
|
|
widthInput.text = tostring(system.properties.interfaceScreenWidth and system.properties.interfaceScreenWidth or screen.getWidth())
|
|
heightInput.text = tostring(system.properties.interfaceScreenHeight and system.properties.interfaceScreenHeight or screen.getHeight())
|
|
resolutionComboBox.hidden = not switch.state
|
|
layout.hidden = switch.state
|
|
end
|
|
|
|
local function updateCykaTextBox()
|
|
local width, height = tonumber(widthInput.text), tonumber(heightInput.text)
|
|
cykaTextBox.hidden = width and height and width * height <= limit
|
|
return width, height
|
|
end
|
|
|
|
switch.onStateChanged = function()
|
|
updateSwitch()
|
|
updateCykaTextBox()
|
|
workspace:draw()
|
|
|
|
system.properties.interfaceScreenAutoScale = switch.state
|
|
system.saveProperties()
|
|
end
|
|
|
|
widthInput.onInputFinished = function()
|
|
local width, height = updateCykaTextBox()
|
|
if cykaTextBox.hidden then
|
|
setResolution(width, height)
|
|
else
|
|
workspace:draw()
|
|
end
|
|
end
|
|
heightInput.onInputFinished = widthInput.onInputFinished
|
|
|
|
updateSwitch()
|
|
updateCykaTextBox()
|
|
end
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
return module
|