Perfomance GUI update #1

This commit is contained in:
Igor Timofeev 2018-12-26 10:34:57 +03:00
parent df985c3916
commit 408196dce1
53 changed files with 1004 additions and 1003 deletions

View File

@ -27,10 +27,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local mainContainer = GUI.fullScreenContainer() local application = GUI.application()
local toolPanel = mainContainer:addChild(GUI.panel(1, 1, 28, mainContainer.height, 0x2D2D2D)) local toolPanel = application:addChild(GUI.panel(1, 1, 28, application.height, 0x2D2D2D))
local toolLayout = mainContainer:addChild(GUI.layout(1, 1, toolPanel.width, toolPanel.height - 3, 1, 1)) local toolLayout = application:addChild(GUI.layout(1, 1, toolPanel.width, toolPanel.height - 3, 1, 1))
toolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) toolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
toolLayout:setMargin(1, 1, 0, 1) toolLayout:setMargin(1, 1, 0, 1)
@ -49,7 +49,7 @@ local function addColorSelector(...)
return toolLayout:addChild(GUI.colorSelector(1, 1, toolLayout.width - 2, 1, ...)) return toolLayout:addChild(GUI.colorSelector(1, 1, toolLayout.width - 2, 1, ...))
end end
local printButton = mainContainer:addChild(GUI.button(1, mainContainer.height - 2, toolLayout.width, 3, 0x4B4B4B, 0xD2D2D2, 0xE1E1E1, 0x3C3C3C, localization.print)) local printButton = application:addChild(GUI.button(1, application.height - 2, toolLayout.width, 3, 0x4B4B4B, 0xD2D2D2, 0xE1E1E1, 0x3C3C3C, localization.print))
toolLayout:addChild(GUI.object(1, 1, toolLayout.width, 5)).draw = function(object) toolLayout:addChild(GUI.object(1, 1, toolLayout.width, 5)).draw = function(object)
local text = tostring(math.floor(currentLayer)) local text = tostring(math.floor(currentLayer))
@ -63,7 +63,7 @@ local newButton = addButton(localization.new)
local openButton = addButton(localization.open) local openButton = addButton(localization.open)
addButton(localization.save).onTouch = function() addButton(localization.save).onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Save", "Cancel", "File name", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "Save", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".3dm") filesystemDialog:addExtensionFilter(".3dm")
filesystemDialog.onSubmit = function(path) filesystemDialog.onSubmit = function(path)
@ -77,7 +77,7 @@ addButton(localization.exit).onTouch = function()
hologram.clear() hologram.clear()
end end
mainContainer:stopEventHandling() application:stop()
end end
addSeparator(localization.elementSettings) addSeparator(localization.elementSettings)
@ -170,7 +170,7 @@ if proxies.hologram then
selector.onColorSelected = function() selector.onColorSelected = function()
if proxies.hologram then if proxies.hologram then
proxies.hologram.setPaletteColor(i, selector.color) proxies.hologram.setPaletteColor(i, selector.color)
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
@ -269,23 +269,23 @@ local function load(path)
end end
openButton.onTouch = function() openButton.onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Open", "Cancel", "File name", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "Open", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".3dm") filesystemDialog:addExtensionFilter(".3dm")
filesystemDialog.onSubmit = function(path) filesystemDialog.onSubmit = function(path)
load(path) load(path)
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
filesystemDialog:show() filesystemDialog:show()
end end
mainContainer:addChild(GUI.panel(toolPanel.width + 1, 1, mainContainer.width - toolPanel.width, toolPanel.height, 0x1E1E1E)) application:addChild(GUI.panel(toolPanel.width + 1, 1, application.width - toolPanel.width, toolPanel.height, 0x1E1E1E))
local view = mainContainer:addChild(GUI.object(1, 1, 16 * viewPixelWidth, 16 * viewPixelHeight)) local view = application:addChild(GUI.object(1, 1, 16 * viewPixelWidth, 16 * viewPixelHeight))
view.localX = math.floor(toolLayout.width + (mainContainer.width - toolLayout.width) / 2 - view.width / 2) view.localX = math.floor(toolLayout.width + (application.width - toolLayout.width) / 2 - view.width / 2)
view.localY = math.floor(mainContainer.height / 2 - view.height / 2) view.localY = math.floor(application.height / 2 - view.height / 2)
view.draw = function() view.draw = function()
local x, y, step = view.x, view.y, true local x, y, step = view.x, view.y, true
for j = 1, 16 do for j = 1, 16 do
@ -326,26 +326,26 @@ view.draw = function()
end end
end end
toolLayout.eventHandler = function(mainContainer, toolLayout, e1, e2, e3, e4, e5) toolLayout.eventHandler = function(application, toolLayout, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
local cell = toolLayout.cells[1][1] local cell = toolLayout.cells[1][1]
if e5 > 0 then if e5 > 0 then
if cell.verticalMargin < 1 then if cell.verticalMargin < 1 then
cell.verticalMargin = cell.verticalMargin + 1 cell.verticalMargin = cell.verticalMargin + 1
mainContainer:drawOnScreen() application:draw()
end end
else else
local child = toolLayout.children[#toolLayout.children] local child = toolLayout.children[#toolLayout.children]
if child.localY + child.height - 1 >= toolLayout.localY + toolLayout.height - 1 then if child.localY + child.height - 1 >= toolLayout.localY + toolLayout.height - 1 then
cell.verticalMargin = cell.verticalMargin - 1 cell.verticalMargin = cell.verticalMargin - 1
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
end end
local touchX, touchY, shapeX, shapeY, shapeZ local touchX, touchY, shapeX, shapeY, shapeZ
view.eventHandler = function(mainContainer, view, e1, e2, e3, e4, e5) view.eventHandler = function(application, view, e1, e2, e3, e4, e5)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
if e5 > 0 then if e5 > 0 then
if e1 == "touch" then if e1 == "touch" then
@ -354,7 +354,7 @@ view.eventHandler = function(mainContainer, view, e1, e2, e3, e4, e5)
view.localX, view.localY = view.localX + e3 - touchX, view.localY + e4 - touchY view.localX, view.localY = view.localX + e3 - touchX, view.localY + e4 - touchY
touchX, touchY = e3, e4 touchX, touchY = e3, e4
mainContainer:drawOnScreen() application:draw()
end end
else else
local shapeIndex = getCurrentShapeIndex() local shapeIndex = getCurrentShapeIndex()
@ -374,7 +374,7 @@ view.eventHandler = function(mainContainer, view, e1, e2, e3, e4, e5)
shape[4], shape[5], shape[6] = shape[4] + 1, shape[5] + 1, shape[6] + 1 shape[4], shape[5], shape[6] = shape[4] + 1, shape[5] + 1, shape[6] + 1
end end
mainContainer:drawOnScreen() application:draw()
end end
end end
elseif e1 == "drop" then elseif e1 == "drop" then
@ -397,7 +397,7 @@ view.eventHandler = function(mainContainer, view, e1, e2, e3, e4, e5)
currentLayer = currentLayer + 1 currentLayer = currentLayer + 1
fix() fix()
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
else else
@ -405,7 +405,7 @@ view.eventHandler = function(mainContainer, view, e1, e2, e3, e4, e5)
currentLayer = currentLayer - 1 currentLayer = currentLayer - 1
fix() fix()
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
end end
@ -430,7 +430,7 @@ rotateButton.onTouch = function()
fixShape(shape) fixShape(shape)
end end
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
@ -453,7 +453,7 @@ flipButton.onTouch = function()
fixShape(shape) fixShape(shape)
end end
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
@ -462,7 +462,7 @@ disabledListItem.onTouch = function()
updateWidgetsFromModel() updateWidgetsFromModel()
updateAddRemoveButtonsState() updateAddRemoveButtonsState()
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
@ -485,14 +485,14 @@ end
newButton.onTouch = function() newButton.onTouch = function()
new() new()
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
addShapeButton.onTouch = function() addShapeButton.onTouch = function()
addShape() addShape()
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
@ -503,7 +503,7 @@ removeShapeButton.onTouch = function()
updateWidgetsFromModel() updateWidgetsFromModel()
updateAddRemoveButtonsState() updateAddRemoveButtonsState()
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
@ -548,7 +548,7 @@ end
elementComboBox.onItemSelected = function() elementComboBox.onItemSelected = function()
updateWidgetsFromModel() updateWidgetsFromModel()
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
end end
@ -570,6 +570,6 @@ else
new() new()
end end
mainContainer:drawOnScreen() application:draw()
updateOnHologram() updateOnHologram()
mainContainer:startEventHandling() application:start()

View File

@ -27,7 +27,7 @@ local meowEngine = require("MeowEngine/Main")
buffer.flush() buffer.flush()
meowEngine.intro(vector.newVector3(0, 0, 0), 20) meowEngine.intro(vector.newVector3(0, 0, 0), 20)
local mainContainer = GUI.fullScreenContainer() local application = GUI.application()
local scene = meowEngine.newScene(0x1D1D1D) local scene = meowEngine.newScene(0x1D1D1D)
scene.renderMode = OCGL.renderModes.flatShading scene.renderMode = OCGL.renderModes.flatShading
@ -280,14 +280,14 @@ local function move(x, y, z)
end end
local function moveLight(x, y, z) local function moveLight(x, y, z)
scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].position[1] = scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].position[1] + x scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[1] = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[1] + x
scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].position[2] = scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].position[2] + y scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[2] = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[2] + y
scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].position[3] = scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].position[3] + z scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[3] = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[3] + z
end end
local controls = { local controls = {
-- F1 -- F1
[59 ] = function() mainContainer.toolbar.hidden = not mainContainer.toolbar.hidden; mainContainer.infoTextBox.hidden = not mainContainer.infoTextBox.hidden end, [59 ] = function() application.toolbar.hidden = not application.toolbar.hidden; application.infoTextBox.hidden = not application.infoTextBox.hidden end,
-- Arrows -- Arrows
[200] = function() scene.camera:rotate(-rotationAngle, 0, 0) end, [200] = function() scene.camera:rotate(-rotationAngle, 0, 0) end,
[208] = function() scene.camera:rotate(rotationAngle, 0, 0) end, [208] = function() scene.camera:rotate(rotationAngle, 0, 0) end,
@ -314,7 +314,7 @@ local controls = {
-------------------------------------------------------- GUI -------------------------------------------------------- -------------------------------------------------------- GUI --------------------------------------------------------
local OCGLView = GUI.object(1, 1, mainContainer.width, mainContainer.height) local OCGLView = GUI.object(1, 1, application.width, application.height)
local function drawInvertedText(x, y, text) local function drawInvertedText(x, y, text)
local index = buffer.getIndex(x, y) local index = buffer.getIndex(x, y)
@ -331,18 +331,17 @@ local function drawCross(x, y)
drawInvertedText(x, y + 1, "") drawInvertedText(x, y + 1, "")
end end
local oldUptime
OCGLView.draw = function(object) OCGLView.draw = function(object)
oldUptime = computer.uptime() application.oldClock = os.clock()
if world then renderWorld() end if world then renderWorld() end
scene:render() scene:render()
if mainContainer.toolbar.zBufferSwitch.state then if application.toolbar.zBufferSwitch.state then
renderer.visualizeDepthBuffer() renderer.visualizeDepthBuffer()
end end
drawCross(renderer.viewport.xCenter, math.floor(renderer.viewport.yCenter / 2)) drawCross(renderer.viewport.xCenter, math.floor(renderer.viewport.yCenter / 2))
end end
OCGLView.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) OCGLView.eventHandler = function(application, object, e1, e2, e3, e4, e5)
if e1 == "touch" then if e1 == "touch" then
local targetVector = vector.newVector3(scene.camera.position[1], scene.camera.position[2], scene.camera.position[3] + 1000) local targetVector = vector.newVector3(scene.camera.position[1], scene.camera.position[2], scene.camera.position[3] + 1000)
OCGL.rotateVectorRelativeToXAxis(targetVector, scene.camera.rotation[1]) OCGL.rotateVectorRelativeToXAxis(targetVector, scene.camera.rotation[1])
@ -369,122 +368,122 @@ OCGLView.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
zWorld = zWorld - 1 zWorld = zWorld - 1
end end
setBlock(xWorld, yWorld, zWorld, e5 == 1 and mainContainer.toolbar.blockColorSelector.color or nil) setBlock(xWorld, yWorld, zWorld, e5 == 1 and application.toolbar.blockColorSelector.color or nil)
end end
end end
end end
mainContainer:addChild(OCGLView) application:addChild(OCGLView)
mainContainer.infoTextBox = mainContainer:addChild(GUI.textBox(2, 4, 45, mainContainer.height, nil, 0xEEEEEE, {}, 1, 0, 0)) application.infoTextBox = application:addChild(GUI.textBox(2, 4, 45, application.height, nil, 0xEEEEEE, {}, 1, 0, 0))
local lines = { local lines = {
"Copyright © 2016-2017 - Developed by ECS Inc.", "Copyright © 2016-2017 - Developed by ECS Inc.",
"Timofeef Igor (vk.com/id7799889), Trifonov Gleb (vk.com/id88323331), Verevkin Yakov (vk.com/id60991376), Bogushevich Victoria (vk.com/id171497518)", "Timofeef Igor (vk.com/id7799889), Trifonov Gleb (vk.com/id88323331), Verevkin Yakov (vk.com/id60991376), Bogushevich Victoria (vk.com/id171497518)",
"All rights reserved", "All rights reserved",
} }
mainContainer:addChild(GUI.textBox(1, mainContainer.height - #lines + 1, mainContainer.width, #lines, nil, 0x3C3C3C, lines, 1)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application:addChild(GUI.textBox(1, application.height - #lines + 1, application.width, #lines, nil, 0x3C3C3C, lines, 1)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
local elementY = 2 local elementY = 2
mainContainer.toolbar = mainContainer:addChild(GUI.container(mainContainer.width - 31, 1, 32, mainContainer.height)) application.toolbar = application:addChild(GUI.container(application.width - 31, 1, 32, application.height))
local elementWidth = mainContainer.toolbar.width - 2 local elementWidth = application.toolbar.width - 2
mainContainer.toolbar:addChild(GUI.panel(1, 1, mainContainer.toolbar.width, mainContainer.toolbar.height, 0x0, 0.5)) application.toolbar:addChild(GUI.panel(1, 1, application.toolbar.width, application.toolbar.height, 0x0, 0.5))
mainContainer.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "Render mode")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2 application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "Render mode")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2
mainContainer.toolbar.renderModeComboBox = mainContainer.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + mainContainer.toolbar.renderModeComboBox.height + 1 application.toolbar.renderModeComboBox = application.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + application.toolbar.renderModeComboBox.height + 1
mainContainer.toolbar.renderModeComboBox:addItem("disabled") application.toolbar.renderModeComboBox:addItem("disabled")
mainContainer.toolbar.renderModeComboBox:addItem("constantShading") application.toolbar.renderModeComboBox:addItem("constantShading")
mainContainer.toolbar.renderModeComboBox:addItem("flatShading") application.toolbar.renderModeComboBox:addItem("flatShading")
mainContainer.toolbar.renderModeComboBox.selectedItem = scene.renderMode application.toolbar.renderModeComboBox.selectedItem = scene.renderMode
mainContainer.toolbar.renderModeComboBox.onItemSelected = function() application.toolbar.renderModeComboBox.onItemSelected = function()
scene.renderMode = mainContainer.toolbar.renderModeComboBox.selectedItem scene.renderMode = application.toolbar.renderModeComboBox.selectedItem
end end
mainContainer.toolbar.auxiliaryModeComboBox = mainContainer.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + mainContainer.toolbar.auxiliaryModeComboBox.height + 1 application.toolbar.auxiliaryModeComboBox = application.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + application.toolbar.auxiliaryModeComboBox.height + 1
mainContainer.toolbar.auxiliaryModeComboBox:addItem("disabled") application.toolbar.auxiliaryModeComboBox:addItem("disabled")
mainContainer.toolbar.auxiliaryModeComboBox:addItem("wireframe") application.toolbar.auxiliaryModeComboBox:addItem("wireframe")
mainContainer.toolbar.auxiliaryModeComboBox:addItem("vertices") application.toolbar.auxiliaryModeComboBox:addItem("vertices")
mainContainer.toolbar.auxiliaryModeComboBox.selectedItem = scene.auxiliaryMode application.toolbar.auxiliaryModeComboBox.selectedItem = scene.auxiliaryMode
mainContainer.toolbar.auxiliaryModeComboBox.onItemSelected = function() application.toolbar.auxiliaryModeComboBox.onItemSelected = function()
scene.auxiliaryMode = mainContainer.toolbar.auxiliaryModeComboBox.selectedItem scene.auxiliaryMode = application.toolbar.auxiliaryModeComboBox.selectedItem
end end
mainContainer.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xAAAAAA, "Perspective proj:")) application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xAAAAAA, "Perspective proj:"))
mainContainer.toolbar.perspectiveSwitch = mainContainer.toolbar:addChild(GUI.switch(mainContainer.toolbar.width - 8, elementY, 8, 0x66DB80, 0x2D2D2D, 0xEEEEEE, scene.camera.projectionEnabled)); elementY = elementY + 2 application.toolbar.perspectiveSwitch = application.toolbar:addChild(GUI.switch(application.toolbar.width - 8, elementY, 8, 0x66DB80, 0x2D2D2D, 0xEEEEEE, scene.camera.projectionEnabled)); elementY = elementY + 2
mainContainer.toolbar.perspectiveSwitch.onStateChanged = function() application.toolbar.perspectiveSwitch.onStateChanged = function()
scene.camera.projectionEnabled = mainContainer.toolbar.perspectiveSwitch.state scene.camera.projectionEnabled = application.toolbar.perspectiveSwitch.state
end end
mainContainer.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xAAAAAA, "Z-buffer visualize:")) application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xAAAAAA, "Z-buffer visualize:"))
mainContainer.toolbar.zBufferSwitch = mainContainer.toolbar:addChild(GUI.switch(mainContainer.toolbar.width - 8, elementY, 8, 0x66DB80, 0x2D2D2D, 0xEEEEEE, false)); elementY = elementY + 2 application.toolbar.zBufferSwitch = application.toolbar:addChild(GUI.switch(application.toolbar.width - 8, elementY, 8, 0x66DB80, 0x2D2D2D, 0xEEEEEE, false)); elementY = elementY + 2
local function calculateLightComboBox() local function calculateLightComboBox()
mainContainer.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children = {} application.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children = {}
for i = 1, #scene.lights do for i = 1, #scene.lights do
mainContainer.toolbar.lightSelectComboBox:addItem(tostring(i)) application.toolbar.lightSelectComboBox:addItem(tostring(i))
end end
mainContainer.toolbar.lightSelectComboBox.selectedItem = #mainContainer.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children application.toolbar.lightSelectComboBox.selectedItem = #application.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children
mainContainer.toolbar.lightIntensitySlider.value = scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].intensity * 100 application.toolbar.lightIntensitySlider.value = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].intensity * 100
mainContainer.toolbar.lightEmissionSlider.value = scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].emissionDistance application.toolbar.lightEmissionSlider.value = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].emissionDistance
end end
mainContainer.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "Light control")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2 application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "Light control")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2
mainContainer.toolbar.lightSelectComboBox = mainContainer.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + mainContainer.toolbar.lightSelectComboBox.height + 1 application.toolbar.lightSelectComboBox = application.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + application.toolbar.lightSelectComboBox.height + 1
mainContainer.toolbar.addLightButton = mainContainer.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Add light")); elementY = elementY + 2 application.toolbar.addLightButton = application.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Add light")); elementY = elementY + 2
mainContainer.toolbar.addLightButton.onTouch = function() application.toolbar.addLightButton.onTouch = function()
scene:addLight(meowEngine.newLight(vector.newVector3(0, 10, 0), mainContainer.toolbar.lightIntensitySlider.value / 100, mainContainer.toolbar.lightEmissionSlider.value)) scene:addLight(meowEngine.newLight(vector.newVector3(0, 10, 0), application.toolbar.lightIntensitySlider.value / 100, application.toolbar.lightEmissionSlider.value))
calculateLightComboBox() calculateLightComboBox()
end end
mainContainer.toolbar.removeLightButton = mainContainer.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Remove light")); elementY = elementY + 2 application.toolbar.removeLightButton = application.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Remove light")); elementY = elementY + 2
mainContainer.toolbar.removeLightButton.onTouch = function() application.toolbar.removeLightButton.onTouch = function()
if #scene.lights > 1 then if #scene.lights > 1 then
table.remove(scene.lights, mainContainer.toolbar.lightSelectComboBox.selectedItem) table.remove(scene.lights, application.toolbar.lightSelectComboBox.selectedItem)
calculateLightComboBox() calculateLightComboBox()
end end
end end
mainContainer.toolbar.lightIntensitySlider = mainContainer.toolbar:addChild(GUI.slider(2, elementY, elementWidth, 0xCCCCCC, 0x2D2D2D, 0xEEEEEE, 0xAAAAAA, 0, 500, 100, false, "Intensity: ", "")); elementY = elementY + 3 application.toolbar.lightIntensitySlider = application.toolbar:addChild(GUI.slider(2, elementY, elementWidth, 0xCCCCCC, 0x2D2D2D, 0xEEEEEE, 0xAAAAAA, 0, 500, 100, false, "Intensity: ", "")); elementY = elementY + 3
mainContainer.toolbar.lightIntensitySlider.onValueChanged = function() application.toolbar.lightIntensitySlider.onValueChanged = function()
scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].intensity = mainContainer.toolbar.lightIntensitySlider.value / 100 scene.lights[application.toolbar.lightSelectComboBox.selectedItem].intensity = application.toolbar.lightIntensitySlider.value / 100
end end
mainContainer.toolbar.lightEmissionSlider = mainContainer.toolbar:addChild(GUI.slider(2, elementY, elementWidth, 0xCCCCCC, 0x2D2D2D, 0xEEEEEE, 0xAAAAAA, 0, scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].emissionDistance, scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].emissionDistance, false, "Distance: ", "")); elementY = elementY + 3 application.toolbar.lightEmissionSlider = application.toolbar:addChild(GUI.slider(2, elementY, elementWidth, 0xCCCCCC, 0x2D2D2D, 0xEEEEEE, 0xAAAAAA, 0, scene.lights[application.toolbar.lightSelectComboBox.selectedItem].emissionDistance, scene.lights[application.toolbar.lightSelectComboBox.selectedItem].emissionDistance, false, "Distance: ", "")); elementY = elementY + 3
mainContainer.toolbar.lightEmissionSlider.onValueChanged = function() application.toolbar.lightEmissionSlider.onValueChanged = function()
scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].emissionDistance = mainContainer.toolbar.lightEmissionSlider.value scene.lights[application.toolbar.lightSelectComboBox.selectedItem].emissionDistance = application.toolbar.lightEmissionSlider.value
end end
calculateLightComboBox() calculateLightComboBox()
mainContainer.toolbar.blockColorSelector = mainContainer.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, 0xEEEEEE, "Block color")); elementY = elementY + mainContainer.toolbar.blockColorSelector.height + 1 application.toolbar.blockColorSelector = application.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, 0xEEEEEE, "Block color")); elementY = elementY + application.toolbar.blockColorSelector.height + 1
mainContainer.toolbar.backgroundColorSelector = mainContainer.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, scene.backgroundColor, "Background color")); elementY = elementY + mainContainer.toolbar.blockColorSelector.height + 1 application.toolbar.backgroundColorSelector = application.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, scene.backgroundColor, "Background color")); elementY = elementY + application.toolbar.blockColorSelector.height + 1
mainContainer.toolbar.backgroundColorSelector.onColorSelected = function() application.toolbar.backgroundColorSelector.onColorSelected = function()
scene.backgroundColor = mainContainer.toolbar.backgroundColorSelector.color scene.backgroundColor = application.toolbar.backgroundColorSelector.color
end end
mainContainer.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "RAM monitoring")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2 application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "RAM monitoring")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2
mainContainer.toolbar.RAMChart = mainContainer.toolbar:addChild(GUI.chart(2, elementY, elementWidth, mainContainer.toolbar.height - elementY - 3, 0xEEEEEE, 0xAAAAAA, 0x555555, 0x66DB80, 0.35, 0.25, "s", "%", true, {})); elementY = elementY + mainContainer.toolbar.RAMChart.height + 1 application.toolbar.RAMChart = application.toolbar:addChild(GUI.chart(2, elementY, elementWidth, application.toolbar.height - elementY - 3, 0xEEEEEE, 0xAAAAAA, 0x555555, 0x66DB80, 0.35, 0.25, "s", "%", true, {})); elementY = elementY + application.toolbar.RAMChart.height + 1
mainContainer.toolbar.RAMChart.roundValues = true application.toolbar.RAMChart.roundValues = true
-- mainContainer.toolbar.RAMChart.showXAxisValues = false -- application.toolbar.RAMChart.showXAxisValues = false
mainContainer.toolbar.RAMChart.counter = 1 application.toolbar.RAMChart.counter = 1
mainContainer.toolbar:addChild(GUI.button(1, mainContainer.toolbar.height - 2, mainContainer.toolbar.width, 3, 0x2D2D2D, 0xEEEEEE, 0x444444, 0xEEEEEE, "Exit")).onTouch = function() application.toolbar:addChild(GUI.button(1, application.toolbar.height - 2, application.toolbar.width, 3, 0x2D2D2D, 0xEEEEEE, 0x444444, 0xEEEEEE, "Exit")).onTouch = function()
mainContainer:stopEventHandling() application:stop()
end end
local FPSCounter = GUI.object(2, 2, 8, 3) local FPSCounter = GUI.object(2, 2, 8, 3)
FPSCounter.draw = function(FPSCounter) FPSCounter.draw = function(FPSCounter)
renderer.renderFPSCounter(FPSCounter.x, FPSCounter.y, tostring(math.ceil(1 / (computer.uptime() - oldUptime))), 0xFFFF00) renderer.renderFPSCounter(FPSCounter.x, FPSCounter.y, tostring(math.ceil(1 / (os.clock() - application.oldClock) / 10)), 0xFFFF00)
end end
mainContainer:addChild(FPSCounter) application:addChild(FPSCounter)
mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) application.eventHandler = function(application, object, e1, e2, e3, e4, e5)
if not mainContainer.toolbar.hidden then if not application.toolbar.hidden then
local totalMemory = computer.totalMemory() local totalMemory = computer.totalMemory()
table.insert(mainContainer.toolbar.RAMChart.values, {mainContainer.toolbar.RAMChart.counter, math.ceil((totalMemory - computer.freeMemory()) / totalMemory * 100)}) table.insert(application.toolbar.RAMChart.values, {application.toolbar.RAMChart.counter, math.ceil((totalMemory - computer.freeMemory()) / totalMemory * 100)})
mainContainer.toolbar.RAMChart.counter = mainContainer.toolbar.RAMChart.counter + 1 application.toolbar.RAMChart.counter = application.toolbar.RAMChart.counter + 1
if #mainContainer.toolbar.RAMChart.values > 20 then table.remove(mainContainer.toolbar.RAMChart.values, 1) end if #application.toolbar.RAMChart.values > 20 then table.remove(application.toolbar.RAMChart.values, 1) end
mainContainer.infoTextBox.lines = { application.infoTextBox.lines = {
" ", " ",
"SceneObjects: " .. #scene.objects, "SceneObjects: " .. #scene.objects,
" ", " ",
@ -511,7 +510,7 @@ mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
"F1 - toggle GUI overlay", "F1 - toggle GUI overlay",
} }
mainContainer.infoTextBox.height = #mainContainer.infoTextBox.lines application.infoTextBox.height = #application.infoTextBox.lines
end end
if e1 == "key_down" then if e1 == "key_down" then
@ -530,9 +529,9 @@ mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
-------------------------------------------------------- Ebat-kopat -------------------------------------------------------- -------------------------------------------------------- Ebat-kopat --------------------------------------------------------
mainContainer:startEventHandling(0) application:start(0)

View File

@ -87,7 +87,7 @@ local config, fileVersions, user
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.tabbedWindow(1, 1, 110, 29)) local application, window = MineOSInterface.addWindow(GUI.tabbedWindow(1, 1, 110, 29))
local contentContainer = window:addChild(GUI.container(1, 4, 1, 1)) local contentContainer = window:addChild(GUI.container(1, 4, 1, 1))
@ -95,7 +95,7 @@ local progressIndicator = window:addChild(GUI.progressIndicator(1, 1, 0x3C3C3C,
local function activity(state) local function activity(state)
progressIndicator.active = state progressIndicator.active = state
mainContainer:drawOnScreen() application:draw()
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -147,7 +147,7 @@ local function RawAPIRequest(script, postData, notUnserialize)
function(chunk) function(chunk)
data = data .. chunk data = data .. chunk
mainContainer:drawOnScreen() application:draw()
progressIndicator:roll() progressIndicator:roll()
end, end,
math.huge math.huge
@ -324,7 +324,7 @@ local function newRatingWidget(x, y, rating, firstColor, secondColor)
end end
local function deletePublication(publication) local function deletePublication(publication)
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, localization.areYouSure) local container = MineOSInterface.addBackgroundContainer(MineOSInterface.application, localization.areYouSure)
local buttonsLayout = container.layout:addChild(newButtonsLayout(1, 1, container.layout.width, 3)) local buttonsLayout = container.layout:addChild(newButtonsLayout(1, 1, container.layout.width, 3))
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xE1E1E1, 0x2D2D2D, 0x0, 0xE1E1E1, localization.yes)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xE1E1E1, 0x2D2D2D, 0x0, 0xE1E1E1, localization.yes)).onTouch = function()
@ -343,7 +343,7 @@ local function deletePublication(publication)
buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xA5A5A5, 0x2D2D2D, 0x0, 0xE1E1E1, localization.no)).onTouch = function() buttonsLayout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0xA5A5A5, 0x2D2D2D, 0x0, 0xE1E1E1, localization.no)).onTouch = function()
container:remove() container:remove()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
@ -383,7 +383,7 @@ local function download(publication)
end end
if publication then if publication then
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, localization.choosePath) local container = MineOSInterface.addBackgroundContainer(MineOSInterface.application, localization.choosePath)
local filesystemChooserPath = fileVersions[publication.file_id] and getApplicationPathFromVersions(fileVersions[publication.file_id].path) local filesystemChooserPath = fileVersions[publication.file_id] and getApplicationPathFromVersions(fileVersions[publication.file_id].path)
if not filesystemChooserPath then if not filesystemChooserPath then
@ -468,7 +468,7 @@ local function download(publication)
local function govnoed(pizda, i) local function govnoed(pizda, i)
container.label.text = localization.downloading .. " " .. fs.name(pizda.path) container.label.text = localization.downloading .. " " .. fs.name(pizda.path)
progressBar.value = math.round(i / countOfShit * 100) progressBar.value = math.round(i / countOfShit * 100)
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
-- SAVED -- SAVED
@ -585,7 +585,7 @@ local function addApplicationInfo(container, publication, limit)
end end
end end
local function containerScrollEventHandler(mainContainer, object, e1, e2, e3, e4, e5) local function containerScrollEventHandler(application, object, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
local first, last = object.children[1], object.children[#object.children] local first, last = object.children[1], object.children[#object.children]
@ -594,14 +594,14 @@ local function containerScrollEventHandler(mainContainer, object, e1, e2, e3, e4
for i = 1, #object.children do for i = 1, #object.children do
object.children[i].localY = object.children[i].localY + 1 object.children[i].localY = object.children[i].localY + 1
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
else else
if last.localY + last.height - 1 >= object.height then if last.localY + last.height - 1 >= object.height then
for i = 1, #object.children do for i = 1, #object.children do
object.children[i].localY = object.children[i].localY - 1 object.children[i].localY = object.children[i].localY - 1
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
end end
@ -609,10 +609,10 @@ end
local newApplicationPreview, newPublicationInfo, mainMenu local newApplicationPreview, newPublicationInfo, mainMenu
local function applicationWidgetEventHandler(mainContainer, object, e1) local function applicationWidgetEventHandler(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
object.parent.panel.colors.background = 0xE1E1E1 object.parent.panel.colors.background = 0xE1E1E1
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
newPublicationInfo(object.parent.file_id) newPublicationInfo(object.parent.file_id)
end end
end end
@ -651,7 +651,7 @@ mainMenu = function(menuID, messageToUser)
local statistics = fieldAPIRequest("result", "statistics") local statistics = fieldAPIRequest("result", "statistics")
if statistics then if statistics then
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
local publications = fieldAPIRequest("result", "publications", { local publications = fieldAPIRequest("result", "publications", {
order_by = "popularity", order_by = "popularity",
@ -688,7 +688,7 @@ mainMenu = function(menuID, messageToUser)
applicationPreview.panel.colors.background = 0xF0F0F0 applicationPreview.panel.colors.background = 0xF0F0F0
statisticsLayout:addChild(GUI.label(1, 1, statisticsLayout.width, 1, 0xA5A5A5, localization.statisticsPopularPublication)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_CENTER) statisticsLayout:addChild(GUI.label(1, 1, statisticsLayout.width, 1, 0xA5A5A5, localization.statisticsPopularPublication)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_CENTER)
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
local uptime, newUptime = computer.uptime() local uptime, newUptime = computer.uptime()
local function tick() local function tick()
@ -745,13 +745,13 @@ mainMenu = function(menuID, messageToUser)
child.localX, child.localY = math.floor(child.moveX), math.floor(child.moveY) child.localX, child.localY = math.floor(child.moveX), math.floor(child.moveY)
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
return true return true
end end
end end
iconsContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4) iconsContainer.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
local child, deltaX, deltaY, vectorLength local child, deltaX, deltaY, vectorLength
for i = 1, #iconsContainer.children do for i = 1, #iconsContainer.children do
@ -778,7 +778,7 @@ mainMenu = function(menuID, messageToUser)
object.forceY = math.random(-100, 100) / 100 * overviewForceLimit object.forceY = math.random(-100, 100) / 100 * overviewForceLimit
if not tick() then if not tick() then
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
@ -843,10 +843,10 @@ mainMenu = function(menuID, messageToUser)
activity(false) activity(false)
end end
local messagesContainer = menuContentContainer:addChild(GUI.container(1, 1, menuContentContainer.width, menuContentContainer.height - 3)) local messagesContainer = menuContentContainer:addChild(GUI.container(1, 4, menuContentContainer.width, menuContentContainer.height - 6))
messagesContainer.eventHandler = containerScrollEventHandler messagesContainer.eventHandler = containerScrollEventHandler
local panel = menuContentContainer:addChild(GUI.panel(1, 1, menuContentContainer.width, 3, 0xFFFFFF, 0.3)) local panel = menuContentContainer:addChild(GUI.panel(1, 1, menuContentContainer.width, 3, 0xFFFFFF))
if not to_user_name then if not to_user_name then
panel.colors.transparency = nil panel.colors.transparency = nil
local text = menuContentContainer:addChild(GUI.text(3, 2, 0x0, localization.toWho)) local text = menuContentContainer:addChild(GUI.text(3, 2, 0x0, localization.toWho))
@ -940,7 +940,7 @@ mainMenu = function(menuID, messageToUser)
dialogContainer:addChild(GUI.keyAndValue(3, 2, nicknameColor, timestampColor, dialogs[i].dialog_user_name, os.date(" (%d.%m.%Y, %H:%M)", dialogs[i].timestamp))) dialogContainer:addChild(GUI.keyAndValue(3, 2, nicknameColor, timestampColor, dialogs[i].dialog_user_name, os.date(" (%d.%m.%Y, %H:%M)", dialogs[i].timestamp)))
dialogContainer:addChild(GUI.text(3, 3, textColor, string.limit((dialogs[i].last_message_user_name == user.name and localization.yourText .. " " or "") .. dialogs[i].text, dialogContainer.width - 4, "right"))) dialogContainer:addChild(GUI.text(3, 3, textColor, string.limit((dialogs[i].last_message_user_name == user.name and localization.yourText .. " " or "") .. dialogs[i].text, dialogContainer.width - 4, "right")))
dialogContainer.eventHandler = function(mainContainer, object, e1) dialogContainer.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
dialogContainer.panel.colors.background = 0xE1E1E1 dialogContainer.panel.colors.background = 0xE1E1E1
dialogGUI(dialogs[i].dialog_user_name) dialogGUI(dialogs[i].dialog_user_name)
@ -981,7 +981,7 @@ mainMenu = function(menuID, messageToUser)
end end
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
local function account() local function account()
@ -1149,7 +1149,7 @@ mainMenu = function(menuID, messageToUser)
activity() activity()
else else
addAccountShit(true, false, false) addAccountShit(true, false, false)
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
@ -1190,7 +1190,7 @@ newPublicationInfo = function(file_id)
}) })
if publication then if publication then
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
local reviews = fieldAPIRequest("result", "reviews", { local reviews = fieldAPIRequest("result", "reviews", {
file_id = file_id, file_id = file_id,
@ -1284,10 +1284,10 @@ newPublicationInfo = function(file_id)
pizda.width = eblo.width + 9 pizda.width = eblo.width + 9
local cyka = pizda:addChild(newRatingWidget(eblo.width + 1, 1, 4)) local cyka = pizda:addChild(newRatingWidget(eblo.width + 1, 1, 4))
cyka.eventHandler = function(mainContainer, object, e1, e2, e3) cyka.eventHandler = function(application, object, e1, e2, e3)
if e1 == "touch" then if e1 == "touch" then
cyka.rating = math.round((e3 - object.x + 1) / object.width * 5) cyka.rating = math.round((e3 - object.x + 1) / object.width * 5)
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
@ -1306,7 +1306,7 @@ newPublicationInfo = function(file_id)
}) })
container:remove() container:remove()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
if success then if success then
newPublicationInfo(publication.file_id) newPublicationInfo(publication.file_id)
@ -1328,7 +1328,7 @@ newPublicationInfo = function(file_id)
end end
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
input.onInputFinished() input.onInputFinished()
@ -1368,10 +1368,12 @@ newPublicationInfo = function(file_id)
if x + textLength + 4 > textDetailsContainer.width - 4 then if x + textLength + 4 > textDetailsContainer.width - 4 then
x, y = 3, y + 2 x, y = 3, y + 2
end end
local button = textDetailsContainer:addChild(GUI.tagButton(x, y, textLength + 2, 1, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, dependency.publication_name)) local button = textDetailsContainer:addChild(GUI.tagButton(x, y, textLength + 2, 1, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, dependency.publication_name))
button.onTouch = function() button.onTouch = function()
newPublicationInfo(publication.all_dependencies[i]) newPublicationInfo(publication.all_dependencies[i])
end end
x = x + button.width + 2 x = x + button.width + 2
end end
end end
@ -1500,7 +1502,7 @@ local function newPlusMinusCyka(width, disableLimit)
layout.removeButton.onTouch = function() layout.removeButton.onTouch = function()
layout.comboBox:removeItem(layout.comboBox.selectedItem) layout.comboBox:removeItem(layout.comboBox.selectedItem)
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
return layout return layout
@ -1584,7 +1586,7 @@ editPublication = function(initialPublication, initialCategoryID)
local lastDependencyType = 1 local lastDependencyType = 1
dependenciesLayout.addButton.onTouch = function() dependenciesLayout.addButton.onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, localization.addDependency) local container = MineOSInterface.addBackgroundContainer(MineOSInterface.application, localization.addDependency)
local dependencyTypeComboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xFFFFFF, 0x696969, 0x969696, 0xE1E1E1)) local dependencyTypeComboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xFFFFFF, 0x696969, 0x969696, 0xE1E1E1))
dependencyTypeComboBox:addItem(localization.fileByURL) dependencyTypeComboBox:addItem(localization.fileByURL)
@ -1605,7 +1607,7 @@ editPublication = function(initialPublication, initialCategoryID)
}) })
container:remove() container:remove()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
publicationNameInput.onInputFinished = function() publicationNameInput.onInputFinished = function()
@ -1627,7 +1629,7 @@ editPublication = function(initialPublication, initialCategoryID)
dependencyTypeComboBox.onItemSelected = function() dependencyTypeComboBox.onItemSelected = function()
onDependencyTypeComboBoxItemSelected() onDependencyTypeComboBoxItemSelected()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
pathType.switch.onStateChanged = function() pathType.switch.onStateChanged = function()
@ -1637,7 +1639,7 @@ editPublication = function(initialPublication, initialCategoryID)
publicationNameInput.onInputFinished() publicationNameInput.onInputFinished()
onDependencyTypeComboBoxItemSelected() onDependencyTypeComboBoxItemSelected()
pathType.switch.onStateChanged() pathType.switch.onStateChanged()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
local publishButton = layout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0x696969, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.save)) local publishButton = layout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0x696969, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.save))
@ -1656,7 +1658,7 @@ editPublication = function(initialPublication, initialCategoryID)
mainPathInput.hidden = pathHint.hidden mainPathInput.hidden = pathHint.hidden
nameInput.onInputFinished() nameInput.onInputFinished()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
categoryComboBox.onItemSelected() categoryComboBox.onItemSelected()
@ -1757,14 +1759,14 @@ updateFileList = function(category_id, updates)
if updates then if updates then
if #result > 0 then if #result > 0 then
layout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0x696969, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.updateAll)).onTouch = function() layout:addChild(GUI.adaptiveRoundedButton(1, 1, 2, 0, 0x696969, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, localization.updateAll)).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, "") local container = MineOSInterface.addBackgroundContainer(MineOSInterface.application, "")
local progressBar = container.layout:addChild(GUI.progressBar(1, 1, 40, 0x66DB80, 0x0, 0xE1E1E1, 0, true, true, "", "%")) local progressBar = container.layout:addChild(GUI.progressBar(1, 1, 40, 0x66DB80, 0x0, 0xE1E1E1, 0, true, true, "", "%"))
for i = 1, #result do for i = 1, #result do
container.label.text = localization.downloading .. " " .. result[i].publication_name container.label.text = localization.downloading .. " " .. result[i].publication_name
progressBar.value = math.round(i / #result * 100) progressBar.value = math.round(i / #result * 100)
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
local publication = fieldAPIRequest("result", "publication", { local publication = fieldAPIRequest("result", "publication", {
file_id = result[i].file_id, file_id = result[i].file_id,
@ -1780,7 +1782,7 @@ updateFileList = function(category_id, updates)
local dependency = publication.dependencies_data[publication.all_dependencies[j]] local dependency = publication.dependencies_data[publication.all_dependencies[j]]
if not dependency.publication_name then if not dependency.publication_name then
container.label.text = localization.downloading .. " " .. dependency.path container.label.text = localization.downloading .. " " .. dependency.path
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
if getUpdateState(publication.all_dependencies[j], dependency.version) < 4 then if getUpdateState(publication.all_dependencies[j], dependency.version) < 4 then
local dependencyPath = getDependencyPath(fileVersions[publication.file_id].path, dependency) local dependencyPath = getDependencyPath(fileVersions[publication.file_id].path, dependency)
@ -1887,7 +1889,7 @@ updateFileList = function(category_id, updates)
end end
counter = counter + 1 counter = counter + 1
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
else else
showLabelAsContent(contentContainer, localization.noUpdates) showLabelAsContent(contentContainer, localization.noUpdates)

View File

@ -10,7 +10,7 @@ local MineOSInterface = require("MineOSInterface")
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 32, 19, 0x2D2D2D)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 32, 19, 0x2D2D2D))
local layout = window:addChild(GUI.layout(1, 2, 1, 1, 1, 1)) local layout = window:addChild(GUI.layout(1, 2, 1, 1, 1, 1))
layout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL) layout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
@ -47,7 +47,7 @@ local function newCell(x, y, shaded)
end end
end end
object.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) object.eventHandler = function(application, object, e1, e2, e3, e4, e5)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
local x, y = math.ceil((e3 - object.x + 1) / 2), e4 - object.y + 1 local x, y = math.ceil((e3 - object.x + 1) / 2), e4 - object.y + 1
@ -66,7 +66,7 @@ local function newCell(x, y, shaded)
object.pixels[y][x] = e5 == 0 and 1 or 0 object.pixels[y][x] = e5 == 0 and 1 or 0
end end
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -112,7 +112,7 @@ local function newNoGUI(width, height)
end end
local function new() local function new()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Create") local container = MineOSInterface.addBackgroundContainer(application, "Create")
local widthTextBox = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, "8", "Width", true)) local widthTextBox = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, "8", "Width", true))
widthTextBox.validator = function(text) widthTextBox.validator = function(text)
@ -124,17 +124,17 @@ local function new()
return tonumber(text) return tonumber(text)
end end
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
container:remove() container:remove()
newNoGUI(tonumber(widthTextBox.text), tonumber(heightTextBox.text)) newNoGUI(tonumber(widthTextBox.text), tonumber(heightTextBox.text))
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
local function fillBrailleArray(source, inverted) local function fillBrailleArray(source, inverted)
@ -163,7 +163,7 @@ newButton.onTouch = function()
end end
saveButton.onTouch = function() saveButton.onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "OK", "Cancel", "Path", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "OK", "Cancel", "Path", "/")
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".pic") filesystemDialog:addExtensionFilter(".pic")
@ -226,7 +226,7 @@ saveButton.onTouch = function()
end end
openButton.onTouch = function() openButton.onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "OK", "Cancel", "Path", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "OK", "Cancel", "Path", "/")
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".braiile") filesystemDialog:addExtensionFilter(".braiile")
@ -243,7 +243,7 @@ openButton.onTouch = function()
drawingArea.children[i].pixels = pizda[i].pixels drawingArea.children[i].pixels = pizda[i].pixels
end end
mainContainer:drawOnScreen() application:draw()
end end
filesystemDialog:show() filesystemDialog:show()
@ -256,7 +256,7 @@ window.actionButtons.maximize:remove()
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
newNoGUI(8, 4) newNoGUI(8, 4)
mainContainer:drawOnScreen() application:draw()

View File

@ -29,7 +29,7 @@ local digitDecimalButtons = {}
-------------------------------------------------------------------- --------------------------------------------------------------------
local mainContainer, window, menu = MineOSInterface.addWindow(GUI.window(1, 1, buttonWidth * 12, buttonHeight * 5 + displayHeight + binaryHeight)) local application, window, menu = MineOSInterface.addWindow(GUI.window(1, 1, buttonWidth * 12, buttonHeight * 5 + displayHeight + binaryHeight))
local displayContainer = window:addChild(GUI.container(1, 1, window.width, displayHeight + binaryHeight)) local displayContainer = window:addChild(GUI.container(1, 1, window.width, displayHeight + binaryHeight))
@ -182,7 +182,7 @@ modeList:addItem("8").onTouch = function()
floatingList.selectedItem = 1 floatingList.selectedItem = 1
setValue(math.floor(value)) setValue(math.floor(value))
mainContainer:drawOnScreen() application:draw()
end end
modeList:addItem("10").onTouch = function() modeList:addItem("10").onTouch = function()
@ -190,7 +190,7 @@ modeList:addItem("10").onTouch = function()
setButtonsDisabled(digitDecimalButtons, false) setButtonsDisabled(digitDecimalButtons, false)
setButtonsDisabled(digitHexadecimalButtons, true) setButtonsDisabled(digitHexadecimalButtons, true)
mainContainer:drawOnScreen() application:draw()
end end
modeList:addItem("16").onTouch = function() modeList:addItem("16").onTouch = function()
@ -201,7 +201,7 @@ modeList:addItem("16").onTouch = function()
floatingList.selectedItem = 1 floatingList.selectedItem = 1
setValue(math.floor(value)) setValue(math.floor(value))
mainContainer:drawOnScreen() application:draw()
end end
local function binaryToNumber() local function binaryToNumber()

View File

@ -58,7 +58,7 @@ local thermal = {
} }
local palette = grayscale local palette = grayscale
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 100, 25, 0x2D2D2D)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 100, 25, 0x2D2D2D))
window.backgroundPanel.width = 22 window.backgroundPanel.width = 22
window.backgroundPanel.height = window.height window.backgroundPanel.height = window.height
@ -101,7 +101,7 @@ local function takePicture()
x, y = 1, y + 1 x, y = 1, y + 1
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
local buttonImage = image.load(fs.path(getCurrentScript()) .. "Icon.pic") local buttonImage = image.load(fs.path(getCurrentScript()) .. "Icon.pic")
@ -111,15 +111,15 @@ shootButton.draw = function()
buffer.drawImage(shootButton.x, shootButton.y, shootButton.pressed and buttonImagePressed or buttonImage) buffer.drawImage(shootButton.x, shootButton.y, shootButton.pressed and buttonImagePressed or buttonImage)
end end
shootButton.eventHandler = function(mainContainer, object, e1) shootButton.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
shootButton.pressed = true shootButton.pressed = true
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
takePicture() takePicture()
shootButton.pressed = false shootButton.pressed = false
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
@ -156,12 +156,12 @@ FOVSlider.onValueChanged = takePicture
paletteSwitch.onStateChanged = function() paletteSwitch.onStateChanged = function()
palette = paletteSwitch.state and thermal or grayscale palette = paletteSwitch.state and thermal or grayscale
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
autoupdateSwitch.onStateChanged = function() autoupdateSwitch.onStateChanged = function()
autoupdateSlider.hidden = not autoupdateSwitch.state autoupdateSlider.hidden = not autoupdateSwitch.state
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
for address in component.list("camera") do for address in component.list("camera") do
@ -180,7 +180,7 @@ window.onResize = function(width, height)
shootButton.localX = math.floor(1 + window.backgroundPanel.width / 2 - shootButton.width / 2) shootButton.localX = math.floor(1 + window.backgroundPanel.width / 2 - shootButton.width / 2)
shootButton.localY = window.height - shootButton.height shootButton.localY = window.height - shootButton.height
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
takePicture() takePicture()
end end

View File

@ -17,7 +17,7 @@ local resourcesPath = MineOSCore.getCurrentScriptDirectory()
local modulesPath = resourcesPath .. "Modules/" local modulesPath = resourcesPath .. "Modules/"
local localization = MineOSCore.getLocalization(resourcesPath .. "Localizations/") local localization = MineOSCore.getLocalization(resourcesPath .. "Localizations/")
local mainContainer, window = MineOSInterface.addWindow(GUI.tabbedWindow(1, 1, 80, 25)) local application, window = MineOSInterface.addWindow(GUI.tabbedWindow(1, 1, 80, 25))
---------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------
@ -28,11 +28,11 @@ local function loadModules()
for i = 1, #fileList do for i = 1, #fileList do
local loadedFile, reason = loadfile(modulesPath .. fileList[i]) local loadedFile, reason = loadfile(modulesPath .. fileList[i])
if loadedFile then if loadedFile then
local pcallSuccess, reason = pcall(loadedFile, mainContainer, window, localization) local pcallSuccess, reason = pcall(loadedFile, application, window, localization)
if pcallSuccess then if pcallSuccess then
window.tabBar:addItem(reason.name).onTouch = function() window.tabBar:addItem(reason.name).onTouch = function()
reason.onTouch() reason.onTouch()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
else else
error("Failed to call loaded module \"" .. tostring(fileList[i]) .. "\": " .. tostring(reason)) error("Failed to call loaded module \"" .. tostring(fileList[i]) .. "\": " .. tostring(reason))

View File

@ -1,6 +1,6 @@
local args = {...} local args = {...}
local mainContainer, window, localization = args[1], args[2], args[3] local application, window, localization = args[1], args[2], args[3]
require("advancedLua") require("advancedLua")
local component = require("component") local component = require("component")

View File

@ -1,6 +1,6 @@
local args = {...} local args = {...}
local mainContainer, window, localization = args[1], args[2], args[3] local application, window, localization = args[1], args[2], args[3]
require("advancedLua") require("advancedLua")
local component = require("component") local component = require("component")
@ -35,7 +35,7 @@ module.onTouch = function()
local button = diskContainer:addChild(GUI.adaptiveRoundedButton(1, 3, 2, 0, 0x2D2D2D, 0xE1E1E1, 0x0, 0xE1E1E1, localization.options)) local button = diskContainer:addChild(GUI.adaptiveRoundedButton(1, 3, 2, 0, 0x2D2D2D, 0xE1E1E1, 0x0, 0xE1E1E1, localization.options))
button.onTouch = function() button.onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, localization.options) local container = MineOSInterface.addBackgroundContainer(application, localization.options)
local inputField = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, proxy.getLabel() or "", localization.diskLabel)) local inputField = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, proxy.getLabel() or "", localization.diskLabel))
inputField.onInputFinished = function() inputField.onInputFinished = function()
if inputField.text and inputField.text:len() > 0 then if inputField.text and inputField.text:len() > 0 then
@ -68,7 +68,7 @@ module.onTouch = function()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
button.localX = diskContainer.width - button.width - 1 button.localX = diskContainer.width - button.width - 1
@ -85,14 +85,14 @@ module.onTouch = function()
y = y + diskContainer.height + 1 y = y + diskContainer.height + 1
end end
container.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) container.eventHandler = function(application, object, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
if e5 < 0 or container.children[1].localY < 2 then if e5 < 0 or container.children[1].localY < 2 then
for i = 1, #container.children do for i = 1, #container.children do
container.children[i].localY = container.children[i].localY + e5 container.children[i].localY = container.children[i].localY + e5
end end
mainContainer:drawOnScreen() application:draw()
end end
elseif e1 == "component_added" or e1 == "component_removed" and e3 == "filesystem" then elseif e1 == "component_added" or e1 == "component_removed" and e3 == "filesystem" then
module.onTouch() module.onTouch()

View File

@ -1,6 +1,6 @@
local args = {...} local args = {...}
local mainContainer, window, localization = args[1], args[2], args[3] local application, window, localization = args[1], args[2], args[3]
require("advancedLua") require("advancedLua")
local component = require("component") local component = require("component")
@ -128,7 +128,7 @@ module.onTouch = function()
out("Failed to load string \"" .. data .. "\": " .. reason) out("Failed to load string \"" .. data .. "\": " .. reason)
end end
mainContainer:drawOnScreen() application:draw()
end end

View File

@ -1,6 +1,6 @@
local args = {...} local args = {...}
local mainContainer, window, localization = args[1], args[2], args[3] local application, window, localization = args[1], args[2], args[3]
require("advancedLua") require("advancedLua")
local component = require("component") local component = require("component")
@ -30,7 +30,7 @@ module.onTouch = function()
local textBox = layout:addChild(GUI.textBox(1, 1, container.width - 4, container.height - 4, nil, 0x888888, {localization.waitingEvents .. "..."}, 1, 0, 0)) local textBox = layout:addChild(GUI.textBox(1, 1, container.width - 4, container.height - 4, nil, 0x888888, {localization.waitingEvents .. "..."}, 1, 0, 0))
local switch = layout:addChild(GUI.switchAndLabel(1, 1, 27, 6, 0x66DB80, 0x1E1E1E, 0xFFFFFF, 0x2D2D2D, localization.processingEnabled .. ": ", true)).switch local switch = layout:addChild(GUI.switchAndLabel(1, 1, 27, 6, 0x66DB80, 0x1E1E1E, 0xFFFFFF, 0x2D2D2D, localization.processingEnabled .. ": ", true)).switch
textBox.eventHandler = function(mainContainer, object, ...) textBox.eventHandler = function(application, object, ...)
local eventData = {...} local eventData = {...}
if switch.state and eventData[1] then if switch.state and eventData[1] then
local lines = table.concat(eventData, " ") local lines = table.concat(eventData, " ")
@ -40,7 +40,7 @@ module.onTouch = function()
end end
textBox:scrollToEnd() textBox:scrollToEnd()
mainContainer:drawOnScreen() application:draw()
end end
end end
end end

View File

@ -43,7 +43,7 @@ local workpathHistoryCurrent = 0
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local mainContainer, window, menu = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 100, 26, 0xE1E1E1)) local application, window, menu = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 100, 26, 0xE1E1E1))
local titlePanel = window:addChild(GUI.panel(1, 1, 1, 3, 0x3C3C3C)) local titlePanel = window:addChild(GUI.panel(1, 1, 1, 3, 0x3C3C3C))
@ -94,7 +94,7 @@ end
local function updateFileListAndDraw() local function updateFileListAndDraw()
iconField:updateFileList() iconField:updateFileList()
MineOSInterface.mainContainer:drawOnScreen() application:draw()
end end
local function workpathHistoryButtonsUpdate() local function workpathHistoryButtonsUpdate()
@ -148,7 +148,7 @@ local function sidebarItemDraw(object)
buffer.drawText(object.x + 1, object.y, textColor, string.limit(object.text, limit, "center")) buffer.drawText(object.x + 1, object.y, textColor, string.limit(object.text, limit, "center"))
end end
local function sidebarItemEventHandler(mainContainer, object, e1, e2, e3, ...) local function sidebarItemEventHandler(application, object, e1, e2, e3, ...)
if e1 == "touch" then if e1 == "touch" then
if object.onRemove and e3 == object.x + object.width - 2 then if object.onRemove and e3 == object.x + object.width - 2 then
object.onRemove() object.onRemove()
@ -198,7 +198,7 @@ openFTP = function(...)
local mountPath = MineOSNetwork.mountPaths.FTP .. MineOSNetwork.getFTPProxyName(...) .. "/" local mountPath = MineOSNetwork.mountPaths.FTP .. MineOSNetwork.getFTPProxyName(...) .. "/"
addWorkpath(mountPath) addWorkpath(mountPath)
mainContainer:drawOnScreen() application:draw()
local proxy, reason = MineOSNetwork.connectToFTP(...) local proxy, reason = MineOSNetwork.connectToFTP(...)
if proxy then if proxy then
@ -227,7 +227,7 @@ updateSidebar = function()
object.onRemove = function() object.onRemove = function()
table.remove(config.favourites, i) table.remove(config.favourites, i)
updateSidebar() updateSidebar()
mainContainer:drawOnScreen() application:draw()
saveConfig() saveConfig()
end end
end end
@ -272,7 +272,7 @@ updateSidebar = function()
object.onRemove = function() object.onRemove = function()
table.remove(MineOSCore.properties.FTPConnections, i) table.remove(MineOSCore.properties.FTPConnections, i)
updateSidebar() updateSidebar()
mainContainer:drawOnScreen() application:draw()
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end
end end
@ -292,7 +292,7 @@ updateSidebar = function()
end end
end end
itemsLayout.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) itemsLayout.eventHandler = function(application, object, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
local cell = itemsLayout.cells[1][1] local cell = itemsLayout.cells[1][1]
local from = 0 local from = 0
@ -305,15 +305,15 @@ itemsLayout.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
cell.verticalMargin = to cell.verticalMargin = to
end end
mainContainer:drawOnScreen() application:draw()
elseif e1 == "component_added" or e1 == "component_removed" then elseif e1 == "component_added" or e1 == "component_removed" then
FTPButton.disabled = not MineOSNetwork.internetProxy FTPButton.disabled = not MineOSNetwork.internetProxy
updateSidebar() updateSidebar()
MineOSInterface.mainContainer:drawOnScreen() application:draw()
elseif e1 == "MineOSNetwork" then elseif e1 == "MineOSNetwork" then
if e2 == "updateProxyList" or e2 == "timeout" then if e2 == "updateProxyList" or e2 == "timeout" then
updateSidebar() updateSidebar()
MineOSInterface.mainContainer:drawOnScreen() application:draw()
end end
end end
end end
@ -356,7 +356,7 @@ prevButton.onTouch = function()
end end
FTPButton.onTouch = function() FTPButton.onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.networkFTPNewConnection) local container = MineOSInterface.addBackgroundContainer(application, MineOSCore.localization.networkFTPNewConnection)
local ad, po, us, pa, la = "ftp.example.com", "21", "root", "1234" local ad, po, us, pa, la = "ftp.example.com", "21", "root", "1234"
if #MineOSCore.properties.FTPConnections > 0 then if #MineOSCore.properties.FTPConnections > 0 then
@ -396,17 +396,17 @@ FTPButton.onTouch = function()
MineOSCore.saveProperties() MineOSCore.saveProperties()
updateSidebar() updateSidebar()
MineOSInterface.mainContainer:drawOnScreen() application:draw()
openFTP(addressInput.text, port, userInput.text, passwordInput.text) openFTP(addressInput.text, port, userInput.text, passwordInput.text)
end end
end end
end end
MineOSInterface.mainContainer:drawOnScreen() application:draw()
end end
iconField.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) iconField.eventHandler = function(application, object, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
iconField.yOffset = iconField.yOffset + e5 * 2 iconField.yOffset = iconField.yOffset + e5 * 2
@ -417,7 +417,7 @@ iconField.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
iconField.iconsContainer.children[i].localY = iconField.iconsContainer.children[i].localY + delta iconField.iconsContainer.children[i].localY = iconField.iconsContainer.children[i].localY + delta
end end
MineOSInterface.mainContainer:drawOnScreen() application:draw()
if scrollTimerID then if scrollTimerID then
event.cancel(scrollTimerID) event.cancel(scrollTimerID)
@ -441,7 +441,7 @@ iconField.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
saveConfig() saveConfig()
updateSidebar() updateSidebar()
MineOSInterface.mainContainer:drawOnScreen() application:draw()
end end
end end
end end
@ -492,7 +492,7 @@ iconField.updateFileList = function(...)
end end
end end
mainContainer:drawOnScreen() application:draw()
overrideUpdateFileList(...) overrideUpdateFileList(...)
updateScrollBar() updateScrollBar()
end end
@ -510,7 +510,7 @@ gotoButton.onTouch = function()
iconField:updateFileList() iconField:updateFileList()
end end
mainContainer:drawOnScreen() application:draw()
end end
statusContainer.hidden = true statusContainer.hidden = true
@ -569,7 +569,7 @@ window.onResize = function(width, height)
window.height = height window.height = height
calculateSizes() calculateSizes()
mainContainer:drawOnScreen() application:draw()
updateFileListAndDraw() updateFileListAndDraw()
end end
@ -577,7 +577,7 @@ resizer.onResize = function(deltaX)
sidebarContainer.width = sidebarContainer.width + deltaX sidebarContainer.width = sidebarContainer.width + deltaX
calculateSizes() calculateSizes()
mainContainer:drawOnScreen() application:draw()
end end
resizer.onResizeFinished = function() resizer.onResizeFinished = function()

View File

@ -14,7 +14,7 @@ else
return return
end end
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, "Fuck The Rain") local container = MineOSInterface.addBackgroundContainer(MineOSInterface.application, "Fuck The Rain")
local lines = string.wrap("This script works as background daemon and checks rain condition in specified interval", 36) local lines = string.wrap("This script works as background daemon and checks rain condition in specified interval", 36)
container.layout:addChild(GUI.textBox(1, 1, 36, #lines, nil, 0xA5A5A5, lines, 1, 0, 0)) container.layout:addChild(GUI.textBox(1, 1, 36, #lines, nil, 0xA5A5A5, lines, 1, 0, 0))
@ -50,7 +50,7 @@ container.layout:addChild(GUI.button(1, 1, 36, 3, 0x444444, 0xFFFFFF, 0x2D2D2D,
end end
container:remove() container:remove()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end

View File

@ -26,7 +26,7 @@ local earthImage = image.load(resourcesDirectory .. "Earth.pic")
local onScreenDataXOffset, onScreenDataYOffset = math.floor(bufferWidth / 2), bufferHeight local onScreenDataXOffset, onScreenDataYOffset = math.floor(bufferWidth / 2), bufferHeight
local onProjectorDataYOffset = 0 local onProjectorDataYOffset = 0
local scanResult = {horizontalRange = 0, verticalRange = 0} local scanResult = {horizontalRange = 0, verticalRange = 0}
local mainContainer = GUI.fullScreenContainer() local application = GUI.application()
-------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------
@ -82,9 +82,9 @@ local function updateData(onScreen, onProjector, onGlasses)
if onProjector then component.hologram.clear() end if onProjector then component.hologram.clear() end
if onGlasses and glassesAvailable then component.glasses.removeAll() end if onGlasses and glassesAvailable then component.glasses.removeAll() end
local min, max = tonumber(mainContainer.minimumHardnessTextBox.text), tonumber(mainContainer.maximumHardnessTextBox.text) local min, max = tonumber(application.minimumHardnessTextBox.text), tonumber(application.maximumHardnessTextBox.text)
if min and max then if min and max then
local horizontalRange, verticalRange = math.floor(mainContainer.horizontalScanRangeSlider.value), math.floor(mainContainer.verticalScanRangeSlider.value) local horizontalRange, verticalRange = math.floor(application.horizontalScanRangeSlider.value), math.floor(application.verticalScanRangeSlider.value)
for x = -horizontalRange, horizontalRange do for x = -horizontalRange, horizontalRange do
for z = -horizontalRange, horizontalRange do for z = -horizontalRange, horizontalRange do
@ -93,11 +93,11 @@ local function updateData(onScreen, onProjector, onGlasses)
if onScreen then if onScreen then
buffer.semiPixelSet(onScreenDataXOffset + x, onScreenDataYOffset + 32 - y, 0x454545) buffer.semiPixelSet(onScreenDataXOffset + x, onScreenDataYOffset + 32 - y, 0x454545)
end end
if onProjector and mainContainer.projectorUpdateSwitch.state then if onProjector and application.projectorUpdateSwitch.state then
component.hologram.set(horizontalRange + x, math.floor(mainContainer.projectorYOffsetSlider.value) + y - 32, horizontalRange + z, 1) component.hologram.set(horizontalRange + x, math.floor(application.projectorYOffsetSlider.value) + y - 32, horizontalRange + z, 1)
end end
if onGlasses and mainContainer.glassesUpdateSwitch.state and glassesAvailable then if onGlasses and application.glassesUpdateSwitch.state and glassesAvailable then
glassesCreateCube(x, y - 32, z, mainContainer.glassesOreColorButton.colors.default.background, "Hardness: " .. string.format("%.2f", scanResult[x][z][y])) glassesCreateCube(x, y - 32, z, application.glassesOreColorButton.colors.default.background, "Hardness: " .. string.format("%.2f", scanResult[x][z][y]))
os.sleep(0) os.sleep(0)
end end
end end
@ -107,91 +107,91 @@ local function updateData(onScreen, onProjector, onGlasses)
end end
end end
local oldDraw = mainContainer.draw local oldDraw = application.draw
mainContainer.draw = function() application.draw = function()
updateData(true, false, false) updateData(true, false, false)
oldDraw(mainContainer) oldDraw(application)
end end
local panelWidth = 30 local panelWidth = 30
local panelX = bufferWidth - panelWidth + 1 local panelX = bufferWidth - panelWidth + 1
local buttonX, objectY = panelX + 2, 2 local buttonX, objectY = panelX + 2, 2
local buttonWidth = panelWidth - 4 local buttonWidth = panelWidth - 4
mainContainer:addChild(GUI.panel(panelX, 1, panelWidth, bufferHeight, 0x444444)) application:addChild(GUI.panel(panelX, 1, panelWidth, bufferHeight, 0x444444))
mainContainer.planetImage = mainContainer:addChild(GUI.image(buttonX, objectY, earthImage)) application.planetImage = application:addChild(GUI.image(buttonX, objectY, earthImage))
objectY = objectY + mainContainer.planetImage.image[2] + 1 objectY = objectY + application.planetImage.image[2] + 1
mainContainer:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xFFFFFF, "GeoScan v2.0")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xFFFFFF, "GeoScan v2.0")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
objectY = objectY + 2 objectY = objectY + 2
mainContainer.horizontalScanRangeSlider = mainContainer:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 4, 24, 16, false, "Horizontal scan range: ")) application.horizontalScanRangeSlider = application:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 4, 24, 16, false, "Horizontal scan range: "))
mainContainer.horizontalScanRangeSlider.roundValues = true application.horizontalScanRangeSlider.roundValues = true
objectY = objectY + 3 objectY = objectY + 3
mainContainer.verticalScanRangeSlider = mainContainer:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 4, 32, 16, false, "Vertical show range: ")) application.verticalScanRangeSlider = application:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 4, 32, 16, false, "Vertical show range: "))
mainContainer.verticalScanRangeSlider.roundValues = true application.verticalScanRangeSlider.roundValues = true
objectY = objectY + 4 objectY = objectY + 4
mainContainer:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xFFFFFF, "Rendering properties")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xFFFFFF, "Rendering properties")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
objectY = objectY + 2 objectY = objectY + 2
mainContainer.minimumHardnessTextBox = mainContainer:addChild(GUI.input(buttonX, objectY, 12, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(2.7), nil, true)) application.minimumHardnessTextBox = application:addChild(GUI.input(buttonX, objectY, 12, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(2.7), nil, true))
mainContainer.maximumHardnessTextBox = mainContainer:addChild(GUI.input(buttonX + 14, objectY, 12, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(10), nil, true)) application.maximumHardnessTextBox = application:addChild(GUI.input(buttonX + 14, objectY, 12, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(10), nil, true))
objectY = objectY + 3 objectY = objectY + 3
mainContainer:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Hardness min Hardness max")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Hardness min Hardness max")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
objectY = objectY + 2 objectY = objectY + 2
mainContainer.projectorScaleSlider = mainContainer:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 0.33, 3, component.hologram.getScale(), false, "Projection scale: ")) application.projectorScaleSlider = application:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 0.33, 3, component.hologram.getScale(), false, "Projection scale: "))
mainContainer.projectorScaleSlider.onValueChanged = function() application.projectorScaleSlider.onValueChanged = function()
component.hologram.setScale(mainContainer.projectorScaleSlider.value) component.hologram.setScale(application.projectorScaleSlider.value)
end end
objectY = objectY + 3 objectY = objectY + 3
mainContainer.projectorYOffsetSlider = mainContainer:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 0, 64, 4, false, "Projection Y offset: ")) application.projectorYOffsetSlider = application:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 0, 64, 4, false, "Projection Y offset: "))
mainContainer.projectorYOffsetSlider.roundValues = true application.projectorYOffsetSlider.roundValues = true
objectY = objectY + 3 objectY = objectY + 3
local function setButtonColorFromPalette(button) local function setButtonColorFromPalette(button)
local selectedColor = GUI.palette(math.floor(mainContainer.width / 2 - 35), math.floor(mainContainer.height / 2 - 12), button.colors.default.background):show() local selectedColor = GUI.palette(math.floor(application.width / 2 - 35), math.floor(application.height / 2 - 12), button.colors.default.background):show()
if selectedColor then button.colors.default.background = selectedColor end if selectedColor then button.colors.default.background = selectedColor end
mainContainer:drawOnScreen() application:draw()
end end
local function updateProjectorColors() local function updateProjectorColors()
component.hologram.setPaletteColor(1, mainContainer.color1Button.colors.default.background) component.hologram.setPaletteColor(1, application.color1Button.colors.default.background)
end end
local color1, color2, color3 = component.hologram.getPaletteColor(1), component.hologram.getPaletteColor(2), component.hologram.getPaletteColor(3) local color1, color2, color3 = component.hologram.getPaletteColor(1), component.hologram.getPaletteColor(2), component.hologram.getPaletteColor(3)
mainContainer.color1Button = mainContainer:addChild(GUI.button(buttonX, objectY, buttonWidth, 1, color1, 0xBBBBBB, 0xEEEEEE, 0x262626, "Projector color")); objectY = objectY + 1 application.color1Button = application:addChild(GUI.button(buttonX, objectY, buttonWidth, 1, color1, 0xBBBBBB, 0xEEEEEE, 0x262626, "Projector color")); objectY = objectY + 1
mainContainer.color1Button.onTouch = function() application.color1Button.onTouch = function()
setButtonColorFromPalette(mainContainer.color1Button) setButtonColorFromPalette(application.color1Button)
updateProjectorColors() updateProjectorColors()
end end
mainContainer.glassesOreColorButton = mainContainer:addChild(GUI.button(buttonX, objectY, buttonWidth, 1, 0x0044FF, 0xBBBBBB, 0xEEEEEE, 0x262626, "Glasses ore color")) application.glassesOreColorButton = application:addChild(GUI.button(buttonX, objectY, buttonWidth, 1, 0x0044FF, 0xBBBBBB, 0xEEEEEE, 0x262626, "Glasses ore color"))
mainContainer.glassesOreColorButton.onTouch = function() application.glassesOreColorButton.onTouch = function()
setButtonColorFromPalette(mainContainer.glassesOreColorButton) setButtonColorFromPalette(application.glassesOreColorButton)
end end
objectY = objectY + 2 objectY = objectY + 2
mainContainer:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Projector update:")) application:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Projector update:"))
mainContainer.projectorUpdateSwitch = mainContainer:addChild(GUI.switch(bufferWidth - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true)) application.projectorUpdateSwitch = application:addChild(GUI.switch(bufferWidth - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true))
objectY = objectY + 2 objectY = objectY + 2
mainContainer:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Glasses update:")) application:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Glasses update:"))
mainContainer.glassesUpdateSwitch = mainContainer:addChild(GUI.switch(bufferWidth - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true)) application.glassesUpdateSwitch = application:addChild(GUI.switch(bufferWidth - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true))
objectY = objectY + 2 objectY = objectY + 2
mainContainer:addChild(GUI.button(bufferWidth, 1, 1, 1, nil, 0xEEEEEE, nil, 0xFF2222, "X")).onTouch = function() application:addChild(GUI.button(bufferWidth, 1, 1, 1, nil, 0xEEEEEE, nil, 0xFF2222, "X")).onTouch = function()
mainContainer:stopEventHandling() application:stop()
createDick(math.random(-48, 48), math.random(1, 32), math.random(-48, 48), 100, true) createDick(math.random(-48, 48), math.random(1, 32), math.random(-48, 48), 100, true)
end end
mainContainer:addChild(GUI.button(panelX, bufferHeight - 5, panelWidth, 3, 0x353535, 0xEEEEEE, 0xAAAAAA, 0x262626, "Update")).onTouch = function() application:addChild(GUI.button(panelX, bufferHeight - 5, panelWidth, 3, 0x353535, 0xEEEEEE, 0xAAAAAA, 0x262626, "Update")).onTouch = function()
updateData(false, true, true) updateData(false, true, true)
end end
mainContainer.scanButton = mainContainer:addChild(GUI.button(panelX, bufferHeight - 2, panelWidth, 3, 0x262626, 0xEEEEEE, 0xAAAAAA, 0x262626, "Scan")) application.scanButton = application:addChild(GUI.button(panelX, bufferHeight - 2, panelWidth, 3, 0x262626, 0xEEEEEE, 0xAAAAAA, 0x262626, "Scan"))
mainContainer.scanButton.onTouch = function() application.scanButton.onTouch = function()
scanResult = {} scanResult = {}
local horizontalRange, verticalRange = math.floor(mainContainer.horizontalScanRangeSlider.value), math.floor(mainContainer.verticalScanRangeSlider.value) local horizontalRange, verticalRange = math.floor(application.horizontalScanRangeSlider.value), math.floor(application.verticalScanRangeSlider.value)
local total, current = (horizontalRange * 2 + 1) ^ 2, 0 local total, current = (horizontalRange * 2 + 1) ^ 2, 0
buffer.clear(0x0, 0.48) buffer.clear(0x0, 0.48)
@ -205,13 +205,13 @@ mainContainer.scanButton.onTouch = function()
end end
end end
mainContainer:drawOnScreen() application:draw()
updateData(false, true, true) updateData(false, true, true)
end end
-------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------
buffer.clear(0x0) buffer.clear(0x0)
mainContainer:drawOnScreen() application:draw()
mainContainer:startEventHandling() application:start()

View File

@ -8,7 +8,7 @@ local MineOSInterface = require("MineOSInterface")
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 110, 25, 0xF0F0F0)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 110, 25, 0xF0F0F0))
local yDependencyString = "math.sin(x)" local yDependencyString = "math.sin(x)"
local xOffset, yOffset, xDrag, yDrag, points = 0, 0, 1, 1 local xOffset, yOffset, xDrag, yDrag, points = 0, 0, 1, 1
@ -86,16 +86,16 @@ functionButton.onTouch = function()
update() update()
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
scaleSlider.onValueChanged = function() scaleSlider.onValueChanged = function()
update() update()
mainContainer:drawOnScreen() application:draw()
end end
rangeSlider.onValueChanged = scaleSlider.onValueChanged rangeSlider.onValueChanged = scaleSlider.onValueChanged
precisionSlider.onValueChanged = scaleSlider.onValueChanged precisionSlider.onValueChanged = scaleSlider.onValueChanged
@ -109,12 +109,12 @@ window.onResize = function(width, height)
update() update()
end end
graph.eventHandler = function(mainContainer, graph, e1, e2, e3, e4, e5) graph.eventHandler = function(application, graph, e1, e2, e3, e4, e5)
if e1 == "touch" then if e1 == "touch" then
xDrag, yDrag = e3, e4 xDrag, yDrag = e3, e4
elseif e1 == "drag" then elseif e1 == "drag" then
xOffset, yOffset = xOffset + (e3 - xDrag), yOffset + (e4 - yDrag) xOffset, yOffset = xOffset + (e3 - xDrag), yOffset + (e4 - yDrag)
mainContainer:drawOnScreen() application:draw()
xDrag, yDrag = e3, e4 xDrag, yDrag = e3, e4
elseif e1 == "scroll" then elseif e1 == "scroll" then
@ -126,14 +126,14 @@ graph.eventHandler = function(mainContainer, graph, e1, e2, e3, e4, e5)
end end
update() update()
mainContainer:drawOnScreen() application:draw()
end end
end end
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
update() update()
mainContainer:drawOnScreen() application:draw()

View File

@ -38,7 +38,7 @@ local scrollBar, titleTextBox
------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 98, 25, colors.background)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 98, 25, colors.background))
window.backgroundPanel.localX, window.backgroundPanel.localY = 11, 5 window.backgroundPanel.localX, window.backgroundPanel.localY = 11, 5
window.backgroundPanel.width, window.backgroundPanel.height = window.width - 10, window.height - 4 window.backgroundPanel.width, window.backgroundPanel.height = window.width - 10, window.height - 4
@ -84,22 +84,22 @@ local function byteFieldDraw(object)
return object return object
end end
local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5) local function byteFieldEventHandler(application, object, e1, e2, e3, e4, e5)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
if e5 == 1 then if e5 == 1 then
local menu = GUI.addContextMenu(mainContainer, e3, e4) local menu = GUI.addContextMenu(application, e3, e4)
menu:addItem("Select all").onTouch = function() menu:addItem("Select all").onTouch = function()
selection.from = 1 selection.from = 1
selection.to = #bytes selection.to = #bytes
mainContainer:drawOnScreen() application:draw()
end end
menu:addSeparator() menu:addSeparator()
menu:addItem("Edit").onTouch = function() menu:addItem("Edit").onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Fill byte range [" .. selection.from .. "; " .. selection.to .. "]") local container = MineOSInterface.addBackgroundContainer(application, "Fill byte range [" .. selection.from .. "; " .. selection.to .. "]")
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, string.format("%02X" , bytes[selection.from]), "Type byte value")) local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, string.format("%02X" , bytes[selection.from]), "Type byte value"))
input.onInputFinished = function(text) input.onInputFinished = function(text)
@ -110,15 +110,15 @@ local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5)
end end
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
menu:addItem("Insert").onTouch = function() menu:addItem("Insert").onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Insert bytes at position " .. selection.from .. "") local container = MineOSInterface.addBackgroundContainer(application, "Insert bytes at position " .. selection.from .. "")
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, "", "Type byte values separated by space", true)) local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, "", "Type byte values separated by space", true))
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0xBBBBBB, "Select inserted bytes:", true)).switch local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0xBBBBBB, "Select inserted bytes:", true)).switch
@ -138,11 +138,11 @@ local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5)
end end
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
menu:addSeparator() menu:addSeparator()
@ -158,7 +158,7 @@ local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5)
end end
end end
mainContainer:drawOnScreen() application:draw()
else else
local index = (math.ceil((e4 - object.y + 1) / 2) - 1) * 16 + math.ceil((e3 - object.x + 1 + object.offset) / object.elementWidth) + offset local index = (math.ceil((e4 - object.y + 1) / 2) - 1) * 16 + math.ceil((e3 - object.x + 1 + object.offset) / object.elementWidth) + offset
@ -180,7 +180,7 @@ local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5)
end end
status() status()
mainContainer:drawOnScreen() application:draw()
end end
end end
elseif e1 == "scroll" then elseif e1 == "scroll" then
@ -192,7 +192,7 @@ local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5)
end end
scrollBar.value = offset scrollBar.value = offset
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -320,17 +320,17 @@ local function load(path)
end end
openFileButton.onTouch = function() openFileButton.onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Open", "Cancel", "File name", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "Open", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
filesystemDialog:show() filesystemDialog:show()
filesystemDialog.onSubmit = function(path) filesystemDialog.onSubmit = function(path)
load(path) load(path)
mainContainer:drawOnScreen() application:draw()
end end
end end
saveFileButton.onTouch = function() saveFileButton.onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Save", "Cancel", "File name", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "Save", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
filesystemDialog:show() filesystemDialog:show()
filesystemDialog.onSubmit = function(path) filesystemDialog.onSubmit = function(path)
@ -358,13 +358,13 @@ window.actionButtons.maximize.onTouch = function()
window.localY = 1 window.localY = 1
mainContainer:drawOnScreen() application:draw()
end end
------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------
load("/bin/resolution.lua") load("/bin/resolution.lua")
mainContainer:drawOnScreen() application:draw()

View File

@ -196,7 +196,7 @@ local function flashback()
buffer.clear(0x0, 0.3) buffer.clear(0x0, 0.3)
end end
local function drawOnScreen() local function draw()
local width, height = 58, 7 local width, height = 58, 7
local x, y = math.floor(buffer.getWidth() / 2 - width / 2), math.floor(buffer.getHeight() / 2 - height / 2) local x, y = math.floor(buffer.getWidth() / 2 - width / 2), math.floor(buffer.getHeight() / 2 - height / 2)
@ -221,7 +221,7 @@ flashback()
while true do while true do
getDate() getDate()
drawOnScreen() draw()
local e = {event.pull(1)} local e = {event.pull(1)}
if e[1] == "scroll" then if e[1] == "scroll" then

View File

@ -76,7 +76,7 @@ end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 110, 27, 0xE1E1E1)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 110, 27, 0xE1E1E1))
local leftPanel = window:addChild(GUI.panel(1, 1, 21, 1, 0x2D2D2D)) local leftPanel = window:addChild(GUI.panel(1, 1, 21, 1, 0x2D2D2D))
local leftLayout = window:addChild(GUI.layout(1, 4, leftPanel.width, 1, 1, 1)) local leftLayout = window:addChild(GUI.layout(1, 4, leftPanel.width, 1, 1, 1))
@ -187,7 +187,7 @@ local function status(text)
loginStatusText.hidden, loginServerLayout.hidden, loginUsernameInput.hidden, loginPasswordSwitchAndLabel.hidden, loginSubmitButton.hidden = not state, state, state, state, state loginStatusText.hidden, loginServerLayout.hidden, loginUsernameInput.hidden, loginPasswordSwitchAndLabel.hidden, loginSubmitButton.hidden = not state, state, state, state, state
loginPasswordInput.hidden = state and true or not loginPasswordSwitchAndLabel.switch.state loginPasswordInput.hidden = state and true or not loginPasswordSwitchAndLabel.switch.state
mainContainer:drawOnScreen() application:draw()
end end
local function updateLeftLayout() local function updateLeftLayout()
@ -256,7 +256,7 @@ local function addContactItemToList(name)
scrollBar.value = scrollBar.maximumValue scrollBar.value = scrollBar.maximumValue
rightLayout:removeChildren() rightLayout:removeChildren()
mainContainer:drawOnScreen() application:draw()
if socketHandle then if socketHandle then
if list == channelsList then if list == channelsList then
@ -386,7 +386,7 @@ end
loginUsernameInput.onInputFinished = function() loginUsernameInput.onInputFinished = function()
checkLoginInputs() checkLoginInputs()
mainContainer:drawOnScreen() application:draw()
end end
loginPasswordInput.onInputFinished = loginUsernameInput.onInputFinished loginPasswordInput.onInputFinished = loginUsernameInput.onInputFinished
@ -429,7 +429,7 @@ chatInput.onInputFinished = function()
chatInput.text = "" chatInput.text = ""
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -444,17 +444,17 @@ local function addScrollEventHandler(layout)
return height return height
end end
layout.eventHandler = function(mainContainer, layout, e1, e2, e3, e4, e5) layout.eventHandler = function(application, layout, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
if e5 > 0 then if e5 > 0 then
if layout.cells[1][1].verticalMargin < 0 then if layout.cells[1][1].verticalMargin < 0 then
layout.cells[1][1].verticalMargin = layout.cells[1][1].verticalMargin + 1 layout.cells[1][1].verticalMargin = layout.cells[1][1].verticalMargin + 1
mainContainer:drawOnScreen() application:draw()
end end
else else
if layout.cells[1][1].verticalMargin > -getTotalHeight(layout) + 1 then if layout.cells[1][1].verticalMargin > -getTotalHeight(layout) + 1 then
layout.cells[1][1].verticalMargin = layout.cells[1][1].verticalMargin - 1 layout.cells[1][1].verticalMargin = layout.cells[1][1].verticalMargin - 1
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
@ -470,7 +470,7 @@ local function selectItem(item)
item.onTouch() item.onTouch()
end end
local function userButtonOnTouch(mainContainer, object) local function userButtonOnTouch(application, object)
local text = object.text:gsub("^[@+]", "") local text = object.text:gsub("^[@+]", "")
if history[text] then if history[text] then
selectItem(getItemByText(text)) selectItem(getItemByText(text))
@ -524,17 +524,17 @@ local function removeUserFromList(name)
end end
end end
chat.eventHandler = function(mainContainer, chat, e1, e2, e3, e4, e5) chat.eventHandler = function(application, chat, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
if e5 > 0 then if e5 > 0 then
if scrollBar.value > 1 then if scrollBar.value > 1 then
scrollBar.value = scrollBar.value - 1 scrollBar.value = scrollBar.value - 1
mainContainer:drawOnScreen() application:draw()
end end
else else
if scrollBar.value < scrollBar.maximumValue then if scrollBar.value < scrollBar.maximumValue then
scrollBar.value = scrollBar.value + 1 scrollBar.value = scrollBar.value + 1
mainContainer:drawOnScreen() application:draw()
end end
end end
elseif not e1 and socketHandle and computer.uptime() - oldUptime > socketReadDelay then elseif not e1 and socketHandle and computer.uptime() - oldUptime > socketReadDelay then
@ -675,7 +675,7 @@ chat.eventHandler = function(mainContainer, chat, e1, e2, e3, e4, e5)
end end
end end
mainContainer:drawOnScreen() application:draw()
break break
else else
break break
@ -728,11 +728,11 @@ settingsButton.onTouch = function()
config.soundNotifications = switchAndLabel.switch.state config.soundNotifications = switchAndLabel.switch.state
backgroundContainer.hidden = true backgroundContainer.hidden = true
mainContainer:drawOnScreen() application:draw()
saveConfig() saveConfig()
end end
mainContainer:drawOnScreen() application:draw()
end end
contactAddButton.onTouch = function() contactAddButton.onTouch = function()
@ -746,11 +746,11 @@ contactAddButton.onTouch = function()
if #input.text > 0 and not history[input.text] then if #input.text > 0 and not history[input.text] then
selectItem(addContactItemToList(input.text)) selectItem(addContactItemToList(input.text))
else else
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
contactRemoveButton.onTouch = function() contactRemoveButton.onTouch = function()
@ -764,7 +764,7 @@ contactRemoveButton.onTouch = function()
selectItem(systemList:getItem(socketUsername)) selectItem(systemList:getItem(socketUsername))
updateLeftLayout() updateLeftLayout()
mainContainer:drawOnScreen() application:draw()
end end
loginPasswordSwitchAndLabel.switch.onStateChanged = function() loginPasswordSwitchAndLabel.switch.onStateChanged = function()
@ -795,7 +795,7 @@ scrollBar.onTouch = function()
scrollBar.value = #history[selectedItem.text] scrollBar.value = #history[selectedItem.text]
end end
mainContainer:drawOnScreen() application:draw()
end end
local overrideWindowClose = window.close local overrideWindowClose = window.close

View File

@ -92,7 +92,7 @@ if filesystem.exists(configPath) then
config = table.fromFile(configPath) config = table.fromFile(configPath)
end end
local mainContainer, window, menu = MineOSInterface.addWindow(GUI.window(1, 1, 120, 30)) local application, window, menu = MineOSInterface.addWindow(GUI.window(1, 1, 120, 30))
menu:removeChildren() menu:removeChildren()
local codeView = window:addChild(GUI.codeView(1, 1, 1, 1, 1, 1, 1, {}, {}, GUI.LUA_SYNTAX_PATTERNS, config.syntaxColorScheme, config.syntaxHighlight, lines)) local codeView = window:addChild(GUI.codeView(1, 1, 1, 1, 1, 1, 1, {}, {}, GUI.LUA_SYNTAX_PATTERNS, config.syntaxColorScheme, config.syntaxHighlight, lines))
@ -253,7 +253,7 @@ end
local function tick(state) local function tick(state)
cursorBlinkState = state cursorBlinkState = state
updateTitle() updateTitle()
mainContainer:drawOnScreen() application:draw()
cursorUptime = computer.uptime() cursorUptime = computer.uptime()
end end
@ -524,7 +524,7 @@ local function optimizeString(s)
end end
local function addBackgroundContainer(title) local function addBackgroundContainer(title)
return GUI.addBackgroundContainer(mainContainer, true, true, title) return GUI.addBackgroundContainer(application, true, true, title)
end end
local function addInputFadeContainer(title, placeholder) local function addInputFadeContainer(title, placeholder)
@ -570,7 +570,7 @@ local function openFile(path)
if counter % config.linesToShowOpenProgress == 0 then if counter % config.linesToShowOpenProgress == 0 then
progressBar.value = math.floor(currentSize / totalSize * 100) progressBar.value = math.floor(currentSize / totalSize * 100)
computer.pullSignal(0) computer.pullSignal(0)
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -582,7 +582,7 @@ local function openFile(path)
if counter > config.linesToShowOpenProgress then if counter > config.linesToShowOpenProgress then
progressBar.value = 100 progressBar.value = 100
mainContainer:drawOnScreen() application:draw()
end end
codeView.hidden = false codeView.hidden = false
@ -598,7 +598,7 @@ end
local function saveFile(path) local function saveFile(path)
filesystem.makeDirectory(filesystem.path(path)) filesystem.makeDirectory(filesystem.path(path))
local file, reason = io.open(path, "w") local file, reason = io.open(path, "w")
if file then if file then
for line = 1, #lines do for line = 1, #lines do
file:write(lines[line], "\n") file:write(lines[line], "\n")
end end
@ -617,25 +617,25 @@ local function gotoLineWindow()
if container.input.text:match("%d+") then if container.input.text:match("%d+") then
gotoLine(tonumber(container.input.text)) gotoLine(tonumber(container.input.text))
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
local function openFileWindow() local function openFileWindow()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(window.height * 0.8), "Open", "Cancel", "File name", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(window.height * 0.8), "Open", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
filesystemDialog.onSubmit = function(path) filesystemDialog.onSubmit = function(path)
openFile(path) openFile(path)
mainContainer:drawOnScreen() application:draw()
end end
filesystemDialog:show() filesystemDialog:show()
end end
local function saveFileAsWindow() local function saveFileAsWindow()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(window.height * 0.8), "Save", "Cancel", "File name", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(window.height * 0.8), "Save", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
filesystemDialog.onSubmit = function(path) filesystemDialog.onSubmit = function(path)
saveFile(path) saveFile(path)
@ -643,7 +643,7 @@ local function saveFileAsWindow()
leftTreeView.selectedItem = (leftTreeView.workPath .. path):gsub("/+", "/") leftTreeView.selectedItem = (leftTreeView.workPath .. path):gsub("/+", "/")
updateTitle() updateTitle()
mainContainer:drawOnScreen() application:draw()
end end
filesystemDialog:show() filesystemDialog:show()
end end
@ -678,7 +678,7 @@ local function downloadFileFromWeb()
if #container.input.text > 0 then if #container.input.text > 0 then
container.input:remove() container.input:remove()
container.layout:addChild(GUI.text(1, 1, 0x969696, localization.downloading)) container.layout:addChild(GUI.text(1, 1, 0x969696, localization.downloading))
mainContainer:drawOnScreen() application:draw()
local result, reason = require("web").request(container.input.text) local result, reason = require("web").request(container.input.text)
if result then if result then
@ -692,10 +692,10 @@ local function downloadFileFromWeb()
end end
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
mainContainer:drawOnScreen() application:draw()
end end
local function getVariables(codePart) local function getVariables(codePart)
@ -740,12 +740,12 @@ continue = function(...)
if coroutine.status(scriptCoroutine) == "dead" then if coroutine.status(scriptCoroutine) == "dead" then
MineOSInterface.waitForPressingAnyKey() MineOSInterface.waitForPressingAnyKey()
buffer.setResolution(oldResolutionX, oldResolutionY) buffer.setResolution(oldResolutionX, oldResolutionY)
mainContainer:drawOnScreen(true) application:draw(true)
else else
-- Тест на пидора, мало ли у чувака в проге тоже есть yield -- Тест на пидора, мало ли у чувака в проге тоже есть yield
if _G.MineCodeIDEDebugInfo then if _G.MineCodeIDEDebugInfo then
buffer.setResolution(oldResolutionX, oldResolutionY) buffer.setResolution(oldResolutionX, oldResolutionY)
mainContainer:drawOnScreen(true) application:draw(true)
gotoLine(_G.MineCodeIDEDebugInfo.line) gotoLine(_G.MineCodeIDEDebugInfo.line)
showBreakpointMessage(_G.MineCodeIDEDebugInfo.variables) showBreakpointMessage(_G.MineCodeIDEDebugInfo.variables)
end end
@ -802,10 +802,10 @@ local function zalupa()
updateHighlights() updateHighlights()
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
container:addChild(GUI.object(1, 1, window.width, window.height)).eventHandler = function(mainContainer, object, e1) container:addChild(GUI.object(1, 1, window.width, window.height)).eventHandler = function(application, object, e1)
if e1 == "touch" or e1 == "key_down" then if e1 == "touch" or e1 == "key_down" then
container.close() container.close()
end end
@ -858,7 +858,7 @@ showTip = function(errorCode, matchCode, beep, force)
tip.localX = math.min(maxX, math.max(minX + 1, math.round(minX + unicode.len(lines[lastErrorLine]) / 2 - tip.width / 2))) tip.localX = math.min(maxX, math.max(minX + 1, math.round(minX + unicode.len(lines[lastErrorLine]) / 2 - tip.width / 2)))
tip.localY = codeView.localY + lastErrorLine - codeView.fromLine + 1 tip.localY = codeView.localY + lastErrorLine - codeView.fromLine + 1
mainContainer:drawOnScreen(force) application:draw(force)
if beep then if beep then
computer.beep(1500, 0.08) computer.beep(1500, 0.08)
@ -900,7 +900,7 @@ showBreakpointMessage = function(variables)
end end
titleDebugMode = true titleDebugMode = true
mainContainer:drawOnScreen() application:draw()
computer.beep(1500, 0.08) computer.beep(1500, 0.08)
end end
@ -916,12 +916,12 @@ local function launchWithArgumentsWindow()
end end
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
run(table.unpack(arguments)) run(table.unpack(arguments))
end end
mainContainer:drawOnScreen() application:draw()
end end
local function deleteLine(line) local function deleteLine(line)
@ -1039,7 +1039,7 @@ local function selectAndPasteColor()
palette.cancelButton.onTouch = function() palette.cancelButton.onTouch = function()
palette:remove() palette:remove()
mainContainer:drawOnScreen() application:draw()
end end
palette.submitButton.onTouch = function() palette.submitButton.onTouch = function()
@ -1292,7 +1292,7 @@ local function toggleBottomToolBar()
calculateSizes() calculateSizes()
if not bottomToolBar.hidden then if not bottomToolBar.hidden then
mainContainer:draw() application:draw()
findFromFirstDisplayedLine() findFromFirstDisplayedLine()
end end
end end
@ -1362,7 +1362,7 @@ local function createEditOrRightClickMenu(menu)
menu:addItem(localization.addBreakpoint, false, "F9").onTouch = function() menu:addItem(localization.addBreakpoint, false, "F9").onTouch = function()
addBreakpoint() addBreakpoint()
mainContainer:drawOnScreen() application:draw()
end end
menu:addItem(localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function() menu:addItem(localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function()
@ -1371,10 +1371,10 @@ local function createEditOrRightClickMenu(menu)
end end
local uptime = computer.uptime() local uptime = computer.uptime()
codeView.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) codeView.eventHandler = function(application, object, e1, e2, e3, e4, e5)
if e1 == "touch" then if e1 == "touch" then
if e5 == 1 then if e5 == 1 then
createEditOrRightClickMenu(GUI.addContextMenu(mainContainer, e3, e4)) createEditOrRightClickMenu(GUI.addContextMenu(application, e3, e4))
else else
setCursorPositionAndClearSelection(convertScreenCoordinatesToTextPosition(e3, e4)) setCursorPositionAndClearSelection(convertScreenCoordinatesToTextPosition(e3, e4))
end end
@ -1586,9 +1586,9 @@ codeView.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
end end
leftTreeView.onItemSelected = function(path) leftTreeView.onItemSelected = function(path)
mainContainer:drawOnScreen() application:draw()
openFile(path) openFile(path)
mainContainer:drawOnScreen() application:draw()
end end
local MineCodeContextMenu = menu:addContextMenu("MineCode", 0x0) local MineCodeContextMenu = menu:addContextMenu("MineCode", 0x0)
@ -1618,13 +1618,13 @@ MineCodeContextMenu:addItem(localization.about).onTouch = function()
textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
textBox.eventHandler = nil textBox.eventHandler = nil
mainContainer:drawOnScreen() application:draw()
end end
local fileContextMenu = menu:addContextMenu(localization.file) local fileContextMenu = menu:addContextMenu(localization.file)
fileContextMenu:addItem(localization.new, false, "^N").onTouch = function() fileContextMenu:addItem(localization.new, false, "^N").onTouch = function()
newFile() newFile()
mainContainer:drawOnScreen() application:draw()
end end
fileContextMenu:addItem(localization.open, false, "^O").onTouch = function() fileContextMenu:addItem(localization.open, false, "^O").onTouch = function()
@ -1650,12 +1650,12 @@ end
fileContextMenu:addItem(MineOSCore.localization.flashEEPROM, not component.isAvailable("eeprom")).onTouch = function() fileContextMenu:addItem(MineOSCore.localization.flashEEPROM, not component.isAvailable("eeprom")).onTouch = function()
local container = addBackgroundContainer(MineOSCore.localization.flashEEPROM) local container = addBackgroundContainer(MineOSCore.localization.flashEEPROM)
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, MineOSCore.localization.flashingEEPROM .. "...")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, MineOSCore.localization.flashingEEPROM .. "...")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
mainContainer:drawOnScreen() application:draw()
pcall(component.eeprom.set, table.concat(lines, ";")) pcall(component.eeprom.set, table.concat(lines, ";"))
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
fileContextMenu:addSeparator() fileContextMenu:addSeparator()
@ -1692,7 +1692,7 @@ end
local propertiesContextMenu = menu:addContextMenu(localization.properties) local propertiesContextMenu = menu:addContextMenu(localization.properties)
propertiesContextMenu:addItem(localization.colorScheme).onTouch = function() propertiesContextMenu:addItem(localization.colorScheme).onTouch = function()
local container = GUI.addBackgroundContainer(mainContainer, true, false, localization.colorScheme) local container = GUI.addBackgroundContainer(application, true, false, localization.colorScheme)
local colorSelectorsCount, colorSelectorCountX = 0, 4; for key in pairs(config.syntaxColorScheme) do colorSelectorsCount = colorSelectorsCount + 1 end local colorSelectorsCount, colorSelectorCountX = 0, 4; for key in pairs(config.syntaxColorScheme) do colorSelectorsCount = colorSelectorsCount + 1 end
local colorSelectorCountY = math.ceil(colorSelectorsCount / colorSelectorCountX) local colorSelectorCountY = math.ceil(colorSelectorsCount / colorSelectorCountX)
@ -1722,7 +1722,7 @@ propertiesContextMenu:addItem(localization.colorScheme).onTouch = function()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function() propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function()
@ -1748,7 +1748,7 @@ propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function(
saveConfig() saveConfig()
end end
mainContainer:drawOnScreen() application:draw()
end end
if topToolBar.hidden then if topToolBar.hidden then
@ -1785,13 +1785,13 @@ end
addBreakpointButton.onTouch = function() addBreakpointButton.onTouch = function()
addBreakpoint() addBreakpoint()
mainContainer:drawOnScreen() application:draw()
end end
syntaxHighlightingButton.onTouch = function() syntaxHighlightingButton.onTouch = function()
config.syntaxHighlight = not config.syntaxHighlight config.syntaxHighlight = not config.syntaxHighlight
codeView.syntaxHighlight = config.syntaxHighlight codeView.syntaxHighlight = config.syntaxHighlight
mainContainer:drawOnScreen() application:draw()
saveConfig() saveConfig()
end end
@ -1799,19 +1799,19 @@ toggleLeftToolBarButton.onTouch = function()
leftTreeView.hidden = not toggleLeftToolBarButton.pressed leftTreeView.hidden = not toggleLeftToolBarButton.pressed
leftTreeViewResizer.hidden = leftTreeView.hidden leftTreeViewResizer.hidden = leftTreeView.hidden
calculateSizes() calculateSizes()
mainContainer:drawOnScreen() application:draw()
end end
toggleBottomToolBarButton.onTouch = function() toggleBottomToolBarButton.onTouch = function()
bottomToolBar.hidden = not toggleBottomToolBarButton.pressed bottomToolBar.hidden = not toggleBottomToolBarButton.pressed
calculateSizes() calculateSizes()
mainContainer:drawOnScreen() application:draw()
end end
toggleTopToolBarButton.onTouch = function() toggleTopToolBarButton.onTouch = function()
topToolBar.hidden = not toggleTopToolBarButton.pressed topToolBar.hidden = not toggleTopToolBarButton.pressed
calculateSizes() calculateSizes()
mainContainer:drawOnScreen() application:draw()
end end
codeView.verticalScrollBar.onTouch = function() codeView.verticalScrollBar.onTouch = function()
@ -1826,7 +1826,7 @@ runButton.onTouch = function()
run() run()
end end
autocomplete.onItemSelected = function(mainContainer, object, e1) autocomplete.onItemSelected = function(application, object, e1)
local firstPart = unicode.sub(lines[cursorPositionLine], 1, autoCompleteWordStart - 1) local firstPart = unicode.sub(lines[cursorPositionLine], 1, autoCompleteWordStart - 1)
local secondPart = unicode.sub(lines[cursorPositionLine], autoCompleteWordEnd + 1, -1) local secondPart = unicode.sub(lines[cursorPositionLine], autoCompleteWordEnd + 1, -1)
local middle = firstPart .. autocomplete.items[autocomplete.selectedItem] local middle = firstPart .. autocomplete.items[autocomplete.selectedItem]
@ -1843,7 +1843,7 @@ end
window.onResize = function(width, height) window.onResize = function(width, height)
calculateSizes() calculateSizes()
mainContainer:drawOnScreen() application:draw()
end end
searchInput.onInputFinished = findFromFirstDisplayedLine searchInput.onInputFinished = findFromFirstDisplayedLine
@ -1855,7 +1855,7 @@ searchButton.onTouch = find
autocomplete:moveToFront() autocomplete:moveToFront()
leftTreeView:updateFileList() leftTreeView:updateFileList()
calculateSizes() calculateSizes()
mainContainer:draw() application:draw()
local initialPath = select(1, ...) local initialPath = select(1, ...)
if initialPath and filesystem.exists(initialPath) then if initialPath and filesystem.exists(initialPath) then
@ -1864,4 +1864,4 @@ else
newFile() newFile()
end end
mainContainer:drawOnScreen() application:draw()

View File

@ -42,7 +42,7 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 80, 22, 0xF0F0F0)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 80, 22, 0xF0F0F0))
local inputsPanel = window:addChild(GUI.panel(1, 1, 19, window.height, 0x2D2D2D)) local inputsPanel = window:addChild(GUI.panel(1, 1, 19, window.height, 0x2D2D2D))
window.backgroundPanel.localX = inputsPanel.width + 1 window.backgroundPanel.localX = inputsPanel.width + 1
window.backgroundPanel.width = window.width - inputsPanel.width window.backgroundPanel.width = window.width - inputsPanel.width
@ -95,7 +95,7 @@ end
local function broadcast(...) local function broadcast(...)
addMessage(localization.sent .. ": ", ...) addMessage(localization.sent .. ": ", ...)
mainContainer:drawOnScreen() application:draw()
modem.broadcast(port, "nanomachines", ...) modem.broadcast(port, "nanomachines", ...)
end end
@ -138,7 +138,7 @@ for i = 1, maxInputs do
local input = inputsContainer:addChild(GUI.switch(x, y, width, 0x66DB80, 0x1E1E1E, 0xE1E1E1, false)) local input = inputsContainer:addChild(GUI.switch(x, y, width, 0x66DB80, 0x1E1E1E, 0xE1E1E1, false))
input.onStateChanged = function() input.onStateChanged = function()
checkSwitches() checkSwitches()
mainContainer:drawOnScreen() application:draw()
broadcastPut("setInput", i, input.state) broadcastPut("setInput", i, input.state)
broadcastPut("getActiveEffects") broadcastPut("getActiveEffects")
@ -230,7 +230,7 @@ local function updateEffects(variants)
effectsLayout.height = #effectsLayout.children * 3 effectsLayout.height = #effectsLayout.children * 3
end end
local function runtimeEventHandler(mainContainer, object, e1, e2, e3, e4, e5, e6, e7, e8, ...) local function runtimeEventHandler(application, object, e1, e2, e3, e4, e5, e6, e7, e8, ...)
if e1 == "modem_message" and e6 == "nanomachines" then if e1 == "modem_message" and e6 == "nanomachines" then
if e7 == "input" then if e7 == "input" then
local child = inputsContainer.children[e8] local child = inputsContainer.children[e8]
@ -245,7 +245,7 @@ local function runtimeEventHandler(mainContainer, object, e1, e2, e3, e4, e5, e6
end end
addMessage(localization.received .. ": ", e7, e8, ...) addMessage(localization.received .. ": ", e7, e8, ...)
mainContainer:drawOnScreen() application:draw()
broadcastNext() broadcastNext()
elseif e1 == "scroll" then elseif e1 == "scroll" then
@ -259,7 +259,7 @@ local function runtimeEventHandler(mainContainer, object, e1, e2, e3, e4, e5, e6
cell.verticalMargin = to cell.verticalMargin = to
end end
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -342,7 +342,7 @@ favouritesComboBox.onItemSelected = function()
end end
checkSwitches() checkSwitches()
mainContainer:drawOnScreen() application:draw()
broadcastNext() broadcastNext()
end end
@ -364,12 +364,12 @@ if component.isAvailable("modem") then
updateEffects(parseEffects()) updateEffects(parseEffects())
syncReset() syncReset()
layout.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5, e6, e7, e8, e9) layout.eventHandler = function(application, object, e1, e2, e3, e4, e5, e6, e7, e8, e9)
if not e1 then if not e1 then
if computer.uptime() >= syncDeadline then if computer.uptime() >= syncDeadline then
syncReset() syncReset()
setLines(localization.syncInfo) setLines(localization.syncInfo)
mainContainer:drawOnScreen() application:draw()
end end
if not syncStarted then if not syncStarted then
@ -394,14 +394,14 @@ if component.isAvailable("modem") then
inputsContainer.children[i]:setState(syncResult[i]) inputsContainer.children[i]:setState(syncResult[i])
end end
checkSwitches() checkSwitches()
mainContainer:drawOnScreen() application:draw()
layout.eventHandler = runtimeEventHandler layout.eventHandler = runtimeEventHandler
return return
end end
setLines(string.format(localization.syncProgress .. localization.syncContacts, #syncResult, maxInputs)) setLines(string.format(localization.syncProgress .. localization.syncContacts, #syncResult, maxInputs))
mainContainer:drawOnScreen() application:draw()
syncUpdate() syncUpdate()
broadcastNext() broadcastNext()
@ -414,4 +414,4 @@ else
setLines(localization.noModem) setLines(localization.noModem)
end end
mainContainer:drawOnScreen() application:draw()

View File

@ -2,10 +2,10 @@
local GUI = require("GUI") local GUI = require("GUI")
local MineOSInterface = require("MineOSInterface") local MineOSInterface = require("MineOSInterface")
local mainContainer, window = MineOSInterface.addWindow(GUI.palette(1, 1, 0x9900FF)) local application, window = MineOSInterface.addWindow(GUI.palette(1, 1, 0x9900FF))
window.submitButton.onTouch = function() window.submitButton.onTouch = function()
window:close() window:close()
mainContainer:drawOnScreen() application:draw()
end end
window.cancelButton.onTouch = window.submitButton.onTouch window.cancelButton.onTouch = window.submitButton.onTouch

View File

@ -74,9 +74,9 @@ end
loadConfig() loadConfig()
local mainContainer = GUI.fullScreenContainer() local application = GUI.application()
mainContainer.menu = mainContainer:addChild(GUI.menu(1, 1, mainContainer.width, 0xE1E1E1, 0x5A5A5A, 0x3366CC, 0xFFFFFF, nil)) application.menu = application:addChild(GUI.menu(1, 1, application.width, 0xE1E1E1, 0x5A5A5A, 0x3366CC, 0xFFFFFF, nil))
local function addTitle(container, text) local function addTitle(container, text)
local titleContainer = container:addChild(GUI.container(1, 1, container.width, 1)) local titleContainer = container:addChild(GUI.container(1, 1, container.width, 1))
@ -87,19 +87,19 @@ local function addTitle(container, text)
end end
local pizdaWidth = 28 local pizdaWidth = 28
mainContainer.sidebarPanel = mainContainer:addChild(GUI.panel(mainContainer.width - pizdaWidth + 1, 2, pizdaWidth, mainContainer.height - 1, 0x3C3C3C)) application.sidebarPanel = application:addChild(GUI.panel(application.width - pizdaWidth + 1, 2, pizdaWidth, application.height - 1, 0x3C3C3C))
mainContainer.sidebarLayout = mainContainer:addChild(GUI.layout(mainContainer.sidebarPanel.localX, 2, mainContainer.sidebarPanel.width, mainContainer.sidebarPanel.height, 1, 1)) application.sidebarLayout = application:addChild(GUI.layout(application.sidebarPanel.localX, 2, application.sidebarPanel.width, application.sidebarPanel.height, 1, 1))
mainContainer.sidebarLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application.sidebarLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
addTitle(mainContainer.sidebarLayout, "Recent colors") addTitle(application.sidebarLayout, "Recent colors")
local recentColorsContainer = mainContainer.sidebarLayout:addChild(GUI.container(1, 1, mainContainer.sidebarLayout.width - 2, 4)) local recentColorsContainer = application.sidebarLayout:addChild(GUI.container(1, 1, application.sidebarLayout.width - 2, 4))
local x, y = 1, 1 local x, y = 1, 1
for i = 1, #config.recentColors do for i = 1, #config.recentColors do
local button = recentColorsContainer:addChild(GUI.button(x, y, 2, 1, 0x0, 0x0, 0x0, 0x0, " ")) local button = recentColorsContainer:addChild(GUI.button(x, y, 2, 1, 0x0, 0x0, 0x0, 0x0, " "))
button.onTouch = function() button.onTouch = function()
mainContainer.primaryColorSelector.color = config.recentColors[i] application.primaryColorSelector.color = config.recentColors[i]
mainContainer:drawOnScreen() application:draw()
end end
x = x + 2 x = x + 2
@ -108,37 +108,37 @@ for i = 1, #config.recentColors do
end end
end end
local currentToolTitle = addTitle(mainContainer.sidebarLayout, "Tool properties") local currentToolTitle = addTitle(application.sidebarLayout, "Tool properties")
mainContainer.currentToolLayout = mainContainer.sidebarLayout:addChild(GUI.layout(1, 1, mainContainer.sidebarLayout.width, 1, 1, 1)) application.currentToolLayout = application.sidebarLayout:addChild(GUI.layout(1, 1, application.sidebarLayout.width, 1, 1, 1))
mainContainer.currentToolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application.currentToolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
mainContainer.currentToolLayout:setFitting(1, 1, true, false, 2, 0) application.currentToolLayout:setFitting(1, 1, true, false, 2, 0)
local aboutToolTitle = addTitle(mainContainer.sidebarLayout, "About tool") local aboutToolTitle = addTitle(application.sidebarLayout, "About tool")
local aboutToolTextBox = mainContainer.sidebarLayout:addChild(GUI.textBox(1, 1, mainContainer.sidebarLayout.width - 2, 1, nil, 0x787878, {}, 1, 0, 0)) local aboutToolTextBox = application.sidebarLayout:addChild(GUI.textBox(1, 1, application.sidebarLayout.width - 2, 1, nil, 0x787878, {}, 1, 0, 0))
mainContainer.toolsList = mainContainer:addChild(GUI.list(1, 2, 6, mainContainer.height - 1, 3, 0, 0x3C3C3C, 0xD2D2D2, 0x3C3C3C, 0xD2D2D2, 0x2D2D2D, 0xD2D2D2)) application.toolsList = application:addChild(GUI.list(1, 2, 6, application.height - 1, 3, 0, 0x3C3C3C, 0xD2D2D2, 0x3C3C3C, 0xD2D2D2, 0x2D2D2D, 0xD2D2D2))
mainContainer.backgroundPanel = mainContainer:addChild(GUI.panel(mainContainer.toolsList.width + 1, 2, mainContainer.width - mainContainer.toolsList.width - mainContainer.sidebarPanel.width, mainContainer.height - 1, 0x1E1E1E)) application.backgroundPanel = application:addChild(GUI.panel(application.toolsList.width + 1, 2, application.width - application.toolsList.width - application.sidebarPanel.width, application.height - 1, 0x1E1E1E))
mainContainer.image = mainContainer:addChild(GUI.object(1, 1, 1, 1)) application.image = application:addChild(GUI.object(1, 1, 1, 1))
mainContainer.image.data = {} application.image.data = {}
local function onToolTouch(index) local function onToolTouch(index)
tool = mainContainer.toolsList:getItem(index).tool tool = application.toolsList:getItem(index).tool
mainContainer.toolsList.selectedItem = index application.toolsList.selectedItem = index
mainContainer.currentToolOverlay:removeChildren() application.currentToolOverlay:removeChildren()
mainContainer.currentToolLayout:removeChildren() application.currentToolLayout:removeChildren()
currentToolTitle.hidden = not tool.onSelection currentToolTitle.hidden = not tool.onSelection
mainContainer.currentToolLayout.hidden = currentToolTitle.hidden application.currentToolLayout.hidden = currentToolTitle.hidden
if tool.onSelection then if tool.onSelection then
local result, reason = pcall(tool.onSelection, mainContainer) local result, reason = pcall(tool.onSelection, application)
if result then if result then
mainContainer.currentToolLayout:update() application.currentToolLayout:update()
local lastChild = mainContainer.currentToolLayout.children[#mainContainer.currentToolLayout.children] local lastChild = application.currentToolLayout.children[#application.currentToolLayout.children]
if lastChild then if lastChild then
mainContainer.currentToolLayout.height = lastChild.localY + lastChild.height - 1 application.currentToolLayout.height = lastChild.localY + lastChild.height - 1
end end
else else
GUI.alert(reason) GUI.alert(reason)
@ -153,7 +153,7 @@ local function onToolTouch(index)
aboutToolTextBox.height = #aboutToolTextBox.lines aboutToolTextBox.height = #aboutToolTextBox.lines
end end
mainContainer:drawOnScreen() application:draw()
end end
local modules = fs.sortedList(toolsPath, "name", false) local modules = fs.sortedList(toolsPath, "name", false)
@ -162,7 +162,7 @@ for i = 1, #modules do
if result then if result then
result, reason = pcall(result) result, reason = pcall(result)
if result then if result then
local item = mainContainer.toolsList:addItem(reason.shortcut) local item = application.toolsList:addItem(reason.shortcut)
item.tool = reason item.tool = reason
item.onTouch = function() item.onTouch = function()
onToolTouch(i) onToolTouch(i)
@ -175,7 +175,7 @@ for i = 1, #modules do
end end
end end
mainContainer.image.draw = function(object) application.image.draw = function(object)
GUI.drawShadow(object.x, object.y, object.width, object.height, nil, true) GUI.drawShadow(object.x, object.y, object.width, object.height, nil, true)
local y, text = object.y + object.height + 1, "Size: " .. object.width .. "x" .. object.height local y, text = object.y + object.height + 1, "Size: " .. object.width .. "x" .. object.height
@ -186,25 +186,25 @@ mainContainer.image.draw = function(object)
buffer.drawText(math.floor(object.x + object.width / 2 - unicode.len(text) / 2), y + 1, 0x5A5A5A, text) buffer.drawText(math.floor(object.x + object.width / 2 - unicode.len(text) / 2), y + 1, 0x5A5A5A, text)
end end
local x, y, step, notStep, background, foreground, symbol = object.x, object.y, false, mainContainer.image.width % 2 local x, y, step, notStep, background, foreground, symbol = object.x, object.y, false, application.image.width % 2
for i = 1, mainContainer.image.width * mainContainer.image.height do for i = 1, application.image.width * application.image.height do
if mainContainer.image.data[5][i] == 0 then if application.image.data[5][i] == 0 then
background = mainContainer.image.data[3][i] background = application.image.data[3][i]
foreground = mainContainer.image.data[4][i] foreground = application.image.data[4][i]
symbol = mainContainer.image.data[6][i] symbol = application.image.data[6][i]
elseif mainContainer.image.data[5][i] < 1 then elseif application.image.data[5][i] < 1 then
background = color.blend(config.transparencyBackground, mainContainer.image.data[3][i], mainContainer.image.data[5][i]) background = color.blend(config.transparencyBackground, application.image.data[3][i], application.image.data[5][i])
foreground = mainContainer.image.data[4][i] foreground = application.image.data[4][i]
symbol = mainContainer.image.data[6][i] symbol = application.image.data[6][i]
else else
if mainContainer.image.data[6][i] == " " then if application.image.data[6][i] == " " then
background = config.transparencyBackground background = config.transparencyBackground
foreground = config.transparencyForeground foreground = config.transparencyForeground
symbol = step and "" or "" symbol = step and "" or ""
else else
background = config.transparencyBackground background = config.transparencyBackground
foreground = mainContainer.image.data[4][i] foreground = application.image.data[4][i]
symbol = mainContainer.image.data[6][i] symbol = application.image.data[6][i]
end end
end end
@ -228,8 +228,8 @@ local function updateRecentColorsButtons()
end end
local function swapColors() local function swapColors()
mainContainer.primaryColorSelector.color, mainContainer.secondaryColorSelector.color = mainContainer.secondaryColorSelector.color, mainContainer.primaryColorSelector.color application.primaryColorSelector.color, application.secondaryColorSelector.color = application.secondaryColorSelector.color, application.primaryColorSelector.color
mainContainer:drawOnScreen() application:draw()
end end
local function colorSelectorDraw(object) local function colorSelectorDraw(object)
@ -240,24 +240,24 @@ local function colorSelectorDraw(object)
end end
end end
mainContainer.secondaryColorSelector = mainContainer:addChild(GUI.colorSelector(2, mainContainer.toolsList.height - 3, 5, 2, 0xFFFFFF, " ")) application.secondaryColorSelector = application:addChild(GUI.colorSelector(2, application.toolsList.height - 3, 5, 2, 0xFFFFFF, " "))
mainContainer.primaryColorSelector = mainContainer:addChild(GUI.colorSelector(1, mainContainer.toolsList.height - 4, 5, 2, 0x880000, " ")) application.primaryColorSelector = application:addChild(GUI.colorSelector(1, application.toolsList.height - 4, 5, 2, 0x880000, " "))
mainContainer.secondaryColorSelector.draw, mainContainer.primaryColorSelector.draw = colorSelectorDraw, colorSelectorDraw application.secondaryColorSelector.draw, application.primaryColorSelector.draw = colorSelectorDraw, colorSelectorDraw
mainContainer:addChild(GUI.adaptiveButton(3, mainContainer.secondaryColorSelector.localY + mainContainer.secondaryColorSelector.height + 1, 0, 0, nil, 0xD2D2D2, nil, 0xA5A5A5, "<>")).onTouch = swapColors application:addChild(GUI.adaptiveButton(3, application.secondaryColorSelector.localY + application.secondaryColorSelector.height + 1, 0, 0, nil, 0xD2D2D2, nil, 0xA5A5A5, "<>")).onTouch = swapColors
mainContainer.image.eventHandler = function(mainContainer, object, e1, e2, e3, e4, ...) application.image.eventHandler = function(application, object, e1, e2, e3, e4, ...)
if e1 == "key_down" then if e1 == "key_down" then
-- D -- D
if e4 == 32 then if e4 == 32 then
mainContainer.primaryColorSelector.color, mainContainer.secondaryColorSelector.color = 0x0, 0xFFFFFF application.primaryColorSelector.color, application.secondaryColorSelector.color = 0x0, 0xFFFFFF
mainContainer:drawOnScreen() application:draw()
-- X -- X
elseif e4 == 45 then elseif e4 == 45 then
swapColors() swapColors()
else else
for i = 1, mainContainer.toolsList:count() do for i = 1, application.toolsList:count() do
if e4 == mainContainer.toolsList:getItem(i).tool.keyCode then if e4 == application.toolsList:getItem(i).tool.keyCode then
onToolTouch(i) onToolTouch(i)
return return
end end
@ -265,37 +265,37 @@ mainContainer.image.eventHandler = function(mainContainer, object, e1, e2, e3, e
end end
end end
local result, reason = pcall(tool.eventHandler, mainContainer, object, e1, e2, e3, e4, ...) local result, reason = pcall(tool.eventHandler, application, object, e1, e2, e3, e4, ...)
if not result then if not result then
GUI.alert("Tool eventHandler() failed: " .. reason) GUI.alert("Tool eventHandler() failed: " .. reason)
end end
end end
mainContainer.image.reposition = function() application.image.reposition = function()
mainContainer.image.width, mainContainer.image.height = mainContainer.image.data[1], mainContainer.image.data[2] application.image.width, application.image.height = application.image.data[1], application.image.data[2]
if mainContainer.image.width <= mainContainer.backgroundPanel.width then if application.image.width <= application.backgroundPanel.width then
mainContainer.image.localX = math.floor(mainContainer.backgroundPanel.x + mainContainer.backgroundPanel.width / 2 - mainContainer.image.width / 2) application.image.localX = math.floor(application.backgroundPanel.x + application.backgroundPanel.width / 2 - application.image.width / 2)
mainContainer.image.localY = math.floor(mainContainer.backgroundPanel.y + mainContainer.backgroundPanel.height / 2 - mainContainer.image.height / 2) application.image.localY = math.floor(application.backgroundPanel.y + application.backgroundPanel.height / 2 - application.image.height / 2)
else else
mainContainer.image.localX, mainContainer.image.localY = 9, 3 application.image.localX, application.image.localY = 9, 3
end end
end end
local function newNoGUI(width, height) local function newNoGUI(width, height)
savePath, saveItem.disabled = nil, true savePath, saveItem.disabled = nil, true
mainContainer.image.data = {width, height, {}, {}, {}, {}} application.image.data = {width, height, {}, {}, {}, {}}
mainContainer.image.reposition() application.image.reposition()
for i = 1, width * height do for i = 1, width * height do
table.insert(mainContainer.image.data[3], 0x0) table.insert(application.image.data[3], 0x0)
table.insert(mainContainer.image.data[4], 0x0) table.insert(application.image.data[4], 0x0)
table.insert(mainContainer.image.data[5], 1) table.insert(application.image.data[5], 1)
table.insert(mainContainer.image.data[6], " ") table.insert(application.image.data[6], " ")
end end
end end
local function new() local function new()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "New picture") local container = MineOSInterface.addBackgroundContainer(application, "New picture")
local widthInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, 0x2D2D2D, "51", "Width")) local widthInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, 0x2D2D2D, "51", "Width"))
local heightInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, 0x2D2D2D, "19", "Height")) local heightInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, 0x2D2D2D, "19", "Height"))
@ -305,15 +305,15 @@ local function new()
end end
heightInput.validator = widthInput.validator heightInput.validator = widthInput.validator
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
newNoGUI(tonumber(widthInput.text), tonumber(heightInput.text)) newNoGUI(tonumber(widthInput.text), tonumber(heightInput.text))
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
local function loadImage(path) local function loadImage(path)
@ -321,32 +321,41 @@ local function loadImage(path)
if result then if result then
savePath, saveItem.disabled = path, false savePath, saveItem.disabled = path, false
addRecentFile(path) addRecentFile(path)
mainContainer.image.data = result application.image.data = result
mainContainer.image.reposition() application.image.reposition()
else else
GUI.alert(reason) GUI.alert(reason)
end end
end end
local function saveImage(path) local function saveImage(path)
local result, reason = image.save(path, mainContainer.image.data, 6) if fs.extension(path) == ".pic" then
if result then local result, reason = image.save(path, application.image.data, 6)
savePath, saveItem.disabled = path, false if result then
addRecentFile(path) savePath, saveItem.disabled = path, false
addRecentFile(path)
else
GUI.alert(reason)
end
else else
GUI.alert(reason) savePath, saveItem.disabled = path, false
local file = io.open(path, "wb")
file:write(image.toString(application.image.data))
file:close()
end end
end end
mainContainer.menu:addItem("PE", 0x00B6FF) application.menu:addItem("PE", 0x00B6FF)
local fileItem = mainContainer.menu:addContextMenu("File") local fileItem = application.menu:addContextMenu("File")
fileItem:addItem("New").onTouch = new fileItem:addItem("New").onTouch = new
fileItem:addSeparator() fileItem:addSeparator()
fileItem:addItem("Open").onTouch = function() fileItem:addItem("Open").onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Open", "Cancel", "File name", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "Open", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".pic") filesystemDialog:addExtensionFilter(".pic")
filesystemDialog:expandPath(MineOSPaths.desktop) filesystemDialog:expandPath(MineOSPaths.desktop)
@ -354,7 +363,7 @@ fileItem:addItem("Open").onTouch = function()
filesystemDialog.onSubmit = function(path) filesystemDialog.onSubmit = function(path)
loadImage(path) loadImage(path)
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -362,19 +371,19 @@ local fileItemSubMenu = fileItem:addSubMenu("Open recent", #config.recentFiles =
for i = 1, #config.recentFiles do for i = 1, #config.recentFiles do
fileItemSubMenu:addItem(string.limit(config.recentFiles[i], 32, "left")).onTouch = function() fileItemSubMenu:addItem(string.limit(config.recentFiles[i], 32, "left")).onTouch = function()
loadImage(config.recentFiles[i]) loadImage(config.recentFiles[i])
mainContainer:drawOnScreen() application:draw()
end end
end end
fileItem:addItem("Open from URL").onTouch = function() fileItem:addItem("Open from URL").onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Open from URL") local container = MineOSInterface.addBackgroundContainer(application, "Open from URL")
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x969696, 0xE1E1E1, 0x2D2D2D, "", "http://example.com/test.pic")) local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x969696, 0xE1E1E1, 0x2D2D2D, "", "http://example.com/test.pic"))
input.onInputFinished = function() input.onInputFinished = function()
if #input.text > 0 then if #input.text > 0 then
input:remove() input:remove()
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, "Downloading file..."):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)) container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x969696, "Downloading file..."):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP))
mainContainer:drawOnScreen() application:draw()
local temporaryPath = MineOSCore.getTemporaryPath() .. ".pic" local temporaryPath = MineOSCore.getTemporaryPath() .. ".pic"
local result, reason = web.download(input.text, temporaryPath) local result, reason = web.download(input.text, temporaryPath)
@ -389,11 +398,11 @@ fileItem:addItem("Open from URL").onTouch = function()
GUI.alert(reason) GUI.alert(reason)
end end
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
fileItem:addSeparator() fileItem:addSeparator()
@ -404,9 +413,10 @@ saveItem.onTouch = function()
end end
fileItem:addItem("Save as").onTouch = function() fileItem:addItem("Save as").onTouch = function()
local filesystemDialog = GUI.addFilesystemDialog(mainContainer, true, 50, math.floor(mainContainer.height * 0.8), "Save", "Cancel", "File name", "/") local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "Save", "Cancel", "File name", "/")
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE) filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
filesystemDialog:addExtensionFilter(".pic") filesystemDialog:addExtensionFilter(".pic")
filesystemDialog:addExtensionFilter(".ocifstring")
filesystemDialog:expandPath(MineOSPaths.desktop) filesystemDialog:expandPath(MineOSPaths.desktop)
filesystemDialog.filesystemTree.selectedItem = MineOSPaths.desktop filesystemDialog.filesystemTree.selectedItem = MineOSPaths.desktop
filesystemDialog:show() filesystemDialog:show()
@ -419,30 +429,30 @@ end
fileItem:addSeparator() fileItem:addSeparator()
fileItem:addItem("Exit").onTouch = function() fileItem:addItem("Exit").onTouch = function()
mainContainer:stopEventHandling() application:stop()
end end
mainContainer.menu:addItem("View").onTouch = function() application.menu:addItem("View").onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "View") local container = MineOSInterface.addBackgroundContainer(application, "View")
local colorSelector1 = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.transparencyBackground, "Transparency background")) local colorSelector1 = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.transparencyBackground, "Transparency background"))
local colorSelector2 = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.transparencyForeground, "Transparency foreground")) local colorSelector2 = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, config.transparencyForeground, "Transparency foreground"))
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
config.transparencyBackground, config.transparencyForeground = colorSelector1.color, colorSelector2.color config.transparencyBackground, config.transparencyForeground = colorSelector1.color, colorSelector2.color
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
saveConfig() saveConfig()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.menu:addItem("Hotkeys").onTouch = function() application.menu:addItem("Hotkeys").onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Hotkeys") local container = MineOSInterface.addBackgroundContainer(application, "Hotkeys")
local lines = { local lines = {
"There are some hotkeys that works exactly like in real Photoshop:", "There are some hotkeys that works exactly like in real Photoshop:",
" ", " ",
@ -461,15 +471,15 @@ mainContainer.menu:addItem("Hotkeys").onTouch = function()
} }
container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x969696, lines, 1, 0, 0, true, true)).eventHandler = nil container.layout:addChild(GUI.textBox(1, 1, 36, 1, nil, 0x969696, lines, 1, 0, 0, true, true)).eventHandler = nil
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.currentToolOverlay = mainContainer:addChild(GUI.container(1, 1, mainContainer.width, mainContainer.height)) application.currentToolOverlay = application:addChild(GUI.container(1, 1, application.width, application.height))
---------------------------------------------------------------- ----------------------------------------------------------------
mainContainer.image:moveToBack() application.image:moveToBack()
mainContainer.backgroundPanel:moveToBack() application.backgroundPanel:moveToBack()
updateRecentColorsButtons() updateRecentColorsButtons()
@ -480,4 +490,4 @@ else
end end
onToolTouch(5) onToolTouch(5)
mainContainer:startEventHandling() application:start()

View File

@ -19,7 +19,7 @@ local rasterizeEllipseButton = GUI.roundedButton(1, 1, 36, 1, 0xE1E1E1, 0x2D2D2D
local clearButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Clear") local clearButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Clear")
local cropButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Crop") local cropButton = GUI.roundedButton(1, 1, 36, 1, 0x696969, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "Crop")
local function repositionSelector(mainContainer) local function repositionSelector(application)
if dragX - touchX >= 0 then if dragX - touchX >= 0 then
selector.localX, selector.width = touchX, dragX - touchX + 1 selector.localX, selector.width = touchX, dragX - touchX + 1
else else
@ -32,100 +32,100 @@ local function repositionSelector(mainContainer)
selector.localY, selector.height = dragY, touchY - dragY + 1 selector.localY, selector.height = dragY, touchY - dragY + 1
end end
mainContainer:drawOnScreen() application:draw()
end end
local function fitSelector(mainContainer) local function fitSelector(application)
touchX, touchY, dragX, dragY = mainContainer.image.localX, mainContainer.image.localY, mainContainer.image.localX + mainContainer.image.width - 1, mainContainer.image.localY + mainContainer.image.height - 1 touchX, touchY, dragX, dragY = application.image.localX, application.image.localY, application.image.localX + application.image.width - 1, application.image.localY + application.image.height - 1
repositionSelector(mainContainer) repositionSelector(application)
end end
tool.onSelection = function(mainContainer) tool.onSelection = function(application)
mainContainer.currentToolLayout:addChild(fillButton).onTouch = function() application.currentToolLayout:addChild(fillButton).onTouch = function()
for j = selector.y, selector.y + selector.height - 1 do for j = selector.y, selector.y + selector.height - 1 do
for i = selector.x, selector.x + selector.width - 1 do for i = selector.x, selector.x + selector.width - 1 do
image.set(mainContainer.image.data, i - mainContainer.image.x + 1, j - mainContainer.image.y + 1, mainContainer.primaryColorSelector.color, 0x0, 0, " ") image.set(application.image.data, i - application.image.x + 1, j - application.image.y + 1, application.primaryColorSelector.color, 0x0, 0, " ")
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.currentToolLayout:addChild(outlineButton).onTouch = function() application.currentToolLayout:addChild(outlineButton).onTouch = function()
local x1, y1 = selector.x - mainContainer.image.x + 1, selector.y - mainContainer.image.y + 1 local x1, y1 = selector.x - application.image.x + 1, selector.y - application.image.y + 1
local x2, y2 = x1 + selector.width - 1, y1 + selector.height - 1 local x2, y2 = x1 + selector.width - 1, y1 + selector.height - 1
for x = x1, x2 do for x = x1, x2 do
image.set(mainContainer.image.data, x, y1, mainContainer.primaryColorSelector.color, 0x0, 0, " ") image.set(application.image.data, x, y1, application.primaryColorSelector.color, 0x0, 0, " ")
image.set(mainContainer.image.data, x, y2, mainContainer.primaryColorSelector.color, 0x0, 0, " ") image.set(application.image.data, x, y2, application.primaryColorSelector.color, 0x0, 0, " ")
end end
for y = y1 + 1, y2 - 1 do for y = y1 + 1, y2 - 1 do
image.set(mainContainer.image.data, x1, y, mainContainer.primaryColorSelector.color, 0x0, 0, " ") image.set(application.image.data, x1, y, application.primaryColorSelector.color, 0x0, 0, " ")
image.set(mainContainer.image.data, x2, y, mainContainer.primaryColorSelector.color, 0x0, 0, " ") image.set(application.image.data, x2, y, application.primaryColorSelector.color, 0x0, 0, " ")
end end
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.currentToolLayout:addChild(rasterizeLineButton).onTouch = function() application.currentToolLayout:addChild(rasterizeLineButton).onTouch = function()
buffer.rasterizeLine( buffer.rasterizeLine(
touchX - mainContainer.image.x + 1, touchX - application.image.x + 1,
touchY - mainContainer.image.y + 1, touchY - application.image.y + 1,
dragX - mainContainer.image.x + 1, dragX - application.image.x + 1,
dragY - mainContainer.image.y + 1, dragY - application.image.y + 1,
function(x, y) function(x, y)
image.set(mainContainer.image.data, x, y, mainContainer.primaryColorSelector.color, 0x0, 0, " ") image.set(application.image.data, x, y, application.primaryColorSelector.color, 0x0, 0, " ")
end end
) )
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.currentToolLayout:addChild(rasterizeEllipseButton).onTouch = function() application.currentToolLayout:addChild(rasterizeEllipseButton).onTouch = function()
local minX, minY, maxX, maxY = math.min(touchX, dragX), math.min(touchY, dragY), math.max(touchX, dragX), math.max(touchY, dragY) local minX, minY, maxX, maxY = math.min(touchX, dragX), math.min(touchY, dragY), math.max(touchX, dragX), math.max(touchY, dragY)
local centerX, centerY = math.ceil(minX + (maxX - minX) / 2), math.ceil(minY + (maxY - minY) / 2) local centerX, centerY = math.ceil(minX + (maxX - minX) / 2), math.ceil(minY + (maxY - minY) / 2)
buffer.rasterizeEllipse( buffer.rasterizeEllipse(
centerX - mainContainer.image.x + 1, centerX - application.image.x + 1,
centerY - mainContainer.image.y + 1, centerY - application.image.y + 1,
maxX - centerX, maxX - centerX,
maxY - centerY, maxY - centerY,
function(x, y) function(x, y)
image.set(mainContainer.image.data, x, y, mainContainer.primaryColorSelector.color, 0x0, 0, " ") image.set(application.image.data, x, y, application.primaryColorSelector.color, 0x0, 0, " ")
end end
) )
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.currentToolLayout:addChild(clearButton).onTouch = function() application.currentToolLayout:addChild(clearButton).onTouch = function()
for j = selector.y, selector.y + selector.height - 1 do for j = selector.y, selector.y + selector.height - 1 do
for i = selector.x, selector.x + selector.width - 1 do for i = selector.x, selector.x + selector.width - 1 do
image.set(mainContainer.image.data, i - mainContainer.image.x + 1, j - mainContainer.image.y + 1, 0x0, 0x0, 1, " ") image.set(application.image.data, i - application.image.x + 1, j - application.image.y + 1, 0x0, 0x0, 1, " ")
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.currentToolLayout:addChild(cropButton).onTouch = function() application.currentToolLayout:addChild(cropButton).onTouch = function()
mainContainer.image.data = image.crop(mainContainer.image.data, selector.x - mainContainer.image.x + 1, selector.y - mainContainer.image.y + 1, selector.width, selector.height) application.image.data = image.crop(application.image.data, selector.x - application.image.x + 1, selector.y - application.image.y + 1, selector.width, selector.height)
mainContainer.image.reposition() application.image.reposition()
fitSelector(mainContainer) fitSelector(application)
end end
mainContainer.currentToolOverlay:addChild(selector) application.currentToolOverlay:addChild(selector)
fitSelector(mainContainer) fitSelector(application)
end end
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4) tool.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" then if e1 == "touch" then
touchX, touchY, dragX, dragY = e3, e4, e3, e4 touchX, touchY, dragX, dragY = e3, e4, e3, e4
repositionSelector(mainContainer) repositionSelector(application)
elseif e1 == "drag" then elseif e1 == "drag" then
dragX, dragY = e3, e4 dragX, dragY = e3, e4
repositionSelector(mainContainer) repositionSelector(application)
end end
end end

View File

@ -9,15 +9,15 @@ tool.keyCode = 47
tool.about = "Move tool allows you to move image as you wish. But be careful: large images will take a time to shift and redraw. Hello, shitty GPUs!" tool.about = "Move tool allows you to move image as you wish. But be careful: large images will take a time to shift and redraw. Hello, shitty GPUs!"
local xOld, yOld local xOld, yOld
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4) tool.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" then if e1 == "touch" then
xOld, yOld = e3, e4 xOld, yOld = e3, e4
elseif e1 == "drag" and xOld and yOld then elseif e1 == "drag" and xOld and yOld then
mainContainer.image.localX = mainContainer.image.localX + (e3 - xOld) application.image.localX = application.image.localX + (e3 - xOld)
mainContainer.image.localY = mainContainer.image.localY + (e4 - yOld) application.image.localY = application.image.localY + (e4 - yOld)
xOld, yOld = e3, e4 xOld, yOld = e3, e4
mainContainer:drawOnScreen() application:draw()
elseif e1 == "drop" then elseif e1 == "drop" then
xOld, yOld = nil, nil xOld, yOld = nil, nil
end end

View File

@ -55,7 +55,7 @@ for j = 1, buttonCount do
buttons[j][i] = buttonsContainer:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0x2D2D2D, 0xB4B4B4, 0x696969, 0xD2D2D2, " ")) buttons[j][i] = buttonsContainer:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0x2D2D2D, 0xB4B4B4, 0x696969, 0xD2D2D2, " "))
buttons[j][i].onTouch = function() buttons[j][i].onTouch = function()
set(i, j) set(i, j)
buttons[j][i].firstParent:drawOnScreen() buttons[j][i].firstParent:draw()
end end
x = x + buttonWidth + stepX x = x + buttonWidth + stepX
@ -66,18 +66,18 @@ end
set(2, 2) set(2, 2)
tool.onSelection = function(mainContainer) tool.onSelection = function(application)
mainContainer.currentToolLayout:addChild(buttonsLayout) application.currentToolLayout:addChild(buttonsLayout)
mainContainer.currentToolLayout:addChild(widthInput) application.currentToolLayout:addChild(widthInput)
mainContainer.currentToolLayout:addChild(heightInput) application.currentToolLayout:addChild(heightInput)
mainContainer.currentToolLayout:addChild(expandButton) application.currentToolLayout:addChild(expandButton)
mainContainer.currentToolLayout:addChild(cropButton) application.currentToolLayout:addChild(cropButton)
widthInput.onInputFinished = function() widthInput.onInputFinished = function()
expandButton.disabled = not widthInput.text:match("^%d+$") or not heightInput.text:match("^%d+$") expandButton.disabled = not widthInput.text:match("^%d+$") or not heightInput.text:match("^%d+$")
cropButton.disabled = expandButton.disabled cropButton.disabled = expandButton.disabled
mainContainer:drawOnScreen() application:draw()
end end
heightInput.onInputFinished = widthInput.onInputFinished heightInput.onInputFinished = widthInput.onInputFinished
widthInput.onInputFinished() widthInput.onInputFinished()
@ -85,33 +85,33 @@ tool.onSelection = function(mainContainer)
expandButton.onTouch = function() expandButton.onTouch = function()
local width, height = tonumber(widthInput.text), tonumber(heightInput.text) local width, height = tonumber(widthInput.text), tonumber(heightInput.text)
mainContainer.image.data = image.expand(mainContainer.image.data, application.image.data = image.expand(application.image.data,
currentY > 1 and height or 0, currentY > 1 and height or 0,
currentY < 3 and height or 0, currentY < 3 and height or 0,
currentX > 1 and width or 0, currentX > 1 and width or 0,
currentX < 3 and width or 0, currentX < 3 and width or 0,
0x0, 0x0, 1, " ") 0x0, 0x0, 1, " ")
mainContainer.image.reposition() application.image.reposition()
mainContainer:drawOnScreen() application:draw()
end end
cropButton.onTouch = function() cropButton.onTouch = function()
local width, height = tonumber(widthInput.text), tonumber(heightInput.text) local width, height = tonumber(widthInput.text), tonumber(heightInput.text)
mainContainer.image.data = image.crop(mainContainer.image.data, application.image.data = image.crop(application.image.data,
currentX == 1 and 1 or width + 1, currentX == 1 and 1 or width + 1,
currentY == 1 and 1 or height + 1, currentY == 1 and 1 or height + 1,
(currentX == 1 or currentX == 3) and mainContainer.image.width - width or mainContainer.image.width - width * 2, (currentX == 1 or currentX == 3) and application.image.width - width or application.image.width - width * 2,
(currentY == 1 or currentY == 3) and mainContainer.image.height - height or mainContainer.image.height - height * 2 (currentY == 1 or currentY == 3) and application.image.height - height or application.image.height - height * 2
) )
mainContainer.image.reposition() application.image.reposition()
mainContainer:drawOnScreen() application:draw()
end end
end end
tool.eventHandler = function(mainContainer, object, e1) tool.eventHandler = function(application, object, e1)
end end

View File

@ -12,26 +12,26 @@ tool.about = "Picker tool allows to select interested data from image as primary
local pickBackgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Pick background:", true) local pickBackgroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Pick background:", true)
local pickForegroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Pick foreground:", true) local pickForegroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Pick foreground:", true)
tool.onSelection = function(mainContainer) tool.onSelection = function(application)
mainContainer.currentToolLayout:addChild(pickBackgroundSwitch) application.currentToolLayout:addChild(pickBackgroundSwitch)
mainContainer.currentToolLayout:addChild(pickForegroundSwitch) application.currentToolLayout:addChild(pickForegroundSwitch)
end end
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4) tool.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
local x, y = e3 - mainContainer.image.x + 1, e4 - mainContainer.image.y + 1 local x, y = e3 - application.image.x + 1, e4 - application.image.y + 1
local background, foreground = image.get(mainContainer.image.data, x, y) local background, foreground = image.get(application.image.data, x, y)
if pickBackgroundSwitch.switch.state then if pickBackgroundSwitch.switch.state then
mainContainer.secondaryColorSelector.color = background application.secondaryColorSelector.color = background
end end
if pickForegroundSwitch.switch.state then if pickForegroundSwitch.switch.state then
mainContainer.primaryColorSelector.color = foreground application.primaryColorSelector.color = foreground
end end
mainContainer:drawOnScreen() application:draw()
end end
end end

View File

@ -25,28 +25,28 @@ local radiusSlider = GUI.slider(1, 1, width, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878
radiusSlider.height = 2 radiusSlider.height = 2
radiusSlider.roundValues = true radiusSlider.roundValues = true
tool.onSelection = function(mainContainer) tool.onSelection = function(application)
mainContainer.currentToolLayout:addChild(backgroundSwitch) application.currentToolLayout:addChild(backgroundSwitch)
mainContainer.currentToolLayout:addChild(foregroundSwitch) application.currentToolLayout:addChild(foregroundSwitch)
mainContainer.currentToolLayout:addChild(alphaSwitch) application.currentToolLayout:addChild(alphaSwitch)
mainContainer.currentToolLayout:addChild(symbolSwitch) application.currentToolLayout:addChild(symbolSwitch)
mainContainer.currentToolLayout:addChild(symbolInput) application.currentToolLayout:addChild(symbolInput)
mainContainer.currentToolLayout:addChild(alphaSlider) application.currentToolLayout:addChild(alphaSlider)
mainContainer.currentToolLayout:addChild(radiusSlider) application.currentToolLayout:addChild(radiusSlider)
end end
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4) tool.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
local x, y = e3 - mainContainer.image.x + 1, e4 - mainContainer.image.y + 1 local x, y = e3 - application.image.x + 1, e4 - application.image.y + 1
local meow = math.floor(radiusSlider.value) local meow = math.floor(radiusSlider.value)
for j = y - meow + 1, y + meow - 1 do for j = y - meow + 1, y + meow - 1 do
for i = x - meow + 1, x + meow - 1 do for i = x - meow + 1, x + meow - 1 do
if i >= 1 and i <= mainContainer.image.width and j >= 1 and j <= mainContainer.image.height then if i >= 1 and i <= application.image.width and j >= 1 and j <= application.image.height then
local background, foreground, alpha, symbol = image.get(mainContainer.image.data, i, j) local background, foreground, alpha, symbol = image.get(application.image.data, i, j)
image.set(mainContainer.image.data, i, j, image.set(application.image.data, i, j,
backgroundSwitch.switch.state and mainContainer.primaryColorSelector.color or background, backgroundSwitch.switch.state and application.primaryColorSelector.color or background,
foregroundSwitch.switch.state and mainContainer.secondaryColorSelector.color or foreground, foregroundSwitch.switch.state and application.secondaryColorSelector.color or foreground,
alphaSwitch.switch.state and alphaSlider.value / 255 or alpha, alphaSwitch.switch.state and alphaSlider.value / 255 or alpha,
symbolSwitch.switch.state and (symbolInput.text == "" and " " or symbolInput.text) or symbol symbolSwitch.switch.state and (symbolInput.text == "" and " " or symbolInput.text) or symbol
) )
@ -54,7 +54,7 @@ tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
end end

View File

@ -17,24 +17,24 @@ local radiusSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787,
radiusSlider.height = 2 radiusSlider.height = 2
radiusSlider.roundValues = true radiusSlider.roundValues = true
tool.onSelection = function(mainContainer) tool.onSelection = function(application)
mainContainer.currentToolLayout:addChild(backgroundSwitch) application.currentToolLayout:addChild(backgroundSwitch)
mainContainer.currentToolLayout:addChild(foregroundSwitch) application.currentToolLayout:addChild(foregroundSwitch)
mainContainer.currentToolLayout:addChild(alphaSwitch) application.currentToolLayout:addChild(alphaSwitch)
mainContainer.currentToolLayout:addChild(symbolSwitch) application.currentToolLayout:addChild(symbolSwitch)
mainContainer.currentToolLayout:addChild(radiusSlider) application.currentToolLayout:addChild(radiusSlider)
end end
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4) tool.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
local x, y = e3 - mainContainer.image.x + 1, e4 - mainContainer.image.y + 1 local x, y = e3 - application.image.x + 1, e4 - application.image.y + 1
local meow = math.floor(radiusSlider.value) local meow = math.floor(radiusSlider.value)
for j = y - meow + 1, y + meow - 1 do for j = y - meow + 1, y + meow - 1 do
for i = x - meow + 1, x + meow - 1 do for i = x - meow + 1, x + meow - 1 do
if i >= 1 and i <= mainContainer.image.width and j >= 1 and j <= mainContainer.image.height then if i >= 1 and i <= application.image.width and j >= 1 and j <= application.image.height then
local background, foreground, alpha, symbol = image.get(mainContainer.image.data, i, j) local background, foreground, alpha, symbol = image.get(application.image.data, i, j)
image.set(mainContainer.image.data, i, j, image.set(application.image.data, i, j,
backgroundSwitch.switch.state and 0x0 or background, backgroundSwitch.switch.state and 0x0 or background,
foregroundSwitch.switch.state and 0x0 or foreground, foregroundSwitch.switch.state and 0x0 or foreground,
alphaSwitch.switch.state and 1 or alpha, alphaSwitch.switch.state and 1 or alpha,
@ -44,7 +44,7 @@ tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
end end

View File

@ -10,28 +10,28 @@ tool.shortcut = "Tx"
tool.keyCode = 20 tool.keyCode = 20
tool.about = "Text tool allows you to type some text data with selected primary color right on your image! It's time to say \"ur mom gay\" to everyone <3" tool.about = "Text tool allows you to type some text data with selected primary color right on your image! It's time to say \"ur mom gay\" to everyone <3"
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4) tool.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" then if e1 == "touch" then
local input = mainContainer:addChild(GUI.input( local input = application:addChild(GUI.input(
e3 - 1, e3 - 1,
e4, e4,
mainContainer.image.x + mainContainer.image.width - e3 + 2, application.image.x + application.image.width - e3 + 2,
1, 1,
nil, nil,
mainContainer.primaryColorSelector.color, application.primaryColorSelector.color,
mainContainer.primaryColorSelector.color, application.primaryColorSelector.color,
nil, nil,
mainContainer.primaryColorSelector.color, application.primaryColorSelector.color,
"" ""
)) ))
input.onInputFinished = function() input.onInputFinished = function()
if #input.text > 0 then if #input.text > 0 then
local x, y = e3 - mainContainer.image.x + 1, e4 - mainContainer.image.y + 1 local x, y = e3 - application.image.x + 1, e4 - application.image.y + 1
for i = 1, unicode.len(input.text) do for i = 1, unicode.len(input.text) do
if x <= mainContainer.image.width then if x <= application.image.width then
local background, foreground, alpha = image.get(mainContainer.image.data, x, y) local background, foreground, alpha = image.get(application.image.data, x, y)
image.set(mainContainer.image.data, x, y, background, mainContainer.primaryColorSelector.color, alpha, unicode.sub(input.text, i, i)) image.set(application.image.data, x, y, background, application.primaryColorSelector.color, alpha, unicode.sub(input.text, i, i))
x = x + 1 x = x + 1
else else
break break
@ -40,7 +40,7 @@ tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
end end
input:remove() input:remove()
mainContainer:drawOnScreen() application:draw()
end end
input:startInput() input:startInput()

View File

@ -29,13 +29,13 @@ local function pizda(x, y, picture, sourceB, sourceF, sourceA, sourceS, newB, ne
if check(x - 1, y, picture, sourceB, sourceF, sourceA, sourceS, newB, newF, newA, newS) then pizda(x - 1, y, picture, sourceB, sourceF, sourceA, sourceS, newB, newF, newA, newS) end if check(x - 1, y, picture, sourceB, sourceF, sourceA, sourceS, newB, newF, newA, newS) then pizda(x - 1, y, picture, sourceB, sourceF, sourceA, sourceS, newB, newF, newA, newS) end
end end
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4) tool.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" then if e1 == "touch" then
local x, y = e3 - mainContainer.image.x + 1, e4 - mainContainer.image.y + 1 local x, y = e3 - application.image.x + 1, e4 - application.image.y + 1
local sourceB, sourceF, sourceA, sourceS = image.get(mainContainer.image.data, x, y) local sourceB, sourceF, sourceA, sourceS = image.get(application.image.data, x, y)
pizda(x, y, mainContainer.image.data, sourceB, sourceF, sourceA, sourceS, mainContainer.primaryColorSelector.color, 0x0, 0, " ") pizda(x, y, application.image.data, sourceB, sourceF, sourceA, sourceS, application.primaryColorSelector.color, 0x0, 0, " ")
mainContainer:drawOnScreen() application:draw()
end end
end end

View File

@ -32,24 +32,24 @@ end
local backgroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw background:", false) local backgroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw background:", false)
tool.onSelection = function(mainContainer) tool.onSelection = function(application)
mainContainer.currentToolLayout:addChild(layout) application.currentToolLayout:addChild(layout)
mainContainer.currentToolLayout:addChild(backgroundSwitch) application.currentToolLayout:addChild(backgroundSwitch)
end end
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4) tool.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "touch" or e1 == "drag" then if e1 == "touch" or e1 == "drag" then
local x, y = e3 - mainContainer.image.x + 1, e4 - mainContainer.image.y + 1 local x, y = e3 - application.image.x + 1, e4 - application.image.y + 1
local background, foreground, alpha, symbol = image.get(mainContainer.image.data, x, y) local background, foreground, alpha, symbol = image.get(application.image.data, x, y)
image.set(mainContainer.image.data, x, y, image.set(application.image.data, x, y,
backgroundSwitch.switch.state and mainContainer.secondaryColorSelector.color or background, backgroundSwitch.switch.state and application.secondaryColorSelector.color or background,
mainContainer.primaryColorSelector.color, application.primaryColorSelector.color,
backgroundSwitch.switch.state and 0 or alpha, backgroundSwitch.switch.state and 0 or alpha,
char char
) )
mainContainer:drawOnScreen() application:draw()
end end
end end

View File

@ -20,7 +20,7 @@ local args, options = require("shell").parse(...)
local startImagePath = args[1] == "open" and args[2] or "/MineOS/System/Icons/Steve.pic" local startImagePath = args[1] == "open" and args[2] or "/MineOS/System/Icons/Steve.pic"
local configPath = MineOSPaths.applicationData .. "PrintImage/Config.cfg" local configPath = MineOSPaths.applicationData .. "PrintImage/Config.cfg"
local panelWidth = 34 local panelWidth = 34
local mainContainer local application
local mainImage local mainImage
local printers local printers
local currentPrinter = 1 local currentPrinter = 1
@ -140,15 +140,14 @@ local function beginPrint()
end end
buffer.clear() buffer.clear()
mainContainer:draw() application:draw()
buffer.drawChanges(true)
end end
----------------------------------------- Window-zaluped parasha ----------------------------------------- ----------------------------------------- Window-zaluped parasha -----------------------------------------
local function getStatus() local function getStatus()
local xBlocks, yBlocks = math.ceil(image.getWidth(mainImage) / shapeResolutionLimit), math.ceil(image.getHeight(mainImage) * 2 / shapeResolutionLimit) local xBlocks, yBlocks = math.ceil(image.getWidth(mainImage) / shapeResolutionLimit), math.ceil(image.getHeight(mainImage) * 2 / shapeResolutionLimit)
mainContainer.shadeContainer.statusTextBox.lines = { application.shadeContainer.statusTextBox.lines = {
"Image size: " .. image.getWidth(mainImage) .. "x" .. image.getHeight(mainImage) .. " px", "Image size: " .. image.getWidth(mainImage) .. "x" .. image.getHeight(mainImage) .. " px",
"Count of printers: " .. #printers, "Count of printers: " .. #printers,
"Print result: " .. xBlocks .. "x" .. yBlocks .. " blocks", "Print result: " .. xBlocks .. "x" .. yBlocks .. " blocks",
@ -185,79 +184,79 @@ local function drawMainImageObject(object)
end end
local function createWindow() local function createWindow()
mainContainer = GUI.fullScreenContainer() application = GUI.application()
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0xEEEEEE)) application:addChild(GUI.panel(1, 1, application.width, application.height, 0xEEEEEE))
mainContainer:addChild(GUI.object(1, 1, mainContainer.width, mainContainer.height)).draw = drawMainImageObject application:addChild(GUI.object(1, 1, application.width, application.height)).draw = drawMainImageObject
local textBoxesWidth = math.floor(panelWidth * 0.55) local textBoxesWidth = math.floor(panelWidth * 0.55)
mainContainer.shadeContainer = mainContainer:addChild(GUI.container(mainContainer.width - panelWidth + 1, 1, panelWidth, mainContainer.height)) application.shadeContainer = application:addChild(GUI.container(application.width - panelWidth + 1, 1, panelWidth, application.height))
mainContainer.shadeContainer:addChild(GUI.panel(1, 1, mainContainer.shadeContainer.width, mainContainer.shadeContainer.height, 0x0000000, 0.4)) application.shadeContainer:addChild(GUI.panel(1, 1, application.shadeContainer.width, application.shadeContainer.height, 0x0000000, 0.4))
local y = 2 local y = 2
mainContainer.shadeContainer:addChild(GUI.label(1, y, mainContainer.shadeContainer.width, 1, 0xFFFFFF, "Main properties")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application.shadeContainer:addChild(GUI.label(1, y, application.shadeContainer.width, 1, 0xFFFFFF, "Main properties")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
y = y + 2 y = y + 2
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Image path:")) application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Image path:"))
local filesystemChooser = mainContainer.shadeContainer:addChild(GUI.filesystemChooser(mainContainer.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x262626, 0x444444, 0x999999, startImagePath, MineOSCore.localization.open, MineOSCore.localization.cancel, "Image path", "/")) local filesystemChooser = application.shadeContainer:addChild(GUI.filesystemChooser(application.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x262626, 0x444444, 0x999999, startImagePath, MineOSCore.localization.open, MineOSCore.localization.cancel, "Image path", "/"))
filesystemChooser:addExtensionFilter(".pic") filesystemChooser:addExtensionFilter(".pic")
filesystemChooser.onSubmit = function(path) filesystemChooser.onSubmit = function(path)
mainImage = image.load(path) mainImage = image.load(path)
getStatus() getStatus()
mainContainer:drawOnScreen() application:draw()
end end
y = y + 2 y = y + 2
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Material:")) application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Material:"))
local mainMaterialTextBox = mainContainer.shadeContainer:addChild(GUI.input(mainContainer.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0x555555, 0xEEEEEE, 0x262626, config.mainMaterial, nil, false)) local mainMaterialTextBox = application.shadeContainer:addChild(GUI.input(application.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0x555555, 0xEEEEEE, 0x262626, config.mainMaterial, nil, false))
mainMaterialTextBox.onInputFinished = function() mainMaterialTextBox.onInputFinished = function()
config.mainMaterial = mainMaterialTextBox.text config.mainMaterial = mainMaterialTextBox.text
save() save()
end end
y = y + 2 y = y + 2
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Print name:")) application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Print name:"))
local printNameTextBox = mainContainer.shadeContainer:addChild(GUI.input(mainContainer.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0x555555, 0xEEEEEE, 0x262626, config.printName, nil, false)) local printNameTextBox = application.shadeContainer:addChild(GUI.input(application.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0x555555, 0xEEEEEE, 0x262626, config.printName, nil, false))
printNameTextBox.onInputFinished = function() printNameTextBox.onInputFinished = function()
config.printName = printNameTextBox.text config.printName = printNameTextBox.text
save() save()
end end
y = y + 2 y = y + 2
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Floor mode:")) application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Floor mode:"))
local floorSwitch = mainContainer.shadeContainer:addChild(GUI.switch(mainContainer.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.floorMode)) local floorSwitch = application.shadeContainer:addChild(GUI.switch(application.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.floorMode))
floorSwitch.onStateChanged = function() floorSwitch.onStateChanged = function()
config.floorMode = floorSwitch.state config.floorMode = floorSwitch.state
save() save()
end end
y = y + 2 y = y + 2
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Show grid:")) application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Show grid:"))
local gridSwitch = mainContainer.shadeContainer:addChild(GUI.switch(mainContainer.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.showGrid)) local gridSwitch = application.shadeContainer:addChild(GUI.switch(application.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.showGrid))
gridSwitch.onStateChanged = function() gridSwitch.onStateChanged = function()
config.showGrid = gridSwitch.state config.showGrid = gridSwitch.state
save() save()
mainContainer:draw() application:draw()
end end
y = y + 4 y = y + 4
mainContainer.shadeContainer:addChild(GUI.label(1, y, mainContainer.shadeContainer.width, 1, 0xFFFFFF, "Frame properties")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application.shadeContainer:addChild(GUI.label(1, y, application.shadeContainer.width, 1, 0xFFFFFF, "Frame properties")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
y = y + 2 y = y + 2
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Enabled:")) application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Enabled:"))
local frameSwitch = mainContainer.shadeContainer:addChild(GUI.switch(mainContainer.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.frame.enabled)) local frameSwitch = application.shadeContainer:addChild(GUI.switch(application.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.frame.enabled))
frameSwitch.onStateChanged = function() frameSwitch.onStateChanged = function()
config.frame.enabled = frameSwitch.state config.frame.enabled = frameSwitch.state
save() save()
end end
y = y + 2 y = y + 2
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Material:")) application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Material:"))
local frameMaterialTextBox = mainContainer.shadeContainer:addChild(GUI.input(mainContainer.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0x555555, 0xEEEEEE, 0x262626, config.frame.material, nil, false)) local frameMaterialTextBox = application.shadeContainer:addChild(GUI.input(application.shadeContainer.width - textBoxesWidth - 1, y, textBoxesWidth, 1, 0xEEEEEE, 0x555555, 0x555555, 0xEEEEEE, 0x262626, config.frame.material, nil, false))
frameMaterialTextBox.onInputFinished = function() frameMaterialTextBox.onInputFinished = function()
config.frame.material = frameMaterialTextBox.text config.frame.material = frameMaterialTextBox.text
save() save()
end end
y = y + 2 y = y + 2
local frameWidthSlider = mainContainer.shadeContainer:addChild(GUI.slider(3, y, mainContainer.shadeContainer.width - 4, 0xFFDB80, 0x000000, 0xFFDB40, 0xCCCCCC, 1, shapeResolutionLimit - 1, config.frame.width, false, "Width: " , " voxel(s)")) local frameWidthSlider = application.shadeContainer:addChild(GUI.slider(3, y, application.shadeContainer.width - 4, 0xFFDB80, 0x000000, 0xFFDB40, 0xCCCCCC, 1, shapeResolutionLimit - 1, config.frame.width, false, "Width: " , " voxel(s)"))
frameWidthSlider.onValueChanged = function() frameWidthSlider.onValueChanged = function()
config.frame.width = frameWidthSlider.value config.frame.width = frameWidthSlider.value
save() save()
@ -265,17 +264,17 @@ local function createWindow()
frameWidthSlider.roundValues = true frameWidthSlider.roundValues = true
y = y + 5 y = y + 5
mainContainer.shadeContainer:addChild(GUI.label(1, y, mainContainer.shadeContainer.width, 1, 0xFFFFFF, "Light emission")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application.shadeContainer:addChild(GUI.label(1, y, application.shadeContainer.width, 1, 0xFFFFFF, "Light emission")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
y = y + 2 y = y + 2
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Enabled:")) application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Enabled:"))
local lightSwitch = mainContainer.shadeContainer:addChild(GUI.switch(mainContainer.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.lightEmission.enabled)) local lightSwitch = application.shadeContainer:addChild(GUI.switch(application.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.lightEmission.enabled))
lightSwitch.onStateChanged = function() lightSwitch.onStateChanged = function()
config.lightEmission.enabled = true config.lightEmission.enabled = true
save() save()
end end
y = y + 2 y = y + 2
local lightSlider = mainContainer.shadeContainer:addChild(GUI.slider(3, y, mainContainer.shadeContainer.width - 4, 0xFFDB80, 0x000000, 0xFFDB40, 0xCCCCCC, 1, 8, 8, false, "Radius: " , " block(s)")) local lightSlider = application.shadeContainer:addChild(GUI.slider(3, y, application.shadeContainer.width - 4, 0xFFDB80, 0x000000, 0xFFDB40, 0xCCCCCC, 1, 8, 8, false, "Radius: " , " block(s)"))
lightSlider.roundValues = true lightSlider.roundValues = true
lightSlider.onValueChanged = function() lightSlider.onValueChanged = function()
config.lightEmission.value = lightSlider.value config.lightEmission.value = lightSlider.value
@ -283,23 +282,23 @@ local function createWindow()
end end
y = y + 5 y = y + 5
mainContainer.shadeContainer:addChild(GUI.label(1, y, mainContainer.shadeContainer.width, 1, 0xFFFFFF, "Summary information:")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application.shadeContainer:addChild(GUI.label(1, y, application.shadeContainer.width, 1, 0xFFFFFF, "Summary information:")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
y = y + 2 y = y + 2
mainContainer.shadeContainer.statusTextBox = mainContainer.shadeContainer:addChild(GUI.textBox(3, y, mainContainer.shadeContainer.width - 4, 5, nil, 0xCCCCCC, {}, 1)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_LEFT, GUI.ALIGNMENT_VERTICAL_TOP) application.shadeContainer.statusTextBox = application.shadeContainer:addChild(GUI.textBox(3, y, application.shadeContainer.width - 4, 5, nil, 0xCCCCCC, {}, 1)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_LEFT, GUI.ALIGNMENT_VERTICAL_TOP)
mainContainer.shadeContainer:addChild(GUI.button(1, mainContainer.shadeContainer.height - 5, mainContainer.shadeContainer.width, 3, 0x363636, 0xFFFFFF, 0xFFFFFF, 0x262626, "Exit")).onTouch = function() application.shadeContainer:addChild(GUI.button(1, application.shadeContainer.height - 5, application.shadeContainer.width, 3, 0x363636, 0xFFFFFF, 0xFFFFFF, 0x262626, "Exit")).onTouch = function()
mainContainer:stopEventHandling() application:stop()
end end
mainContainer.shadeContainer:addChild(GUI.button(1, mainContainer.shadeContainer.height - 2, mainContainer.shadeContainer.width, 3, 0x262626, 0xFFFFFF, 0xFFFFFF, 0x262626, "Start print")).onTouch = function() application.shadeContainer:addChild(GUI.button(1, application.shadeContainer.height - 2, application.shadeContainer.width, 3, 0x262626, 0xFFFFFF, 0xFFFFFF, 0x262626, "Start print")).onTouch = function()
beginPrint() beginPrint()
end end
mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3) application.eventHandler = function(application, object, e1, e2, e3)
if (e1 == "component_added" or e1 == "component_removed") and e3 == "printer3d" then if (e1 == "component_added" or e1 == "component_removed") and e3 == "printer3d" then
getPrinters() getPrinters()
getStatus() getStatus()
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
@ -313,5 +312,5 @@ createWindow()
mainImage = image.load(startImagePath) mainImage = image.load(startImagePath)
getStatus() getStatus()
mainContainer:drawOnScreen() application:draw()
mainContainer:startEventHandling() application:start()

View File

@ -25,7 +25,7 @@ local function menuBackground()
end end
local function settings() local function settings()
local window = GUI.fullScreenContainer() local window = GUI.application()
local oldDraw = window.draw local oldDraw = window.draw
window.draw = function() window.draw = function()
menuBackground() menuBackground()
@ -44,7 +44,7 @@ local function settings()
resolutionTextBoxWidth.validator = function(text) local num = tonumber(text); if num and num >= 40 and num <= 160 then return true end end 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 resolutionTextBoxHeight.validator = function(text) local num = tonumber(text); if num and num >= 12 and num <= 50 then return true end end
local function onAnyResolutionTextBoxInputFinished() local function onAnyResolutionTextBoxInputFinished()
window:stopEventHandling() window:stop()
rayEngine.changeResolution(tonumber(resolutionTextBoxWidth.text), tonumber(resolutionTextBoxHeight.text)) rayEngine.changeResolution(tonumber(resolutionTextBoxWidth.text), tonumber(resolutionTextBoxHeight.text))
settings() settings()
end end
@ -55,28 +55,24 @@ local function settings()
drawDistanceSlider.onValueChanged = function() drawDistanceSlider.onValueChanged = function()
rayEngine.properties.drawDistance = drawDistanceSlider.value rayEngine.properties.drawDistance = drawDistanceSlider.value
window:draw() window:draw()
buffer.drawChanges()
end; y = y + 4 end; y = y + 4
local shadingDistanceSlider = window:addChild(GUI.slider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 100, 3000, rayEngine.properties.shadingDistance, true, localization.shadingDistance)) local shadingDistanceSlider = window:addChild(GUI.slider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 100, 3000, rayEngine.properties.shadingDistance, true, localization.shadingDistance))
shadingDistanceSlider.onValueChanged = function() shadingDistanceSlider.onValueChanged = function()
rayEngine.properties.shadingDistance = shadingDistanceSlider.value rayEngine.properties.shadingDistance = shadingDistanceSlider.value
window:draw() window:draw()
buffer.drawChanges()
end; y = y + 4 end; y = y + 4
local shadingCascadesSlider = window:addChild(GUI.slider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 2, 48, rayEngine.properties.shadingCascades, true, localization.shadingCascades)) local shadingCascadesSlider = window:addChild(GUI.slider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 2, 48, rayEngine.properties.shadingCascades, true, localization.shadingCascades))
shadingCascadesSlider.onValueChanged = function() shadingCascadesSlider.onValueChanged = function()
rayEngine.properties.shadingCascades = shadingCascadesSlider.value rayEngine.properties.shadingCascades = shadingCascadesSlider.value
window:draw() window:draw()
buffer.drawChanges()
end; y = y + 4 end; y = y + 4
local raycastQualitySlider = window:addChild(GUI.slider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 0.5, 32, rayEngine.properties.raycastQuality, true, localization.raycastQuality)) local raycastQualitySlider = window:addChild(GUI.slider(x, y, sliderWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xDDDDDD, 0.5, 32, rayEngine.properties.raycastQuality, true, localization.raycastQuality))
raycastQualitySlider.onValueChanged = function() raycastQualitySlider.onValueChanged = function()
rayEngine.properties.raycastQuality = raycastQualitySlider.value rayEngine.properties.raycastQuality = raycastQualitySlider.value
window:draw() window:draw()
buffer.drawChanges()
end; y = y + 4 end; y = y + 4
local currentTimeSlider = window:addChild(GUI.slider(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:addChild(GUI.slider(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))
@ -86,7 +82,6 @@ local function settings()
currentTimeSlider.colors.active = rayEngine.world.colors.sky.current currentTimeSlider.colors.active = rayEngine.world.colors.sky.current
currentTimeSlider.colors.pipe = rayEngine.world.colors.sky.current currentTimeSlider.colors.pipe = rayEngine.world.colors.sky.current
window:draw() window:draw()
buffer.drawChanges()
end; y = y + 4 end; y = y + 4
window:addChild(GUI.label(x, y, sliderWidth, 1, 0xDDDDDD, localization.enableSemipixelRenderer)) window:addChild(GUI.label(x, y, sliderWidth, 1, 0xDDDDDD, localization.enableSemipixelRenderer))
@ -95,7 +90,6 @@ local function settings()
graphonSwitch.onStateChanged = function() graphonSwitch.onStateChanged = function()
rayEngine.properties.useSimpleRenderer = not graphonSwitch.state rayEngine.properties.useSimpleRenderer = not graphonSwitch.state
window:draw() window:draw()
buffer.drawChanges()
end; y = y + 3 end; y = y + 3
window:addChild(GUI.label(x, y, sliderWidth, 1, 0xDDDDDD, localization.enableDayNightCycle)) window:addChild(GUI.label(x, y, sliderWidth, 1, 0xDDDDDD, localization.enableDayNightCycle))
@ -104,16 +98,16 @@ local function settings()
lockTimeSwitch.onStateChanged = function() lockTimeSwitch.onStateChanged = function()
rayEngine.world.dayNightCycle.enabled = lockTimeSwitch.state rayEngine.world.dayNightCycle.enabled = lockTimeSwitch.state
window:draw() window:draw()
buffer.drawChanges()
end; y = y + 3 end; y = y + 3
window:addChild(GUI.button(x, y, sliderWidth, 3, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.continue)).onTouch = function() window:stopEventHandling(); table.toFile(applicationResourcesDirectory .. "RayEngine.cfg", rayEngine.properties, true) end window:addChild(GUI.button(x, y, sliderWidth, 3, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.continue)).onTouch = function() window:stop(); table.toFile(applicationResourcesDirectory .. "RayEngine.cfg", rayEngine.properties, true) end
window:draw(); buffer.drawChanges(); window:startEventHandling() window:draw()
window:start()
end end
local function menu() local function menu()
local window = GUI.fullScreenContainer() local window = GUI.application()
local oldDraw = window.draw local oldDraw = window.draw
window.draw = function() window.draw = function()
menuBackground() menuBackground()
@ -126,13 +120,13 @@ local function menu()
local x, y = math.floor(window.width / 2 - buttonWidth / 2), math.floor(window.height / 2 - #worlds * (buttonHeight + 1) / 2 - 11) local x, y = math.floor(window.width / 2 - buttonWidth / 2), math.floor(window.height / 2 - #worlds * (buttonHeight + 1) / 2 - 11)
window:addChild(GUI.label(1, y, window.width, 1, 0xFFFFFF, rayWalkVersion)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 3 window:addChild(GUI.label(1, y, window.width, 1, 0xFFFFFF, rayWalkVersion)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 3
window:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.continue)).onTouch = function() window:stopEventHandling() end; y = y + buttonHeight + 1 window:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.continue)).onTouch = function() window:stop() end; y = y + buttonHeight + 1
window:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.settings)).onTouch = function() window:stopEventHandling(); settings() end; y = y + buttonHeight + 1 window:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, localization.settings)).onTouch = function() window:stop(); settings() end; y = y + buttonHeight + 1
window:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0x999999, 0x262626, localization.exit)).onTouch = function() buffer.clear(0x000000); buffer.drawChanges(); os.exit() end; y = y + buttonHeight + 1 window:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0x999999, 0x262626, localization.exit)).onTouch = function() buffer.clear(0x000000); buffer.drawChanges(); os.exit() end; y = y + buttonHeight + 1
window:addChild(GUI.label(1, y, window.width, 1, 0xFFFFFF, localization.loadWorld)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2 window:addChild(GUI.label(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 for i = 1, #worlds do
window:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, worlds[i])).onTouch = function() rayEngine.loadWorld(worldsPath .. worlds[i]); window:stopEventHandling() end window:addChild(GUI.button(x, y, buttonWidth, buttonHeight, 0xEEEEEE, 0x262626, 0xBBBBBB, 0x262626, worlds[i])).onTouch = function() rayEngine.loadWorld(worldsPath .. worlds[i]); window:stop() end
y = y + buttonHeight + 1 y = y + buttonHeight + 1
end end
@ -141,7 +135,8 @@ local function menu()
table.insert(lines, 1, {text = localization.controls, color = 0xFFFFFF}) table.insert(lines, 1, {text = localization.controls, color = 0xFFFFFF})
window:addChild(GUI.textBox(1, y, window.width, #lines, nil, 0xCCCCCC, lines, 1):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)); y = y + #lines + 1 window:addChild(GUI.textBox(1, y, window.width, #lines, nil, 0xCCCCCC, lines, 1):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)); y = y + #lines + 1
window:draw(); buffer.drawChanges(); window:startEventHandling() window:draw()
window:start()
end end

View File

@ -7,7 +7,7 @@ local event = require("event")
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, "Running string setup") local container = MineOSInterface.addBackgroundContainer(MineOSInterface.application, "Running string setup")
local textInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xFFFFFF, 0x696969, 0xB4B4B4, 0xFFFFFF, 0x2D2D2D, "Working on cool things, don't distract me", "Type text here", true)) local textInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xFFFFFF, 0x696969, 0xB4B4B4, 0xFFFFFF, 0x2D2D2D, "Working on cool things, don't distract me", "Type text here", true))
local backgroundColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, 0x0, "Background color")) local backgroundColorSelector = container.layout:addChild(GUI.colorSelector(1, 1, 36, 3, 0x0, "Background color"))
@ -41,7 +41,7 @@ container.layout:addChild(GUI.button(1, 1, 36, 3, 0x444444, 0xFFFFFF, 0x2D2D2D,
end end
buffer.setResolution(buffer.getResolution()) buffer.setResolution(buffer.getResolution())
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end

View File

@ -4,7 +4,7 @@ local computer = require("computer")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -46,7 +46,7 @@ module.onTouch = function()
computer.removeUser(users[i]) computer.removeUser(users[i])
update() update()
mainContainer:drawOnScreen() application:draw()
end end
usersLayout.height, step = usersLayout.height + userContainer.height, not step usersLayout.height, step = usersLayout.height + userContainer.height, not step
@ -60,7 +60,7 @@ module.onTouch = function()
input.text = "" input.text = ""
update() update()
mainContainer:drawOnScreen() application:draw()
end end
end end

View File

@ -9,7 +9,7 @@ local scale = require("scale")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -85,7 +85,7 @@ module.onTouch = function()
switch.onStateChanged = function() switch.onStateChanged = function()
updateSwitch() updateSwitch()
updateCykaTextBox() updateCykaTextBox()
mainContainer:drawOnScreen() application:draw()
MineOSCore.properties.screenAutoScale = switch.state MineOSCore.properties.screenAutoScale = switch.state
MineOSCore.saveProperties() MineOSCore.saveProperties()
@ -96,7 +96,7 @@ module.onTouch = function()
if cykaTextBox.hidden then if cykaTextBox.hidden then
setResolution(width, height) setResolution(width, height)
else else
mainContainer:drawOnScreen() application:draw()
end end
end end
heightInput.onInputFinished = widthInput.onInputFinished heightInput.onInputFinished = widthInput.onInputFinished

View File

@ -6,7 +6,7 @@ local MineOSCore = require("MineOSCore")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -21,7 +21,7 @@ module.onTouch = function()
wallpaperChooser.onSubmit = function(path) wallpaperChooser.onSubmit = function(path)
MineOSCore.properties.wallpaper = path MineOSCore.properties.wallpaper = path
MineOSInterface.changeWallpaper() MineOSInterface.changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end
@ -35,7 +35,7 @@ module.onTouch = function()
wallpaperSwitch.onStateChanged = function() wallpaperSwitch.onStateChanged = function()
MineOSCore.properties.wallpaperEnabled = wallpaperSwitch.state MineOSCore.properties.wallpaperEnabled = wallpaperSwitch.state
MineOSInterface.changeWallpaper() MineOSInterface.changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end
@ -48,7 +48,7 @@ module.onTouch = function()
wallpaperSlider.onValueChanged = function() wallpaperSlider.onValueChanged = function()
MineOSCore.properties.wallpaperBrightness = wallpaperSlider.value / 100 MineOSCore.properties.wallpaperBrightness = wallpaperSlider.value / 100
MineOSInterface.changeWallpaper() MineOSInterface.changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end
@ -56,7 +56,7 @@ module.onTouch = function()
comboBox.onItemSelected = function() comboBox.onItemSelected = function()
MineOSCore.properties.wallpaperMode = comboBox.selectedItem MineOSCore.properties.wallpaperMode = comboBox.selectedItem
MineOSInterface.changeWallpaper() MineOSInterface.changeWallpaper()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end

View File

@ -7,7 +7,7 @@ local MineOSCore = require("MineOSCore")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -33,9 +33,9 @@ module.onTouch = function()
MineOSCore.properties.backgroundColor = backgroundColorSelector.color MineOSCore.properties.backgroundColor = backgroundColorSelector.color
MineOSCore.properties.menuColor = menuColorSelector.color MineOSCore.properties.menuColor = menuColorSelector.color
MineOSCore.properties.dockColor = dockColorSelector.color MineOSCore.properties.dockColor = dockColorSelector.color
MineOSInterface.mainContainer.menu.colors.default.background = MineOSCore.properties.menuColor MineOSInterface.application.menu.colors.default.background = MineOSCore.properties.menuColor
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
menuColorSelector.onColorSelected = backgroundColorSelector.onColorSelected menuColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
dockColorSelector.onColorSelected = backgroundColorSelector.onColorSelected dockColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
@ -79,7 +79,7 @@ module.onTouch = function()
MineOSCore.properties.transparencyEnabled = transparencySwitch.state MineOSCore.properties.transparencyEnabled = transparencySwitch.state
MineOSInterface.applyTransparency() MineOSInterface.applyTransparency()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end

View File

@ -6,7 +6,7 @@ local MineOSCore = require("MineOSCore")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -9,7 +9,7 @@ local filesystem = require("filesystem")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -79,7 +79,7 @@ module.onTouch = function()
comboBox.onItemSelected = function() comboBox.onItemSelected = function()
currentAddress = getProxy().address currentAddress = getProxy().address
update() update()
mainContainer:drawOnScreen() application:draw()
end end
input.onInputFinished = function() input.onInputFinished = function()
@ -92,7 +92,7 @@ module.onTouch = function()
GUI.alert(reason) GUI.alert(reason)
end end
mainContainer:drawOnScreen() application:draw()
end end
button.onTouch = function() button.onTouch = function()
@ -103,7 +103,7 @@ module.onTouch = function()
end end
fill() fill()
mainContainer:drawOnScreen() application:draw()
end end
fill() fill()

View File

@ -8,7 +8,7 @@ local filesystem = require("filesystem")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -63,7 +63,7 @@ module.onTouch = function()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
networkNameInput.onInputFinished = function() networkNameInput.onInputFinished = function()
@ -93,7 +93,7 @@ module.onTouch = function()
end end
-- Empty object-listener -- Empty object-listener
emptyObject.eventHandler = function(mainContainer, object, e1, e2, e3, ...) emptyObject.eventHandler = function(application, object, e1, e2, e3, ...)
if (e1 == "component_added" or e1 == "component_removed") and e3 == "modem" then if (e1 == "component_added" or e1 == "component_removed") and e3 == "modem" then
check() check()
elseif e1 == "MineOSNetwork" and e2 == "updateProxyList" then elseif e1 == "MineOSNetwork" and e2 == "updateProxyList" then

View File

@ -7,7 +7,7 @@ local filesystem = require("filesystem")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -6,7 +6,7 @@ local MineOSCore = require("MineOSCore")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -38,7 +38,7 @@ module.onTouch = function()
MineOSCore.updateTimezone() MineOSCore.updateTimezone()
MineOSCore.updateTime() MineOSCore.updateTime()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end

View File

@ -8,7 +8,7 @@ local unicode = require("unicode")
local module = {} local module = {}
local mainContainer, window, localization = table.unpack({...}) local application, window, localization = table.unpack({...})
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -50,7 +50,7 @@ module.onTouch = function()
RAMComboBox:addItem(libraries[i]) RAMComboBox:addItem(libraries[i])
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
window.contentLayout:addChild(GUI.button(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, localization.systemUnload)).onTouch = function() window.contentLayout:addChild(GUI.button(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, localization.systemUnload)).onTouch = function()
@ -69,7 +69,7 @@ module.onTouch = function()
update() update()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -15,9 +15,9 @@ local spinnerLimit = 8
local spinnerHue = math.random(0, 360) local spinnerHue = math.random(0, 360)
local spinnerHueStep = 20 local spinnerHueStep = 20
local mainContainer = GUI.fullScreenContainer() local application = GUI.application()
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x0)) application:addChild(GUI.panel(1, 1, application.width, application.height, 0x0))
local spinnerImage = mainContainer:addChild(GUI.image(1, 1, {1, 1})) local spinnerImage = application:addChild(GUI.image(1, 1, {1, 1}))
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
@ -43,9 +43,9 @@ local function changeColor(hue, saturation)
spinnerImage.image = spinners[currentSpinner] spinnerImage.image = spinners[currentSpinner]
end end
mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5) application.eventHandler = function(application, object, e1, e2, e3, e4, e5)
if e1 == "key_down" then if e1 == "key_down" then
mainContainer:stopEventHandling() application:stop()
elseif e1 == "touch" then elseif e1 == "touch" then
spinnerHue = spinnerHue + spinnerHueStep * (e5 == 1 and -1 or 1) spinnerHue = spinnerHue + spinnerHueStep * (e5 == 1 and -1 or 1)
if spinnerHue > 360 then if spinnerHue > 360 then
@ -62,7 +62,7 @@ mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
end end
spinnerImage.image = spinners[currentSpinner] spinnerImage.image = spinners[currentSpinner]
mainContainer:drawOnScreen() application:draw()
end end
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
@ -72,14 +72,14 @@ for i = 1, spinnerLimit do
end end
spinnerImage.width = image.getWidth(spinners[currentSpinner]) spinnerImage.width = image.getWidth(spinners[currentSpinner])
spinnerImage.height = image.getHeight(spinners[currentSpinner]) spinnerImage.height = image.getHeight(spinners[currentSpinner])
spinnerImage.localX = math.floor(mainContainer.width / 2 - spinnerImage.width / 2) spinnerImage.localX = math.floor(application.width / 2 - spinnerImage.width / 2)
spinnerImage.localY = math.floor(mainContainer.height / 2 - spinnerImage.height/ 2) spinnerImage.localY = math.floor(application.height / 2 - spinnerImage.height/ 2)
changeColor(spinnerHue, 1) changeColor(spinnerHue, 1)
buffer.flush() buffer.flush()
mainContainer:drawOnScreen() application:draw()
mainContainer:startEventHandling(0) application:start(0)

View File

@ -22,7 +22,7 @@ local contacts = {}
local Ch1Image = image.load(resources .. "Ch1.pic") local Ch1Image = image.load(resources .. "Ch1.pic")
local Ch2Image = image.load(resources .. "Ch2.pic") local Ch2Image = image.load(resources .. "Ch2.pic")
local mainContainer = GUI.fullScreenContainer() local application = GUI.application()
--------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------
@ -56,30 +56,30 @@ local function newChevronObject(x, y)
end end
local function addChevron(x, y) local function addChevron(x, y)
table.insert(mainContainer.chevrons, mainContainer.chevronsContainer:addChild(newChevronObject(x, y))) table.insert(application.chevrons, application.chevronsContainer:addChild(newChevronObject(x, y)))
end end
local function updateChevrons(state) local function updateChevrons(state)
for i = 1, #mainContainer.chevrons do for i = 1, #application.chevrons do
mainContainer.chevrons[i].isActivated = state application.chevrons[i].isActivated = state
if not state then mainContainer.chevrons[i].text = " " end if not state then application.chevrons[i].text = " " end
end end
end end
local function updateButtons() local function updateButtons()
mainContainer.removeContactButton.disabled = #contacts == 0 application.removeContactButton.disabled = #contacts == 0
mainContainer.connectContactButton.disabled = #contacts == 0 application.connectContactButton.disabled = #contacts == 0
end end
local function update() local function update()
local stargateState, irisState, imagePath = stargate.stargateState(), stargate.irisState() local stargateState, irisState, imagePath = stargate.stargateState(), stargate.irisState()
mainContainer.irisButton.text = irisState == "Closed" and "Open Iris" or "Close Iris" application.irisButton.text = irisState == "Closed" and "Open Iris" or "Close Iris"
mainContainer.connectionButton.text = stargateState == "Connected" and "Disconnect" or "Connect" application.connectionButton.text = stargateState == "Connected" and "Disconnect" or "Connect"
mainContainer.connectedToLabel.text = stargateState == "Connected" and "(Connected to " .. stargate.remoteAddress() .. ")" or "(Not connected)" application.connectedToLabel.text = stargateState == "Connected" and "(Connected to " .. stargate.remoteAddress() .. ")" or "(Not connected)"
if stargateState == "Connected" then if stargateState == "Connected" then
mainContainer.connectContactButton.disabled = true application.connectContactButton.disabled = true
mainContainer.messageContactButton.disabled = false application.messageContactButton.disabled = false
if irisState == "Closed" then if irisState == "Closed" then
imagePath = "OnOn.pic" imagePath = "OnOn.pic"
@ -87,8 +87,8 @@ local function update()
imagePath = "OnOff.pic" imagePath = "OnOff.pic"
end end
else else
mainContainer.connectContactButton.disabled = false application.connectContactButton.disabled = false
mainContainer.messageContactButton.disabled = true application.messageContactButton.disabled = true
if irisState == "Closed" then if irisState == "Closed" then
imagePath = "OffOn.pic" imagePath = "OffOn.pic"
@ -98,16 +98,16 @@ local function update()
end end
updateButtons() updateButtons()
mainContainer.SGImage.image = image.load(resources .. imagePath) application.SGImage.image = image.load(resources .. imagePath)
end end
local function updateContacts() local function updateContacts()
mainContainer.contactsComboBox:clear() application.contactsComboBox:clear()
if #contacts == 0 then if #contacts == 0 then
mainContainer.contactsComboBox:addItem("No contacts found") application.contactsComboBox:addItem("No contacts found")
else else
for i = 1, #contacts do for i = 1, #contacts do
mainContainer.contactsComboBox:addItem(contacts[i].name) application.contactsComboBox:addItem(contacts[i].name)
end end
end end
end end
@ -132,8 +132,8 @@ end
local function dial(address) local function dial(address)
local success, reason = stargate.dial(address) local success, reason = stargate.dial(address)
if success then if success then
mainContainer.fuelProgressBar.value = math.ceil(stargate.energyToDial(address) / stargate.energyAvailable() * 100) application.fuelProgressBar.value = math.ceil(stargate.energyToDial(address) / stargate.energyAvailable() * 100)
mainContainer:drawOnScreen() application:draw()
else else
GUI.alert("Failed to dial: " .. tostring(reason)) GUI.alert("Failed to dial: " .. tostring(reason))
end end
@ -142,15 +142,15 @@ end
--------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------
local width, height = 32, 37 local width, height = 32, 37
local x, y = mainContainer.width - width - 3, math.floor(mainContainer.height / 2 - height / 2) local x, y = application.width - width - 3, math.floor(application.height / 2 - height / 2)
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x1E1E1E)) application:addChild(GUI.panel(1, 1, application.width, application.height, 0x1E1E1E))
mainContainer.SGImage = mainContainer:addChild(GUI.image(1, 1, image.load(resources .. "OffOff.pic"))) application.SGImage = application:addChild(GUI.image(1, 1, image.load(resources .. "OffOff.pic")))
mainContainer.SGImage.localX, mainContainer.SGImage.localY = math.floor((x - 2) / 2 - image.getWidth(mainContainer.SGImage.image) / 2), mainContainer.height - image.getHeight(mainContainer.SGImage.image) + 1 application.SGImage.localX, application.SGImage.localY = math.floor((x - 2) / 2 - image.getWidth(application.SGImage.image) / 2), application.height - image.getHeight(application.SGImage.image) + 1
mainContainer.chevronsContainer = mainContainer:addChild(GUI.container(mainContainer.SGImage.localX, mainContainer.SGImage.localY, mainContainer.SGImage.width, mainContainer.SGImage.height)) application.chevronsContainer = application:addChild(GUI.container(application.SGImage.localX, application.SGImage.localY, application.SGImage.width, application.SGImage.height))
mainContainer.chevrons = {} application.chevrons = {}
addChevron(13, 30) addChevron(13, 30)
addChevron(8, 17) addChevron(8, 17)
addChevron(21, 6) addChevron(21, 6)
@ -159,15 +159,15 @@ addChevron(72, 6)
addChevron(83, 17) addChevron(83, 17)
addChevron(79, 30) addChevron(79, 30)
mainContainer:addChild(newThing(mainContainer.SGImage.localX + mainContainer.SGImage.width, y, mainContainer.width - mainContainer.SGImage.localX - mainContainer.SGImage.width - width - 7, height)) application:addChild(newThing(application.SGImage.localX + application.SGImage.width, y, application.width - application.SGImage.localX - application.SGImage.width - width - 7, height))
mainContainer:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Stargate " .. stargate.localAddress())):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 1 application:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Stargate " .. stargate.localAddress())):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 1
mainContainer.connectedToLabel = mainContainer:addChild(GUI.label(x, y, width, 1, 0x555555, "(Not connected)")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2 application.connectedToLabel = application:addChild(GUI.label(x, y, width, 1, 0x555555, "(Not connected)")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2
mainContainer.connectionButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Connect")); y = y + 3 application.connectionButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Connect")); y = y + 3
-- mainContainer.connectionButton.animated = false -- application.connectionButton.animated = false
mainContainer.connectionButton.onTouch = function() application.connectionButton.onTouch = function()
if stargate.stargateState() == "Idle" then if stargate.stargateState() == "Idle" then
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Connect") local container = MineOSInterface.addBackgroundContainer(application, "Connect")
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, contacts.last, "Type address here")) local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, contacts.last, "Type address here"))
input.onInputFinished = function() input.onInputFinished = function()
if input.text then if input.text then
@ -176,24 +176,24 @@ mainContainer.connectionButton.onTouch = function()
saveContacts() saveContacts()
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
end end
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
input.onInputFinished() input.onInputFinished()
end end
end end
mainContainer:drawOnScreen() application:draw()
else else
stargate.disconnect() stargate.disconnect()
end end
end end
mainContainer.irisButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Open Iris")); y = y + 3 application.irisButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Open Iris")); y = y + 3
mainContainer.irisButton.onTouch = function() application.irisButton.onTouch = function()
if stargate.irisState() == "Open" then if stargate.irisState() == "Open" then
stargate.closeIris() stargate.closeIris()
else else
@ -201,43 +201,43 @@ mainContainer.irisButton.onTouch = function()
end end
end end
mainContainer.messageContactButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Message")); y = y + 4 application.messageContactButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Message")); y = y + 4
mainContainer.messageContactButton.onTouch = function() application.messageContactButton.onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Message") local container = MineOSInterface.addBackgroundContainer(application, "Message")
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, nil, "Type message text here")) local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, nil, "Type message text here"))
input.onInputFinished = function() input.onInputFinished = function()
if input.text then if input.text then
container:remove() container:remove()
stargate.sendMessage(input.text) stargate.sendMessage(input.text)
mainContainer:drawOnScreen() application:draw()
end end
end end
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
input.onInputFinished() input.onInputFinished()
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
mainContainer:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Contacts")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2 application:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Contacts")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2
mainContainer.contactsComboBox = mainContainer:addChild(GUI.comboBox(x, y, width, 3, 0x3C3C3C, 0xBBBBBB, 0x555555, 0x888888)); y = y + 4 application.contactsComboBox = application:addChild(GUI.comboBox(x, y, width, 3, 0x3C3C3C, 0xBBBBBB, 0x555555, 0x888888)); y = y + 4
mainContainer.connectContactButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Connect")); y = y + 3 application.connectContactButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Connect")); y = y + 3
mainContainer.connectContactButton.onTouch = function() application.connectContactButton.onTouch = function()
dial(contacts[mainContainer.contactsComboBox.selectedItem].address) dial(contacts[application.contactsComboBox.selectedItem].address)
end end
mainContainer.addContactButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Add contact")); y = y + 3 application.addContactButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Add contact")); y = y + 3
mainContainer.addContactButton.onTouch = function() application.addContactButton.onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Add contact") local container = MineOSInterface.addBackgroundContainer(application, "Add contact")
local input1 = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, nil, "Name")) local input1 = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, nil, "Name"))
local input2 = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, contacts.last, "Address")) local input2 = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, contacts.last, "Address"))
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
if input1.text and input2.text then if input1.text and input2.text then
local exists = false local exists = false
@ -255,48 +255,48 @@ mainContainer.addContactButton.onTouch = function()
end end
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.removeContactButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Remove contact")); y = y + 4 application.removeContactButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Remove contact")); y = y + 4
mainContainer.removeContactButton.onTouch = function() application.removeContactButton.onTouch = function()
if #contacts > 0 then if #contacts > 0 then
table.remove(contacts, mainContainer.contactsComboBox.selectedItem) table.remove(contacts, application.contactsComboBox.selectedItem)
updateContacts() updateContacts()
saveContacts() saveContacts()
updateButtons() updateButtons()
mainContainer:drawOnScreen() application:draw()
end end
end end
mainContainer:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Energy to dial")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2 application:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Energy to dial")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2
mainContainer.fuelProgressBar = mainContainer:addChild(GUI.progressBar(x, y, width, 0xBBBBBB, 0x0, 0xEEEEEE, 100, true, true, "", "%")); y = y + 3 application.fuelProgressBar = application:addChild(GUI.progressBar(x, y, width, 0xBBBBBB, 0x0, 0xEEEEEE, 100, true, true, "", "%")); y = y + 3
mainContainer.exitButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Exit")); y = y + 4 application.exitButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Exit")); y = y + 4
mainContainer.exitButton.onTouch = function() application.exitButton.onTouch = function()
mainContainer:stopEventHandling() application:stop()
end end
mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4) application.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "sgIrisStateChange" then if e1 == "sgIrisStateChange" then
update() update()
mainContainer:drawOnScreen() application:draw()
elseif e1 == "sgStargateStateChange" then elseif e1 == "sgStargateStateChange" then
if e3 == "Idle" or e3 == "Connected" then if e3 == "Idle" or e3 == "Connected" then
update() update()
updateChevrons(e3 == "Connected") updateChevrons(e3 == "Connected")
mainContainer:drawOnScreen() application:draw()
end end
elseif e1 == "sgChevronEngaged" then elseif e1 == "sgChevronEngaged" then
if mainContainer.chevrons[e3] then if application.chevrons[e3] then
mainContainer.chevrons[e3].isActivated = true application.chevrons[e3].isActivated = true
mainContainer.chevrons[e3].text = e4 application.chevrons[e3].text = e4
mainContainer:drawOnScreen() application:draw()
end end
elseif e1 == "sgMessageReceived" then elseif e1 == "sgMessageReceived" then
GUI.alert(e3) GUI.alert(e3)
@ -308,6 +308,5 @@ updateContacts()
update() update()
updateChevrons(stargate.stargateState() == "Connected") updateChevrons(stargate.stargateState() == "Connected")
mainContainer:draw() application:draw()
buffer.drawChanges(true) application:start()
mainContainer:startEventHandling()

View File

@ -21,7 +21,7 @@ local recent = {
-------------------------------------------------------------------- --------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 90, 23, 0xE1E1E1)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 90, 23, 0xE1E1E1))
local sidePanel = window:addChild(GUI.panel(1, 1, 17, 1, 0x2D2D2D)) local sidePanel = window:addChild(GUI.panel(1, 1, 17, 1, 0x2D2D2D))
local buttonsContainer = window:addChild(GUI.container(3, 2, 1, 1)) local buttonsContainer = window:addChild(GUI.container(3, 2, 1, 1))
@ -64,13 +64,13 @@ recentLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
recentLayout:setSpacing(1, 1, 0) recentLayout:setSpacing(1, 1, 0)
recentLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) recentLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
local function onRecentButtonTouch(mainContainer, object) local function onRecentButtonTouch(application, object)
fromChar = object.code fromChar = object.code
selectedChar = object.code selectedChar = object.code
updateChars() updateChars()
updateTexts() updateTexts()
mainContainer:drawOnScreen() application:draw()
end end
local function updateRecent() local function updateRecent()
@ -86,7 +86,7 @@ for i = 1, #recent do
step = not step step = not step
end end
local function charButtonOnTouch(mainContainer, button) local function charButtonOnTouch(application, button)
selectedChar = fromChar + button:indexOf() - 1 selectedChar = fromChar + button:indexOf() - 1
table.insert(recent, 1, selectedChar) table.insert(recent, 1, selectedChar)
table.remove(recent, #recent) table.remove(recent, #recent)
@ -95,7 +95,7 @@ local function charButtonOnTouch(mainContainer, button)
updateTexts() updateTexts()
updateRecent() updateRecent()
mainContainer:drawOnScreen() application:draw()
table.toFile(recentCharsPath, recent) table.toFile(recentCharsPath, recent)
end end
@ -131,7 +131,7 @@ window.onResize = function(width, height)
updateChars() updateChars()
updateTexts() updateTexts()
mainContainer:drawOnScreen() application:draw()
end end
local function onAny() local function onAny()
@ -147,7 +147,7 @@ nextButton.onTouch = function()
updateChars() updateChars()
updateTexts() updateTexts()
mainContainer:drawOnScreen() application:draw()
end end
prevButton.onTouch = function() prevButton.onTouch = function()
@ -156,7 +156,7 @@ prevButton.onTouch = function()
updateChars() updateChars()
updateTexts() updateTexts()
mainContainer:drawOnScreen() application:draw()
end end
local overrideWindowEventHandler = window.eventHandler local overrideWindowEventHandler = window.eventHandler
@ -180,7 +180,7 @@ gotoInput.onInputFinished = function()
updateChars() updateChars()
updateTexts() updateTexts()
mainContainer:drawOnScreen() application:draw()
end end
end end

View File

@ -29,10 +29,10 @@ end
------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------
local mainContainer = GUI.fullScreenContainer() local application = GUI.application()
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x1E1E1E)) application:addChild(GUI.panel(1, 1, application.width, application.height, 0x1E1E1E))
local actionButtons = mainContainer:addChild(GUI.actionButtons(2, 1)) local actionButtons = application:addChild(GUI.actionButtons(3, 2, true))
local layout = mainContainer:addChild(GUI.layout(1, 1, mainContainer.width, mainContainer.height, 1, 1)) local layout = application:addChild(GUI.layout(1, 1, application.width, application.height, 1, 1))
local logo = layout:addChild(GUI.image(1, 1, image.load(resourcesPath .. "Logo.pic"))) local logo = layout:addChild(GUI.image(1, 1, image.load(resourcesPath .. "Logo.pic")))
local elementWidth = image.getWidth(logo.image) local elementWidth = image.getWidth(logo.image)
@ -58,7 +58,7 @@ local infoLabel = layout:addChild(GUI.label(1, 1, elementWidth, 1, 0xFF6D40, " "
local function status(text) local function status(text)
infoLabel.text = text infoLabel.text = text
mainContainer:drawOnScreen() application:draw()
end end
local function getLanguageIndex(text, short) local function getLanguageIndex(text, short)
@ -147,7 +147,7 @@ fromLanguageAutoDetectButton.onTouch = function()
end end
actionButtons.close.onTouch = function() actionButtons.close.onTouch = function()
mainContainer:stopEventHandling() application:stop()
end end
switchButton.onTouch = function() switchButton.onTouch = function()
@ -184,8 +184,5 @@ checkLanguages()
fromComboBox.selectedItem = getLanguageIndex(config.fromLanguage, false) fromComboBox.selectedItem = getLanguageIndex(config.fromLanguage, false)
toComboBox.selectedItem = getLanguageIndex(config.toLanguage, false) toComboBox.selectedItem = getLanguageIndex(config.toLanguage, false)
mainContainer:draw() application:draw()
buffer.drawChanges(true) application:start()
mainContainer:startEventHandling()

View File

@ -72,7 +72,7 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 100, 26, 0x0)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 100, 26, 0x0))
local leftPanel = window:addChild(GUI.panel(1, 1, 1, 1, 0x0)) local leftPanel = window:addChild(GUI.panel(1, 1, 1, 1, 0x0))
local leftLayout = window:addChild(GUI.layout(1, 3, 1, 1, 1, 1)) local leftLayout = window:addChild(GUI.layout(1, 3, 1, 1, 1, 1))
@ -93,7 +93,7 @@ end
local function request(url, postData, headers) local function request(url, postData, headers)
progressIndicator.active = true progressIndicator.active = true
mainContainer:drawOnScreen() application:draw()
-- log("REQUEST URL: ", url) -- log("REQUEST URL: ", url)
@ -109,7 +109,7 @@ local function request(url, postData, headers)
data = data .. chunk data = data .. chunk
progressIndicator:roll() progressIndicator:roll()
mainContainer:drawOnScreen() application:draw()
end, end,
math.huge math.huge
) )
@ -117,7 +117,7 @@ local function request(url, postData, headers)
if success then if success then
data = json.decode(data) data = json.decode(data)
progressIndicator.active = false progressIndicator.active = false
mainContainer:drawOnScreen() application:draw()
return data return data
else else
@ -181,7 +181,7 @@ local function selectableSelect(object)
object.parent.children[i].selected = object.parent.children[i] == object object.parent.children[i].selected = object.parent.children[i] == object
end end
mainContainer:drawOnScreen() application:draw()
if object.onTouch then if object.onTouch then
contentContainer.eventHandler = nil contentContainer.eventHandler = nil
@ -189,7 +189,7 @@ local function selectableSelect(object)
end end
end end
local function selectableEventHandler(mainContainer, object, e1) local function selectableEventHandler(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
object:select() object:select()
end end
@ -237,7 +237,7 @@ local function addPizda(name)
end end
local function addScrollEventHandler(layout, regularDirection, updater) local function addScrollEventHandler(layout, regularDirection, updater)
layout.eventHandler = function(mainContainer, layout, e1, e2, e3, e4, e5) layout.eventHandler = function(application, layout, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
local cell = layout.cells[1][1] local cell = layout.cells[1][1]
@ -270,7 +270,7 @@ local function addScrollEventHandler(layout, regularDirection, updater)
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
@ -338,10 +338,10 @@ local function avatarDraw(object)
end end
end end
local function avatarEventHandler(mainContainer, object, e1) local function avatarEventHandler(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
object.selected = true object.selected = true
mainContainer:drawOnScreen() application:draw()
os.sleep(0.2) os.sleep(0.2)
@ -785,7 +785,7 @@ local function showHistory(container, peerID)
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -1197,7 +1197,7 @@ showUserProfile = function(peerID)
update() update()
end end
contentContainer.eventHandler = function(mainContainer, contentContainer, e1, e2, e3, e4, e5) contentContainer.eventHandler = function(application, contentContainer, e1, e2, e3, e4, e5)
if e1 == "scroll" then if e1 == "scroll" then
userContainer.localY = userContainer.localY + (e5 > 0 and 1 or -1) * config.scrollSpeed userContainer.localY = userContainer.localY + (e5 > 0 and 1 or -1) * config.scrollSpeed
@ -1209,7 +1209,7 @@ showUserProfile = function(peerID)
userContainer.localY = 1 userContainer.localY = 1
end end
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
@ -1319,7 +1319,7 @@ local function showFriends(peerID)
local friends = getFriends() local friends = getFriends()
if friends then if friends then
addFromList(friends) addFromList(friends)
mainContainer:drawOnScreen() application:draw()
end end
end) end)
end end
@ -1387,7 +1387,7 @@ newsSelectable.onTouch = function()
end end
end) end)
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -1494,7 +1494,7 @@ showConversations = function(peerID)
if #layout.children > 0 then if #layout.children > 0 then
layout.children[1]:select() layout.children[1]:select()
else else
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
@ -1565,7 +1565,7 @@ local function showDocuments()
end) end)
end end
mainContainer:drawOnScreen() application:draw()
end end
addPizda(localization.documents).onTouch = function() addPizda(localization.documents).onTouch = function()
@ -1630,7 +1630,7 @@ settingsSelectable.onTouch = function()
addYobaSlider(2, 50, "loadCountDocs") addYobaSlider(2, 50, "loadCountDocs")
addYobaSlider(2, 10, "scrollSpeed") addYobaSlider(2, 10, "scrollSpeed")
mainContainer:drawOnScreen() application:draw()
end end
local function login() local function login()
@ -1653,7 +1653,7 @@ local function login()
usernameInput.onInputFinished = function() usernameInput.onInputFinished = function()
loginButton.disabled = #usernameInput.text == 0 or #passwordInput.text == 0 loginButton.disabled = #usernameInput.text == 0 or #passwordInput.text == 0
mainContainer:drawOnScreen() application:draw()
end end
passwordInput.onInputFinished = usernameInput.onInputFinished passwordInput.onInputFinished = usernameInput.onInputFinished
@ -1680,7 +1680,7 @@ local function login()
lastPizda = login lastPizda = login
usernameInput.onInputFinished() usernameInput.onInputFinished()
mainContainer:drawOnScreen() application:draw()
end end
local function logout() local function logout()

View File

@ -15,7 +15,7 @@ local MineOSPaths = require("MineOSPaths")
-------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------
local mainContainer, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 130, 30, 0)) local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 130, 30, 0))
window.backgroundPanel.colors.transparency = 0.2 window.backgroundPanel.colors.transparency = 0.2
local weatherContainer = window:addChild(GUI.container(1, 1, 1, 23)) local weatherContainer = window:addChild(GUI.container(1, 1, 1, 23))
@ -124,7 +124,7 @@ local function updateForecast()
x = x + object.width + 2 x = x + object.width + 2
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
table.toFile(configPath, config) table.toFile(configPath, config)
else else
GUI.alert(result.message) GUI.alert(result.message)
@ -146,7 +146,7 @@ window.onResize = function(width, height)
end end
window:resize(window.width, window.height) window:resize(window.width, window.height)
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
if fs.exists(configPath) then if fs.exists(configPath) then
config = table.fromFile(configPath) config = table.fromFile(configPath)

198
OS.lua
View File

@ -19,7 +19,7 @@ local MineOSInterface = require("MineOSInterface")
local dockTransparency = 0.4 local dockTransparency = 0.4
local doubleTouchInterval = 0.3 local doubleTouchInterval = 0.3
local mainContainer local application
local bootUptime = computer.uptime() local bootUptime = computer.uptime()
local dateUptime = bootUptime local dateUptime = bootUptime
local screensaverUptime = bootUptime local screensaverUptime = bootUptime
@ -34,25 +34,25 @@ local doubleTouchScreenAddress
---------------------------------------- UI methods ---------------------------------------- ---------------------------------------- UI methods ----------------------------------------
function MineOSInterface.changeWallpaper() function MineOSInterface.changeWallpaper()
mainContainer.backgroundObject.wallpaper = nil application.backgroundObject.wallpaper = nil
if MineOSCore.properties.wallpaperEnabled and MineOSCore.properties.wallpaper then if MineOSCore.properties.wallpaperEnabled and MineOSCore.properties.wallpaper then
local result, reason = image.load(MineOSCore.properties.wallpaper) local result, reason = image.load(MineOSCore.properties.wallpaper)
if result then if result then
mainContainer.backgroundObject.wallpaper, result = result, nil application.backgroundObject.wallpaper, result = result, nil
-- Fit to screen size mode -- Fit to screen size mode
if MineOSCore.properties.wallpaperMode == 1 then if MineOSCore.properties.wallpaperMode == 1 then
mainContainer.backgroundObject.wallpaper = image.transform(mainContainer.backgroundObject.wallpaper, mainContainer.width, mainContainer.height) application.backgroundObject.wallpaper = image.transform(application.backgroundObject.wallpaper, application.width, application.height)
mainContainer.backgroundObject.wallpaperPosition.x, mainContainer.backgroundObject.wallpaperPosition.y = 1, 1 application.backgroundObject.wallpaperPosition.x, application.backgroundObject.wallpaperPosition.y = 1, 1
-- Centerized mode -- Centerized mode
else else
mainContainer.backgroundObject.wallpaperPosition.x = math.floor(1 + mainContainer.width / 2 - image.getWidth(mainContainer.backgroundObject.wallpaper) / 2) application.backgroundObject.wallpaperPosition.x = math.floor(1 + application.width / 2 - image.getWidth(application.backgroundObject.wallpaper) / 2)
mainContainer.backgroundObject.wallpaperPosition.y = math.floor(1 + mainContainer.height / 2 - image.getHeight(mainContainer.backgroundObject.wallpaper) / 2) application.backgroundObject.wallpaperPosition.y = math.floor(1 + application.height / 2 - image.getHeight(application.backgroundObject.wallpaper) / 2)
end end
-- Brightness adjustment -- Brightness adjustment
local backgrounds, foregrounds, r, g, b = mainContainer.backgroundObject.wallpaper[3], mainContainer.backgroundObject.wallpaper[4] local backgrounds, foregrounds, r, g, b = application.backgroundObject.wallpaper[3], application.backgroundObject.wallpaper[4]
for i = 1, #backgrounds do for i = 1, #backgrounds do
r, g, b = color.integerToRGB(backgrounds[i]) r, g, b = color.integerToRGB(backgrounds[i])
backgrounds[i] = color.RGBToInteger( backgrounds[i] = color.RGBToInteger(
@ -77,27 +77,27 @@ end
function MineOSInterface.changeResolution() function MineOSInterface.changeResolution()
buffer.setResolution(table.unpack(MineOSCore.properties.resolution or {buffer.getGPUProxy().maxResolution()})) buffer.setResolution(table.unpack(MineOSCore.properties.resolution or {buffer.getGPUProxy().maxResolution()}))
mainContainer.width, mainContainer.height = buffer.getResolution() application.width, application.height = buffer.getResolution()
mainContainer.iconField.width = mainContainer.width application.iconField.width = application.width
mainContainer.iconField.height = mainContainer.height application.iconField.height = application.height
mainContainer.iconField:updateFileList() application.iconField:updateFileList()
mainContainer.dockContainer.sort() application.dockContainer.sort()
mainContainer.dockContainer.localY = mainContainer.height - mainContainer.dockContainer.height + 1 application.dockContainer.localY = application.height - application.dockContainer.height + 1
mainContainer.menu.width = mainContainer.width application.menu.width = application.width
mainContainer.menuLayout.width = mainContainer.width application.menuLayout.width = application.width
mainContainer.backgroundObject.width, mainContainer.backgroundObject.height = mainContainer.width, mainContainer.height application.backgroundObject.width, application.backgroundObject.height = application.width, application.height
mainContainer.windowsContainer.width, mainContainer.windowsContainer.height = mainContainer.width, mainContainer.height - 1 application.windowsContainer.width, application.windowsContainer.height = application.width, application.height - 1
end end
local function moveDockIcon(index, direction) local function moveDockIcon(index, direction)
mainContainer.dockContainer.children[index], mainContainer.dockContainer.children[index + direction] = mainContainer.dockContainer.children[index + direction], mainContainer.dockContainer.children[index] application.dockContainer.children[index], application.dockContainer.children[index + direction] = application.dockContainer.children[index + direction], application.dockContainer.children[index]
mainContainer.dockContainer.sort() application.dockContainer.sort()
mainContainer.dockContainer.saveToOSSettings() application.dockContainer.saveToOSSettings()
mainContainer:drawOnScreen() application:draw()
end end
local function getPercentageColor(pecent) local function getPercentageColor(pecent)
@ -114,10 +114,10 @@ local function getPercentageColor(pecent)
end end
end end
local function dockIconEventHandler(mainContainer, icon, e1, e2, e3, e4, e5, e6, ...) local function dockIconEventHandler(application, icon, e1, e2, e3, e4, e5, e6, ...)
if e1 == "touch" then if e1 == "touch" then
icon.selected = true icon.selected = true
mainContainer:drawOnScreen() application:draw()
if e5 == 1 then if e5 == 1 then
icon.onRightClick(icon, e1, e2, e3, e4, e5, e6, ...) icon.onRightClick(icon, e1, e2, e3, e4, e5, e6, ...)
@ -128,18 +128,18 @@ local function dockIconEventHandler(mainContainer, icon, e1, e2, e3, e4, e5, e6,
end end
function MineOSInterface.createWidgets() function MineOSInterface.createWidgets()
mainContainer:removeChildren() application:removeChildren()
mainContainer.backgroundObject = mainContainer:addChild(GUI.object(1, 1, 1, 1)) application.backgroundObject = application:addChild(GUI.object(1, 1, 1, 1))
mainContainer.backgroundObject.wallpaperPosition = {x = 1, y = 1} application.backgroundObject.wallpaperPosition = {x = 1, y = 1}
mainContainer.backgroundObject.draw = function(object) application.backgroundObject.draw = function(object)
buffer.drawRectangle(object.x, object.y, object.width, object.height, MineOSCore.properties.backgroundColor, 0, " ") buffer.drawRectangle(object.x, object.y, object.width, object.height, MineOSCore.properties.backgroundColor, 0, " ")
if object.wallpaper then if object.wallpaper then
buffer.drawImage(object.wallpaperPosition.x, object.wallpaperPosition.y, object.wallpaper) buffer.drawImage(object.wallpaperPosition.x, object.wallpaperPosition.y, object.wallpaper)
end end
end end
mainContainer.iconField = mainContainer:addChild( application.iconField = application:addChild(
MineOSInterface.iconField( MineOSInterface.iconField(
1, 2, 1, 1, 3, 2, 1, 2, 1, 1, 3, 2,
0xFFFFFF, 0xFFFFFF,
@ -148,45 +148,45 @@ function MineOSInterface.createWidgets()
) )
) )
mainContainer.iconField.iconConfigEnabled = true application.iconField.iconConfigEnabled = true
mainContainer.iconField.launchers.directory = function(icon) application.iconField.launchers.directory = function(icon)
MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", icon.path) MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", icon.path)
end end
mainContainer.iconField.launchers.showContainingFolder = function(icon) application.iconField.launchers.showContainingFolder = function(icon)
MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", filesystem.path(icon.shortcutPath or icon.path)) MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", filesystem.path(icon.shortcutPath or icon.path))
end end
mainContainer.iconField.launchers.showPackageContent = function(icon) application.iconField.launchers.showPackageContent = function(icon)
MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", icon.path) MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", icon.path)
end end
mainContainer.dockContainer = mainContainer:addChild(GUI.container(1, 1, mainContainer.width, 7)) application.dockContainer = application:addChild(GUI.container(1, 1, application.width, 7))
mainContainer.dockContainer.saveToOSSettings = function() application.dockContainer.saveToOSSettings = function()
MineOSCore.properties.dockShortcuts = {} MineOSCore.properties.dockShortcuts = {}
for i = 1, #mainContainer.dockContainer.children do for i = 1, #application.dockContainer.children do
if mainContainer.dockContainer.children[i].keepInDock then if application.dockContainer.children[i].keepInDock then
table.insert(MineOSCore.properties.dockShortcuts, mainContainer.dockContainer.children[i].path) table.insert(MineOSCore.properties.dockShortcuts, application.dockContainer.children[i].path)
end end
end end
MineOSCore.saveProperties() MineOSCore.saveProperties()
end end
mainContainer.dockContainer.sort = function() application.dockContainer.sort = function()
local x = 4 local x = 4
for i = 1, #mainContainer.dockContainer.children do for i = 1, #application.dockContainer.children do
mainContainer.dockContainer.children[i].localX = x application.dockContainer.children[i].localX = x
x = x + MineOSCore.properties.iconWidth + MineOSCore.properties.iconHorizontalSpaceBetween x = x + MineOSCore.properties.iconWidth + MineOSCore.properties.iconHorizontalSpaceBetween
end end
mainContainer.dockContainer.width = #mainContainer.dockContainer.children * (MineOSCore.properties.iconWidth + MineOSCore.properties.iconHorizontalSpaceBetween) - MineOSCore.properties.iconHorizontalSpaceBetween + 6 application.dockContainer.width = #application.dockContainer.children * (MineOSCore.properties.iconWidth + MineOSCore.properties.iconHorizontalSpaceBetween) - MineOSCore.properties.iconHorizontalSpaceBetween + 6
mainContainer.dockContainer.localX = math.floor(mainContainer.width / 2 - mainContainer.dockContainer.width / 2) application.dockContainer.localX = math.floor(application.width / 2 - application.dockContainer.width / 2)
end end
mainContainer.dockContainer.addIcon = function(path, window) application.dockContainer.addIcon = function(path, window)
local icon = mainContainer.dockContainer:addChild(MineOSInterface.icon(1, 2, path, 0x2D2D2D, 0xFFFFFF)) local icon = application.dockContainer:addChild(MineOSInterface.icon(1, 2, path, 0x2D2D2D, 0xFFFFFF))
icon:analyseExtension() icon:analyseExtension()
icon:moveBackward() icon:moveBackward()
@ -203,7 +203,7 @@ function MineOSInterface.createWidgets()
icon.selected = false icon.selected = false
MineOSInterface.updateMenu() MineOSInterface.updateMenu()
mainContainer:drawOnScreen() application:draw()
else else
MineOSInterface.iconDoubleClick(icon, ...) MineOSInterface.iconDoubleClick(icon, ...)
end end
@ -211,11 +211,11 @@ function MineOSInterface.createWidgets()
icon.onRightClick = function(icon, e1, e2, e3, e4, ...) icon.onRightClick = function(icon, e1, e2, e3, e4, ...)
local indexOf = icon:indexOf() local indexOf = icon:indexOf()
local menu = GUI.addContextMenu(mainContainer, e3, e4) local menu = GUI.addContextMenu(application, e3, e4)
menu.onMenuClosed = function() menu.onMenuClosed = function()
icon.selected = false icon.selected = false
mainContainer:drawOnScreen() application:draw()
end end
if icon.windows then if icon.windows then
@ -227,7 +227,7 @@ function MineOSInterface.createWidgets()
for window in pairs(icon.windows) do for window in pairs(icon.windows) do
window:close() window:close()
end end
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -237,7 +237,7 @@ function MineOSInterface.createWidgets()
menu:addSeparator() menu:addSeparator()
menu:addItem(MineOSCore.localization.moveRight, indexOf >= #mainContainer.dockContainer.children - 1).onTouch = function() menu:addItem(MineOSCore.localization.moveRight, indexOf >= #application.dockContainer.children - 1).onTouch = function()
moveDockIcon(indexOf, 1) moveDockIcon(indexOf, 1)
end end
@ -248,37 +248,37 @@ function MineOSInterface.createWidgets()
menu:addSeparator() menu:addSeparator()
if icon.keepInDock then if icon.keepInDock then
if #mainContainer.dockContainer.children > 1 then if #application.dockContainer.children > 1 then
menu:addItem(MineOSCore.localization.removeFromDock).onTouch = function() menu:addItem(MineOSCore.localization.removeFromDock).onTouch = function()
if icon.windows then if icon.windows then
icon.keepInDock = nil icon.keepInDock = nil
else else
icon:remove() icon:remove()
mainContainer.dockContainer.sort() application.dockContainer.sort()
end end
mainContainer.dockContainer.saveToOSSettings() application.dockContainer.saveToOSSettings()
mainContainer:drawOnScreen() application:draw()
end end
end end
else else
if icon.windows then if icon.windows then
menu:addItem(MineOSCore.localization.keepInDock).onTouch = function() menu:addItem(MineOSCore.localization.keepInDock).onTouch = function()
icon.keepInDock = true icon.keepInDock = true
mainContainer.dockContainer.saveToOSSettings() application.dockContainer.saveToOSSettings()
end end
end end
end end
mainContainer:drawOnScreen() application:draw()
end end
mainContainer.dockContainer.sort() application.dockContainer.sort()
return icon return icon
end end
-- Trash -- Trash
local icon = mainContainer.dockContainer.addIcon(MineOSPaths.trash) local icon = application.dockContainer.addIcon(MineOSPaths.trash)
icon.launchers.directory = function(icon) icon.launchers.directory = function(icon)
MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", icon.path) MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", icon.path)
end end
@ -292,15 +292,15 @@ function MineOSInterface.createWidgets()
end end
icon.onRightClick = function(icon, e1, e2, e3, e4) icon.onRightClick = function(icon, e1, e2, e3, e4)
local menu = GUI.addContextMenu(mainContainer, e3, e4) local menu = GUI.addContextMenu(application, e3, e4)
menu.onMenuClosed = function() menu.onMenuClosed = function()
icon.selected = false icon.selected = false
mainContainer:drawOnScreen() application:draw()
end end
menu:addItem(MineOSCore.localization.emptyTrash).onTouch = function() menu:addItem(MineOSCore.localization.emptyTrash).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, MineOSCore.localization.areYouSure) local container = MineOSInterface.addBackgroundContainer(application, MineOSCore.localization.areYouSure)
container.layout:addChild(GUI.button(1, 1, 30, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, "OK")).onTouch = function() container.layout:addChild(GUI.button(1, 1, 30, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, "OK")).onTouch = function()
for file in filesystem.list(MineOSPaths.trash) do for file in filesystem.list(MineOSPaths.trash) do
@ -312,22 +312,22 @@ function MineOSInterface.createWidgets()
container.panel.onTouch = function() container.panel.onTouch = function()
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
mainContainer:drawOnScreen() application:draw()
end end
mainContainer:drawOnScreen() application:draw()
end end
for i = 1, #MineOSCore.properties.dockShortcuts do for i = 1, #MineOSCore.properties.dockShortcuts do
mainContainer.dockContainer.addIcon(MineOSCore.properties.dockShortcuts[i]).keepInDock = true application.dockContainer.addIcon(MineOSCore.properties.dockShortcuts[i]).keepInDock = true
end end
-- Draw dock drawDock dockDraw cyka заебался искать, блядь -- Draw dock drawDock dockDraw cyka заебался искать, блядь
local overrideDockContainerDraw = mainContainer.dockContainer.draw local overrideDockContainerDraw = application.dockContainer.draw
mainContainer.dockContainer.draw = function(dockContainer) application.dockContainer.draw = function(dockContainer)
local color, currentDockTransparency, currentDockWidth, xPos = MineOSCore.properties.dockColor, dockTransparency, dockContainer.width - 2, dockContainer.x local color, currentDockTransparency, currentDockWidth, xPos = MineOSCore.properties.dockColor, dockTransparency, dockContainer.width - 2, dockContainer.x
for y = dockContainer.y + dockContainer.height - 1, dockContainer.y + dockContainer.height - 4, -1 do for y = dockContainer.y + dockContainer.height - 1, dockContainer.y + dockContainer.height - 4, -1 do
@ -344,13 +344,13 @@ function MineOSInterface.createWidgets()
overrideDockContainerDraw(dockContainer) overrideDockContainerDraw(dockContainer)
end end
mainContainer.windowsContainer = mainContainer:addChild(GUI.container(1, 2, 1, 1)) application.windowsContainer = application:addChild(GUI.container(1, 2, 1, 1))
mainContainer.menu = mainContainer:addChild(GUI.menu(1, 1, mainContainer.width, MineOSCore.properties.menuColor, 0x696969, 0x3366CC, 0xFFFFFF)) application.menu = application:addChild(GUI.menu(1, 1, application.width, MineOSCore.properties.menuColor, 0x696969, 0x3366CC, 0xFFFFFF))
local MineOSContextMenu = mainContainer.menu:addContextMenu("MineOS", 0x000000) local MineOSContextMenu = application.menu:addContextMenu("MineOS", 0x000000)
MineOSContextMenu:addItem(MineOSCore.localization.aboutSystem).onTouch = function() MineOSContextMenu:addItem(MineOSCore.localization.aboutSystem).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(mainContainer, MineOSCore.localization.aboutSystem) local container = MineOSInterface.addBackgroundContainer(application, MineOSCore.localization.aboutSystem)
container.layout:removeChildren() container.layout:removeChildren()
local lines = { local lines = {
@ -390,7 +390,7 @@ function MineOSInterface.createWidgets()
textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
textBox.eventHandler = container.panel.eventHandler textBox.eventHandler = container.panel.eventHandler
mainContainer:drawOnScreen() application:draw()
end end
MineOSContextMenu:addItem(MineOSCore.localization.updates).onTouch = function() MineOSContextMenu:addItem(MineOSCore.localization.updates).onTouch = function()
@ -413,16 +413,16 @@ function MineOSInterface.createWidgets()
MineOSContextMenu:addItem(MineOSCore.localization.returnToShell).onTouch = function() MineOSContextMenu:addItem(MineOSCore.localization.returnToShell).onTouch = function()
MineOSNetwork.broadcastComputerState(false) MineOSNetwork.broadcastComputerState(false)
mainContainer:stopEventHandling() application:stop()
MineOSInterface.clearTerminal() MineOSInterface.clearTerminal()
os.exit() os.exit()
end end
mainContainer.menuLayout = mainContainer:addChild(GUI.layout(1, 1, 1, 1, 1, 1)) application.menuLayout = application:addChild(GUI.layout(1, 1, 1, 1, 1, 1))
mainContainer.menuLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL) application.menuLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
mainContainer.menuLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_RIGHT, GUI.ALIGNMENT_VERTICAL_TOP) application.menuLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_RIGHT, GUI.ALIGNMENT_VERTICAL_TOP)
mainContainer.menuLayout:setMargin(1, 1, 1, 0) application.menuLayout:setMargin(1, 1, 1, 0)
mainContainer.menuLayout:setSpacing(1, 1, 2) application.menuLayout:setSpacing(1, 1, 2)
local dateWidget, dateWidgetText = MineOSInterface.addMenuWidget(MineOSInterface.menuWidget(1)) local dateWidget, dateWidgetText = MineOSInterface.addMenuWidget(MineOSInterface.menuWidget(1))
dateWidget.drawContent = function() dateWidget.drawContent = function()
@ -483,34 +483,34 @@ function MineOSInterface.createWidgets()
end end
MineOSInterface.updateFileListAndDraw = function(...) MineOSInterface.updateFileListAndDraw = function(...)
mainContainer.iconField:updateFileList() application.iconField:updateFileList()
mainContainer:drawOnScreen(...) application:draw(...)
end end
local lastWindowHandled local lastWindowHandled
mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4) application.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "key_down" then if e1 == "key_down" then
local windowsCount = #mainContainer.windowsContainer.children local windowsCount = #application.windowsContainer.children
-- Ctrl or CMD -- Ctrl or CMD
if windowsCount > 0 and not lastWindowHandled and (keyboard.isKeyDown(29) or keyboard.isKeyDown(219)) then if windowsCount > 0 and not lastWindowHandled and (keyboard.isKeyDown(29) or keyboard.isKeyDown(219)) then
-- W -- W
if e4 == 17 then if e4 == 17 then
mainContainer.windowsContainer.children[windowsCount]:close() application.windowsContainer.children[windowsCount]:close()
lastWindowHandled = true lastWindowHandled = true
mainContainer:drawOnScreen() application:draw()
-- H -- H
elseif e4 == 35 then elseif e4 == 35 then
local lastUnhiddenWindowIndex = 1 local lastUnhiddenWindowIndex = 1
for i = 1, #mainContainer.windowsContainer.children do for i = 1, #application.windowsContainer.children do
if not mainContainer.windowsContainer.children[i].hidden then if not application.windowsContainer.children[i].hidden then
lastUnhiddenWindowIndex = i lastUnhiddenWindowIndex = i
end end
end end
mainContainer.windowsContainer.children[lastUnhiddenWindowIndex]:minimize() application.windowsContainer.children[lastUnhiddenWindowIndex]:minimize()
lastWindowHandled = true lastWindowHandled = true
mainContainer:drawOnScreen() application:draw()
end end
end end
elseif lastWindowHandled and e1 == "key_up" and (e4 == 17 or e4 == 35) then elseif lastWindowHandled and e1 == "key_up" and (e4 == 17 or e4 == 35) then
@ -522,7 +522,7 @@ function MineOSInterface.createWidgets()
MineOSInterface.updateFileListAndDraw(true) MineOSInterface.updateFileListAndDraw(true)
elseif e2 == "updateWallpaper" then elseif e2 == "updateWallpaper" then
MineOSInterface.changeWallpaper() MineOSInterface.changeWallpaper()
mainContainer:drawOnScreen() application:draw()
end end
elseif e1 == "MineOSNetwork" then elseif e1 == "MineOSNetwork" then
if e2 == "accessDenied" then if e2 == "accessDenied" then
@ -534,7 +534,7 @@ function MineOSInterface.createWidgets()
if computer.uptime() - dateUptime >= 1 then if computer.uptime() - dateUptime >= 1 then
MineOSCore.updateTime() MineOSCore.updateTime()
mainContainer:drawOnScreen() application:draw()
dateUptime = computer.uptime() dateUptime = computer.uptime()
end end
@ -546,7 +546,7 @@ function MineOSInterface.createWidgets()
if dateUptime - screensaverUptime >= MineOSCore.properties.screensaverDelay then if dateUptime - screensaverUptime >= MineOSCore.properties.screensaverDelay then
if filesystem.exists(MineOSCore.properties.screensaver) then if filesystem.exists(MineOSCore.properties.screensaver) then
MineOSInterface.safeLaunch(MineOSCore.properties.screensaver) MineOSInterface.safeLaunch(MineOSCore.properties.screensaver)
mainContainer:drawOnScreen(true) application:draw(true)
end end
screensaverUptime = computer.uptime() screensaverUptime = computer.uptime()
@ -554,7 +554,7 @@ function MineOSInterface.createWidgets()
end end
end end
MineOSInterface.menuInitialChildren = mainContainer.menu.children MineOSInterface.menuInitialChildren = application.menu.children
end end
---------------------------------------- Main loop ---------------------------------------- ---------------------------------------- Main loop ----------------------------------------
@ -571,8 +571,8 @@ end
-- Creates OS main container and all its widgets -- Creates OS main container and all its widgets
local function createWidgets() local function createWidgets()
mainContainer = GUI.fullScreenContainer() application = GUI.application()
MineOSInterface.mainContainer = mainContainer MineOSInterface.application = application
MineOSInterface.createWidgets() MineOSInterface.createWidgets()
MineOSInterface.changeResolution() MineOSInterface.changeResolution()
@ -611,15 +611,15 @@ MineOSCore.localization = MineOSCore.getLocalization(MineOSPaths.localizationFil
-- Tasks and UI initialization -- Tasks and UI initialization
runTasks(2) runTasks(2)
createWidgets() createWidgets()
mainContainer:drawOnScreen() application:draw()
MineOSNetwork.update() MineOSNetwork.update()
runTasks(1) runTasks(1)
-- Loops with UI regeneration after errors -- Loops with UI regeneration after errors
while true do while true do
local success, path, line, traceback = MineOSCore.call( local success, path, line, traceback = MineOSCore.call(
mainContainer.startEventHandling, application.start,
mainContainer, application,
0 0
) )
@ -627,8 +627,8 @@ while true do
break break
else else
createWidgets() createWidgets()
mainContainer:drawOnScreen() application:draw()
MineOSInterface.showErrorWindow(path, line, traceback) MineOSInterface.showErrorWindow(path, line, traceback)
mainContainer:drawOnScreen() application:draw()
end end
end end

View File

@ -34,8 +34,8 @@ function MineOSInterface.setIconProperties(width, height, horizontalSpaceBetween
MineOSCore.saveProperties() MineOSCore.saveProperties()
calculateIconSizes() calculateIconSizes()
MineOSInterface.mainContainer.iconField:deleteIconConfig() MineOSInterface.application.iconField:deleteIconConfig()
MineOSInterface.mainContainer.dockContainer.sort() MineOSInterface.application.dockContainer.sort()
computer.pushSignal("MineOSCore", "updateFileList") computer.pushSignal("MineOSCore", "updateFileList")
end end
@ -159,7 +159,7 @@ local function iconDraw(icon)
end end
end end
local function iconEventHandler(mainContainer, object, e1, e2, e3, e4, e5, ...) local function iconEventHandler(application, object, e1, e2, e3, e4, e5, ...)
if e1 == "touch" and object:isPointInside(e3, e4) then if e1 == "touch" and object:isPointInside(e3, e4) then
object.lastTouchPosition = object.lastTouchPosition or {} object.lastTouchPosition = object.lastTouchPosition or {}
object.lastTouchPosition.x, object.lastTouchPosition.y = e3, e4 object.lastTouchPosition.x, object.lastTouchPosition.y = e3, e4
@ -179,7 +179,7 @@ local function iconEventHandler(mainContainer, object, e1, e2, e3, e4, e5, ...)
object.localY = object.localY + e4 - object.lastTouchPosition.y object.localY = object.localY + e4 - object.lastTouchPosition.y
object.lastTouchPosition.x, object.lastTouchPosition.y = e3, e4 object.lastTouchPosition.x, object.lastTouchPosition.y = e3, e4
mainContainer:drawOnScreen() application:draw()
elseif e1 == "drop" and object.parent.parent.iconConfigEnabled and object.dragStarted then elseif e1 == "drop" and object.parent.parent.iconConfigEnabled and object.dragStarted then
object.dragStarted = nil object.dragStarted = nil
object.parent.parent.iconConfig[object.name .. (object.isDirectory and "/" or "")] = { object.parent.parent.iconConfig[object.name .. (object.isDirectory and "/" or "")] = {
@ -365,13 +365,13 @@ end
function MineOSInterface.iconLaunchers.showPackageContent(icon) function MineOSInterface.iconLaunchers.showPackageContent(icon)
icon.parent.parent:setWorkpath(icon.path) icon.parent.parent:setWorkpath(icon.path)
icon.parent.parent:updateFileList() icon.parent.parent:updateFileList()
icon.firstParent:drawOnScreen() icon.firstParent:draw()
end end
function MineOSInterface.iconLaunchers.showContainingFolder(icon) function MineOSInterface.iconLaunchers.showContainingFolder(icon)
icon.parent.parent:setWorkpath(fs.path(icon.shortcutPath)) icon.parent.parent:setWorkpath(fs.path(icon.shortcutPath))
icon.parent.parent:updateFileList() icon.parent.parent:updateFileList()
icon.firstParent:drawOnScreen() icon.firstParent:draw()
end end
----------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------
@ -474,7 +474,7 @@ local function iconFieldUpdateFileList(iconField)
return iconField return iconField
end end
local function iconFieldBackgroundObjectEventHandler(mainContainer, object, e1, e2, e3, e4, e5, ...) local function iconFieldBackgroundObjectEventHandler(application, object, e1, e2, e3, e4, e5, ...)
if e1 == "touch" then if e1 == "touch" then
if e5 == 0 then if e5 == 0 then
object.parent:deselectAll() object.parent:deselectAll()
@ -483,28 +483,28 @@ local function iconFieldBackgroundObjectEventHandler(mainContainer, object, e1,
y1 = e4 y1 = e4
} }
mainContainer:drawOnScreen() application:draw()
else else
local menu = GUI.addContextMenu(MineOSInterface.mainContainer, e3, e4) local menu = GUI.addContextMenu(MineOSInterface.application, e3, e4)
local subMenu = menu:addSubMenu(MineOSCore.localization.create) local subMenu = menu:addSubMenu(MineOSCore.localization.create)
subMenu:addItem(MineOSCore.localization.newFile).onTouch = function() subMenu:addItem(MineOSCore.localization.newFile).onTouch = function()
MineOSInterface.newFile(MineOSInterface.mainContainer, object.parent, e3, e4, object.parent.workpath) MineOSInterface.newFile(MineOSInterface.application, object.parent, e3, e4, object.parent.workpath)
end end
subMenu:addItem(MineOSCore.localization.newFolder).onTouch = function() subMenu:addItem(MineOSCore.localization.newFolder).onTouch = function()
MineOSInterface.newFolder(MineOSInterface.mainContainer, object.parent, e3, e4, object.parent.workpath) MineOSInterface.newFolder(MineOSInterface.application, object.parent, e3, e4, object.parent.workpath)
end end
subMenu:addItem(MineOSCore.localization.newFileFromURL, not component.isAvailable("internet")).onTouch = function() subMenu:addItem(MineOSCore.localization.newFileFromURL, not component.isAvailable("internet")).onTouch = function()
MineOSInterface.newFileFromURL(MineOSInterface.mainContainer, object.parent, e3, e4, object.parent.workpath) MineOSInterface.newFileFromURL(MineOSInterface.application, object.parent, e3, e4, object.parent.workpath)
end end
subMenu:addSeparator() subMenu:addSeparator()
subMenu:addItem(MineOSCore.localization.newApplication).onTouch = function() subMenu:addItem(MineOSCore.localization.newApplication).onTouch = function()
MineOSInterface.newApplication(MineOSInterface.mainContainer, object.parent, e3, e4, object.parent.workpath) MineOSInterface.newApplication(MineOSInterface.application, object.parent, e3, e4, object.parent.workpath)
end end
menu:addSeparator() menu:addSeparator()
@ -568,20 +568,20 @@ local function iconFieldBackgroundObjectEventHandler(mainContainer, object, e1,
computer.pushSignal("MineOSCore", "updateFileList") computer.pushSignal("MineOSCore", "updateFileList")
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
elseif e1 == "drag" then elseif e1 == "drag" then
if object.parent.selection then if object.parent.selection then
object.parent.selection.x2, object.parent.selection.y2 = e3, e4 object.parent.selection.x2, object.parent.selection.y2 = e3, e4
object:moveToFront() object:moveToFront()
mainContainer:drawOnScreen() application:draw()
end end
elseif e1 == "drop" then elseif e1 == "drop" then
object.parent.selection = nil object.parent.selection = nil
object:moveToBack() object:moveToBack()
mainContainer:drawOnScreen() application:draw()
end end
end end
@ -690,26 +690,26 @@ function MineOSInterface.iconLeftClick(icon)
end end
icon.selected = true icon.selected = true
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
function MineOSInterface.iconDoubleClick(icon) function MineOSInterface.iconDoubleClick(icon)
icon:launch() icon:launch()
icon.selected = false icon.selected = false
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4) function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
icon.selected = true icon.selected = true
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
local selectedIcons = icon.parent.parent:getSelectedIcons() local selectedIcons = icon.parent.parent:getSelectedIcons()
local menu = GUI.addContextMenu(MineOSInterface.mainContainer, e3, e4) local menu = GUI.addContextMenu(MineOSInterface.application, e3, e4)
menu.onMenuClosed = function() menu.onMenuClosed = function()
icon.parent.parent:deselectAll() icon.parent.parent:deselectAll()
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
if #selectedIcons == 1 then if #selectedIcons == 1 then
@ -720,7 +720,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
end end
menu:addItem(MineOSCore.localization.launchWithArguments).onTouch = function() menu:addItem(MineOSCore.localization.launchWithArguments).onTouch = function()
MineOSInterface.launchWithArguments(MineOSInterface.mainContainer, icon.path .. "Main.lua") MineOSInterface.launchWithArguments(MineOSInterface.application, icon.path .. "Main.lua")
end end
menu:addItem(MineOSCore.localization.edit .. " Main.lua").onTouch = function() menu:addItem(MineOSCore.localization.edit .. " Main.lua").onTouch = function()
@ -732,17 +732,17 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
if icon.extension ~= ".app" then if icon.extension ~= ".app" then
menu:addItem(MineOSCore.localization.addToFavourites).onTouch = function() menu:addItem(MineOSCore.localization.addToFavourites).onTouch = function()
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.addToFavourites) local container = MineOSInterface.addBackgroundContainer(MineOSInterface.application, MineOSCore.localization.addToFavourites)
local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, icon.name, MineOSCore.localization.name)) local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, icon.name, MineOSCore.localization.name))
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
container:remove() container:remove()
if e1 == "touch" and #input.text > 0 then if e1 == "touch" and #input.text > 0 then
computer.pushSignal("Finder", "updateFavourites", {name = input.text, path = icon.path}) computer.pushSignal("Finder", "updateFavourites", {name = input.text, path = icon.path})
else else
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
end end
@ -752,7 +752,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
else else
if icon.isShortcut then if icon.isShortcut then
menu:addItem(MineOSCore.localization.editShortcut).onTouch = function() menu:addItem(MineOSCore.localization.editShortcut).onTouch = function()
MineOSInterface.editShortcut(MineOSInterface.mainContainer, icon.path) MineOSInterface.editShortcut(MineOSInterface.application, icon.path)
computer.pushSignal("MineOSCore", "updateFileList") computer.pushSignal("MineOSCore", "updateFileList")
end end
@ -780,7 +780,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
if #selectedIcons > 1 then if #selectedIcons > 1 then
menu:addItem(MineOSCore.localization.newFolderFromChosen .. " (" .. #selectedIcons .. ")").onTouch = function() menu:addItem(MineOSCore.localization.newFolderFromChosen .. " (" .. #selectedIcons .. ")").onTouch = function()
MineOSInterface.newFolderFromChosen(MineOSInterface.mainContainer, icon.parent.parent, e3, e4, selectedIcons) MineOSInterface.newFolderFromChosen(MineOSInterface.application, icon.parent.parent, e3, e4, selectedIcons)
end end
menu:addSeparator() menu:addSeparator()
end end
@ -851,7 +851,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
if #selectedIcons == 1 then if #selectedIcons == 1 then
menu:addItem(MineOSCore.localization.rename).onTouch = function() menu:addItem(MineOSCore.localization.rename).onTouch = function()
MineOSInterface.rename(MineOSInterface.mainContainer, icon.path) MineOSInterface.rename(MineOSInterface.application, icon.path)
end end
end end
@ -877,8 +877,8 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
if #selectedIcons == 1 then if #selectedIcons == 1 then
menu:addItem(MineOSCore.localization.addToDock).onTouch = function() menu:addItem(MineOSCore.localization.addToDock).onTouch = function()
MineOSInterface.mainContainer.dockContainer.addIcon(icon.path).keepInDock = true MineOSInterface.application.dockContainer.addIcon(icon.path).keepInDock = true
MineOSInterface.mainContainer.dockContainer.saveToOSSettings() MineOSInterface.application.dockContainer.saveToOSSettings()
end end
end end
@ -888,7 +888,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
end end
end end
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
----------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------
@ -914,7 +914,7 @@ end
local function checkFileToExists(container, path) local function checkFileToExists(container, path)
if fs.exists(path) then if fs.exists(path) then
container.label.hidden = false container.label.hidden = false
container.parent:drawOnScreen() container.parent:draw()
else else
container:remove() container:remove()
return true return true
@ -941,7 +941,7 @@ function MineOSInterface.newFile(parentWindow, iconField, x, y, path)
end end
end end
parentWindow:drawOnScreen() parentWindow:draw()
end end
function MineOSInterface.newFolder(parentWindow, iconField, x, y, path) function MineOSInterface.newFolder(parentWindow, iconField, x, y, path)
@ -955,7 +955,7 @@ function MineOSInterface.newFolder(parentWindow, iconField, x, y, path)
end end
end end
parentWindow:drawOnScreen() parentWindow:draw()
return container return container
end end
@ -964,16 +964,16 @@ function MineOSInterface.newFileFromURL(parentWindow, iconField, x, y, path)
local container = addUniversalContainerWithInputTextBox(parentWindow, nil, "Загрузить файл по URL", MineOSCore.localization.fileName) local container = addUniversalContainerWithInputTextBox(parentWindow, nil, "Загрузить файл по URL", MineOSCore.localization.fileName)
container.inputFieldURL = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, nil, "URL", false)) container.inputFieldURL = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, nil, "URL", false))
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
if #container.inputField.text > 0 and #container.inputFieldURL.text > 0 then if #container.inputField.text > 0 and #container.inputFieldURL.text > 0 then
if fs.exists(path .. container.inputField.text) then if fs.exists(path .. container.inputField.text) then
container.label.hidden = false container.label.hidden = false
mainContainer:drawOnScreen() application:draw()
else else
container.layout:removeChildren(2) container.layout:removeChildren(2)
container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x787878, MineOSCore.localization.downloading .. "...")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) container.layout:addChild(GUI.label(1, 1, container.width, 1, 0x787878, MineOSCore.localization.downloading .. "...")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
mainContainer:drawOnScreen() application:draw()
local success, reason = require("web").download(container.inputFieldURL.text, path .. container.inputField.text) local success, reason = require("web").download(container.inputFieldURL.text, path .. container.inputField.text)
container:remove() container:remove()
@ -983,17 +983,17 @@ function MineOSInterface.newFileFromURL(parentWindow, iconField, x, y, path)
computer.pushSignal("MineOSCore", "updateFileList") computer.pushSignal("MineOSCore", "updateFileList")
else else
GUI.alert(reason) GUI.alert(reason)
mainContainer:drawOnScreen() application:draw()
end end
end end
else else
container:remove() container:remove()
mainContainer:drawOnScreen() application:draw()
end end
end end
end end
parentWindow:drawOnScreen() parentWindow:draw()
end end
function MineOSInterface.newApplication(parentWindow, iconField, x, y, path) function MineOSInterface.newApplication(parentWindow, iconField, x, y, path)
@ -1003,7 +1003,7 @@ function MineOSInterface.newApplication(parentWindow, iconField, x, y, path)
filesystemChooser:addExtensionFilter(".pic") filesystemChooser:addExtensionFilter(".pic")
filesystemChooser:moveBackward() filesystemChooser:moveBackward()
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
if #container.inputField.text > 0 then if #container.inputField.text > 0 then
local finalPath = path .. container.inputField.text .. ".app/" local finalPath = path .. container.inputField.text .. ".app/"
@ -1021,12 +1021,12 @@ function MineOSInterface.newApplication(parentWindow, iconField, x, y, path)
end end
else else
container:remove() container:remove()
parentWindow:drawOnScreen() parentWindow:draw()
end end
end end
end end
parentWindow:drawOnScreen() parentWindow:draw()
end end
function MineOSInterface.newFolderFromChosen(parentWindow, iconField, x, y, selectedIcons) function MineOSInterface.newFolderFromChosen(parentWindow, iconField, x, y, selectedIcons)
@ -1045,7 +1045,7 @@ function MineOSInterface.newFolderFromChosen(parentWindow, iconField, x, y, sele
end end
end end
parentWindow:drawOnScreen() parentWindow:draw()
return container return container
end end
@ -1060,7 +1060,7 @@ function MineOSInterface.rename(parentWindow, path)
end end
end end
parentWindow:drawOnScreen() parentWindow:draw()
end end
function MineOSInterface.editShortcut(parentWindow, path) function MineOSInterface.editShortcut(parentWindow, path)
@ -1075,17 +1075,17 @@ function MineOSInterface.editShortcut(parentWindow, path)
else else
container.label.text = MineOSCore.localization.shortcutIsCorrupted container.label.text = MineOSCore.localization.shortcutIsCorrupted
container.label.hidden = false container.label.hidden = false
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
parentWindow:drawOnScreen() parentWindow:draw()
end end
function MineOSInterface.launchWithArguments(parentWindow, path, withTerminal) function MineOSInterface.launchWithArguments(parentWindow, path, withTerminal)
local container = addUniversalContainerWithInputTextBox(parentWindow, nil, MineOSCore.localization.launchWithArguments) local container = addUniversalContainerWithInputTextBox(parentWindow, nil, MineOSCore.localization.launchWithArguments)
container.panel.eventHandler = function(mainContainer, object, e1) container.panel.eventHandler = function(application, object, e1)
if e1 == "touch" then if e1 == "touch" then
local args = {} local args = {}
if container.inputField.text then if container.inputField.text then
@ -1105,7 +1105,7 @@ function MineOSInterface.launchWithArguments(parentWindow, path, withTerminal)
MineOSInterface.safeLaunch(path, table.unpack(args)) MineOSInterface.safeLaunch(path, table.unpack(args))
end end
parentWindow:drawOnScreen(true) parentWindow:draw(true)
end end
end end
end end
@ -1113,18 +1113,18 @@ end
----------------------------------------- Windows patterns ----------------------------------------- ----------------------------------------- Windows patterns -----------------------------------------
function MineOSInterface.updateMenu() function MineOSInterface.updateMenu()
local focusedWindow = MineOSInterface.mainContainer.windowsContainer.children[#MineOSInterface.mainContainer.windowsContainer.children] local focusedWindow = MineOSInterface.application.windowsContainer.children[#MineOSInterface.application.windowsContainer.children]
MineOSInterface.mainContainer.menu.children = focusedWindow and focusedWindow.menu.children or MineOSInterface.menuInitialChildren MineOSInterface.application.menu.children = focusedWindow and focusedWindow.menu.children or MineOSInterface.menuInitialChildren
end end
function MineOSInterface.addWindow(window, preserveCoordinates) function MineOSInterface.addWindow(window, preserveCoordinates)
-- Чекаем коорды -- Чекаем коорды
if not preserveCoordinates then if not preserveCoordinates then
window.x, window.y = math.floor(MineOSInterface.mainContainer.windowsContainer.width / 2 - window.width / 2), math.floor(MineOSInterface.mainContainer.windowsContainer.height / 2 - window.height / 2) window.x, window.y = math.floor(MineOSInterface.application.windowsContainer.width / 2 - window.width / 2), math.floor(MineOSInterface.application.windowsContainer.height / 2 - window.height / 2)
end end
-- Ебурим окно к окнам -- Ебурим окно к окнам
MineOSInterface.mainContainer.windowsContainer:addChild(window) MineOSInterface.application.windowsContainer:addChild(window)
-- Получаем путь залупы -- Получаем путь залупы
local dockPath, info, dockIcon local dockPath, info, dockIcon
@ -1147,14 +1147,14 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
-- GUI.alert(dockPath) -- GUI.alert(dockPath)
-- Чекаем наличие иконки в доке с таким же путем, и еси ее нет, то хуячим новую -- Чекаем наличие иконки в доке с таким же путем, и еси ее нет, то хуячим новую
for i = 1, #MineOSInterface.mainContainer.dockContainer.children do for i = 1, #MineOSInterface.application.dockContainer.children do
if MineOSInterface.mainContainer.dockContainer.children[i].path == dockPath then if MineOSInterface.application.dockContainer.children[i].path == dockPath then
dockIcon = MineOSInterface.mainContainer.dockContainer.children[i] dockIcon = MineOSInterface.application.dockContainer.children[i]
break break
end end
end end
if not dockIcon then if not dockIcon then
dockIcon = MineOSInterface.mainContainer.dockContainer.addIcon(dockPath, window) dockIcon = MineOSInterface.application.dockContainer.addIcon(dockPath, window)
end end
-- Ебурим ссылку на окна в иконку -- Ебурим ссылку на окна в иконку
@ -1163,7 +1163,7 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
-- Взалупливаем иконке индивидуальную менюху. По дефолту тут всякая хуйня и прочее -- Взалупливаем иконке индивидуальную менюху. По дефолту тут всякая хуйня и прочее
window.menu = GUI.menu(1, 1, 1) window.menu = GUI.menu(1, 1, 1)
window.menu.colors = MineOSInterface.mainContainer.menu.colors window.menu.colors = MineOSInterface.application.menu.colors
local name = fs.hideExtension(fs.name(dockPath)) local name = fs.hideExtension(fs.name(dockPath))
local contextMenu = window.menu:addContextMenu(name, 0x0) local contextMenu = window.menu:addContextMenu(name, 0x0)
contextMenu:addItem(MineOSCore.localization.closeWindow .. " " .. name, false, "^W").onTouch = function() contextMenu:addItem(MineOSCore.localization.closeWindow .. " " .. name, false, "^W").onTouch = function()
@ -1172,14 +1172,14 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
-- Смещаем окно правее и ниже, если уже есть открытые окна этой софтины -- Смещаем окно правее и ниже, если уже есть открытые окна этой софтины
local lastIndex local lastIndex
for i = #MineOSInterface.mainContainer.windowsContainer.children, 1, -1 do for i = #MineOSInterface.application.windowsContainer.children, 1, -1 do
if MineOSInterface.mainContainer.windowsContainer.children[i] ~= window and dockIcon.windows[MineOSInterface.mainContainer.windowsContainer.children[i]] then if MineOSInterface.application.windowsContainer.children[i] ~= window and dockIcon.windows[MineOSInterface.application.windowsContainer.children[i]] then
lastIndex = i lastIndex = i
break break
end end
end end
if lastIndex then if lastIndex then
window.localX, window.localY = MineOSInterface.mainContainer.windowsContainer.children[lastIndex].localX + 4, MineOSInterface.mainContainer.windowsContainer.children[lastIndex].localY + 2 window.localX, window.localY = MineOSInterface.application.windowsContainer.children[lastIndex].localX + 4, MineOSInterface.application.windowsContainer.children[lastIndex].localY + 2
end end
-- Когда окно фокусицца, то главная ОСевая менюха заполницца ДЕТИШЕЧКАМИ оконной менюхи -- Когда окно фокусицца, то главная ОСевая менюха заполницца ДЕТИШЕЧКАМИ оконной менюхи
@ -1188,13 +1188,13 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
-- Биндим функции по ресайзу/закрытию и прочему говнищу -- Биндим функции по ресайзу/закрытию и прочему говнищу
window.close = function(window) window.close = function(window)
local sameIconExists = false local sameIconExists = false
for i = 1, #MineOSInterface.mainContainer.dockContainer.children do for i = 1, #MineOSInterface.application.dockContainer.children do
if if
MineOSInterface.mainContainer.dockContainer.children[i].path == dockPath and MineOSInterface.application.dockContainer.children[i].path == dockPath and
MineOSInterface.mainContainer.dockContainer.children[i].windows and MineOSInterface.application.dockContainer.children[i].windows and
table.size(MineOSInterface.mainContainer.dockContainer.children[i].windows) > 1 table.size(MineOSInterface.application.dockContainer.children[i].windows) > 1
then then
MineOSInterface.mainContainer.dockContainer.children[i].windows[window] = nil MineOSInterface.application.dockContainer.children[i].windows[window] = nil
sameIconExists = true sameIconExists = true
break break
end end
@ -1204,7 +1204,7 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
dockIcon.windows = nil dockIcon.windows = nil
if not dockIcon.keepInDock then if not dockIcon.keepInDock then
dockIcon:remove() dockIcon:remove()
MineOSInterface.mainContainer.dockContainer.sort() MineOSInterface.application.dockContainer.sort()
end end
end end
@ -1227,7 +1227,7 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
MineOSInterface.updateMenu() MineOSInterface.updateMenu()
return MineOSInterface.mainContainer, window, window.menu return MineOSInterface.application, window, window.menu
end end
----------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------
@ -1238,7 +1238,7 @@ local function addKeyAndValue(window, x, y, key, value)
end end
function MineOSInterface.propertiesWindow(x, y, width, icon) function MineOSInterface.propertiesWindow(x, y, width, icon)
local mainContainer, window = MineOSInterface.addWindow(GUI.titledWindow(x, y, width, 1, package.loaded.MineOSCore.localization.properties)) local application, window = MineOSInterface.addWindow(GUI.titledWindow(x, y, width, 1, package.loaded.MineOSCore.localization.properties))
window.backgroundPanel.colors.transparency = 0.2 window.backgroundPanel.colors.transparency = 0.2
window:addChild(GUI.image(2, 3, icon.image)) window:addChild(GUI.image(2, 3, icon.image))
@ -1259,20 +1259,20 @@ function MineOSInterface.propertiesWindow(x, y, width, icon)
window.backgroundPanel.width = window.width window.backgroundPanel.width = window.width
window.backgroundPanel.height = textBox.y + textBox.height window.backgroundPanel.height = textBox.y + textBox.height
mainContainer:drawOnScreen() application:draw()
if icon.isDirectory then if icon.isDirectory then
fileSizeLabel.text = string.format("%.2f", fs.directorySize(icon.path) / 1024) .. " KB" fileSizeLabel.text = string.format("%.2f", fs.directorySize(icon.path) / 1024) .. " KB"
mainContainer:drawOnScreen() application:draw()
end end
end end
----------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------
local function GUICopy(parentContainer, fileList, toPath) local function GUICopy(application, fileList, toPath)
local applyYes, breakRecursion local applyYes, breakRecursion
local container = MineOSInterface.addBackgroundContainer(parentContainer, MineOSCore.localization.copying) local container = MineOSInterface.addBackgroundContainer(application, MineOSCore.localization.copying)
local textBox = container.layout:addChild(GUI.textBox(1, 1, container.width, 1, nil, 0x787878, {}, 1, 0, 0, true, true):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)) local textBox = container.layout:addChild(GUI.textBox(1, 1, container.width, 1, nil, 0x787878, {}, 1, 0, 0, true, true):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP))
local switchAndLabel = container.layout:addChild(GUI.switchAndLabel(1, 1, 37, 8, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x787878, MineOSCore.localization.applyToAll .. ":", false)) local switchAndLabel = container.layout:addChild(GUI.switchAndLabel(1, 1, 37, 8, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x787878, MineOSCore.localization.applyToAll .. ":", false))
container.panel.eventHandler = nil container.panel.eventHandler = nil
@ -1283,14 +1283,14 @@ local function GUICopy(parentContainer, fileList, toPath)
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, MineOSCore.localization.yes)).onTouch = function() buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, MineOSCore.localization.yes)).onTouch = function()
applyYes = true applyYes = true
parentContainer:stopEventHandling() application:stop()
end end
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, MineOSCore.localization.no)).onTouch = function() buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, MineOSCore.localization.no)).onTouch = function()
parentContainer:stopEventHandling() application:stop()
end end
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, MineOSCore.localization.cancel)).onTouch = function() buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, MineOSCore.localization.cancel)).onTouch = function()
breakRecursion = true breakRecursion = true
parentContainer:stopEventHandling() application:stop()
end end
buttonsLayout:fitToChildrenSize(1, 1) buttonsLayout:fitToChildrenSize(1, 1)
@ -1304,7 +1304,7 @@ local function GUICopy(parentContainer, fileList, toPath)
} }
textBox:update() textBox:update()
parentContainer:drawOnScreen() application:draw()
fs.remove(finalPath) fs.remove(finalPath)
fs.copy(path, finalPath) fs.copy(path, finalPath)
@ -1335,9 +1335,9 @@ local function GUICopy(parentContainer, fileList, toPath)
} }
textBox:update() textBox:update()
parentContainer:drawOnScreen() application:draw()
parentContainer:startEventHandling() application:start()
parentContainer:drawOnScreen() application:draw()
end end
if applyYes then if applyYes then
@ -1354,7 +1354,7 @@ local function GUICopy(parentContainer, fileList, toPath)
end end
container:remove() container:remove()
parentContainer:drawOnScreen() application:draw()
end end
function MineOSInterface.copy(what, toPath) function MineOSInterface.copy(what, toPath)
@ -1362,18 +1362,18 @@ function MineOSInterface.copy(what, toPath)
what = {what} what = {what}
end end
GUICopy(MineOSInterface.mainContainer, what, toPath) GUICopy(MineOSInterface.application, what, toPath)
end end
local function menuWidgetEventHandler(mainContainer, object, e1, ...) local function menuWidgetEventHandler(application, object, e1, ...)
if e1 == "touch" and object.onTouch then if e1 == "touch" and object.onTouch then
object.selected = true object.selected = true
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
object.onTouch(mainContainer, object, e1, ...) object.onTouch(application, object, e1, ...)
object.selected = false object.selected = false
MineOSInterface.mainContainer:drawOnScreen() MineOSInterface.application:draw()
end end
end end
@ -1399,7 +1399,7 @@ function MineOSInterface.menuWidget(width)
end end
function MineOSInterface.addMenuWidget(object) function MineOSInterface.addMenuWidget(object)
MineOSInterface.mainContainer.menuLayout:addChild(object) MineOSInterface.application.menuLayout:addChild(object)
object:moveToBack() object:moveToBack()
return object return object
@ -1408,17 +1408,17 @@ end
----------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------
function MineOSInterface.showErrorWindow(path, line, traceback) function MineOSInterface.showErrorWindow(path, line, traceback)
local mainContainer = GUI.container(1, 1, buffer.getWidth(), math.floor(buffer.getHeight() * 0.5)) local application = GUI.application(1, 1, buffer.getWidth(), math.floor(buffer.getHeight() * 0.5))
mainContainer.y = math.floor(buffer.getHeight() / 2 - mainContainer.height / 2) application.y = math.floor(buffer.getHeight() / 2 - application.height / 2)
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, 3, 0x383838)) application:addChild(GUI.panel(1, 1, application.width, 3, 0x383838))
mainContainer:addChild(GUI.label(1, 2, mainContainer.width, 1, 0xFFFFFF, MineOSCore.localization.errorWhileRunningProgram .. "\"" .. fs.name(path) .. "\"")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP) application:addChild(GUI.label(1, 2, application.width, 1, 0xFFFFFF, MineOSCore.localization.errorWhileRunningProgram .. "\"" .. fs.name(path) .. "\"")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
local actionButtons = mainContainer:addChild(GUI.actionButtons(2, 2, false)) local actionButtons = application:addChild(GUI.actionButtons(2, 2, false))
local sendToDeveloperButton = mainContainer:addChild(GUI.adaptiveButton(9, 1, 2, 1, 0x444444, 0xFFFFFF, 0x343434, 0xFFFFFF, MineOSCore.localization.sendFeedback)) local sendToDeveloperButton = application:addChild(GUI.adaptiveButton(9, 1, 2, 1, 0x444444, 0xFFFFFF, 0x343434, 0xFFFFFF, MineOSCore.localization.sendFeedback))
local codeView = mainContainer:addChild(GUI.codeView(1, 4, math.floor(mainContainer.width * 0.62), mainContainer.height - 3, 1, 1, 100, {}, {[line] = 0xFF4444}, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, true, {})) local codeView = application:addChild(GUI.codeView(1, 4, math.floor(application.width * 0.62), application.height - 3, 1, 1, 100, {}, {[line] = 0xFF4444}, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, true, {}))
codeView.fromLine = line - math.floor((mainContainer.height - 3) / 2) + 1 codeView.fromLine = line - math.floor((application.height - 3) / 2) + 1
if codeView.fromLine <= 0 then if codeView.fromLine <= 0 then
codeView.fromLine = 1 codeView.fromLine = 1
end end
@ -1438,13 +1438,13 @@ function MineOSInterface.showErrorWindow(path, line, traceback)
end end
end end
mainContainer:addChild(GUI.textBox(codeView.width + 1, 4, mainContainer.width - codeView.width, codeView.height, 0xFFFFFF, 0x0, string.wrap(MineOSCore.parseErrorMessage(traceback, 4), mainContainer.width - codeView.width - 2), 1, 1, 0)) application:addChild(GUI.textBox(codeView.width + 1, 4, application.width - codeView.width, codeView.height, 0xFFFFFF, 0x0, string.wrap(MineOSCore.parseErrorMessage(traceback, 4), application.width - codeView.width - 2), 1, 1, 0))
actionButtons.close.onTouch = function() actionButtons.close.onTouch = function()
mainContainer:stopEventHandling() application:stop()
end end
mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4) application.eventHandler = function(application, object, e1, e2, e3, e4)
if e1 == "key_down" and e4 == 28 then if e1 == "key_down" and e4 == 28 then
actionButtons.close.onTouch() actionButtons.close.onTouch()
end end
@ -1459,7 +1459,7 @@ function MineOSInterface.showErrorWindow(path, line, traceback)
end end
sendToDeveloperButton.text = MineOSCore.localization.sendedFeedback sendToDeveloperButton.text = MineOSCore.localization.sendedFeedback
mainContainer:drawOnScreen() application:draw()
os.sleep(1) os.sleep(1)
end end
@ -1467,13 +1467,13 @@ function MineOSInterface.showErrorWindow(path, line, traceback)
end end
buffer.clear(0x0, 0.5) buffer.clear(0x0, 0.5)
mainContainer:drawOnScreen() application:draw()
for i = 1, 3 do for i = 1, 3 do
component.computer.beep(1500, 0.08) component.computer.beep(1500, 0.08)
end end
mainContainer:startEventHandling() application:start()
end end
function MineOSInterface.safeLaunch(...) function MineOSInterface.safeLaunch(...)