diff --git a/.DS_Store b/.DS_Store index d7df90c2..c8fe1962 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Applications.txt b/Applications.txt index f57bedbf..95fb11c4 100644 --- a/Applications.txt +++ b/Applications.txt @@ -318,13 +318,13 @@ name="lib/GUI.lua", url="IgorTimofeev/OpenComputers/master/lib/GUI.lua", type="Library", - version=1.16, + version=1.17, }, { name="lib/windows.lua", url="IgorTimofeev/OpenComputers/master/lib/windows.lua", type="Library", - version=1.02, + version=1.03, }, { name="lib/serialization.lua", @@ -336,13 +336,7 @@ name="lib/rayEngine.lua", url="IgorTimofeev/OpenComputers/master/lib/rayEngine.lua", type="Library", - version=1.35, - }, - { - name="lib/doubleHeight.lua", - url="IgorTimofeev/OpenComputers/master/lib/doubleHeight.lua", - type="Library", - version=1.02, + version=1.36, }, { name="lib/json.lua", @@ -414,7 +408,7 @@ name="lib/palette.lua", url="IgorTimofeev/OpenComputers/master/lib/palette.lua", type="Library", - version=1.02, + version=1.03, }, { name="lib/doubleBuffering.lua", @@ -525,69 +519,69 @@ version=1.0, }, ----------------------------------------------------- Приложения -------------------------------------------------------------------------- - -- { - -- name="MineOS/Applications/SmartHouse", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/SmartHouse.lua", - -- type="Application", - -- icon="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Icon.pic", - -- createShortcut="desktop", - -- version=1.22, - -- resources={ - -- { - -- name="Modules/redstone/Icon.pic", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/redstone/Icon.pic", - -- }, - -- { - -- name="Modules/redstone/Main.lua", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/redstone/Main.lua", - -- }, - -- -- - -- { - -- name="Modules/mfsu/Icon.pic", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/mfsu/Icon.pic", - -- }, - -- { - -- name="Modules/mfsu/Main.lua", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/mfsu/Main.lua", - -- }, - -- -- - -- { - -- name="Modules/screen/Icon.pic", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/screen/Icon.pic", - -- }, - -- { - -- name="Modules/screen/Main.lua", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/screen/Main.lua", - -- }, - -- -- - -- { - -- name="Modules/homePC/Icon.pic", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/homePC/Icon.pic", - -- }, - -- { - -- name="Modules/homePC/Main.lua", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/homePC/Main.lua", - -- }, - -- -- - -- { - -- name="Modules/motion_sensor/Icon.pic", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/motion_sensor/Icon.pic", - -- }, - -- { - -- name="Modules/motion_sensor/Main.lua", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/motion_sensor/Main.lua", - -- }, - -- -- - -- { - -- name="Modules/reactor/Icon.pic", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/reactor/Icon.pic", - -- }, - -- { - -- name="Modules/reactor/Main.lua", - -- url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/reactor/Main.lua", - -- }, - -- }, - -- }, + { + name="MineOS/Applications/SmartHouse", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/SmartHouse.lua", + type="Application", + icon="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Icon.pic", + createShortcut="desktop", + version=1.23, + resources={ + { + name="Modules/redstone/Icon.pic", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/redstone/Icon.pic", + }, + { + name="Modules/redstone/Main.lua", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/redstone/Main.lua", + }, + -- + { + name="Modules/mfsu/Icon.pic", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/mfsu/Icon.pic", + }, + { + name="Modules/mfsu/Main.lua", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/mfsu/Main.lua", + }, + -- + { + name="Modules/screen/Icon.pic", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/screen/Icon.pic", + }, + { + name="Modules/screen/Main.lua", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/screen/Main.lua", + }, + -- + { + name="Modules/homePC/Icon.pic", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/homePC/Icon.pic", + }, + { + name="Modules/homePC/Main.lua", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/homePC/Main.lua", + }, + -- + { + name="Modules/motion_sensor/Icon.pic", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/motion_sensor/Icon.pic", + }, + { + name="Modules/motion_sensor/Main.lua", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/motion_sensor/Main.lua", + }, + -- + { + name="Modules/reactor/Icon.pic", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/reactor/Icon.pic", + }, + { + name="Modules/reactor/Main.lua", + url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/reactor/Main.lua", + }, + }, + }, { name="MineOS/Applications/VK", url="IgorTimofeev/OpenComputers/master/Applications/VK/VK.lua", @@ -673,7 +667,7 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Icon.pic", createShortcut="desktop", - version=1.54, + version=1.55, resources={ { name="Localization/Russian.lang", @@ -796,7 +790,7 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/PrintImage/Icon.pic", createShortcut="desktop", - version=1.01, + version=1.02, }, { name="MineOS/Applications/Palette", @@ -856,7 +850,7 @@ type="Application", icon="IgorTimofeev/OpenComputers/master/Applications/Graph/Icon.pic", createShortcut="desktop", - version=1.01, + version=1.02, }, { name="MineOS/Applications/MineCode", diff --git a/Applications/.DS_Store b/Applications/.DS_Store index 884894ce..3812211d 100644 Binary files a/Applications/.DS_Store and b/Applications/.DS_Store differ diff --git a/Applications/Graph/Graph.lua b/Applications/Graph/Graph.lua index 7973024c..6e37efe0 100755 --- a/Applications/Graph/Graph.lua +++ b/Applications/Graph/Graph.lua @@ -1,7 +1,6 @@ _G.buffer = require("doubleBuffering") buffer.start() -_G.doubleHeight = require("doubleHeight") _G.unicode = require("unicode") _G.event = require("event") _G.ecs = require("ECSAPI") @@ -72,7 +71,7 @@ local function calculateKeyPoints() if limit(xOld) and limit(yOld) and limit(xNew) and limit(yNew) then table.insert(keyPoints, {x = xOld, y = yOld, x2 = xNew, y2 = yNew}) - -- doubleHeight.line(xOld, yOld, xNew, yNew, graphColor) + -- buffer.semiPixelLine(xOld, yOld, xNew, yNew, graphColor) end xOld, yOld = xNew, yNew @@ -85,7 +84,7 @@ end local function drawGraph() for i = 1, #keyPoints do - doubleHeight.line(xGraph + keyPoints[i].x, yGraph - keyPoints[i].y, xGraph + keyPoints[i].x2, yGraph - keyPoints[i].y2, graphColor) + buffer.semiPixelLine(xGraph + keyPoints[i].x, yGraph - keyPoints[i].y, xGraph + keyPoints[i].x2, yGraph - keyPoints[i].y2, graphColor) if showCornerPoints then buffer.semiPixelSet(xGraph + keyPoints[i].x, yGraph - keyPoints[i].y, 0x00A8FF) end end end diff --git a/Applications/PrintImage/PrintImage.lua b/Applications/PrintImage/PrintImage.lua index 428a2ba2..1b7c5998 100755 --- a/Applications/PrintImage/PrintImage.lua +++ b/Applications/PrintImage/PrintImage.lua @@ -1,7 +1,7 @@ ----------------------------------------- Libraries ----------------------------------------- -package.loaded.windows = nil +-- package.loaded.windows = nil local libraries = { component = "component", @@ -191,19 +191,19 @@ end local function createWindow() window = windows.fullScreen() - window:addPanel("backgroundPanel", 1, 1, window.width, window.height, 0xEEEEEE) - window:addObject("mainImageObject", 1, 1, window.width, window.height).draw = drawMainImageObject + window:addPanel(1, 1, window.width, window.height, 0xEEEEEE) + window:addObject(1, 1, window.width, window.height).draw = drawMainImageObject local textBoxesWidth = math.floor(panelWidth * 0.55) - local shadeContainer = window:addContainer("shadeContainer", window.width - panelWidth + 1, 1, panelWidth, window.height) - shadeContainer:addPanel("shadePanel", 1, 1, shadeContainer.width, shadeContainer.height, 0x0000000, 40) + window.shadeContainer = window:addContainer(window.width - panelWidth + 1, 1, panelWidth, window.height) + window.shadeContainer:addPanel(1, 1, window.shadeContainer.width, window.shadeContainer.height, 0x0000000, 40) local y = 2 - shadeContainer:addLabel("label", 1, y, shadeContainer.width, 1, 0xFFFFFF, "Main properties"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) + window.shadeContainer:addLabel(1, y, window.shadeContainer.width, 1, 0xFFFFFF, "Main properties"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) y = y + 2 - shadeContainer:addLabel("imagePathLabel", 3, y, shadeContainer.width, 1, 0xCCCCCC, "Image path:") - shadeContainer:addInputTextBox("imagePath", shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0xEEEEEE, 0x262626, startImagePath, nil, nil, true).validator = function(text) + window.shadeContainer:addLabel(3, y, window.shadeContainer.width, 1, 0xCCCCCC, "Image path:") + window.shadeContainer:addInputTextBox(window.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0xEEEEEE, 0x262626, startImagePath, nil, nil, true).validator = function(text) if text and fs.exists(text) then if unicode.sub(text, -4, -1) == ".pic" then mainImage = image.load(text) @@ -218,32 +218,32 @@ local function createWindow() end y = y + 2 - shadeContainer:addLabel("mainMaterialLabel", 3, y, shadeContainer.width, 1, 0xCCCCCC, "Material:") - local mainMaterialTextBox = shadeContainer:addInputTextBox("mainMaterialTextBox", shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0xEEEEEE, 0x262626, config.mainMaterial, nil, nil, false) + window.shadeContainer:addLabel(3, y, window.shadeContainer.width, 1, 0xCCCCCC, "Material:") + local mainMaterialTextBox = window.shadeContainer:addInputTextBox(window.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0xEEEEEE, 0x262626, config.mainMaterial, nil, nil, false) mainMaterialTextBox.onInputFinished = function() config.mainMaterial = mainMaterialTextBox.text save() end y = y + 2 - shadeContainer:addLabel("printNameLabel", 3, y, shadeContainer.width, 1, 0xCCCCCC, "Print name:") - local printNameTextBox = shadeContainer:addInputTextBox("printNameTextBox", shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0xEEEEEE, 0x262626, config.printName, nil, nil, false) + window.shadeContainer:addLabel(3, y, window.shadeContainer.width, 1, 0xCCCCCC, "Print name:") + local printNameTextBox = window.shadeContainer:addInputTextBox(window.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0xEEEEEE, 0x262626, config.printName, nil, nil, false) printNameTextBox.onInputFinished = function() config.printName = printNameTextBox.text save() end y = y + 2 - shadeContainer:addLabel("label", 3, y, shadeContainer.width, 1, 0xCCCCCC, "Floor mode:") - local floorSwitch = shadeContainer:addSwitch("floorSwitch", shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.floorMode) + window.shadeContainer:addLabel(3, y, window.shadeContainer.width, 1, 0xCCCCCC, "Floor mode:") + local floorSwitch = window.shadeContainer:addSwitch(window.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.floorMode) floorSwitch.onStateChanged = function() config.floorMode = floorSwitch.state save() end y = y + 2 - shadeContainer:addLabel("label", 3, y, shadeContainer.width, 1, 0xCCCCCC, "Show grid:") - local gridSwitch = shadeContainer:addSwitch("gridSwitch", shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.showGrid) + window.shadeContainer:addLabel(3, y, window.shadeContainer.width, 1, 0xCCCCCC, "Show grid:") + local gridSwitch = window.shadeContainer:addSwitch(window.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.showGrid) gridSwitch.onStateChanged = function() config.showGrid = gridSwitch.state save() @@ -251,24 +251,24 @@ local function createWindow() end y = y + 4 - shadeContainer:addLabel("label", 1, y, shadeContainer.width, 1, 0xFFFFFF, "Frame properties"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) + window.shadeContainer:addLabel(1, y, window.shadeContainer.width, 1, 0xFFFFFF, "Frame properties"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) y = y + 2 - shadeContainer:addLabel("label", 3, y, shadeContainer.width, 1, 0xCCCCCC, "Enabled:") - local frameSwitch = shadeContainer:addSwitch("frameSwitch", shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.frame.enabled) + window.shadeContainer:addLabel(3, y, window.shadeContainer.width, 1, 0xCCCCCC, "Enabled:") + local frameSwitch = window.shadeContainer:addSwitch(window.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.frame.enabled) frameSwitch.onStateChanged = function() config.frame.enabled = frameSwitch.state save() end y = y + 2 - shadeContainer:addLabel("frameMaterialLabel", 3, y, shadeContainer.width, 1, 0xCCCCCC, "Material:") - local frameMaterialTextBox = shadeContainer:addInputTextBox("frameMaterial", shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0xEEEEEE, 0x262626, config.frame.material, nil, nil, false) + window.shadeContainer:addLabel(3, y, window.shadeContainer.width, 1, 0xCCCCCC, "Material:") + local frameMaterialTextBox = window.shadeContainer:addInputTextBox(window.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0xEEEEEE, 0x262626, config.frame.material, nil, nil, false) frameMaterialTextBox.onInputFinished = function() config.frame.material = frameMaterialTextBox.text save() end y = y + 2 - local frameWidthSlider = shadeContainer:addHorizontalSlider("frameWidthSlider", 3, y, shadeContainer.width - 4, 0xFFDB80, 0x000000, 0xFFDB40, 0xCCCCCC, 1, shapeResolutionLimit - 1, config.frame.width, false, "Width: " , " voxel(s)") + local frameWidthSlider = window.shadeContainer:addHorizontalSlider(3, y, window.shadeContainer.width - 4, 0xFFDB80, 0x000000, 0xFFDB40, 0xCCCCCC, 1, shapeResolutionLimit - 1, config.frame.width, false, "Width: " , " voxel(s)") frameWidthSlider.onValueChanged = function(value) config.frame.width = frameWidthSlider.value save() @@ -276,17 +276,17 @@ local function createWindow() frameWidthSlider.roundValues = true y = y + 5 - shadeContainer:addLabel("label", 1, y, shadeContainer.width, 1, 0xFFFFFF, "Light emission"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) + window.shadeContainer:addLabel(1, y, window.shadeContainer.width, 1, 0xFFFFFF, "Light emission"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) y = y + 2 - shadeContainer:addLabel("label", 3, y, shadeContainer.width, 1, 0xCCCCCC, "Enabled:") - local lightSwitch = shadeContainer:addSwitch("lightSwitch", shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.lightEmission.enabled) + window.shadeContainer:addLabel(3, y, window.shadeContainer.width, 1, 0xCCCCCC, "Enabled:") + local lightSwitch = window.shadeContainer:addSwitch(window.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.lightEmission.enabled) lightSwitch.onStateChanged = function() config.lightEmission.enabled = true save() end y = y + 2 - local lightSlider = shadeContainer:addHorizontalSlider("lightSlider", 3, y, shadeContainer.width - 4, 0xFFDB80, 0x000000, 0xFFDB40, 0xCCCCCC, 1, 8, 8, false, "Radius: " , " block(s)") + local lightSlider = window.shadeContainer:addHorizontalSlider(3, y, window.shadeContainer.width - 4, 0xFFDB80, 0x000000, 0xFFDB40, 0xCCCCCC, 1, 8, 8, false, "Radius: " , " block(s)") lightSlider.roundValues = true lightSlider.onValueChanged = function() config.lightEmission.value = lightSlider.value @@ -294,15 +294,15 @@ local function createWindow() end y = y + 5 - shadeContainer:addLabel("label", 1, y, shadeContainer.width, 1, 0xFFFFFF, "Summary information:"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) + window.shadeContainer:addLabel(1, y, window.shadeContainer.width, 1, 0xFFFFFF, "Summary information:"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) y = y + 2 - shadeContainer:addTextBox("statusTextBox", 3, y, shadeContainer.width - 4, 5, nil, 0xCCCCCC, {}, 1):setAlignment(GUI.alignment.horizontal.left, GUI.alignment.vertical.top) + window.shadeContainer.statusTextBox = window.shadeContainer:addTextBox(3, y, window.shadeContainer.width - 4, 5, nil, 0xCCCCCC, {}, 1):setAlignment(GUI.alignment.horizontal.left, GUI.alignment.vertical.top) - shadeContainer:addButton("printButton", 1, shadeContainer.height - 5, shadeContainer.width, 3, 0x363636, 0xFFFFFF, 0xFFFFFF, 0x262626, "Exit").onTouch = function() + window.shadeContainer:addButton(1, window.shadeContainer.height - 5, window.shadeContainer.width, 3, 0x363636, 0xFFFFFF, 0xFFFFFF, 0x262626, "Exit").onTouch = function() window:close() end - shadeContainer:addButton("printButton", 1, shadeContainer.height - 2, shadeContainer.width, 3, 0x262626, 0xFFFFFF, 0xFFFFFF, 0x262626, "Start print").onTouch = function() + window.shadeContainer:addButton(1, window.shadeContainer.height - 2, window.shadeContainer.width, 3, 0x262626, 0xFFFFFF, 0xFFFFFF, 0x262626, "Start print").onTouch = function() beginPrint() end diff --git a/Applications/RayWalk/RayWalk.lua b/Applications/RayWalk/RayWalk.lua index a624a66d..b376e6d1 100755 --- a/Applications/RayWalk/RayWalk.lua +++ b/Applications/RayWalk/RayWalk.lua @@ -1,5 +1,5 @@ -package.loaded.rayEngine, package.loaded.GUI, package.loaded.windows, _G.rayEngine, _G.GUI, _G.windows = nil, nil, nil, nil, nil, nil, nil, nil +-- package.loaded.rayEngine, package.loaded.GUI, package.loaded.windows, _G.rayEngine, _G.GUI, _G.windows = nil, nil, nil, nil, nil, nil, nil, nil local libraries = { component = "component", @@ -35,47 +35,47 @@ local function settings() local sliderWidth, textBoxWidth = 43, 19 local x, y = math.floor(window.width / 2 - sliderWidth / 2), math.floor(window.height / 2 - 19) - window:addLabel("settingsLabel", 1, y, window.width, 1, 0xFFFFFF, localization.rayEngineProperties):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 + window:addLabel(1, y, window.width, 1, 0xFFFFFF, localization.rayEngineProperties):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 - local resolutionTextBoxWidth = window:addInputTextBox("resolutionTextBoxWidth", x, y, textBoxWidth, 3, 0x262626, 0xBBBBBB, 0x262626, 0xFFFFFF, buffer.screen.width, nil, nil, true) - window:addLabel("resolutionCrossLabel", x + textBoxWidth + 2, y + 1, 1, 1, 0xFFFFFF, "X") - local resolutionTextBoxHeight = window:addInputTextBox("resolutionTextBoxHeight", x + textBoxWidth + 5, y, textBoxWidth, 3, 0x262626, 0xBBBBBB, 0x262626, 0xFFFFFF, buffer.screen.height, nil, nil, true); y = y + 4 - window:addLabel("resolutionLabel", 1, y, window.width, 1, 0xDDDDDD, localization.screenResolution):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 + local resolutionTextBoxWidth = window:addInputTextBox(x, y, textBoxWidth, 3, 0x262626, 0xBBBBBB, 0x262626, 0xFFFFFF, buffer.screen.width, nil, nil, true) + window:addLabel(x + textBoxWidth + 2, y + 1, 1, 1, 0xFFFFFF, "X") + local resolutionTextBoxHeight = window:addInputTextBox(x + textBoxWidth + 5, y, textBoxWidth, 3, 0x262626, 0xBBBBBB, 0x262626, 0xFFFFFF, buffer.screen.height, nil, nil, true); y = y + 4 + window:addLabel(1, y, window.width, 1, 0xDDDDDD, localization.screenResolution):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 resolutionTextBoxWidth.validator = function(text) local num = tonumber(text); if num and num >= 40 and num <= 160 then return true end end resolutionTextBoxHeight.validator = function(text) local num = tonumber(text); if num and num >= 12 and num <= 50 then return true end end local function onAnyResolutionTextBoxInputFinished() window:close(); rayEngine.changeResolution(tonumber(resolutionTextBoxWidth.text), tonumber(resolutionTextBoxHeight.text)); settings() end resolutionTextBoxWidth.onInputFinished = onAnyResolutionTextBoxInputFinished resolutionTextBoxHeight.onInputFinished = onAnyResolutionTextBoxInputFinished - local drawDistanceSlider = window:addHorizontalSlider("drawDistanceSlider", x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 100, 5000, rayEngine.properties.drawDistance, true, localization.drawDistance) + local drawDistanceSlider = window:addHorizontalSlider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 100, 5000, rayEngine.properties.drawDistance, true, localization.drawDistance) drawDistanceSlider.onValueChanged = function() rayEngine.properties.drawDistance = drawDistanceSlider.value window:draw() buffer:draw() end; y = y + 4 - local shadingDistanceSlider = window:addHorizontalSlider("shadingDistanceSlider", x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 100, 3000, rayEngine.properties.shadingDistance, true, localization.shadingDistance) + local shadingDistanceSlider = window:addHorizontalSlider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 100, 3000, rayEngine.properties.shadingDistance, true, localization.shadingDistance) shadingDistanceSlider.onValueChanged = function() rayEngine.properties.shadingDistance = shadingDistanceSlider.value window:draw() buffer:draw() end; y = y + 4 - local shadingCascadesSlider = window:addHorizontalSlider("shadingCascadesSlider", x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 2, 48, rayEngine.properties.shadingCascades, true, localization.shadingCascades) + local shadingCascadesSlider = window:addHorizontalSlider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 2, 48, rayEngine.properties.shadingCascades, true, localization.shadingCascades) shadingCascadesSlider.onValueChanged = function() rayEngine.properties.shadingCascades = shadingCascadesSlider.value window:draw() buffer:draw() end; y = y + 4 - local raycastQualitySlider = window:addHorizontalSlider("raycastQualitySlider", x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 0.5, 32, rayEngine.properties.raycastQuality, true, localization.raycastQuality) + local raycastQualitySlider = window:addHorizontalSlider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 0.5, 32, rayEngine.properties.raycastQuality, true, localization.raycastQuality) raycastQualitySlider.onValueChanged = function() rayEngine.properties.raycastQuality = raycastQualitySlider.value window:draw() buffer:draw() end; y = y + 4 - local currentTimeSlider = window:addHorizontalSlider("currentTimeSlider", x, y, sliderWidth, rayEngine.world.colors.sky.current, 0x000000, rayEngine.world.colors.sky.current, 0xDDDDDD, 0, rayEngine.world.dayNightCycle.length, rayEngine.world.dayNightCycle.currentTime, true, localization.dayNightCycle, localization.seconds) + local currentTimeSlider = window:addHorizontalSlider(x, y, sliderWidth, rayEngine.world.colors.sky.current, 0x000000, rayEngine.world.colors.sky.current, 0xDDDDDD, 0, rayEngine.world.dayNightCycle.length, rayEngine.world.dayNightCycle.currentTime, true, localization.dayNightCycle, localization.seconds) currentTimeSlider.onValueChanged = function() rayEngine.world.dayNightCycle.currentTime = currentTimeSlider.value rayEngine.refreshTimeDependentColors() @@ -85,25 +85,25 @@ local function settings() buffer:draw() end; y = y + 4 - window:addLabel("graphonLabel", x, y, sliderWidth, 1, 0xDDDDDD, localization.enableSemipixelRenderer) + window:addLabel(x, y, sliderWidth, 1, 0xDDDDDD, localization.enableSemipixelRenderer) - local graphonSwitch = window:addSwitch("graphonSwitch", x + sliderWidth - 8, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, not rayEngine.properties.useSimpleRenderer) + local graphonSwitch = window:addSwitch(x + sliderWidth - 8, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, not rayEngine.properties.useSimpleRenderer) graphonSwitch.onStateChanged = function() - rayEngine.properties.useSimpleRenderer = not graphonSwith.state + rayEngine.properties.useSimpleRenderer = not graphonSwitch.state window:draw() buffer:draw() end; y = y + 3 - window:addLabel("lockTimeLabel", x, y, sliderWidth, 1, 0xDDDDDD, localization.enableDayNightCycle) + window:addLabel(x, y, sliderWidth, 1, 0xDDDDDD, localization.enableDayNightCycle) - local lockTimeSwitch = window:addSwitch("lockTimeSwitch", x + sliderWidth - 8, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, rayEngine.world.dayNightCycle.enabled) + local lockTimeSwitch = window:addSwitch(x + sliderWidth - 8, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, rayEngine.world.dayNightCycle.enabled) lockTimeSwitch.onStateChanged = function() rayEngine.world.dayNightCycle.enabled = lockTimeSwitch.state window:draw() buffer:draw() end; y = y + 3 - window:addButton("resumeButton", x, y, sliderWidth, 3, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.continue).onTouch = function() window:close(); table.toFile(applicationResourcesDirectory .. "RayEngine.cfg", rayEngine.properties, true) end + window:addButton(x, y, sliderWidth, 3, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.continue).onTouch = function() window:close(); table.toFile(applicationResourcesDirectory .. "RayEngine.cfg", rayEngine.properties, true) end window:draw(); buffer.draw(); window:handleEvents() end @@ -117,21 +117,21 @@ local function menu() for file in fs.list(worldsPath) do table.insert(worlds, unicode.sub(file, 1, -2)) end local x, y = math.floor(window.width / 2 - buttonWidth / 2), math.floor(window.height / 2 - #worlds * (buttonHeight + 1) / 2 - 11) - window:addLabel("versionLabel", 1, y, window.width, 1, 0xFFFFFF, rayWalkVersion):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 - window:addButton("resumeButton", x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.continue).onTouch = function() window:close() end; y = y + buttonHeight + 1 - window:addButton("settingsButton", x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.settings).onTouch = function() window:close(); settings() end; y = y + buttonHeight + 1 - window:addButton("exitButton", x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0x999999, 0x262626, localization.exit).onTouch = function() buffer.clear(0x000000); buffer.draw(); os.exit() end; y = y + buttonHeight + 1 - window:addLabel("loadWorldLabel", 1, y, window.width, 1, 0xFFFFFF, localization.loadWorld):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 2 + window:addLabel(1, y, window.width, 1, 0xFFFFFF, rayWalkVersion):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 3 + window:addButton(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.continue).onTouch = function() window:close() end; y = y + buttonHeight + 1 + window:addButton(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.settings).onTouch = function() window:close(); settings() end; y = y + buttonHeight + 1 + window:addButton(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0x999999, 0x262626, localization.exit).onTouch = function() buffer.clear(0x000000); buffer.draw(); os.exit() end; y = y + buttonHeight + 1 + window:addLabel(1, y, window.width, 1, 0xFFFFFF, localization.loadWorld):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 2 for i = 1, #worlds do - window:addButton("worldButton" .. i, x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, worlds[i]).onTouch = function() rayEngine.loadWorld(worldsPath .. worlds[i]); window:close() end + window:addButton(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, worlds[i]).onTouch = function() rayEngine.loadWorld(worldsPath .. worlds[i]); window:close() end y = y + buttonHeight + 1 end local lines = localization.controlsHelp table.insert(lines, 1, " ") table.insert(lines, 1, {text = localization.controls, color = 0xFFFFFF}) - window:addTextBox("informationTextBox", 1, y, window.width, #lines, nil, 0xDDDDDD, lines, 1):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + #lines + 1 + window:addTextBox(1, y, window.width, #lines, nil, 0xDDDDDD, lines, 1):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + #lines + 1 window:draw(); buffer.draw(); window:handleEvents() end diff --git a/Applications/SmartHouse/Modules/mfsu/Main.lua b/Applications/SmartHouse/Modules/mfsu/Main.lua index d235cf2b..6460d6e7 100755 --- a/Applications/SmartHouse/Modules/mfsu/Main.lua +++ b/Applications/SmartHouse/Modules/mfsu/Main.lua @@ -10,8 +10,8 @@ local module = { function module.start(moduleContainer) local x, y = 2, moduleContainer.children[#moduleContainer.children].localPosition.y + 2 - moduleContainer.capaticyLabel = moduleContainer:addLabel("capaticyLabel", x, y, moduleContainer.width - 2, 1, 0xDDDDDD, "Capacity"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 1 - moduleContainer.chart = moduleContainer:addChart("chart", x, y, moduleContainer.width - 2, math.floor(moduleContainer.width - 2) / 2, 0xFFFFFF, 0x999999, 0xFFDB40, "t", "%", 0, 100, {}) + moduleContainer.capaticyLabel = moduleContainer:addLabel(x, y, moduleContainer.width - 2, 1, 0xDDDDDD, "Capacity"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 1 + moduleContainer.chart = moduleContainer:addChart(x, y, moduleContainer.width - 2, math.floor(moduleContainer.width - 2) / 2, 0xFFFFFF, 0x999999, 0xFFDB40, "t", "%", 0, 100, {}) end -- This method is called on each frame update (every second by default), but only if module details is not hidden or updateWhenModuleDetailsIsHidden == true diff --git a/Applications/SmartHouse/Modules/motion_sensor/Main.lua b/Applications/SmartHouse/Modules/motion_sensor/Main.lua index 285dd496..32932e7f 100755 --- a/Applications/SmartHouse/Modules/motion_sensor/Main.lua +++ b/Applications/SmartHouse/Modules/motion_sensor/Main.lua @@ -13,9 +13,9 @@ function module.start(moduleContainer) local x, y = 1, moduleContainer.children[#moduleContainer.children].localPosition.y + 2 local lines = {limit = 5} - moduleContainer.editWhitelistButton = moduleContainer:addButton("editWhitelistButton", 2, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xAAAAAA, 0x262626, "Whitelist") + moduleContainer.editWhitelistButton = moduleContainer:addButton(2, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xAAAAAA, 0x262626, "Whitelist") y = y + 2 - moduleContainer.sleepSlider = moduleContainer:addHorizontalSlider("sleepSlider", x, y, moduleContainer.width, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 0.5, 2, sleepValue, false, "Sleep: ") + moduleContainer.sleepSlider = moduleContainer:addHorizontalSlider(x, y, moduleContainer.width, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 0.5, 2, sleepValue, false, "Sleep: ") moduleContainer.sleepSlider.onValueChanged = function() sleepValue = moduleContainer.sleepSlider.value end diff --git a/Applications/SmartHouse/Modules/reactor/Main.lua b/Applications/SmartHouse/Modules/reactor/Main.lua index f7cb205a..ac4a3ce8 100755 --- a/Applications/SmartHouse/Modules/reactor/Main.lua +++ b/Applications/SmartHouse/Modules/reactor/Main.lua @@ -10,8 +10,8 @@ local module = { function module.start(moduleContainer) local x, y = 2, moduleContainer.children[#moduleContainer.children].localPosition.y + 2 - moduleContainer.heatLabel = moduleContainer:addLabel("heatLabel", x, y, moduleContainer.width - 2, 1, 0xDDDDDD, ""); y = y + 1 - moduleContainer.outputLabel = moduleContainer:addLabel("outputLabel", x, y, moduleContainer.width - 2, 1, 0xDDDDDD, "") + moduleContainer.heatLabel = moduleContainer:addLabel(x, y, moduleContainer.width - 2, 1, 0xDDDDDD, ""); y = y + 1 + moduleContainer.outputLabel = moduleContainer:addLabel(x, y, moduleContainer.width - 2, 1, 0xDDDDDD, "") end -- This method is called on each frame update (every second by default), but only if module details is not hidden or updateWhenModuleDetailsIsHidden == true diff --git a/Applications/SmartHouse/Modules/redstone/Main.lua b/Applications/SmartHouse/Modules/redstone/Main.lua index f7d626c9..91f87d66 100755 --- a/Applications/SmartHouse/Modules/redstone/Main.lua +++ b/Applications/SmartHouse/Modules/redstone/Main.lua @@ -34,13 +34,13 @@ function module.start(moduleContainer) moduleContainer.redstoneStates[i] = signalStrength > 0 and true or false end - moduleContainer:addLabel("toggleLabel", x, y, moduleContainer.width - 2, 1, 0xDDDDDD, "Signal:") - moduleContainer.signalSwitch = moduleContainer:addSwitch("redstoneSwitch", moduleContainer.width - 6, y, 6, 0xFFDB40, 0xBBBBBB, 0xFFFFFF, false) + moduleContainer:addLabel(x, y, moduleContainer.width - 2, 1, 0xDDDDDD, "Signal:") + moduleContainer.signalSwitch = moduleContainer:addSwitch(moduleContainer.width - 6, y, 6, 0xFFDB40, 0xBBBBBB, 0xFFFFFF, false) moduleContainer.signalSwitch.onStateChanged = function() changeRedstoneState(moduleContainer, moduleContainer.signalSwitch.state) end y = y + 2 - moduleContainer.emitOnceButton = moduleContainer:addButton("emitOnceButton", 2, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xAAAAAA, 0x262626, "Emit once") + moduleContainer.emitOnceButton = moduleContainer:addButton(2, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xAAAAAA, 0x262626, "Emit once") moduleContainer.emitOnceButton.onTouch = function() changeRedstoneState(moduleContainer, true) os.sleep(0.1) @@ -48,9 +48,9 @@ function module.start(moduleContainer) moduleContainer.signalSwitch.state = false end y = y + 2 - moduleContainer:addLabel("sideLabel", x, y, moduleContainer.width - 2, 1, 0xFFFFFF, "Side"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) + moduleContainer:addLabel(x, y, moduleContainer.width - 2, 1, 0xFFFFFF, "Side"):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) y = y + 2 - moduleContainer.sidesComboBox = moduleContainer:addComboBox("comboBox", x, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xCCCCCC, 0x262626, {"All", "Up", "Down", "North", "South", "West", "East"}) + moduleContainer.sidesComboBox = moduleContainer:addComboBox(x, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xCCCCCC, 0x262626, {"All", "Up", "Down", "North", "South", "West", "East"}) moduleContainer.sidesComboBox.onItemSelected = function() local comboBoxText = moduleContainer.sidesComboBox.items[moduleContainer.sidesComboBox.currentItem].text if comboBoxText == "All" then diff --git a/Applications/SmartHouse/SmartHouse.lua b/Applications/SmartHouse/SmartHouse.lua index 82039f18..094c0b5b 100755 --- a/Applications/SmartHouse/SmartHouse.lua +++ b/Applications/SmartHouse/SmartHouse.lua @@ -21,8 +21,8 @@ for library in pairs(libraries) do if not _G[library] then _G[library] = require local window local paths = {} -paths.resources = MineOSCore.getCurrentApplicationResourcesDirectory() --- paths.resources = "/SmartHouse/" +-- paths.resources = MineOSCore.getCurrentApplicationResourcesDirectory() +paths.resources = "/SmartHouse/" paths.modules = paths.resources .. "Modules/" local colors = { @@ -131,7 +131,7 @@ end local function createDevice(x, y, componentName, componentProxy, name) if not modules[componentName] then error("No such module: " .. componentName) end - local container = window:addContainer(name, x, y, 16, 9) + local container = window:addContainer(x, y, 16, 9) container.name = name container.module = modules[componentName] @@ -140,8 +140,8 @@ local function createDevice(x, y, componentName, componentProxy, name) container.detailsIsHidden = true x, y = 1, 1 - local deviceImage = container:addImage("deviceImage", x, y, container.module.icon); y = y + 8 - local stateButton = container:addButton("stateButton", 1, y, container.width, 1, colors.devicesButtonBackground, colors.devicesButtonText, colors.devicesButtonText, colors.devicesButtonBackground, "*") + local deviceImage = container:addImage(x, y, container.module.icon); y = y + 8 + local stateButton = container:addButton(1, y, container.width, 1, colors.devicesButtonBackground, colors.devicesButtonText, colors.devicesButtonText, colors.devicesButtonBackground, "*") stateButton.onTouch = function() container.detailsIsHidden = not container.detailsIsHidden changeChildrenState(container, container.detailsIsHidden) @@ -152,11 +152,11 @@ local function createDevice(x, y, componentName, componentProxy, name) end end - container.backgroundPanel = container:addPanel("backgroundPanel", 1, y, container.width, 1, colors.devicesBackground, colors.devicesBackgroundTransparency) + container.backgroundPanel = container:addPanel(1, y, container.width, 1, colors.devicesBackground, colors.devicesBackgroundTransparency) - container:addLabel("nameLabel", 2, y, container.width - 2, 1, 0xFFFFFF, container.name):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 1 - container:addLabel("addressLabel", 2, y, container.width - 2, 1, 0x999999, container.componentProxy.address):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 2 + container:addLabel(2, y, container.width - 2, 1, 0xFFFFFF, container.name):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 1 + container:addLabel(2, y, container.width - 2, 1, 0x999999, container.componentProxy.address):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top); y = y + 2 container.module.start(container) container.module.update(container, {}) diff --git a/lib/GUI.lua b/lib/GUI.lua index d48b21c6..ce7374cc 100755 --- a/lib/GUI.lua +++ b/lib/GUI.lua @@ -63,6 +63,7 @@ GUI.dropDownMenuElementTypes = enum( ) GUI.objectTypes = enum( + "unknown", "empty", "panel", "label", @@ -150,17 +151,6 @@ end ----------------------------------------- Containers ----------------------------------------- --- Object calling by it's name using 'container["objectName"]' against of 'container.children[1, 2, 3, ...]' -function GUI.setContainerMetasearch(container) - setmetatable(container, { - __index = function(container, objectName) - for objectIndex = 1, #container.children do - if container.children[objectIndex].name == objectName then return container.children[objectIndex] end - end - end - }) -end - -- Go recursively through every container's object (including other containers) and return object that was clicked firstly by it's GUI-layer position function GUI.getClickedObject(container, xEvent, yEvent) local clickedObject, clickedIndex @@ -223,10 +213,9 @@ local function containerObjectMoveToBack(object) table.remove(object.parent.children, objectIndex + 1) end --- Add any object as children to parent container with specified objectName -local function addObjectToContainer(container, objectType, objectName, object) - object.name = objectName - object.type = objectType +-- Add any object as children to parent container with specified objectType +function GUI.addChildToContainer(container, object, objectType) + object.type = objectType or GUI.objectTypes.unknown object.parent = container object.indexOf = containerObjectIndexOf object.moveToFront = containerObjectMoveToFront @@ -241,93 +230,93 @@ local function addObjectToContainer(container, objectType, objectName, object) end -- Add empty GUI.object to container -local function addEmptyObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.empty, objectName, GUI.object(...)) +local function addEmptyObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.object(...), GUI.objectTypes.empty) end -- Add button object to container -local function addButtonObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.button, objectName, GUI.button(...)) +local function addButtonObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.button(...), GUI.objectTypes.button) end -- Add adaptive button object to container -local function addAdaptiveButtonObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.button, objectName, GUI.adaptiveButton(...)) +local function addAdaptiveButtonObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.adaptiveButton(...), GUI.objectTypes.button) end -- Add framedButton object to container -local function addFramedButtonObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.button, objectName, GUI.framedButton(...)) +local function addFramedButtonObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.framedButton(...), GUI.objectTypes.button) end -- Add adaptive framedButton object to container -local function addAdaptiveFramedButtonObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.button, objectName, GUI.adaptiveFramedButton(...)) +local function addAdaptiveFramedButtonObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.adaptiveFramedButton(...), GUI.objectTypes.button) end -- Add label object to container -local function addLabelObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.label, objectName, GUI.label(...)) +local function addLabelObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.label(...), GUI.objectTypes.label) end -- Add panel object to container -local function addPanelObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.panel, objectName, GUI.panel(...)) +local function addPanelObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.panel(...), GUI.objectTypes.panel) end -- Add windowActionButtons object to container -local function addWindowActionButtonsObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.windowActionButtons, objectName, GUI.windowActionButtons(...)) +local function addWindowActionButtonsObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.windowActionButtons(...), GUI.objectTypes.windowActionButtons) end -- Add another container to container -local function addContainerToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.container, objectName, GUI.container(...)) +local function addContainerToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.container(...), GUI.objectTypes.container) end -- Add image object to container -local function addImageObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.image, objectName, GUI.image(...)) +local function addImageObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.image(...), GUI.objectTypes.image) end -- Add image object to container -local function addTabBarObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.tabBar, objectName, GUI.tabBar(...)) +local function addTabBarObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.tabBar(...), GUI.objectTypes.tabBar) end -- Add InputTextBox object to container -local function addInputTextBoxObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.inputTextBox, objectName, GUI.inputTextBox(...)) +local function addInputTextBoxObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.inputTextBox(...), GUI.objectTypes.inputTextBox) end -- Add TextBox object to container -local function addTextBoxObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.textBox, objectName, GUI.textBox(...)) +local function addTextBoxObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.textBox(...), GUI.objectTypes.textBox) end -- Add Horizontal Slider object to container -local function addHorizontalSliderObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.horizontalSlider, objectName, GUI.horizontalSlider(...)) +local function addHorizontalSliderObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.horizontalSlider(...), GUI.objectTypes.horizontalSlider) end -- Add Progressbar object to container -local function addProgressBarObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.progressBar, objectName, GUI.progressBar(...)) +local function addProgressBarObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.progressBar(...), GUI.objectTypes.progressBar) end -- Add Switch object to container -local function addSwitchObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.switch, objectName, GUI.switch(...)) +local function addSwitchObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.switch(...), GUI.objectTypes.switch) end -- Add Chart object to container -local function addChartObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.chart, objectName, GUI.chart(...)) +local function addChartObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.chart(...), GUI.objectTypes.chart) end -- Add ComboBox object to container -local function addComboBoxObjectToContainer(container, objectName, ...) - return addObjectToContainer(container, GUI.objectTypes.comboBox, objectName, GUI.comboBox(...)) +local function addComboBoxObjectToContainer(container, ...) + return GUI.addChildToContainer(container, GUI.comboBox(...), GUI.objectTypes.comboBox) end -- Recursively draw container's content including all children container's content @@ -336,15 +325,16 @@ local function drawContainerContent(container) if not container.children[objectIndex].hidden then container.children[objectIndex].x, container.children[objectIndex].y = container.children[objectIndex].localPosition.x + container.x - 1, container.children[objectIndex].localPosition.y + container.y - 1 if container.children[objectIndex].children then + -- cyka blyad -- drawContainerContent(container.children[objectIndex]) -- We use :draw() method against of recursive call. The reason is possible user-defined :draw() reimplementations container.children[objectIndex]:draw() else - if container.children[objectIndex].draw then + -- if container.children[objectIndex].draw then container.children[objectIndex]:draw() - else - error("Container object with index " .. objectIndex .. " and name \"" .. tostring(container.children[objectIndex].name) .. "\" doesn't have :draw() method") - end + -- else + -- error("Container object with index " .. objectIndex .. " doesn't have :draw() method") + -- end end end end @@ -361,11 +351,11 @@ end function GUI.container(x, y, width, height) local container = GUI.object(x, y, width, height) container.children = {} - GUI.setContainerMetasearch(container) container.draw = drawContainerContent container.getClickedObject = GUI.getClickedObject container.deleteObjects = deleteContainersContent + container.addChild = GUI.addChildToContainer container.addObject = addEmptyObjectToContainer container.addContainer = addContainerToContainer container.addPanel = addPanelObjectToContainer @@ -499,12 +489,12 @@ function GUI.tabBar(x, y, width, height, spaceBetweenElements, backgroundColor, object.reimplementedDraw = object.draw object.draw = drawTabBar - object:addPanel("backgroundPanel", 1, 1, object.width, object.height, backgroundColor).disableClicking = true - object.tabs = object:addContainer("tabs", 1, 1, object.width, object.height) + object:addPanel(1, 1, object.width, object.height, backgroundColor).disableClicking = true + object.tabs = object:addContainer(1, 1, object.width, object.height) x = math.floor(width / 2 - object.tabsWidth / 2) for elementIndex = 1, #elements do - local tab = object.tabs:addButton(elements[elementIndex], x, 1, unicode.len(elements[elementIndex]) + 2, height, backgroundColor, textColor, backgroundSelectedColor, textSelectedColor, elements[elementIndex]) + local tab = object.tabs:addButton(x, 1, unicode.len(elements[elementIndex]) + 2, height, backgroundColor, textColor, backgroundSelectedColor, textSelectedColor, elements[elementIndex]) tab.type = GUI.objectTypes.tabBarTab x = x + tab.width + spaceBetweenElements end @@ -572,12 +562,12 @@ function GUI.windowActionButtons(x, y, fatSymbol) local symbol = fatSymbol and "⬤" or "●" local container = GUI.container(x, y, 5, 1) - local closeButton = container:addButton("close", 1, 1, 1, 1, 0x000000, 0xFF4940, 0x000000, 0x992400, symbol) - local minimizeButton = container:addButton("minimize", 3, 1, 1, 1, 0x000000, 0xFFB640, 0x000000, 0x996D00, symbol) - local maximizeButton = container:addButton("maximize", 5, 1, 1, 1, 0x000000, 0x00B640, 0x000000, 0x006D40, symbol) + container.close = container:addButton(1, 1, 1, 1, 0x000000, 0xFF4940, 0x000000, 0x992400, symbol) + container.minimize = container:addButton(3, 1, 1, 1, 0x000000, 0xFFB640, 0x000000, 0x996D00, symbol) + container.maximize = container:addButton(5, 1, 1, 1, 0x000000, 0x00B640, 0x000000, 0x006D40, symbol) - closeButton.reimplementedDraw, minimizeButton.reimplementedDraw, maximizeButton.reimplementedDraw = closeButton.draw, minimizeButton.draw, maximizeButton.draw - closeButton.draw, minimizeButton.draw, maximizeButton.draw = drawWindowActionButton, drawWindowActionButton, drawWindowActionButton + container.close.reimplementedDraw, container.minimize.reimplementedDraw, container.maximize.reimplementedDraw = container.close.draw, container.minimize.draw, container.maximize.draw + container.close.draw, container.minimize.draw, container.maximize.draw = drawWindowActionButton, drawWindowActionButton, drawWindowActionButton return container end @@ -754,11 +744,11 @@ end function GUI.menu(x, y, width, backgroundColor, textColor, backgroundPressedColor, textPressedColor, backgroundTransparency, ...) local elements = {...} local menuObject = GUI.container(x, y, width, 1) - menuObject:addPanel("backgroundPanel", 1, 1, menuObject.width, 1, backgroundColor, backgroundTransparency).disableClicking = true + menuObject:addPanel(1, 1, menuObject.width, 1, backgroundColor, backgroundTransparency).disableClicking = true local x = 2 for elementIndex = 1, #elements do - local button = menuObject:addAdaptiveButton(elementIndex, x, 1, 1, 0, nil, elements[elementIndex][2] or textColor, elements[elementIndex][3] or backgroundPressedColor, elements[elementIndex][4] or textPressedColor, elements[elementIndex][1]) + local button = menuObject:addAdaptiveButton(x, 1, 1, 0, nil, elements[elementIndex][2] or textColor, elements[elementIndex][3] or backgroundPressedColor, elements[elementIndex][4] or textPressedColor, elements[elementIndex][1]) button.type = GUI.objectTypes.menuElement x = x + button.width end diff --git a/lib/palette.lua b/lib/palette.lua index 2c970ef1..6eb45a15 100755 --- a/lib/palette.lua +++ b/lib/palette.lua @@ -174,8 +174,8 @@ local function createInputs(x, y) } for i = 1, #inputs do - window:addLabel("inputShortcut" .. i, x, y, 2, 1, 0x000000, inputs[i].shortcut) - inputs[i].object = window:addInputTextBox("inputObject" .. i, x + 3, y, 9, 1, 0xFFFFFF, 0x444444, 0xFFFFFF, 0x000000, "", nil, nil, true) + window:addLabel(x, y, 2, 1, 0x000000, inputs[i].shortcut) + inputs[i].object = window:addInputTextBox(x + 3, y, 9, 1, 0xFFFFFF, 0x444444, 0xFFFFFF, 0x000000, "", nil, nil, true) inputs[i].object.validator = inputs[i].validator inputs[i].object.onInputFinished = inputs[i].onInputFinished y = y + 2 @@ -186,7 +186,7 @@ end local function createFavourites() for i = 1, #favourites do - local button = favouritesContainer:addButton("favourite" .. i, i * 2 - 1, 1, 2, 1, favourites[i], 0x0, 0x0, 0x0, " ") + local button = favouritesContainer:addButton(i * 2 - 1, 1, 2, 1, favourites[i], 0x0, 0x0, 0x0, " ") button.onTouch = function() switchColorFromHex(button.colors.default.background) refreshRainbows() @@ -200,9 +200,9 @@ local function createWindow(x, y) window = windows.empty(x, y, 71, 25, 71, 25) x, y = 1, 1 - window:addPanel("backgroundPanel", x, y, window.width, window.height, 0xEEEEEE) + window:addPanel(x, y, window.width, window.height, 0xEEEEEE) - bigRainbow = window:addImage("bigRainbow", x, y, image.create(50, 25)) + bigRainbow = window:addImage(x, y, image.create(50, 25)) bigRainbow.onTouch = function(eventData) xBigCrest, yBigCrest = eventData[3], eventData[4] local _, _, background = component.gpu.get(eventData[3], eventData[4]) @@ -213,7 +213,7 @@ local function createWindow(x, y) x = x + bigRainbow.width + 2 - miniRainbow = window:addImage("miniRainbow", x, y, image.create(3, 25)) + miniRainbow = window:addImage(x, y, image.create(3, 25)) miniRainbow.onTouch = function(eventData) yMiniCrest = eventData[4] switchColorFromHsb((eventData[4] - miniRainbow.y) * 360 / miniRainbow.height, currentColor.hsb.saturation, currentColor.hsb.brightness) @@ -223,26 +223,26 @@ local function createWindow(x, y) miniRainbow.onDrag = miniRainbow.onTouch x, y = x + 5, y + 1 - currentColorPanel = window:addPanel("currentColorPanel", x, y, 12, 3, currentColor.hex) + currentColorPanel = window:addPanel(x, y, 12, 3, currentColor.hex) y = y + 4 - window:addButton("okButton", x, y, 12, 1, 0x444444, 0xFFFFFF, 0x88FF88, 0xFFFFFF, "OK").onTouch = function() + window:addButton(x, y, 12, 1, 0x444444, 0xFFFFFF, 0x88FF88, 0xFFFFFF, "OK").onTouch = function() window:returnData(currentColor.hex) end y = y + 2 - window:addButton("cancelButton", x, y, 12, 1, 0xFFFFFF, 0x444444, 0x88FF88, 0xFFFFFF, "Cancel").onTouch = function() + window:addButton(x, y, 12, 1, 0xFFFFFF, 0x444444, 0x88FF88, 0xFFFFFF, "Cancel").onTouch = function() window:close() end y = y + 2 y = createInputs(x, y) - favouritesContainer = window:addContainer("favouritesContainer", x, y, 12, 1) + favouritesContainer = window:addContainer(x, y, 12, 1) createFavourites() y = y + 1 - window:addButton("favouritesAddButton", x, y, 12, 1, 0xFFFFFF, 0x444444, 0x88FF88, 0xFFFFFF, "+").onTouch = function() + window:addButton(x, y, 12, 1, 0xFFFFFF, 0x444444, 0x88FF88, 0xFFFFFF, "+").onTouch = function() local favouriteExists = false; for i = 1, #favourites do if favourites[i] == currentColor.hex then favouriteExists = true; break end end if not favouriteExists then table.insert(favourites, 1, currentColor.hex); table.remove(favourites, #favourites) diff --git a/lib/rayEngine.lua b/lib/rayEngine.lua index de780ded..8362e6f4 100755 --- a/lib/rayEngine.lua +++ b/lib/rayEngine.lua @@ -4,7 +4,6 @@ local libraries = { colorlib = "colorlib", image = "image", buffer = "doubleBuffering", - doubleHeight = "doubleHeight", GUI = "GUI", files = "files", event = "event", @@ -260,8 +259,8 @@ local function drawFieldOfViewAngle(x, y, distance, color) local firstAngle, secondAngle = math.rad(-(rayEngine.player.rotation - fieldOfViewHalf)), math.rad(-(rayEngine.player.rotation + fieldOfViewHalf)) local xFirst, yFirst = math.floor(x + math.sin(firstAngle) * distance), math.floor(y + math.cos(firstAngle) * distance) local xSecond, ySecond = math.floor(x + math.sin(secondAngle) * distance), math.floor(y + math.cos(secondAngle) * distance) - doubleHeight.line(x, y, xFirst, yFirst, color) - doubleHeight.line(x, y, xSecond, ySecond, color) + buffer.semiPixelLine(x, y, xFirst, yFirst, color) + buffer.semiPixelLine(x, y, xSecond, ySecond, color) end function rayEngine.drawMap(x, y, width, height, transparency) @@ -318,8 +317,8 @@ function rayEngine.compass(x, y) southPoint.x, southPoint.y = math.round(x + math.sin(northAngleRad) * distance * xScaleFactor), math.round(y - math.cos(northAngleRad) * distance) y = y * 2 - doubleHeight.line(x, y, northPoint.x, northPoint.y * 2, 0xFF5555) - doubleHeight.line(x, y, southPoint.x, southPoint.y * 2, 0xFFFFFF) + buffer.semiPixelLine(x, y, northPoint.x, northPoint.y * 2, 0xFF5555) + buffer.semiPixelLine(x, y, southPoint.x, southPoint.y * 2, 0xFFFFFF) buffer.semiPixelSet(x, y, 0x000000) end @@ -339,8 +338,8 @@ function rayEngine.watch(x, y) local xHour, yHour = math.round(x + math.sin(hourAngle) * hourArrowLength * 2), math.round(y - math.cos(hourAngle) * hourArrowLength) y = y * 2 - doubleHeight.line(x, y, xMinute, yMinute * 2, 0xEEEEEE) - doubleHeight.line(x, y, xHour, yHour * 2, 0xEEEEEE) + buffer.semiPixelLine(x, y, xMinute, yMinute * 2, 0xEEEEEE) + buffer.semiPixelLine(x, y, xHour, yHour * 2, 0xEEEEEE) end local function addItemToChatHistory(text, color) diff --git a/lib/windows.lua b/lib/windows.lua index b59161fa..6374e81b 100755 --- a/lib/windows.lua +++ b/lib/windows.lua @@ -214,9 +214,9 @@ end function windows.tabbed(x, y, width, height, minimumWidth, minimumHeight, ...) local tabs = {...} local window = newWindow(x, y, width, height, minimumWidth, minimumHeight) - window:addPanel("windowBackgroundPanel", 1, 1, window.width, window.height, 0xEEEEEE).disabled = true - window:addTabBar("tabBar", 1, 1, window.width, 3, 1, 0xDDDDDD, 0x262626, 0xCCCCCC, 0x262626, ...) - window:addWindowActionButtons("windowActionButtons", 2, 1, false) + window:addPanel(1, 1, window.width, window.height, 0xEEEEEE).disabled = true + window:addTabBar(1, 1, window.width, 3, 1, 0xDDDDDD, 0x262626, 0xCCCCCC, 0x262626, ...) + window:addWindowActionButtons(2, 1, false) return window end @@ -227,9 +227,9 @@ end -- buffer.draw(true) -- local myWindow = windows.empty(10, 5, 60, 20, 60, 20) --- myWindow:addPanel("backgroundPanel", 1, 1, myWindow.width, myWindow.height, 0xEEEEEE) --- myWindow:addLabel("counter", 2, 5, 20, 1, 0x000000, tostring(10)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) --- myWindow:addHorizontalSlider("slider", 2, 4, 20, 0x880000, 0x000000, 0xFF4444, 0, 100, 10).onValueChanged = function(object) +-- myWindow:addPanel(1, 1, myWindow.width, myWindow.height, 0xEEEEEE) +-- myWindow:addLabel(2, 5, 20, 1, 0x000000, tostring(10)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) +-- myWindow:addHorizontalSlider(2, 4, 20, 0x880000, 0x000000, 0xFF4444, 0, 100, 10).onValueChanged = function(object) -- myWindow.counter.text = tostring(object.value) -- end