mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Perfomance GUI update #1
This commit is contained in:
parent
df985c3916
commit
408196dce1
@ -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 toolLayout = mainContainer:addChild(GUI.layout(1, 1, toolPanel.width, toolPanel.height - 3, 1, 1))
|
||||
local toolPanel = application:addChild(GUI.panel(1, 1, 28, application.height, 0x2D2D2D))
|
||||
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:setMargin(1, 1, 0, 1)
|
||||
|
||||
@ -49,7 +49,7 @@ local function addColorSelector(...)
|
||||
return toolLayout:addChild(GUI.colorSelector(1, 1, toolLayout.width - 2, 1, ...))
|
||||
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)
|
||||
local text = tostring(math.floor(currentLayer))
|
||||
@ -63,7 +63,7 @@ local newButton = addButton(localization.new)
|
||||
local openButton = addButton(localization.open)
|
||||
|
||||
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:addExtensionFilter(".3dm")
|
||||
filesystemDialog.onSubmit = function(path)
|
||||
@ -77,7 +77,7 @@ addButton(localization.exit).onTouch = function()
|
||||
hologram.clear()
|
||||
end
|
||||
|
||||
mainContainer:stopEventHandling()
|
||||
application:stop()
|
||||
end
|
||||
|
||||
addSeparator(localization.elementSettings)
|
||||
@ -170,7 +170,7 @@ if proxies.hologram then
|
||||
selector.onColorSelected = function()
|
||||
if proxies.hologram then
|
||||
proxies.hologram.setPaletteColor(i, selector.color)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -269,23 +269,23 @@ local function load(path)
|
||||
end
|
||||
|
||||
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:addExtensionFilter(".3dm")
|
||||
filesystemDialog.onSubmit = function(path)
|
||||
load(path)
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
filesystemDialog:show()
|
||||
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))
|
||||
view.localX = math.floor(toolLayout.width + (mainContainer.width - toolLayout.width) / 2 - view.width / 2)
|
||||
view.localY = math.floor(mainContainer.height / 2 - view.height / 2)
|
||||
local view = application:addChild(GUI.object(1, 1, 16 * viewPixelWidth, 16 * viewPixelHeight))
|
||||
view.localX = math.floor(toolLayout.width + (application.width - toolLayout.width) / 2 - view.width / 2)
|
||||
view.localY = math.floor(application.height / 2 - view.height / 2)
|
||||
view.draw = function()
|
||||
local x, y, step = view.x, view.y, true
|
||||
for j = 1, 16 do
|
||||
@ -326,26 +326,26 @@ view.draw = function()
|
||||
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
|
||||
local cell = toolLayout.cells[1][1]
|
||||
if e5 > 0 then
|
||||
if cell.verticalMargin < 1 then
|
||||
cell.verticalMargin = cell.verticalMargin + 1
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
else
|
||||
local child = toolLayout.children[#toolLayout.children]
|
||||
if child.localY + child.height - 1 >= toolLayout.localY + toolLayout.height - 1 then
|
||||
cell.verticalMargin = cell.verticalMargin - 1
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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 e5 > 0 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
|
||||
touchX, touchY = e3, e4
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
else
|
||||
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
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
elseif e1 == "drop" then
|
||||
@ -397,7 +397,7 @@ view.eventHandler = function(mainContainer, view, e1, e2, e3, e4, e5)
|
||||
currentLayer = currentLayer + 1
|
||||
fix()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
else
|
||||
@ -405,7 +405,7 @@ view.eventHandler = function(mainContainer, view, e1, e2, e3, e4, e5)
|
||||
currentLayer = currentLayer - 1
|
||||
fix()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
end
|
||||
@ -430,7 +430,7 @@ rotateButton.onTouch = function()
|
||||
fixShape(shape)
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
|
||||
@ -453,7 +453,7 @@ flipButton.onTouch = function()
|
||||
fixShape(shape)
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
|
||||
@ -462,7 +462,7 @@ disabledListItem.onTouch = function()
|
||||
updateWidgetsFromModel()
|
||||
updateAddRemoveButtonsState()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
|
||||
@ -485,14 +485,14 @@ end
|
||||
newButton.onTouch = function()
|
||||
new()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
|
||||
addShapeButton.onTouch = function()
|
||||
addShape()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
|
||||
@ -503,7 +503,7 @@ removeShapeButton.onTouch = function()
|
||||
updateWidgetsFromModel()
|
||||
updateAddRemoveButtonsState()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
|
||||
@ -548,7 +548,7 @@ end
|
||||
elementComboBox.onItemSelected = function()
|
||||
updateWidgetsFromModel()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
end
|
||||
|
||||
@ -570,6 +570,6 @@ else
|
||||
new()
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateOnHologram()
|
||||
mainContainer:startEventHandling()
|
||||
application:start()
|
||||
@ -27,7 +27,7 @@ local meowEngine = require("MeowEngine/Main")
|
||||
buffer.flush()
|
||||
meowEngine.intro(vector.newVector3(0, 0, 0), 20)
|
||||
|
||||
local mainContainer = GUI.fullScreenContainer()
|
||||
local application = GUI.application()
|
||||
local scene = meowEngine.newScene(0x1D1D1D)
|
||||
|
||||
scene.renderMode = OCGL.renderModes.flatShading
|
||||
@ -280,14 +280,14 @@ local function move(x, y, z)
|
||||
end
|
||||
|
||||
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[mainContainer.toolbar.lightSelectComboBox.selectedItem].position[2] = scene.lights[mainContainer.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[1] = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[1] + x
|
||||
scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[2] = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[2] + y
|
||||
scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[3] = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[3] + z
|
||||
end
|
||||
|
||||
local controls = {
|
||||
-- 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
|
||||
[200] = function() scene.camera:rotate(-rotationAngle, 0, 0) end,
|
||||
[208] = function() scene.camera:rotate(rotationAngle, 0, 0) end,
|
||||
@ -314,7 +314,7 @@ local controls = {
|
||||
|
||||
-------------------------------------------------------- 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 index = buffer.getIndex(x, y)
|
||||
@ -331,18 +331,17 @@ local function drawCross(x, y)
|
||||
drawInvertedText(x, y + 1, "┃")
|
||||
end
|
||||
|
||||
local oldUptime
|
||||
OCGLView.draw = function(object)
|
||||
oldUptime = computer.uptime()
|
||||
application.oldClock = os.clock()
|
||||
if world then renderWorld() end
|
||||
scene:render()
|
||||
if mainContainer.toolbar.zBufferSwitch.state then
|
||||
if application.toolbar.zBufferSwitch.state then
|
||||
renderer.visualizeDepthBuffer()
|
||||
end
|
||||
drawCross(renderer.viewport.xCenter, math.floor(renderer.viewport.yCenter / 2))
|
||||
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
|
||||
local targetVector = vector.newVector3(scene.camera.position[1], scene.camera.position[2], scene.camera.position[3] + 1000)
|
||||
OCGL.rotateVectorRelativeToXAxis(targetVector, scene.camera.rotation[1])
|
||||
@ -369,122 +368,122 @@ OCGLView.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
zWorld = zWorld - 1
|
||||
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
|
||||
|
||||
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 = {
|
||||
"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)",
|
||||
"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
|
||||
mainContainer.toolbar = mainContainer:addChild(GUI.container(mainContainer.width - 31, 1, 32, mainContainer.height))
|
||||
local elementWidth = mainContainer.toolbar.width - 2
|
||||
mainContainer.toolbar:addChild(GUI.panel(1, 1, mainContainer.toolbar.width, mainContainer.toolbar.height, 0x0, 0.5))
|
||||
application.toolbar = application:addChild(GUI.container(application.width - 31, 1, 32, application.height))
|
||||
local elementWidth = application.toolbar.width - 2
|
||||
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
|
||||
mainContainer.toolbar.renderModeComboBox = mainContainer.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + mainContainer.toolbar.renderModeComboBox.height + 1
|
||||
mainContainer.toolbar.renderModeComboBox:addItem("disabled")
|
||||
mainContainer.toolbar.renderModeComboBox:addItem("constantShading")
|
||||
mainContainer.toolbar.renderModeComboBox:addItem("flatShading")
|
||||
mainContainer.toolbar.renderModeComboBox.selectedItem = scene.renderMode
|
||||
mainContainer.toolbar.renderModeComboBox.onItemSelected = function()
|
||||
scene.renderMode = mainContainer.toolbar.renderModeComboBox.selectedItem
|
||||
application.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.renderModeComboBox = application.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + application.toolbar.renderModeComboBox.height + 1
|
||||
application.toolbar.renderModeComboBox:addItem("disabled")
|
||||
application.toolbar.renderModeComboBox:addItem("constantShading")
|
||||
application.toolbar.renderModeComboBox:addItem("flatShading")
|
||||
application.toolbar.renderModeComboBox.selectedItem = scene.renderMode
|
||||
application.toolbar.renderModeComboBox.onItemSelected = function()
|
||||
scene.renderMode = application.toolbar.renderModeComboBox.selectedItem
|
||||
end
|
||||
|
||||
mainContainer.toolbar.auxiliaryModeComboBox = mainContainer.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + mainContainer.toolbar.auxiliaryModeComboBox.height + 1
|
||||
mainContainer.toolbar.auxiliaryModeComboBox:addItem("disabled")
|
||||
mainContainer.toolbar.auxiliaryModeComboBox:addItem("wireframe")
|
||||
mainContainer.toolbar.auxiliaryModeComboBox:addItem("vertices")
|
||||
mainContainer.toolbar.auxiliaryModeComboBox.selectedItem = scene.auxiliaryMode
|
||||
mainContainer.toolbar.auxiliaryModeComboBox.onItemSelected = function()
|
||||
scene.auxiliaryMode = mainContainer.toolbar.auxiliaryModeComboBox.selectedItem
|
||||
application.toolbar.auxiliaryModeComboBox = application.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + application.toolbar.auxiliaryModeComboBox.height + 1
|
||||
application.toolbar.auxiliaryModeComboBox:addItem("disabled")
|
||||
application.toolbar.auxiliaryModeComboBox:addItem("wireframe")
|
||||
application.toolbar.auxiliaryModeComboBox:addItem("vertices")
|
||||
application.toolbar.auxiliaryModeComboBox.selectedItem = scene.auxiliaryMode
|
||||
application.toolbar.auxiliaryModeComboBox.onItemSelected = function()
|
||||
scene.auxiliaryMode = application.toolbar.auxiliaryModeComboBox.selectedItem
|
||||
end
|
||||
|
||||
mainContainer.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
|
||||
mainContainer.toolbar.perspectiveSwitch.onStateChanged = function()
|
||||
scene.camera.projectionEnabled = mainContainer.toolbar.perspectiveSwitch.state
|
||||
application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xAAAAAA, "Perspective proj:"))
|
||||
application.toolbar.perspectiveSwitch = application.toolbar:addChild(GUI.switch(application.toolbar.width - 8, elementY, 8, 0x66DB80, 0x2D2D2D, 0xEEEEEE, scene.camera.projectionEnabled)); elementY = elementY + 2
|
||||
application.toolbar.perspectiveSwitch.onStateChanged = function()
|
||||
scene.camera.projectionEnabled = application.toolbar.perspectiveSwitch.state
|
||||
end
|
||||
|
||||
mainContainer.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:addChild(GUI.label(2, elementY, elementWidth, 1, 0xAAAAAA, "Z-buffer visualize:"))
|
||||
application.toolbar.zBufferSwitch = application.toolbar:addChild(GUI.switch(application.toolbar.width - 8, elementY, 8, 0x66DB80, 0x2D2D2D, 0xEEEEEE, false)); elementY = elementY + 2
|
||||
|
||||
|
||||
local function calculateLightComboBox()
|
||||
mainContainer.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children = {}
|
||||
application.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children = {}
|
||||
for i = 1, #scene.lights do
|
||||
mainContainer.toolbar.lightSelectComboBox:addItem(tostring(i))
|
||||
application.toolbar.lightSelectComboBox:addItem(tostring(i))
|
||||
end
|
||||
mainContainer.toolbar.lightSelectComboBox.selectedItem = #mainContainer.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children
|
||||
mainContainer.toolbar.lightIntensitySlider.value = scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].intensity * 100
|
||||
mainContainer.toolbar.lightEmissionSlider.value = scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].emissionDistance
|
||||
application.toolbar.lightSelectComboBox.selectedItem = #application.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children
|
||||
application.toolbar.lightIntensitySlider.value = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].intensity * 100
|
||||
application.toolbar.lightEmissionSlider.value = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].emissionDistance
|
||||
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
|
||||
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:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "Light control")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2
|
||||
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
|
||||
mainContainer.toolbar.addLightButton.onTouch = function()
|
||||
scene:addLight(meowEngine.newLight(vector.newVector3(0, 10, 0), mainContainer.toolbar.lightIntensitySlider.value / 100, mainContainer.toolbar.lightEmissionSlider.value))
|
||||
application.toolbar.addLightButton = application.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Add light")); elementY = elementY + 2
|
||||
application.toolbar.addLightButton.onTouch = function()
|
||||
scene:addLight(meowEngine.newLight(vector.newVector3(0, 10, 0), application.toolbar.lightIntensitySlider.value / 100, application.toolbar.lightEmissionSlider.value))
|
||||
calculateLightComboBox()
|
||||
end
|
||||
|
||||
mainContainer.toolbar.removeLightButton = mainContainer.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 = application.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Remove light")); elementY = elementY + 2
|
||||
application.toolbar.removeLightButton.onTouch = function()
|
||||
if #scene.lights > 1 then
|
||||
table.remove(scene.lights, mainContainer.toolbar.lightSelectComboBox.selectedItem)
|
||||
table.remove(scene.lights, application.toolbar.lightSelectComboBox.selectedItem)
|
||||
calculateLightComboBox()
|
||||
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
|
||||
mainContainer.toolbar.lightIntensitySlider.onValueChanged = function()
|
||||
scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].intensity = mainContainer.toolbar.lightIntensitySlider.value / 100
|
||||
application.toolbar.lightIntensitySlider = application.toolbar:addChild(GUI.slider(2, elementY, elementWidth, 0xCCCCCC, 0x2D2D2D, 0xEEEEEE, 0xAAAAAA, 0, 500, 100, false, "Intensity: ", "")); elementY = elementY + 3
|
||||
application.toolbar.lightIntensitySlider.onValueChanged = function()
|
||||
scene.lights[application.toolbar.lightSelectComboBox.selectedItem].intensity = application.toolbar.lightIntensitySlider.value / 100
|
||||
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
|
||||
mainContainer.toolbar.lightEmissionSlider.onValueChanged = function()
|
||||
scene.lights[mainContainer.toolbar.lightSelectComboBox.selectedItem].emissionDistance = mainContainer.toolbar.lightEmissionSlider.value
|
||||
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
|
||||
application.toolbar.lightEmissionSlider.onValueChanged = function()
|
||||
scene.lights[application.toolbar.lightSelectComboBox.selectedItem].emissionDistance = application.toolbar.lightEmissionSlider.value
|
||||
end
|
||||
calculateLightComboBox()
|
||||
|
||||
mainContainer.toolbar.blockColorSelector = mainContainer.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, 0xEEEEEE, "Block color")); elementY = elementY + mainContainer.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
|
||||
mainContainer.toolbar.backgroundColorSelector.onColorSelected = function()
|
||||
scene.backgroundColor = mainContainer.toolbar.backgroundColorSelector.color
|
||||
application.toolbar.blockColorSelector = application.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, 0xEEEEEE, "Block color")); elementY = elementY + application.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
|
||||
application.toolbar.backgroundColorSelector.onColorSelected = function()
|
||||
scene.backgroundColor = application.toolbar.backgroundColorSelector.color
|
||||
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
|
||||
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
|
||||
mainContainer.toolbar.RAMChart.roundValues = true
|
||||
-- mainContainer.toolbar.RAMChart.showXAxisValues = false
|
||||
mainContainer.toolbar.RAMChart.counter = 1
|
||||
application.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.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
|
||||
application.toolbar.RAMChart.roundValues = true
|
||||
-- application.toolbar.RAMChart.showXAxisValues = false
|
||||
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()
|
||||
mainContainer:stopEventHandling()
|
||||
application.toolbar:addChild(GUI.button(1, application.toolbar.height - 2, application.toolbar.width, 3, 0x2D2D2D, 0xEEEEEE, 0x444444, 0xEEEEEE, "Exit")).onTouch = function()
|
||||
application:stop()
|
||||
end
|
||||
|
||||
local FPSCounter = GUI.object(2, 2, 8, 3)
|
||||
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
|
||||
mainContainer:addChild(FPSCounter)
|
||||
application:addChild(FPSCounter)
|
||||
|
||||
mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
if not mainContainer.toolbar.hidden then
|
||||
application.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
||||
if not application.toolbar.hidden then
|
||||
local totalMemory = computer.totalMemory()
|
||||
table.insert(mainContainer.toolbar.RAMChart.values, {mainContainer.toolbar.RAMChart.counter, math.ceil((totalMemory - computer.freeMemory()) / totalMemory * 100)})
|
||||
mainContainer.toolbar.RAMChart.counter = mainContainer.toolbar.RAMChart.counter + 1
|
||||
if #mainContainer.toolbar.RAMChart.values > 20 then table.remove(mainContainer.toolbar.RAMChart.values, 1) end
|
||||
table.insert(application.toolbar.RAMChart.values, {application.toolbar.RAMChart.counter, math.ceil((totalMemory - computer.freeMemory()) / totalMemory * 100)})
|
||||
application.toolbar.RAMChart.counter = application.toolbar.RAMChart.counter + 1
|
||||
if #application.toolbar.RAMChart.values > 20 then table.remove(application.toolbar.RAMChart.values, 1) end
|
||||
|
||||
mainContainer.infoTextBox.lines = {
|
||||
application.infoTextBox.lines = {
|
||||
" ",
|
||||
"SceneObjects: " .. #scene.objects,
|
||||
" ",
|
||||
@ -511,7 +510,7 @@ mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
"F1 - toggle GUI overlay",
|
||||
}
|
||||
|
||||
mainContainer.infoTextBox.height = #mainContainer.infoTextBox.lines
|
||||
application.infoTextBox.height = #application.infoTextBox.lines
|
||||
end
|
||||
|
||||
if e1 == "key_down" then
|
||||
@ -530,9 +529,9 @@ mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
-------------------------------------------------------- Ebat-kopat --------------------------------------------------------
|
||||
|
||||
mainContainer:startEventHandling(0)
|
||||
application:start(0)
|
||||
@ -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))
|
||||
|
||||
@ -95,7 +95,7 @@ local progressIndicator = window:addChild(GUI.progressIndicator(1, 1, 0x3C3C3C,
|
||||
|
||||
local function activity(state)
|
||||
progressIndicator.active = state
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -147,7 +147,7 @@ local function RawAPIRequest(script, postData, notUnserialize)
|
||||
function(chunk)
|
||||
data = data .. chunk
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
progressIndicator:roll()
|
||||
end,
|
||||
math.huge
|
||||
@ -324,7 +324,7 @@ local function newRatingWidget(x, y, rating, firstColor, secondColor)
|
||||
end
|
||||
|
||||
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))
|
||||
|
||||
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()
|
||||
container:remove()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -383,7 +383,7 @@ local function download(publication)
|
||||
end
|
||||
|
||||
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)
|
||||
if not filesystemChooserPath then
|
||||
@ -468,7 +468,7 @@ local function download(publication)
|
||||
local function govnoed(pizda, i)
|
||||
container.label.text = localization.downloading .. " " .. fs.name(pizda.path)
|
||||
progressBar.value = math.round(i / countOfShit * 100)
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
-- SAVED
|
||||
@ -585,7 +585,7 @@ local function addApplicationInfo(container, publication, limit)
|
||||
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
|
||||
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
|
||||
object.children[i].localY = object.children[i].localY + 1
|
||||
end
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
else
|
||||
if last.localY + last.height - 1 >= object.height then
|
||||
for i = 1, #object.children do
|
||||
object.children[i].localY = object.children[i].localY - 1
|
||||
end
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -609,10 +609,10 @@ end
|
||||
|
||||
local newApplicationPreview, newPublicationInfo, mainMenu
|
||||
|
||||
local function applicationWidgetEventHandler(mainContainer, object, e1)
|
||||
local function applicationWidgetEventHandler(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
object.parent.panel.colors.background = 0xE1E1E1
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
newPublicationInfo(object.parent.file_id)
|
||||
end
|
||||
end
|
||||
@ -651,7 +651,7 @@ mainMenu = function(menuID, messageToUser)
|
||||
|
||||
local statistics = fieldAPIRequest("result", "statistics")
|
||||
if statistics then
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
local publications = fieldAPIRequest("result", "publications", {
|
||||
order_by = "popularity",
|
||||
@ -688,7 +688,7 @@ mainMenu = function(menuID, messageToUser)
|
||||
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)
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
local uptime, newUptime = computer.uptime()
|
||||
local function tick()
|
||||
@ -745,13 +745,13 @@ mainMenu = function(menuID, messageToUser)
|
||||
child.localX, child.localY = math.floor(child.moveX), math.floor(child.moveY)
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
return true
|
||||
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
|
||||
local child, deltaX, deltaY, vectorLength
|
||||
for i = 1, #iconsContainer.children do
|
||||
@ -778,7 +778,7 @@ mainMenu = function(menuID, messageToUser)
|
||||
object.forceY = math.random(-100, 100) / 100 * overviewForceLimit
|
||||
|
||||
if not tick() then
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -843,10 +843,10 @@ mainMenu = function(menuID, messageToUser)
|
||||
activity(false)
|
||||
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
|
||||
|
||||
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
|
||||
panel.colors.transparency = nil
|
||||
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.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
|
||||
dialogContainer.panel.colors.background = 0xE1E1E1
|
||||
dialogGUI(dialogs[i].dialog_user_name)
|
||||
@ -981,7 +981,7 @@ mainMenu = function(menuID, messageToUser)
|
||||
end
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
local function account()
|
||||
@ -1149,7 +1149,7 @@ mainMenu = function(menuID, messageToUser)
|
||||
activity()
|
||||
else
|
||||
addAccountShit(true, false, false)
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -1190,7 +1190,7 @@ newPublicationInfo = function(file_id)
|
||||
})
|
||||
|
||||
if publication then
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
local reviews = fieldAPIRequest("result", "reviews", {
|
||||
file_id = file_id,
|
||||
@ -1284,10 +1284,10 @@ newPublicationInfo = function(file_id)
|
||||
pizda.width = eblo.width + 9
|
||||
|
||||
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
|
||||
cyka.rating = math.round((e3 - object.x + 1) / object.width * 5)
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -1306,7 +1306,7 @@ newPublicationInfo = function(file_id)
|
||||
})
|
||||
|
||||
container:remove()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
if success then
|
||||
newPublicationInfo(publication.file_id)
|
||||
@ -1328,7 +1328,7 @@ newPublicationInfo = function(file_id)
|
||||
end
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
input.onInputFinished()
|
||||
@ -1368,10 +1368,12 @@ newPublicationInfo = function(file_id)
|
||||
if x + textLength + 4 > textDetailsContainer.width - 4 then
|
||||
x, y = 3, y + 2
|
||||
end
|
||||
|
||||
local button = textDetailsContainer:addChild(GUI.tagButton(x, y, textLength + 2, 1, 0xC3C3C3, 0xFFFFFF, 0x2D2D2D, 0xFFFFFF, dependency.publication_name))
|
||||
button.onTouch = function()
|
||||
newPublicationInfo(publication.all_dependencies[i])
|
||||
end
|
||||
|
||||
x = x + button.width + 2
|
||||
end
|
||||
end
|
||||
@ -1500,7 +1502,7 @@ local function newPlusMinusCyka(width, disableLimit)
|
||||
|
||||
layout.removeButton.onTouch = function()
|
||||
layout.comboBox:removeItem(layout.comboBox.selectedItem)
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
return layout
|
||||
@ -1584,7 +1586,7 @@ editPublication = function(initialPublication, initialCategoryID)
|
||||
local lastDependencyType = 1
|
||||
|
||||
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))
|
||||
dependencyTypeComboBox:addItem(localization.fileByURL)
|
||||
@ -1605,7 +1607,7 @@ editPublication = function(initialPublication, initialCategoryID)
|
||||
})
|
||||
|
||||
container:remove()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
publicationNameInput.onInputFinished = function()
|
||||
@ -1627,7 +1629,7 @@ editPublication = function(initialPublication, initialCategoryID)
|
||||
|
||||
dependencyTypeComboBox.onItemSelected = function()
|
||||
onDependencyTypeComboBoxItemSelected()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
pathType.switch.onStateChanged = function()
|
||||
@ -1637,7 +1639,7 @@ editPublication = function(initialPublication, initialCategoryID)
|
||||
publicationNameInput.onInputFinished()
|
||||
onDependencyTypeComboBoxItemSelected()
|
||||
pathType.switch.onStateChanged()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
nameInput.onInputFinished()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
categoryComboBox.onItemSelected()
|
||||
@ -1757,14 +1759,14 @@ updateFileList = function(category_id, updates)
|
||||
if updates then
|
||||
if #result > 0 then
|
||||
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, "", "%"))
|
||||
|
||||
for i = 1, #result do
|
||||
container.label.text = localization.downloading .. " " .. result[i].publication_name
|
||||
progressBar.value = math.round(i / #result * 100)
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
local publication = fieldAPIRequest("result", "publication", {
|
||||
file_id = result[i].file_id,
|
||||
@ -1780,7 +1782,7 @@ updateFileList = function(category_id, updates)
|
||||
local dependency = publication.dependencies_data[publication.all_dependencies[j]]
|
||||
if not dependency.publication_name then
|
||||
container.label.text = localization.downloading .. " " .. dependency.path
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
if getUpdateState(publication.all_dependencies[j], dependency.version) < 4 then
|
||||
local dependencyPath = getDependencyPath(fileVersions[publication.file_id].path, dependency)
|
||||
@ -1887,7 +1889,7 @@ updateFileList = function(category_id, updates)
|
||||
end
|
||||
counter = counter + 1
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
else
|
||||
showLabelAsContent(contentContainer, localization.noUpdates)
|
||||
|
||||
@ -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))
|
||||
layout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
|
||||
@ -47,7 +47,7 @@ local function newCell(x, y, shaded)
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -112,7 +112,7 @@ local function newNoGUI(width, height)
|
||||
end
|
||||
|
||||
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))
|
||||
widthTextBox.validator = function(text)
|
||||
@ -124,17 +124,17 @@ local function new()
|
||||
return tonumber(text)
|
||||
end
|
||||
|
||||
container.panel.eventHandler = function(mainContainer, object, e1)
|
||||
container.panel.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
container:remove()
|
||||
|
||||
newNoGUI(tonumber(widthTextBox.text), tonumber(heightTextBox.text))
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function fillBrailleArray(source, inverted)
|
||||
@ -163,7 +163,7 @@ newButton.onTouch = function()
|
||||
end
|
||||
|
||||
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:addExtensionFilter(".pic")
|
||||
@ -226,7 +226,7 @@ saveButton.onTouch = function()
|
||||
end
|
||||
|
||||
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:addExtensionFilter(".braiile")
|
||||
@ -243,7 +243,7 @@ openButton.onTouch = function()
|
||||
drawingArea.children[i].pixels = pizda[i].pixels
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
filesystemDialog:show()
|
||||
@ -256,7 +256,7 @@ window.actionButtons.maximize:remove()
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
newNoGUI(8, 4)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -182,7 +182,7 @@ modeList:addItem("8").onTouch = function()
|
||||
floatingList.selectedItem = 1
|
||||
setValue(math.floor(value))
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
modeList:addItem("10").onTouch = function()
|
||||
@ -190,7 +190,7 @@ modeList:addItem("10").onTouch = function()
|
||||
setButtonsDisabled(digitDecimalButtons, false)
|
||||
setButtonsDisabled(digitHexadecimalButtons, true)
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
modeList:addItem("16").onTouch = function()
|
||||
@ -201,7 +201,7 @@ modeList:addItem("16").onTouch = function()
|
||||
floatingList.selectedItem = 1
|
||||
setValue(math.floor(value))
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function binaryToNumber()
|
||||
|
||||
@ -58,7 +58,7 @@ local thermal = {
|
||||
}
|
||||
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.height = window.height
|
||||
@ -101,7 +101,7 @@ local function takePicture()
|
||||
x, y = 1, y + 1
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
shootButton.eventHandler = function(mainContainer, object, e1)
|
||||
shootButton.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
shootButton.pressed = true
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
takePicture()
|
||||
|
||||
shootButton.pressed = false
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -156,12 +156,12 @@ FOVSlider.onValueChanged = takePicture
|
||||
|
||||
paletteSwitch.onStateChanged = function()
|
||||
palette = paletteSwitch.state and thermal or grayscale
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
autoupdateSwitch.onStateChanged = function()
|
||||
autoupdateSlider.hidden = not autoupdateSwitch.state
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
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.localY = window.height - shootButton.height
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
takePicture()
|
||||
end
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ local resourcesPath = MineOSCore.getCurrentScriptDirectory()
|
||||
local modulesPath = resourcesPath .. "Modules/"
|
||||
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
|
||||
local loadedFile, reason = loadfile(modulesPath .. fileList[i])
|
||||
if loadedFile then
|
||||
local pcallSuccess, reason = pcall(loadedFile, mainContainer, window, localization)
|
||||
local pcallSuccess, reason = pcall(loadedFile, application, window, localization)
|
||||
if pcallSuccess then
|
||||
window.tabBar:addItem(reason.name).onTouch = function()
|
||||
reason.onTouch()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
else
|
||||
error("Failed to call loaded module \"" .. tostring(fileList[i]) .. "\": " .. tostring(reason))
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
local args = {...}
|
||||
local mainContainer, window, localization = args[1], args[2], args[3]
|
||||
local application, window, localization = args[1], args[2], args[3]
|
||||
|
||||
require("advancedLua")
|
||||
local component = require("component")
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
local args = {...}
|
||||
local mainContainer, window, localization = args[1], args[2], args[3]
|
||||
local application, window, localization = args[1], args[2], args[3]
|
||||
|
||||
require("advancedLua")
|
||||
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))
|
||||
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))
|
||||
inputField.onInputFinished = function()
|
||||
if inputField.text and inputField.text:len() > 0 then
|
||||
@ -68,7 +68,7 @@ module.onTouch = function()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
button.localX = diskContainer.width - button.width - 1
|
||||
|
||||
@ -85,14 +85,14 @@ module.onTouch = function()
|
||||
y = y + diskContainer.height + 1
|
||||
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 e5 < 0 or container.children[1].localY < 2 then
|
||||
for i = 1, #container.children do
|
||||
container.children[i].localY = container.children[i].localY + e5
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
elseif e1 == "component_added" or e1 == "component_removed" and e3 == "filesystem" then
|
||||
module.onTouch()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
local args = {...}
|
||||
local mainContainer, window, localization = args[1], args[2], args[3]
|
||||
local application, window, localization = args[1], args[2], args[3]
|
||||
|
||||
require("advancedLua")
|
||||
local component = require("component")
|
||||
@ -128,7 +128,7 @@ module.onTouch = function()
|
||||
out("Failed to load string \"" .. data .. "\": " .. reason)
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
local args = {...}
|
||||
local mainContainer, window, localization = args[1], args[2], args[3]
|
||||
local application, window, localization = args[1], args[2], args[3]
|
||||
|
||||
require("advancedLua")
|
||||
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 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 = {...}
|
||||
if switch.state and eventData[1] then
|
||||
local lines = table.concat(eventData, " ")
|
||||
@ -40,7 +40,7 @@ module.onTouch = function()
|
||||
end
|
||||
textBox:scrollToEnd()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -94,7 +94,7 @@ end
|
||||
|
||||
local function updateFileListAndDraw()
|
||||
iconField:updateFileList()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
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"))
|
||||
end
|
||||
|
||||
local function sidebarItemEventHandler(mainContainer, object, e1, e2, e3, ...)
|
||||
local function sidebarItemEventHandler(application, object, e1, e2, e3, ...)
|
||||
if e1 == "touch" then
|
||||
if object.onRemove and e3 == object.x + object.width - 2 then
|
||||
object.onRemove()
|
||||
@ -198,7 +198,7 @@ openFTP = function(...)
|
||||
local mountPath = MineOSNetwork.mountPaths.FTP .. MineOSNetwork.getFTPProxyName(...) .. "/"
|
||||
|
||||
addWorkpath(mountPath)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
local proxy, reason = MineOSNetwork.connectToFTP(...)
|
||||
if proxy then
|
||||
@ -227,7 +227,7 @@ updateSidebar = function()
|
||||
object.onRemove = function()
|
||||
table.remove(config.favourites, i)
|
||||
updateSidebar()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
saveConfig()
|
||||
end
|
||||
end
|
||||
@ -272,7 +272,7 @@ updateSidebar = function()
|
||||
object.onRemove = function()
|
||||
table.remove(MineOSCore.properties.FTPConnections, i)
|
||||
updateSidebar()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
MineOSCore.saveProperties()
|
||||
end
|
||||
end
|
||||
@ -292,7 +292,7 @@ updateSidebar = function()
|
||||
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
|
||||
local cell = itemsLayout.cells[1][1]
|
||||
local from = 0
|
||||
@ -305,15 +305,15 @@ itemsLayout.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
cell.verticalMargin = to
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
elseif e1 == "component_added" or e1 == "component_removed" then
|
||||
FTPButton.disabled = not MineOSNetwork.internetProxy
|
||||
updateSidebar()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
elseif e1 == "MineOSNetwork" then
|
||||
if e2 == "updateProxyList" or e2 == "timeout" then
|
||||
updateSidebar()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -356,7 +356,7 @@ prevButton.onTouch = function()
|
||||
end
|
||||
|
||||
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"
|
||||
if #MineOSCore.properties.FTPConnections > 0 then
|
||||
@ -396,17 +396,17 @@ FTPButton.onTouch = function()
|
||||
MineOSCore.saveProperties()
|
||||
|
||||
updateSidebar()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
openFTP(addressInput.text, port, userInput.text, passwordInput.text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
if scrollTimerID then
|
||||
event.cancel(scrollTimerID)
|
||||
@ -441,7 +441,7 @@ iconField.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
|
||||
saveConfig()
|
||||
updateSidebar()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -492,7 +492,7 @@ iconField.updateFileList = function(...)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
overrideUpdateFileList(...)
|
||||
updateScrollBar()
|
||||
end
|
||||
@ -510,7 +510,7 @@ gotoButton.onTouch = function()
|
||||
iconField:updateFileList()
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
statusContainer.hidden = true
|
||||
@ -569,7 +569,7 @@ window.onResize = function(width, height)
|
||||
window.height = height
|
||||
calculateSizes()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateFileListAndDraw()
|
||||
end
|
||||
|
||||
@ -577,7 +577,7 @@ resizer.onResize = function(deltaX)
|
||||
sidebarContainer.width = sidebarContainer.width + deltaX
|
||||
calculateSizes()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
resizer.onResizeFinished = function()
|
||||
|
||||
@ -14,7 +14,7 @@ else
|
||||
return
|
||||
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)
|
||||
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
|
||||
|
||||
container:remove()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ local earthImage = image.load(resourcesDirectory .. "Earth.pic")
|
||||
local onScreenDataXOffset, onScreenDataYOffset = math.floor(bufferWidth / 2), bufferHeight
|
||||
local onProjectorDataYOffset = 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 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
|
||||
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 z = -horizontalRange, horizontalRange do
|
||||
@ -93,11 +93,11 @@ local function updateData(onScreen, onProjector, onGlasses)
|
||||
if onScreen then
|
||||
buffer.semiPixelSet(onScreenDataXOffset + x, onScreenDataYOffset + 32 - y, 0x454545)
|
||||
end
|
||||
if onProjector and mainContainer.projectorUpdateSwitch.state then
|
||||
component.hologram.set(horizontalRange + x, math.floor(mainContainer.projectorYOffsetSlider.value) + y - 32, horizontalRange + z, 1)
|
||||
if onProjector and application.projectorUpdateSwitch.state then
|
||||
component.hologram.set(horizontalRange + x, math.floor(application.projectorYOffsetSlider.value) + y - 32, horizontalRange + z, 1)
|
||||
end
|
||||
if onGlasses and mainContainer.glassesUpdateSwitch.state and glassesAvailable then
|
||||
glassesCreateCube(x, y - 32, z, mainContainer.glassesOreColorButton.colors.default.background, "Hardness: " .. string.format("%.2f", scanResult[x][z][y]))
|
||||
if onGlasses and application.glassesUpdateSwitch.state and glassesAvailable then
|
||||
glassesCreateCube(x, y - 32, z, application.glassesOreColorButton.colors.default.background, "Hardness: " .. string.format("%.2f", scanResult[x][z][y]))
|
||||
os.sleep(0)
|
||||
end
|
||||
end
|
||||
@ -107,91 +107,91 @@ local function updateData(onScreen, onProjector, onGlasses)
|
||||
end
|
||||
end
|
||||
|
||||
local oldDraw = mainContainer.draw
|
||||
mainContainer.draw = function()
|
||||
local oldDraw = application.draw
|
||||
application.draw = function()
|
||||
updateData(true, false, false)
|
||||
oldDraw(mainContainer)
|
||||
oldDraw(application)
|
||||
end
|
||||
|
||||
local panelWidth = 30
|
||||
local panelX = bufferWidth - panelWidth + 1
|
||||
local buttonX, objectY = panelX + 2, 2
|
||||
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))
|
||||
objectY = objectY + mainContainer.planetImage.image[2] + 1
|
||||
application.planetImage = application:addChild(GUI.image(buttonX, objectY, earthImage))
|
||||
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
|
||||
|
||||
mainContainer.horizontalScanRangeSlider = mainContainer:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 4, 24, 16, false, "Horizontal scan range: "))
|
||||
mainContainer.horizontalScanRangeSlider.roundValues = true
|
||||
application.horizontalScanRangeSlider = application:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 4, 24, 16, false, "Horizontal scan range: "))
|
||||
application.horizontalScanRangeSlider.roundValues = true
|
||||
objectY = objectY + 3
|
||||
mainContainer.verticalScanRangeSlider = mainContainer:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 4, 32, 16, false, "Vertical show range: "))
|
||||
mainContainer.verticalScanRangeSlider.roundValues = true
|
||||
application.verticalScanRangeSlider = application:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 4, 32, 16, false, "Vertical show range: "))
|
||||
application.verticalScanRangeSlider.roundValues = true
|
||||
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
|
||||
|
||||
mainContainer.minimumHardnessTextBox = mainContainer: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.minimumHardnessTextBox = application:addChild(GUI.input(buttonX, objectY, 12, 3, 0x262626, 0xBBBBBB, 0xBBBBBB, 0x262626, 0xFFFFFF, tostring(2.7), 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
|
||||
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
|
||||
|
||||
|
||||
mainContainer.projectorScaleSlider = mainContainer:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 0.33, 3, component.hologram.getScale(), false, "Projection scale: "))
|
||||
mainContainer.projectorScaleSlider.onValueChanged = function()
|
||||
component.hologram.setScale(mainContainer.projectorScaleSlider.value)
|
||||
application.projectorScaleSlider = application:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 0.33, 3, component.hologram.getScale(), false, "Projection scale: "))
|
||||
application.projectorScaleSlider.onValueChanged = function()
|
||||
component.hologram.setScale(application.projectorScaleSlider.value)
|
||||
end
|
||||
objectY = objectY + 3
|
||||
mainContainer.projectorYOffsetSlider = mainContainer:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 0, 64, 4, false, "Projection Y offset: "))
|
||||
mainContainer.projectorYOffsetSlider.roundValues = true
|
||||
application.projectorYOffsetSlider = application:addChild(GUI.slider(buttonX, objectY, buttonWidth, 0xFFDB80, 0x000000, 0xFFDB40, 0xBBBBBB, 0, 64, 4, false, "Projection Y offset: "))
|
||||
application.projectorYOffsetSlider.roundValues = true
|
||||
objectY = objectY + 3
|
||||
|
||||
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
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function updateProjectorColors()
|
||||
component.hologram.setPaletteColor(1, mainContainer.color1Button.colors.default.background)
|
||||
component.hologram.setPaletteColor(1, application.color1Button.colors.default.background)
|
||||
end
|
||||
|
||||
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
|
||||
mainContainer.color1Button.onTouch = function()
|
||||
setButtonColorFromPalette(mainContainer.color1Button)
|
||||
application.color1Button = application:addChild(GUI.button(buttonX, objectY, buttonWidth, 1, color1, 0xBBBBBB, 0xEEEEEE, 0x262626, "Projector color")); objectY = objectY + 1
|
||||
application.color1Button.onTouch = function()
|
||||
setButtonColorFromPalette(application.color1Button)
|
||||
updateProjectorColors()
|
||||
end
|
||||
mainContainer.glassesOreColorButton = mainContainer:addChild(GUI.button(buttonX, objectY, buttonWidth, 1, 0x0044FF, 0xBBBBBB, 0xEEEEEE, 0x262626, "Glasses ore color"))
|
||||
mainContainer.glassesOreColorButton.onTouch = function()
|
||||
setButtonColorFromPalette(mainContainer.glassesOreColorButton)
|
||||
application.glassesOreColorButton = application:addChild(GUI.button(buttonX, objectY, buttonWidth, 1, 0x0044FF, 0xBBBBBB, 0xEEEEEE, 0x262626, "Glasses ore color"))
|
||||
application.glassesOreColorButton.onTouch = function()
|
||||
setButtonColorFromPalette(application.glassesOreColorButton)
|
||||
end
|
||||
objectY = objectY + 2
|
||||
|
||||
mainContainer: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:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Projector update:"))
|
||||
application.projectorUpdateSwitch = application:addChild(GUI.switch(bufferWidth - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true))
|
||||
objectY = objectY + 2
|
||||
mainContainer: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:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xBBBBBB, "Glasses update:"))
|
||||
application.glassesUpdateSwitch = application:addChild(GUI.switch(bufferWidth - 8, objectY, 7, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, true))
|
||||
objectY = objectY + 2
|
||||
|
||||
mainContainer:addChild(GUI.button(bufferWidth, 1, 1, 1, nil, 0xEEEEEE, nil, 0xFF2222, "X")).onTouch = function()
|
||||
mainContainer:stopEventHandling()
|
||||
application:addChild(GUI.button(bufferWidth, 1, 1, 1, nil, 0xEEEEEE, nil, 0xFF2222, "X")).onTouch = function()
|
||||
application:stop()
|
||||
createDick(math.random(-48, 48), math.random(1, 32), math.random(-48, 48), 100, true)
|
||||
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)
|
||||
end
|
||||
mainContainer.scanButton = mainContainer:addChild(GUI.button(panelX, bufferHeight - 2, panelWidth, 3, 0x262626, 0xEEEEEE, 0xAAAAAA, 0x262626, "Scan"))
|
||||
mainContainer.scanButton.onTouch = function()
|
||||
application.scanButton = application:addChild(GUI.button(panelX, bufferHeight - 2, panelWidth, 3, 0x262626, 0xEEEEEE, 0xAAAAAA, 0x262626, "Scan"))
|
||||
application.scanButton.onTouch = function()
|
||||
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
|
||||
|
||||
buffer.clear(0x0, 0.48)
|
||||
@ -205,13 +205,13 @@ mainContainer.scanButton.onTouch = function()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
updateData(false, true, true)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
buffer.clear(0x0)
|
||||
mainContainer:drawOnScreen()
|
||||
mainContainer:startEventHandling()
|
||||
application:draw()
|
||||
application:start()
|
||||
|
||||
|
||||
@ -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 xOffset, yOffset, xDrag, yDrag, points = 0, 0, 1, 1
|
||||
|
||||
@ -86,16 +86,16 @@ functionButton.onTouch = function()
|
||||
update()
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
scaleSlider.onValueChanged = function()
|
||||
update()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
rangeSlider.onValueChanged = scaleSlider.onValueChanged
|
||||
precisionSlider.onValueChanged = scaleSlider.onValueChanged
|
||||
@ -109,12 +109,12 @@ window.onResize = function(width, height)
|
||||
update()
|
||||
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
|
||||
xDrag, yDrag = e3, e4
|
||||
elseif e1 == "drag" then
|
||||
xOffset, yOffset = xOffset + (e3 - xDrag), yOffset + (e4 - yDrag)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
xDrag, yDrag = e3, e4
|
||||
elseif e1 == "scroll" then
|
||||
@ -126,14 +126,14 @@ graph.eventHandler = function(mainContainer, graph, e1, e2, e3, e4, e5)
|
||||
end
|
||||
|
||||
update()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
|
||||
update()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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.width, window.backgroundPanel.height = window.width - 10, window.height - 4
|
||||
@ -84,22 +84,22 @@ local function byteFieldDraw(object)
|
||||
return object
|
||||
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 e5 == 1 then
|
||||
local menu = GUI.addContextMenu(mainContainer, e3, e4)
|
||||
local menu = GUI.addContextMenu(application, e3, e4)
|
||||
|
||||
menu:addItem("Select all").onTouch = function()
|
||||
selection.from = 1
|
||||
selection.to = #bytes
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
menu:addSeparator()
|
||||
|
||||
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"))
|
||||
input.onInputFinished = function(text)
|
||||
@ -110,15 +110,15 @@ local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
end
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
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 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
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
menu:addSeparator()
|
||||
@ -158,7 +158,7 @@ local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
else
|
||||
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
|
||||
|
||||
status()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
elseif e1 == "scroll" then
|
||||
@ -192,7 +192,7 @@ local function byteFieldEventHandler(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
end
|
||||
scrollBar.value = offset
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -320,17 +320,17 @@ local function load(path)
|
||||
end
|
||||
|
||||
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:show()
|
||||
filesystemDialog.onSubmit = function(path)
|
||||
load(path)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
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:show()
|
||||
filesystemDialog.onSubmit = function(path)
|
||||
@ -358,13 +358,13 @@ window.actionButtons.maximize.onTouch = function()
|
||||
|
||||
window.localY = 1
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
load("/bin/resolution.lua")
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
|
||||
|
||||
|
||||
@ -196,7 +196,7 @@ local function flashback()
|
||||
buffer.clear(0x0, 0.3)
|
||||
end
|
||||
|
||||
local function drawOnScreen()
|
||||
local function draw()
|
||||
local width, height = 58, 7
|
||||
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
|
||||
getDate()
|
||||
drawOnScreen()
|
||||
draw()
|
||||
|
||||
local e = {event.pull(1)}
|
||||
if e[1] == "scroll" then
|
||||
|
||||
@ -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 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
|
||||
loginPasswordInput.hidden = state and true or not loginPasswordSwitchAndLabel.switch.state
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function updateLeftLayout()
|
||||
@ -256,7 +256,7 @@ local function addContactItemToList(name)
|
||||
scrollBar.value = scrollBar.maximumValue
|
||||
|
||||
rightLayout:removeChildren()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
if socketHandle then
|
||||
if list == channelsList then
|
||||
@ -386,7 +386,7 @@ end
|
||||
|
||||
loginUsernameInput.onInputFinished = function()
|
||||
checkLoginInputs()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
loginPasswordInput.onInputFinished = loginUsernameInput.onInputFinished
|
||||
@ -429,7 +429,7 @@ chatInput.onInputFinished = function()
|
||||
|
||||
chatInput.text = ""
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -444,17 +444,17 @@ local function addScrollEventHandler(layout)
|
||||
return height
|
||||
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 e5 > 0 then
|
||||
if layout.cells[1][1].verticalMargin < 0 then
|
||||
layout.cells[1][1].verticalMargin = layout.cells[1][1].verticalMargin + 1
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
else
|
||||
if layout.cells[1][1].verticalMargin > -getTotalHeight(layout) + 1 then
|
||||
layout.cells[1][1].verticalMargin = layout.cells[1][1].verticalMargin - 1
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -470,7 +470,7 @@ local function selectItem(item)
|
||||
item.onTouch()
|
||||
end
|
||||
|
||||
local function userButtonOnTouch(mainContainer, object)
|
||||
local function userButtonOnTouch(application, object)
|
||||
local text = object.text:gsub("^[@+]", "")
|
||||
if history[text] then
|
||||
selectItem(getItemByText(text))
|
||||
@ -524,17 +524,17 @@ local function removeUserFromList(name)
|
||||
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 e5 > 0 then
|
||||
if scrollBar.value > 1 then
|
||||
scrollBar.value = scrollBar.value - 1
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
else
|
||||
if scrollBar.value < scrollBar.maximumValue then
|
||||
scrollBar.value = scrollBar.value + 1
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
break
|
||||
else
|
||||
break
|
||||
@ -728,11 +728,11 @@ settingsButton.onTouch = function()
|
||||
config.soundNotifications = switchAndLabel.switch.state
|
||||
backgroundContainer.hidden = true
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
saveConfig()
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
contactAddButton.onTouch = function()
|
||||
@ -746,11 +746,11 @@ contactAddButton.onTouch = function()
|
||||
if #input.text > 0 and not history[input.text] then
|
||||
selectItem(addContactItemToList(input.text))
|
||||
else
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
contactRemoveButton.onTouch = function()
|
||||
@ -764,7 +764,7 @@ contactRemoveButton.onTouch = function()
|
||||
selectItem(systemList:getItem(socketUsername))
|
||||
updateLeftLayout()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
loginPasswordSwitchAndLabel.switch.onStateChanged = function()
|
||||
@ -795,7 +795,7 @@ scrollBar.onTouch = function()
|
||||
scrollBar.value = #history[selectedItem.text]
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local overrideWindowClose = window.close
|
||||
|
||||
@ -92,7 +92,7 @@ if filesystem.exists(configPath) then
|
||||
config = table.fromFile(configPath)
|
||||
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()
|
||||
|
||||
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)
|
||||
cursorBlinkState = state
|
||||
updateTitle()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
cursorUptime = computer.uptime()
|
||||
end
|
||||
@ -524,7 +524,7 @@ local function optimizeString(s)
|
||||
end
|
||||
|
||||
local function addBackgroundContainer(title)
|
||||
return GUI.addBackgroundContainer(mainContainer, true, true, title)
|
||||
return GUI.addBackgroundContainer(application, true, true, title)
|
||||
end
|
||||
|
||||
local function addInputFadeContainer(title, placeholder)
|
||||
@ -570,7 +570,7 @@ local function openFile(path)
|
||||
if counter % config.linesToShowOpenProgress == 0 then
|
||||
progressBar.value = math.floor(currentSize / totalSize * 100)
|
||||
computer.pullSignal(0)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -582,7 +582,7 @@ local function openFile(path)
|
||||
|
||||
if counter > config.linesToShowOpenProgress then
|
||||
progressBar.value = 100
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
codeView.hidden = false
|
||||
@ -598,7 +598,7 @@ end
|
||||
local function saveFile(path)
|
||||
filesystem.makeDirectory(filesystem.path(path))
|
||||
local file, reason = io.open(path, "w")
|
||||
if file then
|
||||
if file then
|
||||
for line = 1, #lines do
|
||||
file:write(lines[line], "\n")
|
||||
end
|
||||
@ -617,25 +617,25 @@ local function gotoLineWindow()
|
||||
if container.input.text:match("%d+") then
|
||||
gotoLine(tonumber(container.input.text))
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
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.onSubmit = function(path)
|
||||
openFile(path)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
filesystemDialog:show()
|
||||
end
|
||||
|
||||
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.onSubmit = function(path)
|
||||
saveFile(path)
|
||||
@ -643,7 +643,7 @@ local function saveFileAsWindow()
|
||||
leftTreeView.selectedItem = (leftTreeView.workPath .. path):gsub("/+", "/")
|
||||
|
||||
updateTitle()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
filesystemDialog:show()
|
||||
end
|
||||
@ -678,7 +678,7 @@ local function downloadFileFromWeb()
|
||||
if #container.input.text > 0 then
|
||||
container.input:remove()
|
||||
container.layout:addChild(GUI.text(1, 1, 0x969696, localization.downloading))
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
local result, reason = require("web").request(container.input.text)
|
||||
if result then
|
||||
@ -692,10 +692,10 @@ local function downloadFileFromWeb()
|
||||
end
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function getVariables(codePart)
|
||||
@ -740,12 +740,12 @@ continue = function(...)
|
||||
if coroutine.status(scriptCoroutine) == "dead" then
|
||||
MineOSInterface.waitForPressingAnyKey()
|
||||
buffer.setResolution(oldResolutionX, oldResolutionY)
|
||||
mainContainer:drawOnScreen(true)
|
||||
application:draw(true)
|
||||
else
|
||||
-- Тест на пидора, мало ли у чувака в проге тоже есть yield
|
||||
if _G.MineCodeIDEDebugInfo then
|
||||
buffer.setResolution(oldResolutionX, oldResolutionY)
|
||||
mainContainer:drawOnScreen(true)
|
||||
application:draw(true)
|
||||
gotoLine(_G.MineCodeIDEDebugInfo.line)
|
||||
showBreakpointMessage(_G.MineCodeIDEDebugInfo.variables)
|
||||
end
|
||||
@ -802,10 +802,10 @@ local function zalupa()
|
||||
updateHighlights()
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
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
|
||||
container.close()
|
||||
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.localY = codeView.localY + lastErrorLine - codeView.fromLine + 1
|
||||
|
||||
mainContainer:drawOnScreen(force)
|
||||
application:draw(force)
|
||||
|
||||
if beep then
|
||||
computer.beep(1500, 0.08)
|
||||
@ -900,7 +900,7 @@ showBreakpointMessage = function(variables)
|
||||
end
|
||||
|
||||
titleDebugMode = true
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
computer.beep(1500, 0.08)
|
||||
end
|
||||
@ -916,12 +916,12 @@ local function launchWithArgumentsWindow()
|
||||
end
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
run(table.unpack(arguments))
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function deleteLine(line)
|
||||
@ -1039,7 +1039,7 @@ local function selectAndPasteColor()
|
||||
|
||||
palette.cancelButton.onTouch = function()
|
||||
palette:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
palette.submitButton.onTouch = function()
|
||||
@ -1292,7 +1292,7 @@ local function toggleBottomToolBar()
|
||||
calculateSizes()
|
||||
|
||||
if not bottomToolBar.hidden then
|
||||
mainContainer:draw()
|
||||
application:draw()
|
||||
findFromFirstDisplayedLine()
|
||||
end
|
||||
end
|
||||
@ -1362,7 +1362,7 @@ local function createEditOrRightClickMenu(menu)
|
||||
|
||||
menu:addItem(localization.addBreakpoint, false, "F9").onTouch = function()
|
||||
addBreakpoint()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
menu:addItem(localization.clearBreakpoints, not breakpointLines, "^F9").onTouch = function()
|
||||
@ -1371,10 +1371,10 @@ local function createEditOrRightClickMenu(menu)
|
||||
end
|
||||
|
||||
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 e5 == 1 then
|
||||
createEditOrRightClickMenu(GUI.addContextMenu(mainContainer, e3, e4))
|
||||
createEditOrRightClickMenu(GUI.addContextMenu(application, e3, e4))
|
||||
else
|
||||
setCursorPositionAndClearSelection(convertScreenCoordinatesToTextPosition(e3, e4))
|
||||
end
|
||||
@ -1586,9 +1586,9 @@ codeView.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
end
|
||||
|
||||
leftTreeView.onItemSelected = function(path)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
openFile(path)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
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.eventHandler = nil
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local fileContextMenu = menu:addContextMenu(localization.file)
|
||||
fileContextMenu:addItem(localization.new, false, "^N").onTouch = function()
|
||||
newFile()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
fileContextMenu:addItem(localization.open, false, "^O").onTouch = function()
|
||||
@ -1650,12 +1650,12 @@ end
|
||||
fileContextMenu:addItem(MineOSCore.localization.flashEEPROM, not component.isAvailable("eeprom")).onTouch = function()
|
||||
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)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
pcall(component.eeprom.set, table.concat(lines, ";"))
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
fileContextMenu:addSeparator()
|
||||
@ -1692,7 +1692,7 @@ end
|
||||
|
||||
local propertiesContextMenu = menu:addContextMenu(localization.properties)
|
||||
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 colorSelectorCountY = math.ceil(colorSelectorsCount / colorSelectorCountX)
|
||||
@ -1722,7 +1722,7 @@ propertiesContextMenu:addItem(localization.colorScheme).onTouch = function()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function()
|
||||
@ -1748,7 +1748,7 @@ propertiesContextMenu:addItem(localization.cursorProperties).onTouch = function(
|
||||
saveConfig()
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
if topToolBar.hidden then
|
||||
@ -1785,13 +1785,13 @@ end
|
||||
|
||||
addBreakpointButton.onTouch = function()
|
||||
addBreakpoint()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
syntaxHighlightingButton.onTouch = function()
|
||||
config.syntaxHighlight = not config.syntaxHighlight
|
||||
codeView.syntaxHighlight = config.syntaxHighlight
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
saveConfig()
|
||||
end
|
||||
|
||||
@ -1799,19 +1799,19 @@ toggleLeftToolBarButton.onTouch = function()
|
||||
leftTreeView.hidden = not toggleLeftToolBarButton.pressed
|
||||
leftTreeViewResizer.hidden = leftTreeView.hidden
|
||||
calculateSizes()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
toggleBottomToolBarButton.onTouch = function()
|
||||
bottomToolBar.hidden = not toggleBottomToolBarButton.pressed
|
||||
calculateSizes()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
toggleTopToolBarButton.onTouch = function()
|
||||
topToolBar.hidden = not toggleTopToolBarButton.pressed
|
||||
calculateSizes()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
codeView.verticalScrollBar.onTouch = function()
|
||||
@ -1826,7 +1826,7 @@ runButton.onTouch = function()
|
||||
run()
|
||||
end
|
||||
|
||||
autocomplete.onItemSelected = function(mainContainer, object, e1)
|
||||
autocomplete.onItemSelected = function(application, object, e1)
|
||||
local firstPart = unicode.sub(lines[cursorPositionLine], 1, autoCompleteWordStart - 1)
|
||||
local secondPart = unicode.sub(lines[cursorPositionLine], autoCompleteWordEnd + 1, -1)
|
||||
local middle = firstPart .. autocomplete.items[autocomplete.selectedItem]
|
||||
@ -1843,7 +1843,7 @@ end
|
||||
|
||||
window.onResize = function(width, height)
|
||||
calculateSizes()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
searchInput.onInputFinished = findFromFirstDisplayedLine
|
||||
@ -1855,7 +1855,7 @@ searchButton.onTouch = find
|
||||
autocomplete:moveToFront()
|
||||
leftTreeView:updateFileList()
|
||||
calculateSizes()
|
||||
mainContainer:draw()
|
||||
application:draw()
|
||||
|
||||
local initialPath = select(1, ...)
|
||||
if initialPath and filesystem.exists(initialPath) then
|
||||
@ -1864,4 +1864,4 @@ else
|
||||
newFile()
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
@ -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))
|
||||
window.backgroundPanel.localX = inputsPanel.width + 1
|
||||
window.backgroundPanel.width = window.width - inputsPanel.width
|
||||
@ -95,7 +95,7 @@ end
|
||||
|
||||
local function broadcast(...)
|
||||
addMessage(localization.sent .. ": ", ...)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
modem.broadcast(port, "nanomachines", ...)
|
||||
end
|
||||
@ -138,7 +138,7 @@ for i = 1, maxInputs do
|
||||
local input = inputsContainer:addChild(GUI.switch(x, y, width, 0x66DB80, 0x1E1E1E, 0xE1E1E1, false))
|
||||
input.onStateChanged = function()
|
||||
checkSwitches()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
broadcastPut("setInput", i, input.state)
|
||||
broadcastPut("getActiveEffects")
|
||||
@ -230,7 +230,7 @@ local function updateEffects(variants)
|
||||
effectsLayout.height = #effectsLayout.children * 3
|
||||
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 e7 == "input" then
|
||||
local child = inputsContainer.children[e8]
|
||||
@ -245,7 +245,7 @@ local function runtimeEventHandler(mainContainer, object, e1, e2, e3, e4, e5, e6
|
||||
end
|
||||
|
||||
addMessage(localization.received .. ": ", e7, e8, ...)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
broadcastNext()
|
||||
elseif e1 == "scroll" then
|
||||
@ -259,7 +259,7 @@ local function runtimeEventHandler(mainContainer, object, e1, e2, e3, e4, e5, e6
|
||||
cell.verticalMargin = to
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -342,7 +342,7 @@ favouritesComboBox.onItemSelected = function()
|
||||
end
|
||||
|
||||
checkSwitches()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
broadcastNext()
|
||||
end
|
||||
|
||||
@ -364,12 +364,12 @@ if component.isAvailable("modem") then
|
||||
updateEffects(parseEffects())
|
||||
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 computer.uptime() >= syncDeadline then
|
||||
syncReset()
|
||||
setLines(localization.syncInfo)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
if not syncStarted then
|
||||
@ -394,14 +394,14 @@ if component.isAvailable("modem") then
|
||||
inputsContainer.children[i]:setState(syncResult[i])
|
||||
end
|
||||
checkSwitches()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
layout.eventHandler = runtimeEventHandler
|
||||
return
|
||||
end
|
||||
|
||||
setLines(string.format(localization.syncProgress .. localization.syncContacts, #syncResult, maxInputs))
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
syncUpdate()
|
||||
broadcastNext()
|
||||
@ -414,4 +414,4 @@ else
|
||||
setLines(localization.noModem)
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
@ -2,10 +2,10 @@
|
||||
local GUI = require("GUI")
|
||||
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:close()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
window.cancelButton.onTouch = window.submitButton.onTouch
|
||||
@ -74,9 +74,9 @@ end
|
||||
|
||||
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 titleContainer = container:addChild(GUI.container(1, 1, container.width, 1))
|
||||
@ -87,19 +87,19 @@ local function addTitle(container, text)
|
||||
end
|
||||
|
||||
local pizdaWidth = 28
|
||||
mainContainer.sidebarPanel = mainContainer:addChild(GUI.panel(mainContainer.width - pizdaWidth + 1, 2, pizdaWidth, mainContainer.height - 1, 0x3C3C3C))
|
||||
mainContainer.sidebarLayout = mainContainer:addChild(GUI.layout(mainContainer.sidebarPanel.localX, 2, mainContainer.sidebarPanel.width, mainContainer.sidebarPanel.height, 1, 1))
|
||||
mainContainer.sidebarLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
application.sidebarPanel = application:addChild(GUI.panel(application.width - pizdaWidth + 1, 2, pizdaWidth, application.height - 1, 0x3C3C3C))
|
||||
application.sidebarLayout = application:addChild(GUI.layout(application.sidebarPanel.localX, 2, application.sidebarPanel.width, application.sidebarPanel.height, 1, 1))
|
||||
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
|
||||
for i = 1, #config.recentColors do
|
||||
local button = recentColorsContainer:addChild(GUI.button(x, y, 2, 1, 0x0, 0x0, 0x0, 0x0, " "))
|
||||
button.onTouch = function()
|
||||
mainContainer.primaryColorSelector.color = config.recentColors[i]
|
||||
mainContainer:drawOnScreen()
|
||||
application.primaryColorSelector.color = config.recentColors[i]
|
||||
application:draw()
|
||||
end
|
||||
|
||||
x = x + 2
|
||||
@ -108,37 +108,37 @@ for i = 1, #config.recentColors do
|
||||
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))
|
||||
mainContainer.currentToolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
mainContainer.currentToolLayout:setFitting(1, 1, true, false, 2, 0)
|
||||
application.currentToolLayout = application.sidebarLayout:addChild(GUI.layout(1, 1, application.sidebarLayout.width, 1, 1, 1))
|
||||
application.currentToolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
application.currentToolLayout:setFitting(1, 1, true, false, 2, 0)
|
||||
|
||||
local aboutToolTitle = addTitle(mainContainer.sidebarLayout, "About tool")
|
||||
local aboutToolTextBox = mainContainer.sidebarLayout:addChild(GUI.textBox(1, 1, mainContainer.sidebarLayout.width - 2, 1, nil, 0x787878, {}, 1, 0, 0))
|
||||
local aboutToolTitle = addTitle(application.sidebarLayout, "About tool")
|
||||
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))
|
||||
mainContainer.backgroundPanel = mainContainer:addChild(GUI.panel(mainContainer.toolsList.width + 1, 2, mainContainer.width - mainContainer.toolsList.width - mainContainer.sidebarPanel.width, mainContainer.height - 1, 0x1E1E1E))
|
||||
mainContainer.image = mainContainer:addChild(GUI.object(1, 1, 1, 1))
|
||||
mainContainer.image.data = {}
|
||||
application.toolsList = application:addChild(GUI.list(1, 2, 6, application.height - 1, 3, 0, 0x3C3C3C, 0xD2D2D2, 0x3C3C3C, 0xD2D2D2, 0x2D2D2D, 0xD2D2D2))
|
||||
application.backgroundPanel = application:addChild(GUI.panel(application.toolsList.width + 1, 2, application.width - application.toolsList.width - application.sidebarPanel.width, application.height - 1, 0x1E1E1E))
|
||||
application.image = application:addChild(GUI.object(1, 1, 1, 1))
|
||||
application.image.data = {}
|
||||
|
||||
local function onToolTouch(index)
|
||||
tool = mainContainer.toolsList:getItem(index).tool
|
||||
tool = application.toolsList:getItem(index).tool
|
||||
|
||||
mainContainer.toolsList.selectedItem = index
|
||||
mainContainer.currentToolOverlay:removeChildren()
|
||||
mainContainer.currentToolLayout:removeChildren()
|
||||
application.toolsList.selectedItem = index
|
||||
application.currentToolOverlay:removeChildren()
|
||||
application.currentToolLayout:removeChildren()
|
||||
|
||||
currentToolTitle.hidden = not tool.onSelection
|
||||
mainContainer.currentToolLayout.hidden = currentToolTitle.hidden
|
||||
application.currentToolLayout.hidden = currentToolTitle.hidden
|
||||
|
||||
if tool.onSelection then
|
||||
local result, reason = pcall(tool.onSelection, mainContainer)
|
||||
local result, reason = pcall(tool.onSelection, application)
|
||||
if result then
|
||||
mainContainer.currentToolLayout:update()
|
||||
local lastChild = mainContainer.currentToolLayout.children[#mainContainer.currentToolLayout.children]
|
||||
application.currentToolLayout:update()
|
||||
local lastChild = application.currentToolLayout.children[#application.currentToolLayout.children]
|
||||
if lastChild then
|
||||
mainContainer.currentToolLayout.height = lastChild.localY + lastChild.height - 1
|
||||
application.currentToolLayout.height = lastChild.localY + lastChild.height - 1
|
||||
end
|
||||
else
|
||||
GUI.alert(reason)
|
||||
@ -153,7 +153,7 @@ local function onToolTouch(index)
|
||||
aboutToolTextBox.height = #aboutToolTextBox.lines
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local modules = fs.sortedList(toolsPath, "name", false)
|
||||
@ -162,7 +162,7 @@ for i = 1, #modules do
|
||||
if result then
|
||||
result, reason = pcall(result)
|
||||
if result then
|
||||
local item = mainContainer.toolsList:addItem(reason.shortcut)
|
||||
local item = application.toolsList:addItem(reason.shortcut)
|
||||
item.tool = reason
|
||||
item.onTouch = function()
|
||||
onToolTouch(i)
|
||||
@ -175,7 +175,7 @@ for i = 1, #modules do
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer.image.draw = function(object)
|
||||
application.image.draw = function(object)
|
||||
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
|
||||
@ -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)
|
||||
end
|
||||
|
||||
local x, y, step, notStep, background, foreground, symbol = object.x, object.y, false, mainContainer.image.width % 2
|
||||
for i = 1, mainContainer.image.width * mainContainer.image.height do
|
||||
if mainContainer.image.data[5][i] == 0 then
|
||||
background = mainContainer.image.data[3][i]
|
||||
foreground = mainContainer.image.data[4][i]
|
||||
symbol = mainContainer.image.data[6][i]
|
||||
elseif mainContainer.image.data[5][i] < 1 then
|
||||
background = color.blend(config.transparencyBackground, mainContainer.image.data[3][i], mainContainer.image.data[5][i])
|
||||
foreground = mainContainer.image.data[4][i]
|
||||
symbol = mainContainer.image.data[6][i]
|
||||
local x, y, step, notStep, background, foreground, symbol = object.x, object.y, false, application.image.width % 2
|
||||
for i = 1, application.image.width * application.image.height do
|
||||
if application.image.data[5][i] == 0 then
|
||||
background = application.image.data[3][i]
|
||||
foreground = application.image.data[4][i]
|
||||
symbol = application.image.data[6][i]
|
||||
elseif application.image.data[5][i] < 1 then
|
||||
background = color.blend(config.transparencyBackground, application.image.data[3][i], application.image.data[5][i])
|
||||
foreground = application.image.data[4][i]
|
||||
symbol = application.image.data[6][i]
|
||||
else
|
||||
if mainContainer.image.data[6][i] == " " then
|
||||
if application.image.data[6][i] == " " then
|
||||
background = config.transparencyBackground
|
||||
foreground = config.transparencyForeground
|
||||
symbol = step and "▒" or "░"
|
||||
else
|
||||
background = config.transparencyBackground
|
||||
foreground = mainContainer.image.data[4][i]
|
||||
symbol = mainContainer.image.data[6][i]
|
||||
foreground = application.image.data[4][i]
|
||||
symbol = application.image.data[6][i]
|
||||
end
|
||||
end
|
||||
|
||||
@ -228,8 +228,8 @@ local function updateRecentColorsButtons()
|
||||
end
|
||||
|
||||
local function swapColors()
|
||||
mainContainer.primaryColorSelector.color, mainContainer.secondaryColorSelector.color = mainContainer.secondaryColorSelector.color, mainContainer.primaryColorSelector.color
|
||||
mainContainer:drawOnScreen()
|
||||
application.primaryColorSelector.color, application.secondaryColorSelector.color = application.secondaryColorSelector.color, application.primaryColorSelector.color
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function colorSelectorDraw(object)
|
||||
@ -240,24 +240,24 @@ local function colorSelectorDraw(object)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer.secondaryColorSelector = mainContainer:addChild(GUI.colorSelector(2, mainContainer.toolsList.height - 3, 5, 2, 0xFFFFFF, " "))
|
||||
mainContainer.primaryColorSelector = mainContainer:addChild(GUI.colorSelector(1, mainContainer.toolsList.height - 4, 5, 2, 0x880000, " "))
|
||||
mainContainer.secondaryColorSelector.draw, mainContainer.primaryColorSelector.draw = colorSelectorDraw, colorSelectorDraw
|
||||
application.secondaryColorSelector = application:addChild(GUI.colorSelector(2, application.toolsList.height - 3, 5, 2, 0xFFFFFF, " "))
|
||||
application.primaryColorSelector = application:addChild(GUI.colorSelector(1, application.toolsList.height - 4, 5, 2, 0x880000, " "))
|
||||
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
|
||||
-- D
|
||||
if e4 == 32 then
|
||||
mainContainer.primaryColorSelector.color, mainContainer.secondaryColorSelector.color = 0x0, 0xFFFFFF
|
||||
mainContainer:drawOnScreen()
|
||||
application.primaryColorSelector.color, application.secondaryColorSelector.color = 0x0, 0xFFFFFF
|
||||
application:draw()
|
||||
-- X
|
||||
elseif e4 == 45 then
|
||||
swapColors()
|
||||
else
|
||||
for i = 1, mainContainer.toolsList:count() do
|
||||
if e4 == mainContainer.toolsList:getItem(i).tool.keyCode then
|
||||
for i = 1, application.toolsList:count() do
|
||||
if e4 == application.toolsList:getItem(i).tool.keyCode then
|
||||
onToolTouch(i)
|
||||
return
|
||||
end
|
||||
@ -265,37 +265,37 @@ mainContainer.image.eventHandler = function(mainContainer, object, e1, e2, e3, e
|
||||
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
|
||||
GUI.alert("Tool eventHandler() failed: " .. reason)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer.image.reposition = function()
|
||||
mainContainer.image.width, mainContainer.image.height = mainContainer.image.data[1], mainContainer.image.data[2]
|
||||
if mainContainer.image.width <= mainContainer.backgroundPanel.width then
|
||||
mainContainer.image.localX = math.floor(mainContainer.backgroundPanel.x + mainContainer.backgroundPanel.width / 2 - mainContainer.image.width / 2)
|
||||
mainContainer.image.localY = math.floor(mainContainer.backgroundPanel.y + mainContainer.backgroundPanel.height / 2 - mainContainer.image.height / 2)
|
||||
application.image.reposition = function()
|
||||
application.image.width, application.image.height = application.image.data[1], application.image.data[2]
|
||||
if application.image.width <= application.backgroundPanel.width then
|
||||
application.image.localX = math.floor(application.backgroundPanel.x + application.backgroundPanel.width / 2 - application.image.width / 2)
|
||||
application.image.localY = math.floor(application.backgroundPanel.y + application.backgroundPanel.height / 2 - application.image.height / 2)
|
||||
else
|
||||
mainContainer.image.localX, mainContainer.image.localY = 9, 3
|
||||
application.image.localX, application.image.localY = 9, 3
|
||||
end
|
||||
end
|
||||
|
||||
local function newNoGUI(width, height)
|
||||
savePath, saveItem.disabled = nil, true
|
||||
mainContainer.image.data = {width, height, {}, {}, {}, {}}
|
||||
mainContainer.image.reposition()
|
||||
application.image.data = {width, height, {}, {}, {}, {}}
|
||||
application.image.reposition()
|
||||
|
||||
for i = 1, width * height do
|
||||
table.insert(mainContainer.image.data[3], 0x0)
|
||||
table.insert(mainContainer.image.data[4], 0x0)
|
||||
table.insert(mainContainer.image.data[5], 1)
|
||||
table.insert(mainContainer.image.data[6], " ")
|
||||
table.insert(application.image.data[3], 0x0)
|
||||
table.insert(application.image.data[4], 0x0)
|
||||
table.insert(application.image.data[5], 1)
|
||||
table.insert(application.image.data[6], " ")
|
||||
end
|
||||
end
|
||||
|
||||
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 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
|
||||
heightInput.validator = widthInput.validator
|
||||
|
||||
container.panel.eventHandler = function(mainContainer, object, e1)
|
||||
container.panel.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
newNoGUI(tonumber(widthInput.text), tonumber(heightInput.text))
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function loadImage(path)
|
||||
@ -321,32 +321,41 @@ local function loadImage(path)
|
||||
if result then
|
||||
savePath, saveItem.disabled = path, false
|
||||
addRecentFile(path)
|
||||
mainContainer.image.data = result
|
||||
mainContainer.image.reposition()
|
||||
application.image.data = result
|
||||
application.image.reposition()
|
||||
else
|
||||
GUI.alert(reason)
|
||||
end
|
||||
end
|
||||
|
||||
local function saveImage(path)
|
||||
local result, reason = image.save(path, mainContainer.image.data, 6)
|
||||
if result then
|
||||
savePath, saveItem.disabled = path, false
|
||||
addRecentFile(path)
|
||||
if fs.extension(path) == ".pic" then
|
||||
local result, reason = image.save(path, application.image.data, 6)
|
||||
if result then
|
||||
savePath, saveItem.disabled = path, false
|
||||
|
||||
addRecentFile(path)
|
||||
else
|
||||
GUI.alert(reason)
|
||||
end
|
||||
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
|
||||
|
||||
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:addSeparator()
|
||||
|
||||
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:addExtensionFilter(".pic")
|
||||
filesystemDialog:expandPath(MineOSPaths.desktop)
|
||||
@ -354,7 +363,7 @@ fileItem:addItem("Open").onTouch = function()
|
||||
|
||||
filesystemDialog.onSubmit = function(path)
|
||||
loadImage(path)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -362,19 +371,19 @@ local fileItemSubMenu = fileItem:addSubMenu("Open recent", #config.recentFiles =
|
||||
for i = 1, #config.recentFiles do
|
||||
fileItemSubMenu:addItem(string.limit(config.recentFiles[i], 32, "left")).onTouch = function()
|
||||
loadImage(config.recentFiles[i])
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
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"))
|
||||
input.onInputFinished = function()
|
||||
if #input.text > 0 then
|
||||
input:remove()
|
||||
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 result, reason = web.download(input.text, temporaryPath)
|
||||
@ -389,11 +398,11 @@ fileItem:addItem("Open from URL").onTouch = function()
|
||||
GUI.alert(reason)
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
fileItem:addSeparator()
|
||||
@ -404,9 +413,10 @@ saveItem.onTouch = function()
|
||||
end
|
||||
|
||||
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:addExtensionFilter(".pic")
|
||||
filesystemDialog:addExtensionFilter(".ocifstring")
|
||||
filesystemDialog:expandPath(MineOSPaths.desktop)
|
||||
filesystemDialog.filesystemTree.selectedItem = MineOSPaths.desktop
|
||||
filesystemDialog:show()
|
||||
@ -419,30 +429,30 @@ end
|
||||
fileItem:addSeparator()
|
||||
|
||||
fileItem:addItem("Exit").onTouch = function()
|
||||
mainContainer:stopEventHandling()
|
||||
application:stop()
|
||||
end
|
||||
|
||||
mainContainer.menu:addItem("View").onTouch = function()
|
||||
local container = MineOSInterface.addBackgroundContainer(mainContainer, "View")
|
||||
application.menu:addItem("View").onTouch = function()
|
||||
local container = MineOSInterface.addBackgroundContainer(application, "View")
|
||||
|
||||
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"))
|
||||
|
||||
container.panel.eventHandler = function(mainContainer, object, e1)
|
||||
container.panel.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
config.transparencyBackground, config.transparencyForeground = colorSelector1.color, colorSelector2.color
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
saveConfig()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer.menu:addItem("Hotkeys").onTouch = function()
|
||||
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Hotkeys")
|
||||
application.menu:addItem("Hotkeys").onTouch = function()
|
||||
local container = MineOSInterface.addBackgroundContainer(application, "Hotkeys")
|
||||
local lines = {
|
||||
"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
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
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()
|
||||
mainContainer.backgroundPanel:moveToBack()
|
||||
application.image:moveToBack()
|
||||
application.backgroundPanel:moveToBack()
|
||||
|
||||
updateRecentColorsButtons()
|
||||
|
||||
@ -480,4 +490,4 @@ else
|
||||
end
|
||||
|
||||
onToolTouch(5)
|
||||
mainContainer:startEventHandling()
|
||||
application:start()
|
||||
@ -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 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
|
||||
selector.localX, selector.width = touchX, dragX - touchX + 1
|
||||
else
|
||||
@ -32,100 +32,100 @@ local function repositionSelector(mainContainer)
|
||||
selector.localY, selector.height = dragY, touchY - dragY + 1
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function fitSelector(mainContainer)
|
||||
touchX, touchY, dragX, dragY = mainContainer.image.localX, mainContainer.image.localY, mainContainer.image.localX + mainContainer.image.width - 1, mainContainer.image.localY + mainContainer.image.height - 1
|
||||
repositionSelector(mainContainer)
|
||||
local function fitSelector(application)
|
||||
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(application)
|
||||
end
|
||||
|
||||
tool.onSelection = function(mainContainer)
|
||||
mainContainer.currentToolLayout:addChild(fillButton).onTouch = function()
|
||||
tool.onSelection = function(application)
|
||||
application.currentToolLayout:addChild(fillButton).onTouch = function()
|
||||
for j = selector.y, selector.y + selector.height - 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
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer.currentToolLayout:addChild(outlineButton).onTouch = function()
|
||||
local x1, y1 = selector.x - mainContainer.image.x + 1, selector.y - mainContainer.image.y + 1
|
||||
application.currentToolLayout:addChild(outlineButton).onTouch = function()
|
||||
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
|
||||
|
||||
for x = x1, x2 do
|
||||
image.set(mainContainer.image.data, x, y1, mainContainer.primaryColorSelector.color, 0x0, 0, " ")
|
||||
image.set(mainContainer.image.data, x, y2, mainContainer.primaryColorSelector.color, 0x0, 0, " ")
|
||||
image.set(application.image.data, x, y1, application.primaryColorSelector.color, 0x0, 0, " ")
|
||||
image.set(application.image.data, x, y2, application.primaryColorSelector.color, 0x0, 0, " ")
|
||||
end
|
||||
|
||||
for y = y1 + 1, y2 - 1 do
|
||||
image.set(mainContainer.image.data, x1, y, mainContainer.primaryColorSelector.color, 0x0, 0, " ")
|
||||
image.set(mainContainer.image.data, x2, y, mainContainer.primaryColorSelector.color, 0x0, 0, " ")
|
||||
image.set(application.image.data, x1, y, application.primaryColorSelector.color, 0x0, 0, " ")
|
||||
image.set(application.image.data, x2, y, application.primaryColorSelector.color, 0x0, 0, " ")
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer.currentToolLayout:addChild(rasterizeLineButton).onTouch = function()
|
||||
application.currentToolLayout:addChild(rasterizeLineButton).onTouch = function()
|
||||
buffer.rasterizeLine(
|
||||
touchX - mainContainer.image.x + 1,
|
||||
touchY - mainContainer.image.y + 1,
|
||||
dragX - mainContainer.image.x + 1,
|
||||
dragY - mainContainer.image.y + 1,
|
||||
touchX - application.image.x + 1,
|
||||
touchY - application.image.y + 1,
|
||||
dragX - application.image.x + 1,
|
||||
dragY - application.image.y + 1,
|
||||
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
|
||||
)
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
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 centerX, centerY = math.ceil(minX + (maxX - minX) / 2), math.ceil(minY + (maxY - minY) / 2)
|
||||
|
||||
buffer.rasterizeEllipse(
|
||||
centerX - mainContainer.image.x + 1,
|
||||
centerY - mainContainer.image.y + 1,
|
||||
centerX - application.image.x + 1,
|
||||
centerY - application.image.y + 1,
|
||||
maxX - centerX,
|
||||
maxY - centerY,
|
||||
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
|
||||
)
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer.currentToolLayout:addChild(clearButton).onTouch = function()
|
||||
application.currentToolLayout:addChild(clearButton).onTouch = function()
|
||||
for j = selector.y, selector.y + selector.height - 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
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer.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)
|
||||
mainContainer.image.reposition()
|
||||
fitSelector(mainContainer)
|
||||
application.currentToolLayout:addChild(cropButton).onTouch = function()
|
||||
application.image.data = image.crop(application.image.data, selector.x - application.image.x + 1, selector.y - application.image.y + 1, selector.width, selector.height)
|
||||
application.image.reposition()
|
||||
fitSelector(application)
|
||||
end
|
||||
|
||||
mainContainer.currentToolOverlay:addChild(selector)
|
||||
fitSelector(mainContainer)
|
||||
application.currentToolOverlay:addChild(selector)
|
||||
fitSelector(application)
|
||||
end
|
||||
|
||||
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
|
||||
tool.eventHandler = function(application, object, e1, e2, e3, e4)
|
||||
if e1 == "touch" then
|
||||
touchX, touchY, dragX, dragY = e3, e4, e3, e4
|
||||
repositionSelector(mainContainer)
|
||||
repositionSelector(application)
|
||||
elseif e1 == "drag" then
|
||||
dragX, dragY = e3, e4
|
||||
repositionSelector(mainContainer)
|
||||
repositionSelector(application)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -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!"
|
||||
|
||||
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
|
||||
xOld, yOld = e3, e4
|
||||
elseif e1 == "drag" and xOld and yOld then
|
||||
mainContainer.image.localX = mainContainer.image.localX + (e3 - xOld)
|
||||
mainContainer.image.localY = mainContainer.image.localY + (e4 - yOld)
|
||||
application.image.localX = application.image.localX + (e3 - xOld)
|
||||
application.image.localY = application.image.localY + (e4 - yOld)
|
||||
xOld, yOld = e3, e4
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
elseif e1 == "drop" then
|
||||
xOld, yOld = nil, nil
|
||||
end
|
||||
|
||||
@ -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].onTouch = function()
|
||||
set(i, j)
|
||||
buttons[j][i].firstParent:drawOnScreen()
|
||||
buttons[j][i].firstParent:draw()
|
||||
end
|
||||
|
||||
x = x + buttonWidth + stepX
|
||||
@ -66,18 +66,18 @@ end
|
||||
|
||||
set(2, 2)
|
||||
|
||||
tool.onSelection = function(mainContainer)
|
||||
mainContainer.currentToolLayout:addChild(buttonsLayout)
|
||||
mainContainer.currentToolLayout:addChild(widthInput)
|
||||
mainContainer.currentToolLayout:addChild(heightInput)
|
||||
mainContainer.currentToolLayout:addChild(expandButton)
|
||||
mainContainer.currentToolLayout:addChild(cropButton)
|
||||
tool.onSelection = function(application)
|
||||
application.currentToolLayout:addChild(buttonsLayout)
|
||||
application.currentToolLayout:addChild(widthInput)
|
||||
application.currentToolLayout:addChild(heightInput)
|
||||
application.currentToolLayout:addChild(expandButton)
|
||||
application.currentToolLayout:addChild(cropButton)
|
||||
|
||||
widthInput.onInputFinished = function()
|
||||
expandButton.disabled = not widthInput.text:match("^%d+$") or not heightInput.text:match("^%d+$")
|
||||
cropButton.disabled = expandButton.disabled
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
heightInput.onInputFinished = widthInput.onInputFinished
|
||||
widthInput.onInputFinished()
|
||||
@ -85,33 +85,33 @@ tool.onSelection = function(mainContainer)
|
||||
expandButton.onTouch = function()
|
||||
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 < 3 and height or 0,
|
||||
currentX > 1 and width or 0,
|
||||
currentX < 3 and width or 0,
|
||||
0x0, 0x0, 1, " ")
|
||||
|
||||
mainContainer.image.reposition()
|
||||
mainContainer:drawOnScreen()
|
||||
application.image.reposition()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
cropButton.onTouch = function()
|
||||
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,
|
||||
currentY == 1 and 1 or height + 1,
|
||||
(currentX == 1 or currentX == 3) and mainContainer.image.width - width or mainContainer.image.width - width * 2,
|
||||
(currentY == 1 or currentY == 3) and mainContainer.image.height - height or mainContainer.image.height - height * 2
|
||||
(currentX == 1 or currentX == 3) and application.image.width - width or application.image.width - width * 2,
|
||||
(currentY == 1 or currentY == 3) and application.image.height - height or application.image.height - height * 2
|
||||
)
|
||||
|
||||
mainContainer.image.reposition()
|
||||
mainContainer:drawOnScreen()
|
||||
application.image.reposition()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
tool.eventHandler = function(mainContainer, object, e1)
|
||||
tool.eventHandler = function(application, object, e1)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -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 pickForegroundSwitch = GUI.switchAndLabel(1, 1, width, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Pick foreground:", true)
|
||||
|
||||
tool.onSelection = function(mainContainer)
|
||||
mainContainer.currentToolLayout:addChild(pickBackgroundSwitch)
|
||||
mainContainer.currentToolLayout:addChild(pickForegroundSwitch)
|
||||
tool.onSelection = function(application)
|
||||
application.currentToolLayout:addChild(pickBackgroundSwitch)
|
||||
application.currentToolLayout:addChild(pickForegroundSwitch)
|
||||
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
|
||||
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
|
||||
mainContainer.secondaryColorSelector.color = background
|
||||
application.secondaryColorSelector.color = background
|
||||
end
|
||||
|
||||
if pickForegroundSwitch.switch.state then
|
||||
mainContainer.primaryColorSelector.color = foreground
|
||||
application.primaryColorSelector.color = foreground
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -25,28 +25,28 @@ local radiusSlider = GUI.slider(1, 1, width, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878
|
||||
radiusSlider.height = 2
|
||||
radiusSlider.roundValues = true
|
||||
|
||||
tool.onSelection = function(mainContainer)
|
||||
mainContainer.currentToolLayout:addChild(backgroundSwitch)
|
||||
mainContainer.currentToolLayout:addChild(foregroundSwitch)
|
||||
mainContainer.currentToolLayout:addChild(alphaSwitch)
|
||||
mainContainer.currentToolLayout:addChild(symbolSwitch)
|
||||
mainContainer.currentToolLayout:addChild(symbolInput)
|
||||
mainContainer.currentToolLayout:addChild(alphaSlider)
|
||||
mainContainer.currentToolLayout:addChild(radiusSlider)
|
||||
tool.onSelection = function(application)
|
||||
application.currentToolLayout:addChild(backgroundSwitch)
|
||||
application.currentToolLayout:addChild(foregroundSwitch)
|
||||
application.currentToolLayout:addChild(alphaSwitch)
|
||||
application.currentToolLayout:addChild(symbolSwitch)
|
||||
application.currentToolLayout:addChild(symbolInput)
|
||||
application.currentToolLayout:addChild(alphaSlider)
|
||||
application.currentToolLayout:addChild(radiusSlider)
|
||||
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
|
||||
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)
|
||||
|
||||
for j = y - meow + 1, y + 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
|
||||
local background, foreground, alpha, symbol = image.get(mainContainer.image.data, i, j)
|
||||
image.set(mainContainer.image.data, i, j,
|
||||
backgroundSwitch.switch.state and mainContainer.primaryColorSelector.color or background,
|
||||
foregroundSwitch.switch.state and mainContainer.secondaryColorSelector.color or foreground,
|
||||
if i >= 1 and i <= application.image.width and j >= 1 and j <= application.image.height then
|
||||
local background, foreground, alpha, symbol = image.get(application.image.data, i, j)
|
||||
image.set(application.image.data, i, j,
|
||||
backgroundSwitch.switch.state and application.primaryColorSelector.color or background,
|
||||
foregroundSwitch.switch.state and application.secondaryColorSelector.color or foreground,
|
||||
alphaSwitch.switch.state and alphaSlider.value / 255 or alpha,
|
||||
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
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -17,24 +17,24 @@ local radiusSlider = GUI.slider(1, 1, 1, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787,
|
||||
radiusSlider.height = 2
|
||||
radiusSlider.roundValues = true
|
||||
|
||||
tool.onSelection = function(mainContainer)
|
||||
mainContainer.currentToolLayout:addChild(backgroundSwitch)
|
||||
mainContainer.currentToolLayout:addChild(foregroundSwitch)
|
||||
mainContainer.currentToolLayout:addChild(alphaSwitch)
|
||||
mainContainer.currentToolLayout:addChild(symbolSwitch)
|
||||
mainContainer.currentToolLayout:addChild(radiusSlider)
|
||||
tool.onSelection = function(application)
|
||||
application.currentToolLayout:addChild(backgroundSwitch)
|
||||
application.currentToolLayout:addChild(foregroundSwitch)
|
||||
application.currentToolLayout:addChild(alphaSwitch)
|
||||
application.currentToolLayout:addChild(symbolSwitch)
|
||||
application.currentToolLayout:addChild(radiusSlider)
|
||||
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
|
||||
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)
|
||||
|
||||
for j = y - meow + 1, y + 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
|
||||
local background, foreground, alpha, symbol = image.get(mainContainer.image.data, i, j)
|
||||
image.set(mainContainer.image.data, i, j,
|
||||
if i >= 1 and i <= application.image.width and j >= 1 and j <= application.image.height then
|
||||
local background, foreground, alpha, symbol = image.get(application.image.data, i, j)
|
||||
image.set(application.image.data, i, j,
|
||||
backgroundSwitch.switch.state and 0x0 or background,
|
||||
foregroundSwitch.switch.state and 0x0 or foreground,
|
||||
alphaSwitch.switch.state and 1 or alpha,
|
||||
@ -44,7 +44,7 @@ tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -10,28 +10,28 @@ tool.shortcut = "Tx"
|
||||
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.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
|
||||
tool.eventHandler = function(application, object, e1, e2, e3, e4)
|
||||
if e1 == "touch" then
|
||||
local input = mainContainer:addChild(GUI.input(
|
||||
local input = application:addChild(GUI.input(
|
||||
e3 - 1,
|
||||
e4,
|
||||
mainContainer.image.x + mainContainer.image.width - e3 + 2,
|
||||
application.image.x + application.image.width - e3 + 2,
|
||||
1,
|
||||
nil,
|
||||
mainContainer.primaryColorSelector.color,
|
||||
mainContainer.primaryColorSelector.color,
|
||||
application.primaryColorSelector.color,
|
||||
application.primaryColorSelector.color,
|
||||
nil,
|
||||
mainContainer.primaryColorSelector.color,
|
||||
application.primaryColorSelector.color,
|
||||
""
|
||||
))
|
||||
|
||||
input.onInputFinished = function()
|
||||
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
|
||||
if x <= mainContainer.image.width then
|
||||
local background, foreground, alpha = image.get(mainContainer.image.data, x, y)
|
||||
image.set(mainContainer.image.data, x, y, background, mainContainer.primaryColorSelector.color, alpha, unicode.sub(input.text, i, i))
|
||||
if x <= application.image.width then
|
||||
local background, foreground, alpha = image.get(application.image.data, x, y)
|
||||
image.set(application.image.data, x, y, background, application.primaryColorSelector.color, alpha, unicode.sub(input.text, i, i))
|
||||
x = x + 1
|
||||
else
|
||||
break
|
||||
@ -40,7 +40,7 @@ tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
|
||||
end
|
||||
|
||||
input:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
input:startInput()
|
||||
|
||||
@ -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
|
||||
end
|
||||
|
||||
tool.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
|
||||
tool.eventHandler = function(application, object, e1, e2, e3, e4)
|
||||
if e1 == "touch" then
|
||||
local x, y = e3 - mainContainer.image.x + 1, e4 - mainContainer.image.y + 1
|
||||
local sourceB, sourceF, sourceA, sourceS = image.get(mainContainer.image.data, x, y)
|
||||
pizda(x, y, mainContainer.image.data, sourceB, sourceF, sourceA, sourceS, mainContainer.primaryColorSelector.color, 0x0, 0, " ")
|
||||
local x, y = e3 - application.image.x + 1, e4 - application.image.y + 1
|
||||
local sourceB, sourceF, sourceA, sourceS = image.get(application.image.data, x, y)
|
||||
pizda(x, y, application.image.data, sourceB, sourceF, sourceA, sourceS, application.primaryColorSelector.color, 0x0, 0, " ")
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -32,24 +32,24 @@ end
|
||||
|
||||
local backgroundSwitch = GUI.switchAndLabel(1, 1, 1, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x878787, "Draw background:", false)
|
||||
|
||||
tool.onSelection = function(mainContainer)
|
||||
mainContainer.currentToolLayout:addChild(layout)
|
||||
mainContainer.currentToolLayout:addChild(backgroundSwitch)
|
||||
tool.onSelection = function(application)
|
||||
application.currentToolLayout:addChild(layout)
|
||||
application.currentToolLayout:addChild(backgroundSwitch)
|
||||
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
|
||||
local x, y = e3 - mainContainer.image.x + 1, e4 - mainContainer.image.y + 1
|
||||
local background, foreground, alpha, symbol = image.get(mainContainer.image.data, x, y)
|
||||
local x, y = e3 - application.image.x + 1, e4 - application.image.y + 1
|
||||
local background, foreground, alpha, symbol = image.get(application.image.data, x, y)
|
||||
|
||||
image.set(mainContainer.image.data, x, y,
|
||||
backgroundSwitch.switch.state and mainContainer.secondaryColorSelector.color or background,
|
||||
mainContainer.primaryColorSelector.color,
|
||||
image.set(application.image.data, x, y,
|
||||
backgroundSwitch.switch.state and application.secondaryColorSelector.color or background,
|
||||
application.primaryColorSelector.color,
|
||||
backgroundSwitch.switch.state and 0 or alpha,
|
||||
char
|
||||
)
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -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 configPath = MineOSPaths.applicationData .. "PrintImage/Config.cfg"
|
||||
local panelWidth = 34
|
||||
local mainContainer
|
||||
local application
|
||||
local mainImage
|
||||
local printers
|
||||
local currentPrinter = 1
|
||||
@ -140,15 +140,14 @@ local function beginPrint()
|
||||
end
|
||||
|
||||
buffer.clear()
|
||||
mainContainer:draw()
|
||||
buffer.drawChanges(true)
|
||||
application:draw()
|
||||
end
|
||||
|
||||
----------------------------------------- Window-zaluped parasha -----------------------------------------
|
||||
|
||||
local function getStatus()
|
||||
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",
|
||||
"Count of printers: " .. #printers,
|
||||
"Print result: " .. xBlocks .. "x" .. yBlocks .. " blocks",
|
||||
@ -185,79 +184,79 @@ local function drawMainImageObject(object)
|
||||
end
|
||||
|
||||
local function createWindow()
|
||||
mainContainer = GUI.fullScreenContainer()
|
||||
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0xEEEEEE))
|
||||
mainContainer:addChild(GUI.object(1, 1, mainContainer.width, mainContainer.height)).draw = drawMainImageObject
|
||||
application = GUI.application()
|
||||
application:addChild(GUI.panel(1, 1, application.width, application.height, 0xEEEEEE))
|
||||
application:addChild(GUI.object(1, 1, application.width, application.height)).draw = drawMainImageObject
|
||||
local textBoxesWidth = math.floor(panelWidth * 0.55)
|
||||
|
||||
mainContainer.shadeContainer = mainContainer:addChild(GUI.container(mainContainer.width - panelWidth + 1, 1, panelWidth, mainContainer.height))
|
||||
mainContainer.shadeContainer:addChild(GUI.panel(1, 1, mainContainer.shadeContainer.width, mainContainer.shadeContainer.height, 0x0000000, 0.4))
|
||||
application.shadeContainer = application:addChild(GUI.container(application.width - panelWidth + 1, 1, panelWidth, application.height))
|
||||
application.shadeContainer:addChild(GUI.panel(1, 1, application.shadeContainer.width, application.shadeContainer.height, 0x0000000, 0.4))
|
||||
|
||||
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
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.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", "/"))
|
||||
application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "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.onSubmit = function(path)
|
||||
mainImage = image.load(path)
|
||||
getStatus()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
y = y + 2
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.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))
|
||||
application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Material:"))
|
||||
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()
|
||||
config.mainMaterial = mainMaterialTextBox.text
|
||||
save()
|
||||
end
|
||||
|
||||
y = y + 2
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.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))
|
||||
application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Print name:"))
|
||||
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()
|
||||
config.printName = printNameTextBox.text
|
||||
save()
|
||||
end
|
||||
|
||||
y = y + 2
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Floor mode:"))
|
||||
local floorSwitch = mainContainer.shadeContainer:addChild(GUI.switch(mainContainer.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.floorMode))
|
||||
application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Floor mode:"))
|
||||
local floorSwitch = application.shadeContainer:addChild(GUI.switch(application.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.floorMode))
|
||||
floorSwitch.onStateChanged = function()
|
||||
config.floorMode = floorSwitch.state
|
||||
save()
|
||||
end
|
||||
|
||||
y = y + 2
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Show grid:"))
|
||||
local gridSwitch = mainContainer.shadeContainer:addChild(GUI.switch(mainContainer.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.showGrid))
|
||||
application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Show grid:"))
|
||||
local gridSwitch = application.shadeContainer:addChild(GUI.switch(application.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.showGrid))
|
||||
gridSwitch.onStateChanged = function()
|
||||
config.showGrid = gridSwitch.state
|
||||
save()
|
||||
mainContainer:draw()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
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
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Enabled:"))
|
||||
local frameSwitch = mainContainer.shadeContainer:addChild(GUI.switch(mainContainer.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.frame.enabled))
|
||||
application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Enabled:"))
|
||||
local frameSwitch = application.shadeContainer:addChild(GUI.switch(application.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.frame.enabled))
|
||||
frameSwitch.onStateChanged = function()
|
||||
config.frame.enabled = frameSwitch.state
|
||||
save()
|
||||
end
|
||||
y = y + 2
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.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))
|
||||
application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Material:"))
|
||||
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()
|
||||
config.frame.material = frameMaterialTextBox.text
|
||||
save()
|
||||
end
|
||||
|
||||
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()
|
||||
config.frame.width = frameWidthSlider.value
|
||||
save()
|
||||
@ -265,17 +264,17 @@ local function createWindow()
|
||||
frameWidthSlider.roundValues = true
|
||||
|
||||
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
|
||||
mainContainer.shadeContainer:addChild(GUI.label(3, y, mainContainer.shadeContainer.width, 1, 0xCCCCCC, "Enabled:"))
|
||||
local lightSwitch = mainContainer.shadeContainer:addChild(GUI.switch(mainContainer.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.lightEmission.enabled))
|
||||
application.shadeContainer:addChild(GUI.label(3, y, application.shadeContainer.width, 1, 0xCCCCCC, "Enabled:"))
|
||||
local lightSwitch = application.shadeContainer:addChild(GUI.switch(application.shadeContainer.width - 9, y, 8, 0xFFDB40, 0xAAAAAA, 0xFFFFFF, config.lightEmission.enabled))
|
||||
lightSwitch.onStateChanged = function()
|
||||
config.lightEmission.enabled = true
|
||||
save()
|
||||
end
|
||||
|
||||
y = y + 2
|
||||
local lightSlider = 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.onValueChanged = function()
|
||||
config.lightEmission.value = lightSlider.value
|
||||
@ -283,23 +282,23 @@ local function createWindow()
|
||||
end
|
||||
|
||||
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
|
||||
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()
|
||||
mainContainer:stopEventHandling()
|
||||
application.shadeContainer:addChild(GUI.button(1, application.shadeContainer.height - 5, application.shadeContainer.width, 3, 0x363636, 0xFFFFFF, 0xFFFFFF, 0x262626, "Exit")).onTouch = function()
|
||||
application:stop()
|
||||
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()
|
||||
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
|
||||
getPrinters()
|
||||
getStatus()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -313,5 +312,5 @@ createWindow()
|
||||
mainImage = image.load(startImagePath)
|
||||
getStatus()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
mainContainer:startEventHandling()
|
||||
application:draw()
|
||||
application:start()
|
||||
|
||||
@ -25,7 +25,7 @@ local function menuBackground()
|
||||
end
|
||||
|
||||
local function settings()
|
||||
local window = GUI.fullScreenContainer()
|
||||
local window = GUI.application()
|
||||
local oldDraw = window.draw
|
||||
window.draw = function()
|
||||
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
|
||||
resolutionTextBoxHeight.validator = function(text) local num = tonumber(text); if num and num >= 12 and num <= 50 then return true end end
|
||||
local function onAnyResolutionTextBoxInputFinished()
|
||||
window:stopEventHandling()
|
||||
window:stop()
|
||||
rayEngine.changeResolution(tonumber(resolutionTextBoxWidth.text), tonumber(resolutionTextBoxHeight.text))
|
||||
settings()
|
||||
end
|
||||
@ -55,28 +55,24 @@ local function settings()
|
||||
drawDistanceSlider.onValueChanged = function()
|
||||
rayEngine.properties.drawDistance = drawDistanceSlider.value
|
||||
window:draw()
|
||||
buffer.drawChanges()
|
||||
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))
|
||||
shadingDistanceSlider.onValueChanged = function()
|
||||
rayEngine.properties.shadingDistance = shadingDistanceSlider.value
|
||||
window:draw()
|
||||
buffer.drawChanges()
|
||||
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))
|
||||
shadingCascadesSlider.onValueChanged = function()
|
||||
rayEngine.properties.shadingCascades = shadingCascadesSlider.value
|
||||
window:draw()
|
||||
buffer.drawChanges()
|
||||
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))
|
||||
raycastQualitySlider.onValueChanged = function()
|
||||
rayEngine.properties.raycastQuality = raycastQualitySlider.value
|
||||
window:draw()
|
||||
buffer.drawChanges()
|
||||
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))
|
||||
@ -86,7 +82,6 @@ local function settings()
|
||||
currentTimeSlider.colors.active = rayEngine.world.colors.sky.current
|
||||
currentTimeSlider.colors.pipe = rayEngine.world.colors.sky.current
|
||||
window:draw()
|
||||
buffer.drawChanges()
|
||||
end; y = y + 4
|
||||
|
||||
window:addChild(GUI.label(x, y, sliderWidth, 1, 0xDDDDDD, localization.enableSemipixelRenderer))
|
||||
@ -95,7 +90,6 @@ local function settings()
|
||||
graphonSwitch.onStateChanged = function()
|
||||
rayEngine.properties.useSimpleRenderer = not graphonSwitch.state
|
||||
window:draw()
|
||||
buffer.drawChanges()
|
||||
end; y = y + 3
|
||||
|
||||
window:addChild(GUI.label(x, y, sliderWidth, 1, 0xDDDDDD, localization.enableDayNightCycle))
|
||||
@ -104,16 +98,16 @@ local function settings()
|
||||
lockTimeSwitch.onStateChanged = function()
|
||||
rayEngine.world.dayNightCycle.enabled = lockTimeSwitch.state
|
||||
window:draw()
|
||||
buffer.drawChanges()
|
||||
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
|
||||
|
||||
local function menu()
|
||||
local window = GUI.fullScreenContainer()
|
||||
local window = GUI.application()
|
||||
local oldDraw = window.draw
|
||||
window.draw = function()
|
||||
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)
|
||||
|
||||
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.settings)).onTouch = function() window:stopEventHandling(); 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, 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: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.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
|
||||
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
|
||||
end
|
||||
|
||||
@ -141,7 +135,8 @@ local function menu()
|
||||
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:draw(); buffer.drawChanges(); window:startEventHandling()
|
||||
window:draw()
|
||||
window:start()
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -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 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
|
||||
|
||||
buffer.setResolution(buffer.getResolution())
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ local computer = require("computer")
|
||||
|
||||
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])
|
||||
|
||||
update()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
usersLayout.height, step = usersLayout.height + userContainer.height, not step
|
||||
@ -60,7 +60,7 @@ module.onTouch = function()
|
||||
input.text = ""
|
||||
|
||||
update()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ local scale = require("scale")
|
||||
|
||||
local module = {}
|
||||
|
||||
local mainContainer, window, localization = table.unpack({...})
|
||||
local application, window, localization = table.unpack({...})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -85,7 +85,7 @@ module.onTouch = function()
|
||||
switch.onStateChanged = function()
|
||||
updateSwitch()
|
||||
updateCykaTextBox()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
MineOSCore.properties.screenAutoScale = switch.state
|
||||
MineOSCore.saveProperties()
|
||||
@ -96,7 +96,7 @@ module.onTouch = function()
|
||||
if cykaTextBox.hidden then
|
||||
setResolution(width, height)
|
||||
else
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
heightInput.onInputFinished = widthInput.onInputFinished
|
||||
|
||||
@ -6,7 +6,7 @@ local MineOSCore = require("MineOSCore")
|
||||
|
||||
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)
|
||||
MineOSCore.properties.wallpaper = path
|
||||
MineOSInterface.changeWallpaper()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
MineOSCore.saveProperties()
|
||||
end
|
||||
@ -35,7 +35,7 @@ module.onTouch = function()
|
||||
wallpaperSwitch.onStateChanged = function()
|
||||
MineOSCore.properties.wallpaperEnabled = wallpaperSwitch.state
|
||||
MineOSInterface.changeWallpaper()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
MineOSCore.saveProperties()
|
||||
end
|
||||
@ -48,7 +48,7 @@ module.onTouch = function()
|
||||
wallpaperSlider.onValueChanged = function()
|
||||
MineOSCore.properties.wallpaperBrightness = wallpaperSlider.value / 100
|
||||
MineOSInterface.changeWallpaper()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
MineOSCore.saveProperties()
|
||||
end
|
||||
@ -56,7 +56,7 @@ module.onTouch = function()
|
||||
comboBox.onItemSelected = function()
|
||||
MineOSCore.properties.wallpaperMode = comboBox.selectedItem
|
||||
MineOSInterface.changeWallpaper()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
MineOSCore.saveProperties()
|
||||
end
|
||||
|
||||
@ -7,7 +7,7 @@ local MineOSCore = require("MineOSCore")
|
||||
|
||||
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.menuColor = menuColorSelector.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
|
||||
menuColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
|
||||
dockColorSelector.onColorSelected = backgroundColorSelector.onColorSelected
|
||||
@ -79,7 +79,7 @@ module.onTouch = function()
|
||||
MineOSCore.properties.transparencyEnabled = transparencySwitch.state
|
||||
|
||||
MineOSInterface.applyTransparency()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
MineOSCore.saveProperties()
|
||||
end
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ local MineOSCore = require("MineOSCore")
|
||||
|
||||
local module = {}
|
||||
|
||||
local mainContainer, window, localization = table.unpack({...})
|
||||
local application, window, localization = table.unpack({...})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ local filesystem = require("filesystem")
|
||||
|
||||
local module = {}
|
||||
|
||||
local mainContainer, window, localization = table.unpack({...})
|
||||
local application, window, localization = table.unpack({...})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -79,7 +79,7 @@ module.onTouch = function()
|
||||
comboBox.onItemSelected = function()
|
||||
currentAddress = getProxy().address
|
||||
update()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
input.onInputFinished = function()
|
||||
@ -92,7 +92,7 @@ module.onTouch = function()
|
||||
GUI.alert(reason)
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
button.onTouch = function()
|
||||
@ -103,7 +103,7 @@ module.onTouch = function()
|
||||
end
|
||||
|
||||
fill()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
fill()
|
||||
|
||||
@ -8,7 +8,7 @@ local filesystem = require("filesystem")
|
||||
|
||||
local module = {}
|
||||
|
||||
local mainContainer, window, localization = table.unpack({...})
|
||||
local application, window, localization = table.unpack({...})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -63,7 +63,7 @@ module.onTouch = function()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
networkNameInput.onInputFinished = function()
|
||||
@ -93,7 +93,7 @@ module.onTouch = function()
|
||||
end
|
||||
|
||||
-- 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
|
||||
check()
|
||||
elseif e1 == "MineOSNetwork" and e2 == "updateProxyList" then
|
||||
|
||||
@ -7,7 +7,7 @@ local filesystem = require("filesystem")
|
||||
|
||||
local module = {}
|
||||
|
||||
local mainContainer, window, localization = table.unpack({...})
|
||||
local application, window, localization = table.unpack({...})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ local MineOSCore = require("MineOSCore")
|
||||
|
||||
local module = {}
|
||||
|
||||
local mainContainer, window, localization = table.unpack({...})
|
||||
local application, window, localization = table.unpack({...})
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -38,7 +38,7 @@ module.onTouch = function()
|
||||
|
||||
MineOSCore.updateTimezone()
|
||||
MineOSCore.updateTime()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
MineOSCore.saveProperties()
|
||||
end
|
||||
|
||||
@ -8,7 +8,7 @@ local unicode = require("unicode")
|
||||
|
||||
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])
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
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()
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -15,9 +15,9 @@ local spinnerLimit = 8
|
||||
local spinnerHue = math.random(0, 360)
|
||||
local spinnerHueStep = 20
|
||||
|
||||
local mainContainer = GUI.fullScreenContainer()
|
||||
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x0))
|
||||
local spinnerImage = mainContainer:addChild(GUI.image(1, 1, {1, 1}))
|
||||
local application = GUI.application()
|
||||
application:addChild(GUI.panel(1, 1, application.width, application.height, 0x0))
|
||||
local spinnerImage = application:addChild(GUI.image(1, 1, {1, 1}))
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
@ -43,9 +43,9 @@ local function changeColor(hue, saturation)
|
||||
spinnerImage.image = spinners[currentSpinner]
|
||||
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
|
||||
mainContainer:stopEventHandling()
|
||||
application:stop()
|
||||
elseif e1 == "touch" then
|
||||
spinnerHue = spinnerHue + spinnerHueStep * (e5 == 1 and -1 or 1)
|
||||
if spinnerHue > 360 then
|
||||
@ -62,7 +62,7 @@ mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4, e5)
|
||||
end
|
||||
spinnerImage.image = spinners[currentSpinner]
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
@ -72,14 +72,14 @@ for i = 1, spinnerLimit do
|
||||
end
|
||||
spinnerImage.width = image.getWidth(spinners[currentSpinner])
|
||||
spinnerImage.height = image.getHeight(spinners[currentSpinner])
|
||||
spinnerImage.localX = math.floor(mainContainer.width / 2 - spinnerImage.width / 2)
|
||||
spinnerImage.localY = math.floor(mainContainer.height / 2 - spinnerImage.height/ 2)
|
||||
spinnerImage.localX = math.floor(application.width / 2 - spinnerImage.width / 2)
|
||||
spinnerImage.localY = math.floor(application.height / 2 - spinnerImage.height/ 2)
|
||||
|
||||
changeColor(spinnerHue, 1)
|
||||
buffer.flush()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
mainContainer:startEventHandling(0)
|
||||
application:start(0)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ local contacts = {}
|
||||
local Ch1Image = image.load(resources .. "Ch1.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
|
||||
|
||||
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
|
||||
|
||||
local function updateChevrons(state)
|
||||
for i = 1, #mainContainer.chevrons do
|
||||
mainContainer.chevrons[i].isActivated = state
|
||||
if not state then mainContainer.chevrons[i].text = " " end
|
||||
for i = 1, #application.chevrons do
|
||||
application.chevrons[i].isActivated = state
|
||||
if not state then application.chevrons[i].text = " " end
|
||||
end
|
||||
end
|
||||
|
||||
local function updateButtons()
|
||||
mainContainer.removeContactButton.disabled = #contacts == 0
|
||||
mainContainer.connectContactButton.disabled = #contacts == 0
|
||||
application.removeContactButton.disabled = #contacts == 0
|
||||
application.connectContactButton.disabled = #contacts == 0
|
||||
end
|
||||
|
||||
local function update()
|
||||
local stargateState, irisState, imagePath = stargate.stargateState(), stargate.irisState()
|
||||
mainContainer.irisButton.text = irisState == "Closed" and "Open Iris" or "Close Iris"
|
||||
mainContainer.connectionButton.text = stargateState == "Connected" and "Disconnect" or "Connect"
|
||||
mainContainer.connectedToLabel.text = stargateState == "Connected" and "(Connected to " .. stargate.remoteAddress() .. ")" or "(Not connected)"
|
||||
application.irisButton.text = irisState == "Closed" and "Open Iris" or "Close Iris"
|
||||
application.connectionButton.text = stargateState == "Connected" and "Disconnect" or "Connect"
|
||||
application.connectedToLabel.text = stargateState == "Connected" and "(Connected to " .. stargate.remoteAddress() .. ")" or "(Not connected)"
|
||||
|
||||
if stargateState == "Connected" then
|
||||
mainContainer.connectContactButton.disabled = true
|
||||
mainContainer.messageContactButton.disabled = false
|
||||
application.connectContactButton.disabled = true
|
||||
application.messageContactButton.disabled = false
|
||||
|
||||
if irisState == "Closed" then
|
||||
imagePath = "OnOn.pic"
|
||||
@ -87,8 +87,8 @@ local function update()
|
||||
imagePath = "OnOff.pic"
|
||||
end
|
||||
else
|
||||
mainContainer.connectContactButton.disabled = false
|
||||
mainContainer.messageContactButton.disabled = true
|
||||
application.connectContactButton.disabled = false
|
||||
application.messageContactButton.disabled = true
|
||||
|
||||
if irisState == "Closed" then
|
||||
imagePath = "OffOn.pic"
|
||||
@ -98,16 +98,16 @@ local function update()
|
||||
end
|
||||
|
||||
updateButtons()
|
||||
mainContainer.SGImage.image = image.load(resources .. imagePath)
|
||||
application.SGImage.image = image.load(resources .. imagePath)
|
||||
end
|
||||
|
||||
local function updateContacts()
|
||||
mainContainer.contactsComboBox:clear()
|
||||
application.contactsComboBox:clear()
|
||||
if #contacts == 0 then
|
||||
mainContainer.contactsComboBox:addItem("No contacts found")
|
||||
application.contactsComboBox:addItem("No contacts found")
|
||||
else
|
||||
for i = 1, #contacts do
|
||||
mainContainer.contactsComboBox:addItem(contacts[i].name)
|
||||
application.contactsComboBox:addItem(contacts[i].name)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -132,8 +132,8 @@ end
|
||||
local function dial(address)
|
||||
local success, reason = stargate.dial(address)
|
||||
if success then
|
||||
mainContainer.fuelProgressBar.value = math.ceil(stargate.energyToDial(address) / stargate.energyAvailable() * 100)
|
||||
mainContainer:drawOnScreen()
|
||||
application.fuelProgressBar.value = math.ceil(stargate.energyToDial(address) / stargate.energyAvailable() * 100)
|
||||
application:draw()
|
||||
else
|
||||
GUI.alert("Failed to dial: " .. tostring(reason))
|
||||
end
|
||||
@ -142,15 +142,15 @@ end
|
||||
---------------------------------------------------------------------------------------------
|
||||
|
||||
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")))
|
||||
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 = application:addChild(GUI.image(1, 1, image.load(resources .. "OffOff.pic")))
|
||||
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))
|
||||
mainContainer.chevrons = {}
|
||||
application.chevronsContainer = application:addChild(GUI.container(application.SGImage.localX, application.SGImage.localY, application.SGImage.width, application.SGImage.height))
|
||||
application.chevrons = {}
|
||||
addChevron(13, 30)
|
||||
addChevron(8, 17)
|
||||
addChevron(21, 6)
|
||||
@ -159,15 +159,15 @@ addChevron(72, 6)
|
||||
addChevron(83, 17)
|
||||
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
|
||||
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
|
||||
mainContainer.connectionButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Connect")); y = y + 3
|
||||
-- mainContainer.connectionButton.animated = false
|
||||
mainContainer.connectionButton.onTouch = function()
|
||||
application:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Stargate " .. stargate.localAddress())):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 1
|
||||
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
|
||||
application.connectionButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Connect")); y = y + 3
|
||||
-- application.connectionButton.animated = false
|
||||
application.connectionButton.onTouch = function()
|
||||
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"))
|
||||
input.onInputFinished = function()
|
||||
if input.text then
|
||||
@ -176,24 +176,24 @@ mainContainer.connectionButton.onTouch = function()
|
||||
saveContacts()
|
||||
container:remove()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
container.panel.eventHandler = function(mainContainer, object, e1)
|
||||
container.panel.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
input.onInputFinished()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
else
|
||||
stargate.disconnect()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer.irisButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Open Iris")); y = y + 3
|
||||
mainContainer.irisButton.onTouch = function()
|
||||
application.irisButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Open Iris")); y = y + 3
|
||||
application.irisButton.onTouch = function()
|
||||
if stargate.irisState() == "Open" then
|
||||
stargate.closeIris()
|
||||
else
|
||||
@ -201,43 +201,43 @@ mainContainer.irisButton.onTouch = function()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer.messageContactButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Message")); y = y + 4
|
||||
mainContainer.messageContactButton.onTouch = function()
|
||||
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Message")
|
||||
application.messageContactButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Message")); y = y + 4
|
||||
application.messageContactButton.onTouch = function()
|
||||
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"))
|
||||
input.onInputFinished = function()
|
||||
if input.text then
|
||||
container:remove()
|
||||
stargate.sendMessage(input.text)
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
container.panel.eventHandler = function(mainContainer, object, e1)
|
||||
container.panel.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
input.onInputFinished()
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer: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:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Contacts")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2
|
||||
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
|
||||
mainContainer.connectContactButton.onTouch = function()
|
||||
dial(contacts[mainContainer.contactsComboBox.selectedItem].address)
|
||||
application.connectContactButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Connect")); y = y + 3
|
||||
application.connectContactButton.onTouch = function()
|
||||
dial(contacts[application.contactsComboBox.selectedItem].address)
|
||||
end
|
||||
|
||||
mainContainer.addContactButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Add contact")); y = y + 3
|
||||
mainContainer.addContactButton.onTouch = function()
|
||||
local container = MineOSInterface.addBackgroundContainer(mainContainer, "Add contact")
|
||||
application.addContactButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Add contact")); y = y + 3
|
||||
application.addContactButton.onTouch = function()
|
||||
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 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 input1.text and input2.text then
|
||||
local exists = false
|
||||
@ -255,48 +255,48 @@ mainContainer.addContactButton.onTouch = function()
|
||||
end
|
||||
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer.removeContactButton = mainContainer:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Remove contact")); y = y + 4
|
||||
mainContainer.removeContactButton.onTouch = function()
|
||||
application.removeContactButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Remove contact")); y = y + 4
|
||||
application.removeContactButton.onTouch = function()
|
||||
if #contacts > 0 then
|
||||
table.remove(contacts, mainContainer.contactsComboBox.selectedItem)
|
||||
table.remove(contacts, application.contactsComboBox.selectedItem)
|
||||
updateContacts()
|
||||
saveContacts()
|
||||
updateButtons()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
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
|
||||
mainContainer.fuelProgressBar = mainContainer: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
|
||||
mainContainer.exitButton.onTouch = function()
|
||||
mainContainer:stopEventHandling()
|
||||
application:addChild(GUI.label(x, y, width, 1, 0xEEEEEE, "Energy to dial")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); y = y + 2
|
||||
application.fuelProgressBar = application:addChild(GUI.progressBar(x, y, width, 0xBBBBBB, 0x0, 0xEEEEEE, 100, true, true, "", "%")); y = y + 3
|
||||
application.exitButton = application:addChild(GUI.framedButton(x, y, width, 3, 0xEEEEEE, 0xEEEEEE, 0xBBBBBB, 0xBBBBBB, "Exit")); y = y + 4
|
||||
application.exitButton.onTouch = function()
|
||||
application:stop()
|
||||
end
|
||||
|
||||
mainContainer.eventHandler = function(mainContainer, object, e1, e2, e3, e4)
|
||||
application.eventHandler = function(application, object, e1, e2, e3, e4)
|
||||
if e1 == "sgIrisStateChange" then
|
||||
update()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
elseif e1 == "sgStargateStateChange" then
|
||||
if e3 == "Idle" or e3 == "Connected" then
|
||||
update()
|
||||
updateChevrons(e3 == "Connected")
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
elseif e1 == "sgChevronEngaged" then
|
||||
if mainContainer.chevrons[e3] then
|
||||
mainContainer.chevrons[e3].isActivated = true
|
||||
mainContainer.chevrons[e3].text = e4
|
||||
mainContainer:drawOnScreen()
|
||||
if application.chevrons[e3] then
|
||||
application.chevrons[e3].isActivated = true
|
||||
application.chevrons[e3].text = e4
|
||||
application:draw()
|
||||
end
|
||||
elseif e1 == "sgMessageReceived" then
|
||||
GUI.alert(e3)
|
||||
@ -308,6 +308,5 @@ updateContacts()
|
||||
update()
|
||||
updateChevrons(stargate.stargateState() == "Connected")
|
||||
|
||||
mainContainer:draw()
|
||||
buffer.drawChanges(true)
|
||||
mainContainer:startEventHandling()
|
||||
application:draw()
|
||||
application:start()
|
||||
@ -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 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:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
|
||||
local function onRecentButtonTouch(mainContainer, object)
|
||||
local function onRecentButtonTouch(application, object)
|
||||
fromChar = object.code
|
||||
selectedChar = object.code
|
||||
updateChars()
|
||||
updateTexts()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function updateRecent()
|
||||
@ -86,7 +86,7 @@ for i = 1, #recent do
|
||||
step = not step
|
||||
end
|
||||
|
||||
local function charButtonOnTouch(mainContainer, button)
|
||||
local function charButtonOnTouch(application, button)
|
||||
selectedChar = fromChar + button:indexOf() - 1
|
||||
table.insert(recent, 1, selectedChar)
|
||||
table.remove(recent, #recent)
|
||||
@ -95,7 +95,7 @@ local function charButtonOnTouch(mainContainer, button)
|
||||
updateTexts()
|
||||
updateRecent()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
table.toFile(recentCharsPath, recent)
|
||||
end
|
||||
|
||||
@ -131,7 +131,7 @@ window.onResize = function(width, height)
|
||||
|
||||
updateChars()
|
||||
updateTexts()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function onAny()
|
||||
@ -147,7 +147,7 @@ nextButton.onTouch = function()
|
||||
|
||||
updateChars()
|
||||
updateTexts()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
prevButton.onTouch = function()
|
||||
@ -156,7 +156,7 @@ prevButton.onTouch = function()
|
||||
|
||||
updateChars()
|
||||
updateTexts()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local overrideWindowEventHandler = window.eventHandler
|
||||
@ -180,7 +180,7 @@ gotoInput.onInputFinished = function()
|
||||
updateChars()
|
||||
updateTexts()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -29,10 +29,10 @@ end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local mainContainer = GUI.fullScreenContainer()
|
||||
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x1E1E1E))
|
||||
local actionButtons = mainContainer:addChild(GUI.actionButtons(2, 1))
|
||||
local layout = mainContainer:addChild(GUI.layout(1, 1, mainContainer.width, mainContainer.height, 1, 1))
|
||||
local application = GUI.application()
|
||||
application:addChild(GUI.panel(1, 1, application.width, application.height, 0x1E1E1E))
|
||||
local actionButtons = application:addChild(GUI.actionButtons(3, 2, true))
|
||||
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 elementWidth = image.getWidth(logo.image)
|
||||
@ -58,7 +58,7 @@ local infoLabel = layout:addChild(GUI.label(1, 1, elementWidth, 1, 0xFF6D40, " "
|
||||
|
||||
local function status(text)
|
||||
infoLabel.text = text
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function getLanguageIndex(text, short)
|
||||
@ -147,7 +147,7 @@ fromLanguageAutoDetectButton.onTouch = function()
|
||||
end
|
||||
|
||||
actionButtons.close.onTouch = function()
|
||||
mainContainer:stopEventHandling()
|
||||
application:stop()
|
||||
end
|
||||
|
||||
switchButton.onTouch = function()
|
||||
@ -184,8 +184,5 @@ checkLanguages()
|
||||
fromComboBox.selectedItem = getLanguageIndex(config.fromLanguage, false)
|
||||
toComboBox.selectedItem = getLanguageIndex(config.toLanguage, false)
|
||||
|
||||
mainContainer:draw()
|
||||
buffer.drawChanges(true)
|
||||
mainContainer:startEventHandling()
|
||||
|
||||
|
||||
application:draw()
|
||||
application:start()
|
||||
|
||||
@ -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 leftLayout = window:addChild(GUI.layout(1, 3, 1, 1, 1, 1))
|
||||
@ -93,7 +93,7 @@ end
|
||||
|
||||
local function request(url, postData, headers)
|
||||
progressIndicator.active = true
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
-- log("REQUEST URL: ", url)
|
||||
|
||||
@ -109,7 +109,7 @@ local function request(url, postData, headers)
|
||||
data = data .. chunk
|
||||
|
||||
progressIndicator:roll()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end,
|
||||
math.huge
|
||||
)
|
||||
@ -117,7 +117,7 @@ local function request(url, postData, headers)
|
||||
if success then
|
||||
data = json.decode(data)
|
||||
progressIndicator.active = false
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
return data
|
||||
else
|
||||
@ -181,7 +181,7 @@ local function selectableSelect(object)
|
||||
object.parent.children[i].selected = object.parent.children[i] == object
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
if object.onTouch then
|
||||
contentContainer.eventHandler = nil
|
||||
@ -189,7 +189,7 @@ local function selectableSelect(object)
|
||||
end
|
||||
end
|
||||
|
||||
local function selectableEventHandler(mainContainer, object, e1)
|
||||
local function selectableEventHandler(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
object:select()
|
||||
end
|
||||
@ -237,7 +237,7 @@ local function addPizda(name)
|
||||
end
|
||||
|
||||
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
|
||||
local cell = layout.cells[1][1]
|
||||
|
||||
@ -270,7 +270,7 @@ local function addScrollEventHandler(layout, regularDirection, updater)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -338,10 +338,10 @@ local function avatarDraw(object)
|
||||
end
|
||||
end
|
||||
|
||||
local function avatarEventHandler(mainContainer, object, e1)
|
||||
local function avatarEventHandler(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
object.selected = true
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
os.sleep(0.2)
|
||||
|
||||
@ -785,7 +785,7 @@ local function showHistory(container, peerID)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -1197,7 +1197,7 @@ showUserProfile = function(peerID)
|
||||
update()
|
||||
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
|
||||
userContainer.localY = userContainer.localY + (e5 > 0 and 1 or -1) * config.scrollSpeed
|
||||
|
||||
@ -1209,7 +1209,7 @@ showUserProfile = function(peerID)
|
||||
userContainer.localY = 1
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1319,7 +1319,7 @@ local function showFriends(peerID)
|
||||
local friends = getFriends()
|
||||
if friends then
|
||||
addFromList(friends)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end)
|
||||
end
|
||||
@ -1387,7 +1387,7 @@ newsSelectable.onTouch = function()
|
||||
end
|
||||
end)
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -1494,7 +1494,7 @@ showConversations = function(peerID)
|
||||
if #layout.children > 0 then
|
||||
layout.children[1]:select()
|
||||
else
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1565,7 +1565,7 @@ local function showDocuments()
|
||||
end)
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
addPizda(localization.documents).onTouch = function()
|
||||
@ -1630,7 +1630,7 @@ settingsSelectable.onTouch = function()
|
||||
addYobaSlider(2, 50, "loadCountDocs")
|
||||
addYobaSlider(2, 10, "scrollSpeed")
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function login()
|
||||
@ -1653,7 +1653,7 @@ local function login()
|
||||
|
||||
usernameInput.onInputFinished = function()
|
||||
loginButton.disabled = #usernameInput.text == 0 or #passwordInput.text == 0
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
passwordInput.onInputFinished = usernameInput.onInputFinished
|
||||
|
||||
@ -1680,7 +1680,7 @@ local function login()
|
||||
|
||||
lastPizda = login
|
||||
usernameInput.onInputFinished()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function logout()
|
||||
|
||||
@ -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
|
||||
|
||||
local weatherContainer = window:addChild(GUI.container(1, 1, 1, 23))
|
||||
@ -124,7 +124,7 @@ local function updateForecast()
|
||||
x = x + object.width + 2
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
table.toFile(configPath, config)
|
||||
else
|
||||
GUI.alert(result.message)
|
||||
@ -146,7 +146,7 @@ window.onResize = function(width, height)
|
||||
end
|
||||
|
||||
window:resize(window.width, window.height)
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
if fs.exists(configPath) then
|
||||
config = table.fromFile(configPath)
|
||||
|
||||
198
OS.lua
198
OS.lua
@ -19,7 +19,7 @@ local MineOSInterface = require("MineOSInterface")
|
||||
local dockTransparency = 0.4
|
||||
local doubleTouchInterval = 0.3
|
||||
|
||||
local mainContainer
|
||||
local application
|
||||
local bootUptime = computer.uptime()
|
||||
local dateUptime = bootUptime
|
||||
local screensaverUptime = bootUptime
|
||||
@ -34,25 +34,25 @@ local doubleTouchScreenAddress
|
||||
---------------------------------------- UI methods ----------------------------------------
|
||||
|
||||
function MineOSInterface.changeWallpaper()
|
||||
mainContainer.backgroundObject.wallpaper = nil
|
||||
application.backgroundObject.wallpaper = nil
|
||||
|
||||
if MineOSCore.properties.wallpaperEnabled and MineOSCore.properties.wallpaper then
|
||||
local result, reason = image.load(MineOSCore.properties.wallpaper)
|
||||
if result then
|
||||
mainContainer.backgroundObject.wallpaper, result = result, nil
|
||||
application.backgroundObject.wallpaper, result = result, nil
|
||||
|
||||
-- Fit to screen size mode
|
||||
if MineOSCore.properties.wallpaperMode == 1 then
|
||||
mainContainer.backgroundObject.wallpaper = image.transform(mainContainer.backgroundObject.wallpaper, mainContainer.width, mainContainer.height)
|
||||
mainContainer.backgroundObject.wallpaperPosition.x, mainContainer.backgroundObject.wallpaperPosition.y = 1, 1
|
||||
application.backgroundObject.wallpaper = image.transform(application.backgroundObject.wallpaper, application.width, application.height)
|
||||
application.backgroundObject.wallpaperPosition.x, application.backgroundObject.wallpaperPosition.y = 1, 1
|
||||
-- Centerized mode
|
||||
else
|
||||
mainContainer.backgroundObject.wallpaperPosition.x = math.floor(1 + mainContainer.width / 2 - image.getWidth(mainContainer.backgroundObject.wallpaper) / 2)
|
||||
mainContainer.backgroundObject.wallpaperPosition.y = math.floor(1 + mainContainer.height / 2 - image.getHeight(mainContainer.backgroundObject.wallpaper) / 2)
|
||||
application.backgroundObject.wallpaperPosition.x = math.floor(1 + application.width / 2 - image.getWidth(application.backgroundObject.wallpaper) / 2)
|
||||
application.backgroundObject.wallpaperPosition.y = math.floor(1 + application.height / 2 - image.getHeight(application.backgroundObject.wallpaper) / 2)
|
||||
end
|
||||
|
||||
-- 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
|
||||
r, g, b = color.integerToRGB(backgrounds[i])
|
||||
backgrounds[i] = color.RGBToInteger(
|
||||
@ -77,27 +77,27 @@ end
|
||||
function MineOSInterface.changeResolution()
|
||||
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
|
||||
mainContainer.iconField.height = mainContainer.height
|
||||
mainContainer.iconField:updateFileList()
|
||||
application.iconField.width = application.width
|
||||
application.iconField.height = application.height
|
||||
application.iconField:updateFileList()
|
||||
|
||||
mainContainer.dockContainer.sort()
|
||||
mainContainer.dockContainer.localY = mainContainer.height - mainContainer.dockContainer.height + 1
|
||||
application.dockContainer.sort()
|
||||
application.dockContainer.localY = application.height - application.dockContainer.height + 1
|
||||
|
||||
mainContainer.menu.width = mainContainer.width
|
||||
mainContainer.menuLayout.width = mainContainer.width
|
||||
mainContainer.backgroundObject.width, mainContainer.backgroundObject.height = mainContainer.width, mainContainer.height
|
||||
application.menu.width = application.width
|
||||
application.menuLayout.width = application.width
|
||||
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
|
||||
|
||||
local function moveDockIcon(index, direction)
|
||||
mainContainer.dockContainer.children[index], mainContainer.dockContainer.children[index + direction] = mainContainer.dockContainer.children[index + direction], mainContainer.dockContainer.children[index]
|
||||
mainContainer.dockContainer.sort()
|
||||
mainContainer.dockContainer.saveToOSSettings()
|
||||
mainContainer:drawOnScreen()
|
||||
application.dockContainer.children[index], application.dockContainer.children[index + direction] = application.dockContainer.children[index + direction], application.dockContainer.children[index]
|
||||
application.dockContainer.sort()
|
||||
application.dockContainer.saveToOSSettings()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
local function getPercentageColor(pecent)
|
||||
@ -114,10 +114,10 @@ local function getPercentageColor(pecent)
|
||||
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
|
||||
icon.selected = true
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
if e5 == 1 then
|
||||
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
|
||||
|
||||
function MineOSInterface.createWidgets()
|
||||
mainContainer:removeChildren()
|
||||
application:removeChildren()
|
||||
|
||||
mainContainer.backgroundObject = mainContainer:addChild(GUI.object(1, 1, 1, 1))
|
||||
mainContainer.backgroundObject.wallpaperPosition = {x = 1, y = 1}
|
||||
mainContainer.backgroundObject.draw = function(object)
|
||||
application.backgroundObject = application:addChild(GUI.object(1, 1, 1, 1))
|
||||
application.backgroundObject.wallpaperPosition = {x = 1, y = 1}
|
||||
application.backgroundObject.draw = function(object)
|
||||
buffer.drawRectangle(object.x, object.y, object.width, object.height, MineOSCore.properties.backgroundColor, 0, " ")
|
||||
if object.wallpaper then
|
||||
buffer.drawImage(object.wallpaperPosition.x, object.wallpaperPosition.y, object.wallpaper)
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer.iconField = mainContainer:addChild(
|
||||
application.iconField = application:addChild(
|
||||
MineOSInterface.iconField(
|
||||
1, 2, 1, 1, 3, 2,
|
||||
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)
|
||||
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))
|
||||
end
|
||||
|
||||
mainContainer.iconField.launchers.showPackageContent = function(icon)
|
||||
application.iconField.launchers.showPackageContent = function(icon)
|
||||
MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", icon.path)
|
||||
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 = {}
|
||||
for i = 1, #mainContainer.dockContainer.children do
|
||||
if mainContainer.dockContainer.children[i].keepInDock then
|
||||
table.insert(MineOSCore.properties.dockShortcuts, mainContainer.dockContainer.children[i].path)
|
||||
for i = 1, #application.dockContainer.children do
|
||||
if application.dockContainer.children[i].keepInDock then
|
||||
table.insert(MineOSCore.properties.dockShortcuts, application.dockContainer.children[i].path)
|
||||
end
|
||||
end
|
||||
MineOSCore.saveProperties()
|
||||
end
|
||||
|
||||
mainContainer.dockContainer.sort = function()
|
||||
application.dockContainer.sort = function()
|
||||
local x = 4
|
||||
for i = 1, #mainContainer.dockContainer.children do
|
||||
mainContainer.dockContainer.children[i].localX = x
|
||||
for i = 1, #application.dockContainer.children do
|
||||
application.dockContainer.children[i].localX = x
|
||||
x = x + MineOSCore.properties.iconWidth + MineOSCore.properties.iconHorizontalSpaceBetween
|
||||
end
|
||||
|
||||
mainContainer.dockContainer.width = #mainContainer.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.width = #application.dockContainer.children * (MineOSCore.properties.iconWidth + MineOSCore.properties.iconHorizontalSpaceBetween) - MineOSCore.properties.iconHorizontalSpaceBetween + 6
|
||||
application.dockContainer.localX = math.floor(application.width / 2 - application.dockContainer.width / 2)
|
||||
end
|
||||
|
||||
mainContainer.dockContainer.addIcon = function(path, window)
|
||||
local icon = mainContainer.dockContainer:addChild(MineOSInterface.icon(1, 2, path, 0x2D2D2D, 0xFFFFFF))
|
||||
application.dockContainer.addIcon = function(path, window)
|
||||
local icon = application.dockContainer:addChild(MineOSInterface.icon(1, 2, path, 0x2D2D2D, 0xFFFFFF))
|
||||
icon:analyseExtension()
|
||||
icon:moveBackward()
|
||||
|
||||
@ -203,7 +203,7 @@ function MineOSInterface.createWidgets()
|
||||
|
||||
icon.selected = false
|
||||
MineOSInterface.updateMenu()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
else
|
||||
MineOSInterface.iconDoubleClick(icon, ...)
|
||||
end
|
||||
@ -211,11 +211,11 @@ function MineOSInterface.createWidgets()
|
||||
|
||||
icon.onRightClick = function(icon, e1, e2, e3, e4, ...)
|
||||
local indexOf = icon:indexOf()
|
||||
local menu = GUI.addContextMenu(mainContainer, e3, e4)
|
||||
local menu = GUI.addContextMenu(application, e3, e4)
|
||||
|
||||
menu.onMenuClosed = function()
|
||||
icon.selected = false
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
if icon.windows then
|
||||
@ -227,7 +227,7 @@ function MineOSInterface.createWidgets()
|
||||
for window in pairs(icon.windows) do
|
||||
window:close()
|
||||
end
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -237,7 +237,7 @@ function MineOSInterface.createWidgets()
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
@ -248,37 +248,37 @@ function MineOSInterface.createWidgets()
|
||||
menu:addSeparator()
|
||||
|
||||
if icon.keepInDock then
|
||||
if #mainContainer.dockContainer.children > 1 then
|
||||
if #application.dockContainer.children > 1 then
|
||||
menu:addItem(MineOSCore.localization.removeFromDock).onTouch = function()
|
||||
if icon.windows then
|
||||
icon.keepInDock = nil
|
||||
else
|
||||
icon:remove()
|
||||
mainContainer.dockContainer.sort()
|
||||
application.dockContainer.sort()
|
||||
end
|
||||
mainContainer.dockContainer.saveToOSSettings()
|
||||
mainContainer:drawOnScreen()
|
||||
application.dockContainer.saveToOSSettings()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
else
|
||||
if icon.windows then
|
||||
menu:addItem(MineOSCore.localization.keepInDock).onTouch = function()
|
||||
icon.keepInDock = true
|
||||
mainContainer.dockContainer.saveToOSSettings()
|
||||
application.dockContainer.saveToOSSettings()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer.dockContainer.sort()
|
||||
application.dockContainer.sort()
|
||||
|
||||
return icon
|
||||
end
|
||||
|
||||
-- Trash
|
||||
local icon = mainContainer.dockContainer.addIcon(MineOSPaths.trash)
|
||||
local icon = application.dockContainer.addIcon(MineOSPaths.trash)
|
||||
icon.launchers.directory = function(icon)
|
||||
MineOSInterface.safeLaunch(MineOSPaths.explorer, "-o", icon.path)
|
||||
end
|
||||
@ -292,15 +292,15 @@ function MineOSInterface.createWidgets()
|
||||
end
|
||||
|
||||
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()
|
||||
icon.selected = false
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
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()
|
||||
for file in filesystem.list(MineOSPaths.trash) do
|
||||
@ -312,22 +312,22 @@ function MineOSInterface.createWidgets()
|
||||
|
||||
container.panel.onTouch = function()
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
-- Draw dock drawDock dockDraw cyka заебался искать, блядь
|
||||
local overrideDockContainerDraw = mainContainer.dockContainer.draw
|
||||
mainContainer.dockContainer.draw = function(dockContainer)
|
||||
local overrideDockContainerDraw = application.dockContainer.draw
|
||||
application.dockContainer.draw = function(dockContainer)
|
||||
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
|
||||
@ -344,13 +344,13 @@ function MineOSInterface.createWidgets()
|
||||
overrideDockContainerDraw(dockContainer)
|
||||
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()
|
||||
local container = MineOSInterface.addBackgroundContainer(mainContainer, MineOSCore.localization.aboutSystem)
|
||||
local container = MineOSInterface.addBackgroundContainer(application, MineOSCore.localization.aboutSystem)
|
||||
container.layout:removeChildren()
|
||||
|
||||
local lines = {
|
||||
@ -390,7 +390,7 @@ function MineOSInterface.createWidgets()
|
||||
textBox:setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
textBox.eventHandler = container.panel.eventHandler
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
MineOSContextMenu:addItem(MineOSCore.localization.updates).onTouch = function()
|
||||
@ -413,16 +413,16 @@ function MineOSInterface.createWidgets()
|
||||
|
||||
MineOSContextMenu:addItem(MineOSCore.localization.returnToShell).onTouch = function()
|
||||
MineOSNetwork.broadcastComputerState(false)
|
||||
mainContainer:stopEventHandling()
|
||||
application:stop()
|
||||
MineOSInterface.clearTerminal()
|
||||
os.exit()
|
||||
end
|
||||
|
||||
mainContainer.menuLayout = mainContainer:addChild(GUI.layout(1, 1, 1, 1, 1, 1))
|
||||
mainContainer.menuLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
|
||||
mainContainer.menuLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_RIGHT, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
mainContainer.menuLayout:setMargin(1, 1, 1, 0)
|
||||
mainContainer.menuLayout:setSpacing(1, 1, 2)
|
||||
application.menuLayout = application:addChild(GUI.layout(1, 1, 1, 1, 1, 1))
|
||||
application.menuLayout:setDirection(1, 1, GUI.DIRECTION_HORIZONTAL)
|
||||
application.menuLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_RIGHT, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||
application.menuLayout:setMargin(1, 1, 1, 0)
|
||||
application.menuLayout:setSpacing(1, 1, 2)
|
||||
|
||||
local dateWidget, dateWidgetText = MineOSInterface.addMenuWidget(MineOSInterface.menuWidget(1))
|
||||
dateWidget.drawContent = function()
|
||||
@ -483,34 +483,34 @@ function MineOSInterface.createWidgets()
|
||||
end
|
||||
|
||||
MineOSInterface.updateFileListAndDraw = function(...)
|
||||
mainContainer.iconField:updateFileList()
|
||||
mainContainer:drawOnScreen(...)
|
||||
application.iconField:updateFileList()
|
||||
application:draw(...)
|
||||
end
|
||||
|
||||
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
|
||||
local windowsCount = #mainContainer.windowsContainer.children
|
||||
local windowsCount = #application.windowsContainer.children
|
||||
-- Ctrl or CMD
|
||||
if windowsCount > 0 and not lastWindowHandled and (keyboard.isKeyDown(29) or keyboard.isKeyDown(219)) then
|
||||
-- W
|
||||
if e4 == 17 then
|
||||
mainContainer.windowsContainer.children[windowsCount]:close()
|
||||
application.windowsContainer.children[windowsCount]:close()
|
||||
lastWindowHandled = true
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
-- H
|
||||
elseif e4 == 35 then
|
||||
local lastUnhiddenWindowIndex = 1
|
||||
for i = 1, #mainContainer.windowsContainer.children do
|
||||
if not mainContainer.windowsContainer.children[i].hidden then
|
||||
for i = 1, #application.windowsContainer.children do
|
||||
if not application.windowsContainer.children[i].hidden then
|
||||
lastUnhiddenWindowIndex = i
|
||||
end
|
||||
end
|
||||
mainContainer.windowsContainer.children[lastUnhiddenWindowIndex]:minimize()
|
||||
application.windowsContainer.children[lastUnhiddenWindowIndex]:minimize()
|
||||
lastWindowHandled = true
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
elseif lastWindowHandled and e1 == "key_up" and (e4 == 17 or e4 == 35) then
|
||||
@ -522,7 +522,7 @@ function MineOSInterface.createWidgets()
|
||||
MineOSInterface.updateFileListAndDraw(true)
|
||||
elseif e2 == "updateWallpaper" then
|
||||
MineOSInterface.changeWallpaper()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
elseif e1 == "MineOSNetwork" then
|
||||
if e2 == "accessDenied" then
|
||||
@ -534,7 +534,7 @@ function MineOSInterface.createWidgets()
|
||||
|
||||
if computer.uptime() - dateUptime >= 1 then
|
||||
MineOSCore.updateTime()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
dateUptime = computer.uptime()
|
||||
end
|
||||
|
||||
@ -546,7 +546,7 @@ function MineOSInterface.createWidgets()
|
||||
if dateUptime - screensaverUptime >= MineOSCore.properties.screensaverDelay then
|
||||
if filesystem.exists(MineOSCore.properties.screensaver) then
|
||||
MineOSInterface.safeLaunch(MineOSCore.properties.screensaver)
|
||||
mainContainer:drawOnScreen(true)
|
||||
application:draw(true)
|
||||
end
|
||||
|
||||
screensaverUptime = computer.uptime()
|
||||
@ -554,7 +554,7 @@ function MineOSInterface.createWidgets()
|
||||
end
|
||||
end
|
||||
|
||||
MineOSInterface.menuInitialChildren = mainContainer.menu.children
|
||||
MineOSInterface.menuInitialChildren = application.menu.children
|
||||
end
|
||||
|
||||
---------------------------------------- Main loop ----------------------------------------
|
||||
@ -571,8 +571,8 @@ end
|
||||
|
||||
-- Creates OS main container and all its widgets
|
||||
local function createWidgets()
|
||||
mainContainer = GUI.fullScreenContainer()
|
||||
MineOSInterface.mainContainer = mainContainer
|
||||
application = GUI.application()
|
||||
MineOSInterface.application = application
|
||||
|
||||
MineOSInterface.createWidgets()
|
||||
MineOSInterface.changeResolution()
|
||||
@ -611,15 +611,15 @@ MineOSCore.localization = MineOSCore.getLocalization(MineOSPaths.localizationFil
|
||||
-- Tasks and UI initialization
|
||||
runTasks(2)
|
||||
createWidgets()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
MineOSNetwork.update()
|
||||
runTasks(1)
|
||||
|
||||
-- Loops with UI regeneration after errors
|
||||
while true do
|
||||
local success, path, line, traceback = MineOSCore.call(
|
||||
mainContainer.startEventHandling,
|
||||
mainContainer,
|
||||
application.start,
|
||||
application,
|
||||
0
|
||||
)
|
||||
|
||||
@ -627,8 +627,8 @@ while true do
|
||||
break
|
||||
else
|
||||
createWidgets()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
MineOSInterface.showErrorWindow(path, line, traceback)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
@ -34,8 +34,8 @@ function MineOSInterface.setIconProperties(width, height, horizontalSpaceBetween
|
||||
MineOSCore.saveProperties()
|
||||
calculateIconSizes()
|
||||
|
||||
MineOSInterface.mainContainer.iconField:deleteIconConfig()
|
||||
MineOSInterface.mainContainer.dockContainer.sort()
|
||||
MineOSInterface.application.iconField:deleteIconConfig()
|
||||
MineOSInterface.application.dockContainer.sort()
|
||||
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
@ -159,7 +159,7 @@ local function iconDraw(icon)
|
||||
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
|
||||
object.lastTouchPosition = object.lastTouchPosition or {}
|
||||
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.lastTouchPosition.x, object.lastTouchPosition.y = e3, e4
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
elseif e1 == "drop" and object.parent.parent.iconConfigEnabled and object.dragStarted then
|
||||
object.dragStarted = nil
|
||||
object.parent.parent.iconConfig[object.name .. (object.isDirectory and "/" or "")] = {
|
||||
@ -365,13 +365,13 @@ end
|
||||
function MineOSInterface.iconLaunchers.showPackageContent(icon)
|
||||
icon.parent.parent:setWorkpath(icon.path)
|
||||
icon.parent.parent:updateFileList()
|
||||
icon.firstParent:drawOnScreen()
|
||||
icon.firstParent:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.iconLaunchers.showContainingFolder(icon)
|
||||
icon.parent.parent:setWorkpath(fs.path(icon.shortcutPath))
|
||||
icon.parent.parent:updateFileList()
|
||||
icon.firstParent:drawOnScreen()
|
||||
icon.firstParent:draw()
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -474,7 +474,7 @@ local function iconFieldUpdateFileList(iconField)
|
||||
return iconField
|
||||
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 e5 == 0 then
|
||||
object.parent:deselectAll()
|
||||
@ -483,28 +483,28 @@ local function iconFieldBackgroundObjectEventHandler(mainContainer, object, e1,
|
||||
y1 = e4
|
||||
}
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
else
|
||||
local menu = GUI.addContextMenu(MineOSInterface.mainContainer, e3, e4)
|
||||
local menu = GUI.addContextMenu(MineOSInterface.application, e3, e4)
|
||||
|
||||
local subMenu = menu:addSubMenu(MineOSCore.localization.create)
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
subMenu:addSeparator()
|
||||
|
||||
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
|
||||
|
||||
menu:addSeparator()
|
||||
@ -568,20 +568,20 @@ local function iconFieldBackgroundObjectEventHandler(mainContainer, object, e1,
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
elseif e1 == "drag" then
|
||||
if object.parent.selection then
|
||||
object.parent.selection.x2, object.parent.selection.y2 = e3, e4
|
||||
object:moveToFront()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
elseif e1 == "drop" then
|
||||
object.parent.selection = nil
|
||||
object:moveToBack()
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -690,26 +690,26 @@ function MineOSInterface.iconLeftClick(icon)
|
||||
end
|
||||
icon.selected = true
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.iconDoubleClick(icon)
|
||||
icon:launch()
|
||||
icon.selected = false
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
|
||||
icon.selected = true
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
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()
|
||||
icon.parent.parent:deselectAll()
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
if #selectedIcons == 1 then
|
||||
@ -720,7 +720,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
|
||||
end
|
||||
|
||||
menu:addItem(MineOSCore.localization.launchWithArguments).onTouch = function()
|
||||
MineOSInterface.launchWithArguments(MineOSInterface.mainContainer, icon.path .. "Main.lua")
|
||||
MineOSInterface.launchWithArguments(MineOSInterface.application, icon.path .. "Main.lua")
|
||||
end
|
||||
|
||||
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
|
||||
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))
|
||||
container.panel.eventHandler = function(mainContainer, object, e1)
|
||||
container.panel.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
container:remove()
|
||||
|
||||
if e1 == "touch" and #input.text > 0 then
|
||||
computer.pushSignal("Finder", "updateFavourites", {name = input.text, path = icon.path})
|
||||
else
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -752,7 +752,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
|
||||
else
|
||||
if icon.isShortcut then
|
||||
menu:addItem(MineOSCore.localization.editShortcut).onTouch = function()
|
||||
MineOSInterface.editShortcut(MineOSInterface.mainContainer, icon.path)
|
||||
MineOSInterface.editShortcut(MineOSInterface.application, icon.path)
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
end
|
||||
|
||||
@ -780,7 +780,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
|
||||
|
||||
if #selectedIcons > 1 then
|
||||
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
|
||||
menu:addSeparator()
|
||||
end
|
||||
@ -851,7 +851,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
|
||||
|
||||
if #selectedIcons == 1 then
|
||||
menu:addItem(MineOSCore.localization.rename).onTouch = function()
|
||||
MineOSInterface.rename(MineOSInterface.mainContainer, icon.path)
|
||||
MineOSInterface.rename(MineOSInterface.application, icon.path)
|
||||
end
|
||||
end
|
||||
|
||||
@ -877,8 +877,8 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
|
||||
|
||||
if #selectedIcons == 1 then
|
||||
menu:addItem(MineOSCore.localization.addToDock).onTouch = function()
|
||||
MineOSInterface.mainContainer.dockContainer.addIcon(icon.path).keepInDock = true
|
||||
MineOSInterface.mainContainer.dockContainer.saveToOSSettings()
|
||||
MineOSInterface.application.dockContainer.addIcon(icon.path).keepInDock = true
|
||||
MineOSInterface.application.dockContainer.saveToOSSettings()
|
||||
end
|
||||
end
|
||||
|
||||
@ -888,7 +888,7 @@ function MineOSInterface.iconRightClick(icon, e1, e2, e3, e4)
|
||||
end
|
||||
end
|
||||
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -914,7 +914,7 @@ end
|
||||
local function checkFileToExists(container, path)
|
||||
if fs.exists(path) then
|
||||
container.label.hidden = false
|
||||
container.parent:drawOnScreen()
|
||||
container.parent:draw()
|
||||
else
|
||||
container:remove()
|
||||
return true
|
||||
@ -941,7 +941,7 @@ function MineOSInterface.newFile(parentWindow, iconField, x, y, path)
|
||||
end
|
||||
end
|
||||
|
||||
parentWindow:drawOnScreen()
|
||||
parentWindow:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.newFolder(parentWindow, iconField, x, y, path)
|
||||
@ -955,7 +955,7 @@ function MineOSInterface.newFolder(parentWindow, iconField, x, y, path)
|
||||
end
|
||||
end
|
||||
|
||||
parentWindow:drawOnScreen()
|
||||
parentWindow:draw()
|
||||
|
||||
return container
|
||||
end
|
||||
@ -964,16 +964,16 @@ function MineOSInterface.newFileFromURL(parentWindow, iconField, x, y, path)
|
||||
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.panel.eventHandler = function(mainContainer, object, e1)
|
||||
container.panel.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
if #container.inputField.text > 0 and #container.inputFieldURL.text > 0 then
|
||||
if fs.exists(path .. container.inputField.text) then
|
||||
container.label.hidden = false
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
else
|
||||
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)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
local success, reason = require("web").download(container.inputFieldURL.text, path .. container.inputField.text)
|
||||
container:remove()
|
||||
@ -983,17 +983,17 @@ function MineOSInterface.newFileFromURL(parentWindow, iconField, x, y, path)
|
||||
computer.pushSignal("MineOSCore", "updateFileList")
|
||||
else
|
||||
GUI.alert(reason)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
else
|
||||
container:remove()
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
parentWindow:drawOnScreen()
|
||||
parentWindow:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.newApplication(parentWindow, iconField, x, y, path)
|
||||
@ -1003,7 +1003,7 @@ function MineOSInterface.newApplication(parentWindow, iconField, x, y, path)
|
||||
filesystemChooser:addExtensionFilter(".pic")
|
||||
filesystemChooser:moveBackward()
|
||||
|
||||
container.panel.eventHandler = function(mainContainer, object, e1)
|
||||
container.panel.eventHandler = function(application, object, e1)
|
||||
if e1 == "touch" then
|
||||
if #container.inputField.text > 0 then
|
||||
local finalPath = path .. container.inputField.text .. ".app/"
|
||||
@ -1021,12 +1021,12 @@ function MineOSInterface.newApplication(parentWindow, iconField, x, y, path)
|
||||
end
|
||||
else
|
||||
container:remove()
|
||||
parentWindow:drawOnScreen()
|
||||
parentWindow:draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
parentWindow:drawOnScreen()
|
||||
parentWindow:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.newFolderFromChosen(parentWindow, iconField, x, y, selectedIcons)
|
||||
@ -1045,7 +1045,7 @@ function MineOSInterface.newFolderFromChosen(parentWindow, iconField, x, y, sele
|
||||
end
|
||||
end
|
||||
|
||||
parentWindow:drawOnScreen()
|
||||
parentWindow:draw()
|
||||
|
||||
return container
|
||||
end
|
||||
@ -1060,7 +1060,7 @@ function MineOSInterface.rename(parentWindow, path)
|
||||
end
|
||||
end
|
||||
|
||||
parentWindow:drawOnScreen()
|
||||
parentWindow:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.editShortcut(parentWindow, path)
|
||||
@ -1075,17 +1075,17 @@ function MineOSInterface.editShortcut(parentWindow, path)
|
||||
else
|
||||
container.label.text = MineOSCore.localization.shortcutIsCorrupted
|
||||
container.label.hidden = false
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
parentWindow:drawOnScreen()
|
||||
parentWindow:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.launchWithArguments(parentWindow, path, withTerminal)
|
||||
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
|
||||
local args = {}
|
||||
if container.inputField.text then
|
||||
@ -1105,7 +1105,7 @@ function MineOSInterface.launchWithArguments(parentWindow, path, withTerminal)
|
||||
MineOSInterface.safeLaunch(path, table.unpack(args))
|
||||
end
|
||||
|
||||
parentWindow:drawOnScreen(true)
|
||||
parentWindow:draw(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1113,18 +1113,18 @@ end
|
||||
----------------------------------------- Windows patterns -----------------------------------------
|
||||
|
||||
function MineOSInterface.updateMenu()
|
||||
local focusedWindow = MineOSInterface.mainContainer.windowsContainer.children[#MineOSInterface.mainContainer.windowsContainer.children]
|
||||
MineOSInterface.mainContainer.menu.children = focusedWindow and focusedWindow.menu.children or MineOSInterface.menuInitialChildren
|
||||
local focusedWindow = MineOSInterface.application.windowsContainer.children[#MineOSInterface.application.windowsContainer.children]
|
||||
MineOSInterface.application.menu.children = focusedWindow and focusedWindow.menu.children or MineOSInterface.menuInitialChildren
|
||||
end
|
||||
|
||||
function MineOSInterface.addWindow(window, preserveCoordinates)
|
||||
-- Чекаем коорды
|
||||
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
|
||||
|
||||
-- Ебурим окно к окнам
|
||||
MineOSInterface.mainContainer.windowsContainer:addChild(window)
|
||||
MineOSInterface.application.windowsContainer:addChild(window)
|
||||
|
||||
-- Получаем путь залупы
|
||||
local dockPath, info, dockIcon
|
||||
@ -1147,14 +1147,14 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
|
||||
-- GUI.alert(dockPath)
|
||||
|
||||
-- Чекаем наличие иконки в доке с таким же путем, и еси ее нет, то хуячим новую
|
||||
for i = 1, #MineOSInterface.mainContainer.dockContainer.children do
|
||||
if MineOSInterface.mainContainer.dockContainer.children[i].path == dockPath then
|
||||
dockIcon = MineOSInterface.mainContainer.dockContainer.children[i]
|
||||
for i = 1, #MineOSInterface.application.dockContainer.children do
|
||||
if MineOSInterface.application.dockContainer.children[i].path == dockPath then
|
||||
dockIcon = MineOSInterface.application.dockContainer.children[i]
|
||||
break
|
||||
end
|
||||
end
|
||||
if not dockIcon then
|
||||
dockIcon = MineOSInterface.mainContainer.dockContainer.addIcon(dockPath, window)
|
||||
dockIcon = MineOSInterface.application.dockContainer.addIcon(dockPath, window)
|
||||
end
|
||||
|
||||
-- Ебурим ссылку на окна в иконку
|
||||
@ -1163,7 +1163,7 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
|
||||
|
||||
-- Взалупливаем иконке индивидуальную менюху. По дефолту тут всякая хуйня и прочее
|
||||
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 contextMenu = window.menu:addContextMenu(name, 0x0)
|
||||
contextMenu:addItem(MineOSCore.localization.closeWindow .. " " .. name, false, "^W").onTouch = function()
|
||||
@ -1172,14 +1172,14 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
|
||||
|
||||
-- Смещаем окно правее и ниже, если уже есть открытые окна этой софтины
|
||||
local lastIndex
|
||||
for i = #MineOSInterface.mainContainer.windowsContainer.children, 1, -1 do
|
||||
if MineOSInterface.mainContainer.windowsContainer.children[i] ~= window and dockIcon.windows[MineOSInterface.mainContainer.windowsContainer.children[i]] then
|
||||
for i = #MineOSInterface.application.windowsContainer.children, 1, -1 do
|
||||
if MineOSInterface.application.windowsContainer.children[i] ~= window and dockIcon.windows[MineOSInterface.application.windowsContainer.children[i]] then
|
||||
lastIndex = i
|
||||
break
|
||||
end
|
||||
end
|
||||
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
|
||||
|
||||
-- Когда окно фокусицца, то главная ОСевая менюха заполницца ДЕТИШЕЧКАМИ оконной менюхи
|
||||
@ -1188,13 +1188,13 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
|
||||
-- Биндим функции по ресайзу/закрытию и прочему говнищу
|
||||
window.close = function(window)
|
||||
local sameIconExists = false
|
||||
for i = 1, #MineOSInterface.mainContainer.dockContainer.children do
|
||||
for i = 1, #MineOSInterface.application.dockContainer.children do
|
||||
if
|
||||
MineOSInterface.mainContainer.dockContainer.children[i].path == dockPath and
|
||||
MineOSInterface.mainContainer.dockContainer.children[i].windows and
|
||||
table.size(MineOSInterface.mainContainer.dockContainer.children[i].windows) > 1
|
||||
MineOSInterface.application.dockContainer.children[i].path == dockPath and
|
||||
MineOSInterface.application.dockContainer.children[i].windows and
|
||||
table.size(MineOSInterface.application.dockContainer.children[i].windows) > 1
|
||||
then
|
||||
MineOSInterface.mainContainer.dockContainer.children[i].windows[window] = nil
|
||||
MineOSInterface.application.dockContainer.children[i].windows[window] = nil
|
||||
sameIconExists = true
|
||||
break
|
||||
end
|
||||
@ -1204,7 +1204,7 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
|
||||
dockIcon.windows = nil
|
||||
if not dockIcon.keepInDock then
|
||||
dockIcon:remove()
|
||||
MineOSInterface.mainContainer.dockContainer.sort()
|
||||
MineOSInterface.application.dockContainer.sort()
|
||||
end
|
||||
end
|
||||
|
||||
@ -1227,7 +1227,7 @@ function MineOSInterface.addWindow(window, preserveCoordinates)
|
||||
|
||||
MineOSInterface.updateMenu()
|
||||
|
||||
return MineOSInterface.mainContainer, window, window.menu
|
||||
return MineOSInterface.application, window, window.menu
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1238,7 +1238,7 @@ local function addKeyAndValue(window, x, y, key, value)
|
||||
end
|
||||
|
||||
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: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.height = textBox.y + textBox.height
|
||||
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
if icon.isDirectory then
|
||||
fileSizeLabel.text = string.format("%.2f", fs.directorySize(icon.path) / 1024) .. " KB"
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function GUICopy(parentContainer, fileList, toPath)
|
||||
local function GUICopy(application, fileList, toPath)
|
||||
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 switchAndLabel = container.layout:addChild(GUI.switchAndLabel(1, 1, 37, 8, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x787878, MineOSCore.localization.applyToAll .. ":", false))
|
||||
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()
|
||||
applyYes = true
|
||||
parentContainer:stopEventHandling()
|
||||
application:stop()
|
||||
end
|
||||
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, MineOSCore.localization.no)).onTouch = function()
|
||||
parentContainer:stopEventHandling()
|
||||
application:stop()
|
||||
end
|
||||
buttonsLayout:addChild(GUI.button(1, 1, 11, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, MineOSCore.localization.cancel)).onTouch = function()
|
||||
breakRecursion = true
|
||||
parentContainer:stopEventHandling()
|
||||
application:stop()
|
||||
end
|
||||
|
||||
buttonsLayout:fitToChildrenSize(1, 1)
|
||||
@ -1304,7 +1304,7 @@ local function GUICopy(parentContainer, fileList, toPath)
|
||||
}
|
||||
textBox:update()
|
||||
|
||||
parentContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
fs.remove(finalPath)
|
||||
fs.copy(path, finalPath)
|
||||
@ -1335,9 +1335,9 @@ local function GUICopy(parentContainer, fileList, toPath)
|
||||
}
|
||||
textBox:update()
|
||||
|
||||
parentContainer:drawOnScreen()
|
||||
parentContainer:startEventHandling()
|
||||
parentContainer:drawOnScreen()
|
||||
application:draw()
|
||||
application:start()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
if applyYes then
|
||||
@ -1354,7 +1354,7 @@ local function GUICopy(parentContainer, fileList, toPath)
|
||||
end
|
||||
|
||||
container:remove()
|
||||
parentContainer:drawOnScreen()
|
||||
application:draw()
|
||||
end
|
||||
|
||||
function MineOSInterface.copy(what, toPath)
|
||||
@ -1362,18 +1362,18 @@ function MineOSInterface.copy(what, toPath)
|
||||
what = {what}
|
||||
end
|
||||
|
||||
GUICopy(MineOSInterface.mainContainer, what, toPath)
|
||||
GUICopy(MineOSInterface.application, what, toPath)
|
||||
end
|
||||
|
||||
local function menuWidgetEventHandler(mainContainer, object, e1, ...)
|
||||
local function menuWidgetEventHandler(application, object, e1, ...)
|
||||
if e1 == "touch" and object.onTouch then
|
||||
object.selected = true
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
|
||||
object.onTouch(mainContainer, object, e1, ...)
|
||||
object.onTouch(application, object, e1, ...)
|
||||
|
||||
object.selected = false
|
||||
MineOSInterface.mainContainer:drawOnScreen()
|
||||
MineOSInterface.application:draw()
|
||||
end
|
||||
end
|
||||
|
||||
@ -1399,7 +1399,7 @@ function MineOSInterface.menuWidget(width)
|
||||
end
|
||||
|
||||
function MineOSInterface.addMenuWidget(object)
|
||||
MineOSInterface.mainContainer.menuLayout:addChild(object)
|
||||
MineOSInterface.application.menuLayout:addChild(object)
|
||||
object:moveToBack()
|
||||
|
||||
return object
|
||||
@ -1408,17 +1408,17 @@ end
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function MineOSInterface.showErrorWindow(path, line, traceback)
|
||||
local mainContainer = GUI.container(1, 1, buffer.getWidth(), math.floor(buffer.getHeight() * 0.5))
|
||||
mainContainer.y = math.floor(buffer.getHeight() / 2 - mainContainer.height / 2)
|
||||
local application = GUI.application(1, 1, buffer.getWidth(), math.floor(buffer.getHeight() * 0.5))
|
||||
application.y = math.floor(buffer.getHeight() / 2 - application.height / 2)
|
||||
|
||||
mainContainer:addChild(GUI.panel(1, 1, mainContainer.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)
|
||||
local actionButtons = mainContainer:addChild(GUI.actionButtons(2, 2, false))
|
||||
local sendToDeveloperButton = mainContainer:addChild(GUI.adaptiveButton(9, 1, 2, 1, 0x444444, 0xFFFFFF, 0x343434, 0xFFFFFF, MineOSCore.localization.sendFeedback))
|
||||
application:addChild(GUI.panel(1, 1, application.width, 3, 0x383838))
|
||||
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 = application:addChild(GUI.actionButtons(2, 2, false))
|
||||
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
|
||||
codeView.fromLine = 1
|
||||
end
|
||||
@ -1438,13 +1438,13 @@ function MineOSInterface.showErrorWindow(path, line, traceback)
|
||||
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()
|
||||
mainContainer:stopEventHandling()
|
||||
application:stop()
|
||||
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
|
||||
actionButtons.close.onTouch()
|
||||
end
|
||||
@ -1459,7 +1459,7 @@ function MineOSInterface.showErrorWindow(path, line, traceback)
|
||||
end
|
||||
|
||||
sendToDeveloperButton.text = MineOSCore.localization.sendedFeedback
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
os.sleep(1)
|
||||
end
|
||||
|
||||
@ -1467,13 +1467,13 @@ function MineOSInterface.showErrorWindow(path, line, traceback)
|
||||
end
|
||||
|
||||
buffer.clear(0x0, 0.5)
|
||||
mainContainer:drawOnScreen()
|
||||
application:draw()
|
||||
|
||||
for i = 1, 3 do
|
||||
component.computer.beep(1500, 0.08)
|
||||
end
|
||||
|
||||
mainContainer:startEventHandling()
|
||||
application:start()
|
||||
end
|
||||
|
||||
function MineOSInterface.safeLaunch(...)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user