mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Переходим на MineOS Standalone #1
This commit is contained in:
parent
86678610ff
commit
b8bc282b94
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
Mounts/
|
||||||
|
Temporary/
|
||||||
|
Users/
|
||||||
@ -1,18 +1,16 @@
|
|||||||
|
|
||||||
local args, options = require("shell").parse(...)
|
local number = require("Number")
|
||||||
|
|
||||||
require("advancedLua")
|
|
||||||
local component = require("component")
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local buffer = require("doubleBuffering")
|
local screen = require("Screen")
|
||||||
local color = require("color")
|
local color = require("Color")
|
||||||
local unicode = require("unicode")
|
local system = require("System")
|
||||||
local MineOSCore = require("MineOSCore")
|
|
||||||
local bigLetters = require("bigLetters")
|
local bigLetters = require("bigLetters")
|
||||||
|
|
||||||
|
local args, options = system.parseArguments(...)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local localization = MineOSCore.getCurrentScriptLocalization()
|
local localization = system.getCurrentScriptLocalization()
|
||||||
local currentLayer = 0
|
local currentLayer = 0
|
||||||
local model
|
local model
|
||||||
local shapeLimit = 24
|
local shapeLimit = 24
|
||||||
@ -27,17 +25,17 @@ end
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local application = GUI.application()
|
local workspace = GUI.workspace()
|
||||||
|
|
||||||
local toolPanel = application:addChild(GUI.panel(1, 1, 28, application.height, 0x2D2D2D))
|
local toolPanel = workspace:addChild(GUI.panel(1, 1, 28, workspace.height, 0x2D2D2D))
|
||||||
local toolLayout = application:addChild(GUI.layout(1, 1, toolPanel.width, toolPanel.height - 3, 1, 1))
|
local toolLayout = workspace:addChild(GUI.layout(1, 1, toolPanel.width, toolPanel.height - 3, 1, 1))
|
||||||
toolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
toolLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||||
toolLayout:setMargin(1, 1, 0, 1)
|
toolLayout:setMargin(1, 1, 0, 1)
|
||||||
|
|
||||||
local function addSeparator(text)
|
local function addSeparator(text)
|
||||||
toolLayout:addChild(GUI.object(1, 1, toolLayout.width, 1)).draw = function(object)
|
toolLayout:addChild(GUI.object(1, 1, toolLayout.width, 1)).draw = function(object)
|
||||||
buffer.drawRectangle(object.x, object.y, object.width, 1, 0x0F0F0F, 0xE1E1E1, " ")
|
screen.drawRectangle(object.x, object.y, object.width, 1, 0x0F0F0F, 0xE1E1E1, " ")
|
||||||
buffer.drawText(object.x + 1, object.y, 0xE1E1E1, text)
|
screen.drawText(object.x + 1, object.y, 0xE1E1E1, text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,7 +47,7 @@ local function addColorSelector(...)
|
|||||||
return toolLayout:addChild(GUI.colorSelector(1, 1, toolLayout.width - 2, 1, ...))
|
return toolLayout:addChild(GUI.colorSelector(1, 1, toolLayout.width - 2, 1, ...))
|
||||||
end
|
end
|
||||||
|
|
||||||
local printButton = application:addChild(GUI.button(1, application.height - 2, toolLayout.width, 3, 0x4B4B4B, 0xD2D2D2, 0xE1E1E1, 0x3C3C3C, localization.print))
|
local printButton = workspace:addChild(GUI.button(1, workspace.height - 2, toolLayout.width, 3, 0x4B4B4B, 0xD2D2D2, 0xE1E1E1, 0x3C3C3C, localization.print))
|
||||||
|
|
||||||
toolLayout:addChild(GUI.object(1, 1, toolLayout.width, 5)).draw = function(object)
|
toolLayout:addChild(GUI.object(1, 1, toolLayout.width, 5)).draw = function(object)
|
||||||
local text = tostring(math.floor(currentLayer))
|
local text = tostring(math.floor(currentLayer))
|
||||||
@ -63,11 +61,11 @@ local newButton = addButton(localization.new)
|
|||||||
local openButton = addButton(localization.open)
|
local openButton = addButton(localization.open)
|
||||||
|
|
||||||
addButton(localization.save).onTouch = function()
|
addButton(localization.save).onTouch = function()
|
||||||
local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "Save", "Cancel", "File name", "/")
|
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Save", "Cancel", "File name", "/")
|
||||||
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
|
filesystemDialog:setMode(GUI.IO_MODE_SAVE, GUI.IO_MODE_FILE)
|
||||||
filesystemDialog:addExtensionFilter(".3dm")
|
filesystemDialog:addExtensionFilter(".3dm")
|
||||||
filesystemDialog.onSubmit = function(path)
|
filesystemDialog.onSubmit = function(path)
|
||||||
table.toFile(path, model, true)
|
filesystem.writeTable(path, model, true)
|
||||||
end
|
end
|
||||||
filesystemDialog:show()
|
filesystemDialog:show()
|
||||||
end
|
end
|
||||||
@ -77,7 +75,7 @@ addButton(localization.exit).onTouch = function()
|
|||||||
hologram.clear()
|
hologram.clear()
|
||||||
end
|
end
|
||||||
|
|
||||||
application:stop()
|
workspace:stop()
|
||||||
end
|
end
|
||||||
|
|
||||||
addSeparator(localization.elementSettings)
|
addSeparator(localization.elementSettings)
|
||||||
@ -170,7 +168,7 @@ if proxies.hologram then
|
|||||||
selector.onColorSelected = function()
|
selector.onColorSelected = function()
|
||||||
if proxies.hologram then
|
if proxies.hologram then
|
||||||
proxies.hologram.setPaletteColor(i, selector.color)
|
proxies.hologram.setPaletteColor(i, selector.color)
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -261,7 +259,7 @@ local function updateModelFromWidgets()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function load(path)
|
local function load(path)
|
||||||
model = table.fromFile(path)
|
model = filesystem.readTable(path)
|
||||||
|
|
||||||
updateComboBoxFromModel()
|
updateComboBoxFromModel()
|
||||||
updateWidgetsFromModel()
|
updateWidgetsFromModel()
|
||||||
@ -269,28 +267,28 @@ local function load(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
openButton.onTouch = function()
|
openButton.onTouch = function()
|
||||||
local filesystemDialog = GUI.addFilesystemDialog(application, true, 50, math.floor(application.height * 0.8), "Open", "Cancel", "File name", "/")
|
local filesystemDialog = GUI.addFilesystemDialog(workspace, true, 50, math.floor(workspace.height * 0.8), "Open", "Cancel", "File name", "/")
|
||||||
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
|
filesystemDialog:setMode(GUI.IO_MODE_OPEN, GUI.IO_MODE_FILE)
|
||||||
filesystemDialog:addExtensionFilter(".3dm")
|
filesystemDialog:addExtensionFilter(".3dm")
|
||||||
filesystemDialog.onSubmit = function(path)
|
filesystemDialog.onSubmit = function(path)
|
||||||
load(path)
|
load(path)
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
filesystemDialog:show()
|
filesystemDialog:show()
|
||||||
end
|
end
|
||||||
|
|
||||||
application:addChild(GUI.panel(toolPanel.width + 1, 1, application.width - toolPanel.width, toolPanel.height, 0x1E1E1E))
|
workspace:addChild(GUI.panel(toolPanel.width + 1, 1, workspace.width - toolPanel.width, toolPanel.height, 0x1E1E1E))
|
||||||
|
|
||||||
local view = application:addChild(GUI.object(1, 1, 16 * viewPixelWidth, 16 * viewPixelHeight))
|
local view = workspace:addChild(GUI.object(1, 1, 16 * viewPixelWidth, 16 * viewPixelHeight))
|
||||||
view.localX = math.floor(toolLayout.width + (application.width - toolLayout.width) / 2 - view.width / 2)
|
view.localX = math.floor(toolLayout.width + (workspace.width - toolLayout.width) / 2 - view.width / 2)
|
||||||
view.localY = math.floor(application.height / 2 - view.height / 2)
|
view.localY = math.floor(workspace.height / 2 - view.height / 2)
|
||||||
view.draw = function()
|
view.draw = function()
|
||||||
local x, y, step = view.x, view.y, true
|
local x, y, step = view.x, view.y, true
|
||||||
for j = 1, 16 do
|
for j = 1, 16 do
|
||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
buffer.drawRectangle(x, y, viewPixelWidth, viewPixelHeight, 0xF0F0F0, 0xE1E1E1, step and " " or "█")
|
screen.drawRectangle(x, y, viewPixelWidth, viewPixelHeight, 0xF0F0F0, 0xE1E1E1, step and " " or "█")
|
||||||
x, step = x + viewPixelWidth, not step
|
x, step = x + viewPixelWidth, not step
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -311,14 +309,14 @@ view.draw = function()
|
|||||||
local y = view.y + view.height - shape[2] * viewPixelHeight - height
|
local y = view.y + view.height - shape[2] * viewPixelHeight - height
|
||||||
|
|
||||||
if width > 0 and height > 0 and currentLayer >= shape[3] and currentLayer <= shape[6] - 1 then
|
if width > 0 and height > 0 and currentLayer >= shape[3] and currentLayer <= shape[6] - 1 then
|
||||||
buffer.drawRectangle(x, y, width, height, i == shapeIndex and colors[i] or color.blend(colors[i], 0xFFFFFF, 0.5), 0x0, " ")
|
screen.drawRectangle(x, y, width, height, i == shapeIndex and colors[i] or color.blend(colors[i], 0xFFFFFF, 0.5), 0x0, " ")
|
||||||
|
|
||||||
if currentLayer == shape[3] then
|
if currentLayer == shape[3] then
|
||||||
buffer.drawRectangle(x, y, viewPixelWidth, viewPixelHeight, 0x0, 0x0, " ", i == shapeIndex and 0.2 or 0.6)
|
screen.drawRectangle(x, y, viewPixelWidth, viewPixelHeight, 0x0, 0x0, " ", i == shapeIndex and 0.2 or 0.6)
|
||||||
end
|
end
|
||||||
|
|
||||||
if currentLayer == shape[6] - 1 then
|
if currentLayer == shape[6] - 1 then
|
||||||
buffer.drawRectangle(x + width - viewPixelWidth, y + height - viewPixelHeight, viewPixelWidth, viewPixelHeight, 0x0, 0x0, " ", i == shapeIndex and 0.4 or 0.8)
|
screen.drawRectangle(x + width - viewPixelWidth, y + height - viewPixelHeight, viewPixelWidth, viewPixelHeight, 0x0, 0x0, " ", i == shapeIndex and 0.4 or 0.8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -326,26 +324,26 @@ view.draw = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
toolLayout.eventHandler = function(application, toolLayout, e1, e2, e3, e4, e5)
|
toolLayout.eventHandler = function(workspace, toolLayout, e1, e2, e3, e4, e5)
|
||||||
if e1 == "scroll" then
|
if e1 == "scroll" then
|
||||||
local cell = toolLayout.cells[1][1]
|
local cell = toolLayout.cells[1][1]
|
||||||
if e5 > 0 then
|
if e5 > 0 then
|
||||||
if cell.verticalMargin < 1 then
|
if cell.verticalMargin < 1 then
|
||||||
cell.verticalMargin = cell.verticalMargin + 1
|
cell.verticalMargin = cell.verticalMargin + 1
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local child = toolLayout.children[#toolLayout.children]
|
local child = toolLayout.children[#toolLayout.children]
|
||||||
if child.localY + child.height - 1 >= toolLayout.localY + toolLayout.height - 1 then
|
if child.localY + child.height - 1 >= toolLayout.localY + toolLayout.height - 1 then
|
||||||
cell.verticalMargin = cell.verticalMargin - 1
|
cell.verticalMargin = cell.verticalMargin - 1
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local touchX, touchY, shapeX, shapeY, shapeZ
|
local touchX, touchY, shapeX, shapeY, shapeZ
|
||||||
view.eventHandler = function(application, view, e1, e2, e3, e4, e5)
|
view.eventHandler = function(workspace, view, e1, e2, e3, e4, e5)
|
||||||
if e1 == "touch" or e1 == "drag" then
|
if e1 == "touch" or e1 == "drag" then
|
||||||
if e5 > 0 then
|
if e5 > 0 then
|
||||||
if e1 == "touch" then
|
if e1 == "touch" then
|
||||||
@ -354,7 +352,7 @@ view.eventHandler = function(application, view, e1, e2, e3, e4, e5)
|
|||||||
view.localX, view.localY = view.localX + e3 - touchX, view.localY + e4 - touchY
|
view.localX, view.localY = view.localX + e3 - touchX, view.localY + e4 - touchY
|
||||||
touchX, touchY = e3, e4
|
touchX, touchY = e3, e4
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local shapeIndex = getCurrentShapeIndex()
|
local shapeIndex = getCurrentShapeIndex()
|
||||||
@ -374,7 +372,7 @@ view.eventHandler = function(application, view, e1, e2, e3, e4, e5)
|
|||||||
shape[4], shape[5], shape[6] = shape[4] + 1, shape[5] + 1, shape[6] + 1
|
shape[4], shape[5], shape[6] = shape[4] + 1, shape[5] + 1, shape[6] + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif e1 == "drop" then
|
elseif e1 == "drop" then
|
||||||
@ -397,7 +395,7 @@ view.eventHandler = function(application, view, e1, e2, e3, e4, e5)
|
|||||||
currentLayer = currentLayer + 1
|
currentLayer = currentLayer + 1
|
||||||
fix()
|
fix()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -405,7 +403,7 @@ view.eventHandler = function(application, view, e1, e2, e3, e4, e5)
|
|||||||
currentLayer = currentLayer - 1
|
currentLayer = currentLayer - 1
|
||||||
fix()
|
fix()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -430,7 +428,7 @@ rotateButton.onTouch = function()
|
|||||||
fixShape(shape)
|
fixShape(shape)
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -453,7 +451,7 @@ flipButton.onTouch = function()
|
|||||||
fixShape(shape)
|
fixShape(shape)
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -462,7 +460,7 @@ disabledListItem.onTouch = function()
|
|||||||
updateWidgetsFromModel()
|
updateWidgetsFromModel()
|
||||||
updateAddRemoveButtonsState()
|
updateAddRemoveButtonsState()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -485,14 +483,14 @@ end
|
|||||||
newButton.onTouch = function()
|
newButton.onTouch = function()
|
||||||
new()
|
new()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
|
|
||||||
addShapeButton.onTouch = function()
|
addShapeButton.onTouch = function()
|
||||||
addShape()
|
addShape()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -503,7 +501,7 @@ removeShapeButton.onTouch = function()
|
|||||||
updateWidgetsFromModel()
|
updateWidgetsFromModel()
|
||||||
updateAddRemoveButtonsState()
|
updateAddRemoveButtonsState()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -548,7 +546,7 @@ end
|
|||||||
elementComboBox.onItemSelected = function()
|
elementComboBox.onItemSelected = function()
|
||||||
updateWidgetsFromModel()
|
updateWidgetsFromModel()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -570,6 +568,6 @@ else
|
|||||||
new()
|
new()
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateOnHologram()
|
updateOnHologram()
|
||||||
application:start()
|
workspace:start()
|
||||||
181
Applications/3DTest/3DTest.lua → Applications/3D Test.app/Main.lua
Executable file → Normal file
181
Applications/3DTest/3DTest.lua → Applications/3D Test.app/Main.lua
Executable file → Normal file
@ -1,20 +1,11 @@
|
|||||||
|
|
||||||
-------------------------------------------------------- Libraries --------------------------------------------------------
|
-------------------------------------------------------- Libraries --------------------------------------------------------
|
||||||
|
|
||||||
-- package.loaded["GUI"] = nil
|
local color = require("Color")
|
||||||
-- package.loaded["doubleBuffering"] = nil
|
local screen = require("Screen")
|
||||||
-- package.loaded["vector"] = nil
|
local event = require("Event")
|
||||||
-- package.loaded["OpenComputersGL/Main"] = nil
|
|
||||||
-- package.loaded["OpenComputersGL/Materials"] = nil
|
|
||||||
-- package.loaded["OpenComputersGL/Renderer"] = nil
|
|
||||||
-- package.loaded["MeowEngine/Main"] = nil
|
|
||||||
|
|
||||||
local color = require("color")
|
|
||||||
local computer = require("computer")
|
|
||||||
local buffer = require("doubleBuffering")
|
|
||||||
local event = require("event")
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local vector = require("vector")
|
local vector = require("Vector")
|
||||||
local materials = require("OpenComputersGL/Materials")
|
local materials = require("OpenComputersGL/Materials")
|
||||||
local renderer = require("OpenComputersGL/Renderer")
|
local renderer = require("OpenComputersGL/Renderer")
|
||||||
local OCGL = require("OpenComputersGL/Main")
|
local OCGL = require("OpenComputersGL/Main")
|
||||||
@ -24,10 +15,10 @@ local meowEngine = require("MeowEngine/Main")
|
|||||||
|
|
||||||
-- /MineOS/Desktop/3DTest.app/3DTest.lua
|
-- /MineOS/Desktop/3DTest.app/3DTest.lua
|
||||||
|
|
||||||
buffer.flush()
|
screen.flush()
|
||||||
meowEngine.intro(vector.newVector3(0, 0, 0), 20)
|
meowEngine.intro(vector.newVector3(0, 0, 0), 20)
|
||||||
|
|
||||||
local application = GUI.application()
|
local workspace = GUI.workspace()
|
||||||
local scene = meowEngine.newScene(0x1D1D1D)
|
local scene = meowEngine.newScene(0x1D1D1D)
|
||||||
|
|
||||||
scene.renderMode = OCGL.renderModes.flatShading
|
scene.renderMode = OCGL.renderModes.flatShading
|
||||||
@ -280,14 +271,14 @@ local function move(x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function moveLight(x, y, z)
|
local function moveLight(x, y, z)
|
||||||
scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[1] = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[1] + x
|
scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].position[1] = scene.lights[workspace.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[workspace.toolbar.lightSelectComboBox.selectedItem].position[2] = scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].position[2] + y
|
||||||
scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[3] = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].position[3] + z
|
scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].position[3] = scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].position[3] + z
|
||||||
end
|
end
|
||||||
|
|
||||||
local controls = {
|
local controls = {
|
||||||
-- F1
|
-- F1
|
||||||
[59 ] = function() application.toolbar.hidden = not application.toolbar.hidden; application.infoTextBox.hidden = not application.infoTextBox.hidden end,
|
[59 ] = function() workspace.toolbar.hidden = not workspace.toolbar.hidden; workspace.infoTextBox.hidden = not workspace.infoTextBox.hidden end,
|
||||||
-- Arrows
|
-- Arrows
|
||||||
[200] = function() scene.camera:rotate(-rotationAngle, 0, 0) end,
|
[200] = function() scene.camera:rotate(-rotationAngle, 0, 0) end,
|
||||||
[208] = function() scene.camera:rotate(rotationAngle, 0, 0) end,
|
[208] = function() scene.camera:rotate(rotationAngle, 0, 0) end,
|
||||||
@ -314,12 +305,12 @@ local controls = {
|
|||||||
|
|
||||||
-------------------------------------------------------- GUI --------------------------------------------------------
|
-------------------------------------------------------- GUI --------------------------------------------------------
|
||||||
|
|
||||||
local OCGLView = GUI.object(1, 1, application.width, application.height)
|
local OCGLView = GUI.object(1, 1, workspace.width, workspace.height)
|
||||||
|
|
||||||
local function drawInvertedText(x, y, text)
|
local function drawInvertedText(x, y, text)
|
||||||
local index = buffer.getIndex(x, y)
|
local index = screen.getIndex(x, y)
|
||||||
local background, foreground = buffer.rawGet(index)
|
local background, foreground = screen.rawGet(index)
|
||||||
buffer.rawSet(index, background, 0xFFFFFF - foreground, text)
|
screen.rawSet(index, background, 0xFFFFFF - foreground, text)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function drawCross(x, y)
|
local function drawCross(x, y)
|
||||||
@ -332,16 +323,16 @@ local function drawCross(x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
OCGLView.draw = function(object)
|
OCGLView.draw = function(object)
|
||||||
application.oldClock = os.clock()
|
workspace.oldClock = os.clock()
|
||||||
if world then renderWorld() end
|
if world then renderWorld() end
|
||||||
scene:render()
|
scene:render()
|
||||||
if application.toolbar.zBufferSwitch.state then
|
if workspace.toolbar.zBufferSwitch.state then
|
||||||
renderer.visualizeDepthBuffer()
|
renderer.visualizeDepthBuffer()
|
||||||
end
|
end
|
||||||
drawCross(renderer.viewport.xCenter, math.floor(renderer.viewport.yCenter / 2))
|
drawCross(renderer.viewport.xCenter, math.floor(renderer.viewport.yCenter / 2))
|
||||||
end
|
end
|
||||||
|
|
||||||
OCGLView.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
OCGLView.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
|
||||||
if e1 == "touch" then
|
if e1 == "touch" then
|
||||||
local targetVector = vector.newVector3(scene.camera.position[1], scene.camera.position[2], scene.camera.position[3] + 1000)
|
local targetVector = vector.newVector3(scene.camera.position[1], scene.camera.position[2], scene.camera.position[3] + 1000)
|
||||||
OCGL.rotateVectorRelativeToXAxis(targetVector, scene.camera.rotation[1])
|
OCGL.rotateVectorRelativeToXAxis(targetVector, scene.camera.rotation[1])
|
||||||
@ -368,122 +359,122 @@ OCGLView.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
|||||||
zWorld = zWorld - 1
|
zWorld = zWorld - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
setBlock(xWorld, yWorld, zWorld, e5 == 1 and application.toolbar.blockColorSelector.color or nil)
|
setBlock(xWorld, yWorld, zWorld, e5 == 1 and workspace.toolbar.blockColorSelector.color or nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
application:addChild(OCGLView)
|
workspace:addChild(OCGLView)
|
||||||
|
|
||||||
application.infoTextBox = application:addChild(GUI.textBox(2, 4, 45, application.height, nil, 0xEEEEEE, {}, 1, 0, 0))
|
workspace.infoTextBox = workspace:addChild(GUI.textBox(2, 4, 45, workspace.height, nil, 0xEEEEEE, {}, 1, 0, 0))
|
||||||
local lines = {
|
local lines = {
|
||||||
"Copyright © 2016-2017 - Developed by ECS Inc.",
|
"Copyright © 2016-2017 - Developed by ECS Inc.",
|
||||||
"Timofeef Igor (vk.com/id7799889), Trifonov Gleb (vk.com/id88323331), Verevkin Yakov (vk.com/id60991376), Bogushevich Victoria (vk.com/id171497518)",
|
"Timofeef Igor (vk.com/id7799889), Trifonov Gleb (vk.com/id88323331), Verevkin Yakov (vk.com/id60991376), Bogushevich Victoria (vk.com/id171497518)",
|
||||||
"All rights reserved",
|
"All rights reserved",
|
||||||
}
|
}
|
||||||
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)
|
workspace:addChild(GUI.textBox(1, workspace.height - #lines + 1, workspace.width, #lines, nil, 0x3C3C3C, lines, 1)):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||||
|
|
||||||
local elementY = 2
|
local elementY = 2
|
||||||
application.toolbar = application:addChild(GUI.container(application.width - 31, 1, 32, application.height))
|
workspace.toolbar = workspace:addChild(GUI.container(workspace.width - 31, 1, 32, workspace.height))
|
||||||
local elementWidth = application.toolbar.width - 2
|
local elementWidth = workspace.toolbar.width - 2
|
||||||
application.toolbar:addChild(GUI.panel(1, 1, application.toolbar.width, application.toolbar.height, 0x0, 0.5))
|
workspace.toolbar:addChild(GUI.panel(1, 1, workspace.toolbar.width, workspace.toolbar.height, 0x0, 0.5))
|
||||||
|
|
||||||
application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "Render mode")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2
|
workspace.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
|
workspace.toolbar.renderModeComboBox = workspace.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + workspace.toolbar.renderModeComboBox.height + 1
|
||||||
application.toolbar.renderModeComboBox:addItem("disabled")
|
workspace.toolbar.renderModeComboBox:addItem("disabled")
|
||||||
application.toolbar.renderModeComboBox:addItem("constantShading")
|
workspace.toolbar.renderModeComboBox:addItem("constantShading")
|
||||||
application.toolbar.renderModeComboBox:addItem("flatShading")
|
workspace.toolbar.renderModeComboBox:addItem("flatShading")
|
||||||
application.toolbar.renderModeComboBox.selectedItem = scene.renderMode
|
workspace.toolbar.renderModeComboBox.selectedItem = scene.renderMode
|
||||||
application.toolbar.renderModeComboBox.onItemSelected = function()
|
workspace.toolbar.renderModeComboBox.onItemSelected = function()
|
||||||
scene.renderMode = application.toolbar.renderModeComboBox.selectedItem
|
scene.renderMode = workspace.toolbar.renderModeComboBox.selectedItem
|
||||||
end
|
end
|
||||||
|
|
||||||
application.toolbar.auxiliaryModeComboBox = application.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + application.toolbar.auxiliaryModeComboBox.height + 1
|
workspace.toolbar.auxiliaryModeComboBox = workspace.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + workspace.toolbar.auxiliaryModeComboBox.height + 1
|
||||||
application.toolbar.auxiliaryModeComboBox:addItem("disabled")
|
workspace.toolbar.auxiliaryModeComboBox:addItem("disabled")
|
||||||
application.toolbar.auxiliaryModeComboBox:addItem("wireframe")
|
workspace.toolbar.auxiliaryModeComboBox:addItem("wireframe")
|
||||||
application.toolbar.auxiliaryModeComboBox:addItem("vertices")
|
workspace.toolbar.auxiliaryModeComboBox:addItem("vertices")
|
||||||
application.toolbar.auxiliaryModeComboBox.selectedItem = scene.auxiliaryMode
|
workspace.toolbar.auxiliaryModeComboBox.selectedItem = scene.auxiliaryMode
|
||||||
application.toolbar.auxiliaryModeComboBox.onItemSelected = function()
|
workspace.toolbar.auxiliaryModeComboBox.onItemSelected = function()
|
||||||
scene.auxiliaryMode = application.toolbar.auxiliaryModeComboBox.selectedItem
|
scene.auxiliaryMode = workspace.toolbar.auxiliaryModeComboBox.selectedItem
|
||||||
end
|
end
|
||||||
|
|
||||||
application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xAAAAAA, "Perspective proj:"))
|
workspace.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
|
workspace.toolbar.perspectiveSwitch = workspace.toolbar:addChild(GUI.switch(workspace.toolbar.width - 8, elementY, 8, 0x66DB80, 0x2D2D2D, 0xEEEEEE, scene.camera.projectionEnabled)); elementY = elementY + 2
|
||||||
application.toolbar.perspectiveSwitch.onStateChanged = function()
|
workspace.toolbar.perspectiveSwitch.onStateChanged = function()
|
||||||
scene.camera.projectionEnabled = application.toolbar.perspectiveSwitch.state
|
scene.camera.projectionEnabled = workspace.toolbar.perspectiveSwitch.state
|
||||||
end
|
end
|
||||||
|
|
||||||
application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xAAAAAA, "Z-buffer visualize:"))
|
workspace.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
|
workspace.toolbar.zBufferSwitch = workspace.toolbar:addChild(GUI.switch(workspace.toolbar.width - 8, elementY, 8, 0x66DB80, 0x2D2D2D, 0xEEEEEE, false)); elementY = elementY + 2
|
||||||
|
|
||||||
|
|
||||||
local function calculateLightComboBox()
|
local function calculateLightComboBox()
|
||||||
application.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children = {}
|
workspace.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children = {}
|
||||||
for i = 1, #scene.lights do
|
for i = 1, #scene.lights do
|
||||||
application.toolbar.lightSelectComboBox:addItem(tostring(i))
|
workspace.toolbar.lightSelectComboBox:addItem(tostring(i))
|
||||||
end
|
end
|
||||||
application.toolbar.lightSelectComboBox.selectedItem = #application.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children
|
workspace.toolbar.lightSelectComboBox.selectedItem = #workspace.toolbar.lightSelectComboBox.dropDownMenu.itemsContainer.children
|
||||||
application.toolbar.lightIntensitySlider.value = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].intensity * 100
|
workspace.toolbar.lightIntensitySlider.value = scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].intensity * 100
|
||||||
application.toolbar.lightEmissionSlider.value = scene.lights[application.toolbar.lightSelectComboBox.selectedItem].emissionDistance
|
workspace.toolbar.lightEmissionSlider.value = scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].emissionDistance
|
||||||
end
|
end
|
||||||
|
|
||||||
application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "Light control")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2
|
workspace.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
|
workspace.toolbar.lightSelectComboBox = workspace.toolbar:addChild(GUI.comboBox(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0x888888)); elementY = elementY + workspace.toolbar.lightSelectComboBox.height + 1
|
||||||
|
|
||||||
application.toolbar.addLightButton = application.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Add light")); elementY = elementY + 2
|
workspace.toolbar.addLightButton = workspace.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Add light")); elementY = elementY + 2
|
||||||
application.toolbar.addLightButton.onTouch = function()
|
workspace.toolbar.addLightButton.onTouch = function()
|
||||||
scene:addLight(meowEngine.newLight(vector.newVector3(0, 10, 0), application.toolbar.lightIntensitySlider.value / 100, application.toolbar.lightEmissionSlider.value))
|
scene:addLight(meowEngine.newLight(vector.newVector3(0, 10, 0), workspace.toolbar.lightIntensitySlider.value / 100, workspace.toolbar.lightEmissionSlider.value))
|
||||||
calculateLightComboBox()
|
calculateLightComboBox()
|
||||||
end
|
end
|
||||||
|
|
||||||
application.toolbar.removeLightButton = application.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Remove light")); elementY = elementY + 2
|
workspace.toolbar.removeLightButton = workspace.toolbar:addChild(GUI.button(2, elementY, elementWidth, 1, 0x2D2D2D, 0xAAAAAA, 0x555555, 0xAAAAAA, "Remove light")); elementY = elementY + 2
|
||||||
application.toolbar.removeLightButton.onTouch = function()
|
workspace.toolbar.removeLightButton.onTouch = function()
|
||||||
if #scene.lights > 1 then
|
if #scene.lights > 1 then
|
||||||
table.remove(scene.lights, application.toolbar.lightSelectComboBox.selectedItem)
|
table.remove(scene.lights, workspace.toolbar.lightSelectComboBox.selectedItem)
|
||||||
calculateLightComboBox()
|
calculateLightComboBox()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
application.toolbar.lightIntensitySlider = application.toolbar:addChild(GUI.slider(2, elementY, elementWidth, 0xCCCCCC, 0x2D2D2D, 0xEEEEEE, 0xAAAAAA, 0, 500, 100, false, "Intensity: ", "")); elementY = elementY + 3
|
workspace.toolbar.lightIntensitySlider = workspace.toolbar:addChild(GUI.slider(2, elementY, elementWidth, 0xCCCCCC, 0x2D2D2D, 0xEEEEEE, 0xAAAAAA, 0, 500, 100, false, "Intensity: ", "")); elementY = elementY + 3
|
||||||
application.toolbar.lightIntensitySlider.onValueChanged = function()
|
workspace.toolbar.lightIntensitySlider.onValueChanged = function()
|
||||||
scene.lights[application.toolbar.lightSelectComboBox.selectedItem].intensity = application.toolbar.lightIntensitySlider.value / 100
|
scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].intensity = workspace.toolbar.lightIntensitySlider.value / 100
|
||||||
end
|
end
|
||||||
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
|
workspace.toolbar.lightEmissionSlider = workspace.toolbar:addChild(GUI.slider(2, elementY, elementWidth, 0xCCCCCC, 0x2D2D2D, 0xEEEEEE, 0xAAAAAA, 0, scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].emissionDistance, scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].emissionDistance, false, "Distance: ", "")); elementY = elementY + 3
|
||||||
application.toolbar.lightEmissionSlider.onValueChanged = function()
|
workspace.toolbar.lightEmissionSlider.onValueChanged = function()
|
||||||
scene.lights[application.toolbar.lightSelectComboBox.selectedItem].emissionDistance = application.toolbar.lightEmissionSlider.value
|
scene.lights[workspace.toolbar.lightSelectComboBox.selectedItem].emissionDistance = workspace.toolbar.lightEmissionSlider.value
|
||||||
end
|
end
|
||||||
calculateLightComboBox()
|
calculateLightComboBox()
|
||||||
|
|
||||||
application.toolbar.blockColorSelector = application.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, 0xEEEEEE, "Block color")); elementY = elementY + application.toolbar.blockColorSelector.height + 1
|
workspace.toolbar.blockColorSelector = workspace.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, 0xEEEEEE, "Block color")); elementY = elementY + workspace.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
|
workspace.toolbar.backgroundColorSelector = workspace.toolbar:addChild(GUI.colorSelector(2, elementY, elementWidth, 1, scene.backgroundColor, "Background color")); elementY = elementY + workspace.toolbar.blockColorSelector.height + 1
|
||||||
application.toolbar.backgroundColorSelector.onColorSelected = function()
|
workspace.toolbar.backgroundColorSelector.onColorSelected = function()
|
||||||
scene.backgroundColor = application.toolbar.backgroundColorSelector.color
|
scene.backgroundColor = workspace.toolbar.backgroundColorSelector.color
|
||||||
end
|
end
|
||||||
|
|
||||||
application.toolbar:addChild(GUI.label(2, elementY, elementWidth, 1, 0xEEEEEE, "RAM monitoring")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP); elementY = elementY + 2
|
workspace.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
|
workspace.toolbar.RAMChart = workspace.toolbar:addChild(GUI.chart(2, elementY, elementWidth, workspace.toolbar.height - elementY - 3, 0xEEEEEE, 0xAAAAAA, 0x555555, 0x66DB80, 0.35, 0.25, "s", "%", true, {})); elementY = elementY + workspace.toolbar.RAMChart.height + 1
|
||||||
application.toolbar.RAMChart.roundValues = true
|
workspace.toolbar.RAMChart.roundValues = true
|
||||||
-- application.toolbar.RAMChart.showXAxisValues = false
|
-- workspace.toolbar.RAMChart.showXAxisValues = false
|
||||||
application.toolbar.RAMChart.counter = 1
|
workspace.toolbar.RAMChart.counter = 1
|
||||||
|
|
||||||
application.toolbar:addChild(GUI.button(1, application.toolbar.height - 2, application.toolbar.width, 3, 0x2D2D2D, 0xEEEEEE, 0x444444, 0xEEEEEE, "Exit")).onTouch = function()
|
workspace.toolbar:addChild(GUI.button(1, workspace.toolbar.height - 2, workspace.toolbar.width, 3, 0x2D2D2D, 0xEEEEEE, 0x444444, 0xEEEEEE, "Exit")).onTouch = function()
|
||||||
application:stop()
|
workspace:stop()
|
||||||
end
|
end
|
||||||
|
|
||||||
local FPSCounter = GUI.object(2, 2, 8, 3)
|
local FPSCounter = GUI.object(2, 2, 8, 3)
|
||||||
FPSCounter.draw = function(FPSCounter)
|
FPSCounter.draw = function(FPSCounter)
|
||||||
renderer.renderFPSCounter(FPSCounter.x, FPSCounter.y, tostring(math.ceil(1 / (os.clock() - application.oldClock) / 10)), 0xFFFF00)
|
renderer.renderFPSCounter(FPSCounter.x, FPSCounter.y, tostring(math.ceil(1 / (os.clock() - workspace.oldClock) / 10)), 0xFFFF00)
|
||||||
end
|
end
|
||||||
application:addChild(FPSCounter)
|
workspace:addChild(FPSCounter)
|
||||||
|
|
||||||
application.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
workspace.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
|
||||||
if not application.toolbar.hidden then
|
if not workspace.toolbar.hidden then
|
||||||
local totalMemory = computer.totalMemory()
|
local totalMemory = computer.totalMemory()
|
||||||
table.insert(application.toolbar.RAMChart.values, {application.toolbar.RAMChart.counter, math.ceil((totalMemory - computer.freeMemory()) / totalMemory * 100)})
|
table.insert(workspace.toolbar.RAMChart.values, {workspace.toolbar.RAMChart.counter, math.ceil((totalMemory - computer.freeMemory()) / totalMemory * 100)})
|
||||||
application.toolbar.RAMChart.counter = application.toolbar.RAMChart.counter + 1
|
workspace.toolbar.RAMChart.counter = workspace.toolbar.RAMChart.counter + 1
|
||||||
if #application.toolbar.RAMChart.values > 20 then table.remove(application.toolbar.RAMChart.values, 1) end
|
if #workspace.toolbar.RAMChart.values > 20 then table.remove(workspace.toolbar.RAMChart.values, 1) end
|
||||||
|
|
||||||
application.infoTextBox.lines = {
|
workspace.infoTextBox.lines = {
|
||||||
" ",
|
" ",
|
||||||
"SceneObjects: " .. #scene.objects,
|
"SceneObjects: " .. #scene.objects,
|
||||||
" ",
|
" ",
|
||||||
@ -510,7 +501,7 @@ application.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
|||||||
"F1 - toggle GUI overlay",
|
"F1 - toggle GUI overlay",
|
||||||
}
|
}
|
||||||
|
|
||||||
application.infoTextBox.height = #application.infoTextBox.lines
|
workspace.infoTextBox.height = #workspace.infoTextBox.lines
|
||||||
end
|
end
|
||||||
|
|
||||||
if e1 == "key_down" then
|
if e1 == "key_down" then
|
||||||
@ -529,9 +520,9 @@ application.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------- Ebat-kopat --------------------------------------------------------
|
-------------------------------------------------------- Ebat-kopat --------------------------------------------------------
|
||||||
|
|
||||||
application:start(0)
|
workspace:start(0)
|
||||||
@ -1 +0,0 @@
|
|||||||
This is a program for demostration of the capabilities of our 3D-engine, created specifically for low-performance computers. It embodies almost all the achievements of our team: rendering complex 3D-objects, dynamic lighting, texturing and user interface based on a powerful GUI library.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Программа-демонстратор возможностей 3D-движка, созданного специально для низкопроизводительных компьютеров. В ней воплощены практически все наработки нашей команды: от отрисовки сложных трехмерных объектов и динамического освещения до текстурирования и пользовательского интерфейса на мощной GUI-библиотеке.
|
|
||||||
BIN
Applications/App Market.app/Icon.pic
Normal file
BIN
Applications/App Market.app/Icon.pic
Normal file
Binary file not shown.
@ -26,6 +26,7 @@
|
|||||||
statisticsPublicationsCount = "Publications count",
|
statisticsPublicationsCount = "Publications count",
|
||||||
statisticsReviewsCount = "Reviews count",
|
statisticsReviewsCount = "Reviews count",
|
||||||
statisticsPopularPublication = "(popular publication)",
|
statisticsPopularPublication = "(popular publication)",
|
||||||
|
statisticsMessagesCount = "Messages count",
|
||||||
|
|
||||||
whatsNew = "What's new",
|
whatsNew = "What's new",
|
||||||
whatsNewInVersion = "What's new in version",
|
whatsNewInVersion = "What's new in version",
|
||||||
@ -26,6 +26,7 @@
|
|||||||
statisticsPublicationsCount = "Nombre de publications",
|
statisticsPublicationsCount = "Nombre de publications",
|
||||||
statisticsReviewsCount = "Nombre de commentaires",
|
statisticsReviewsCount = "Nombre de commentaires",
|
||||||
statisticsPopularPublication = "(publication populaire)",
|
statisticsPopularPublication = "(publication populaire)",
|
||||||
|
statisticsMessagesCount = "Nombre de messages",
|
||||||
|
|
||||||
whatsNew = "Quoi de neuf",
|
whatsNew = "Quoi de neuf",
|
||||||
whatsNewInVersion = "Quoi de neuf dans la version",
|
whatsNewInVersion = "Quoi de neuf dans la version",
|
||||||
@ -26,6 +26,7 @@
|
|||||||
statisticsPublicationsCount = "Число публикаций",
|
statisticsPublicationsCount = "Число публикаций",
|
||||||
statisticsReviewsCount = "Число отзывов",
|
statisticsReviewsCount = "Число отзывов",
|
||||||
statisticsPopularPublication = "(популярная публикация)",
|
statisticsPopularPublication = "(популярная публикация)",
|
||||||
|
statisticsMessagesCount = "Число сообщений",
|
||||||
|
|
||||||
whatsNew = "Что нового",
|
whatsNew = "Что нового",
|
||||||
whatsNewInVersion = "Что нового в версии",
|
whatsNewInVersion = "Что нового в версии",
|
||||||
@ -26,6 +26,7 @@
|
|||||||
statisticsPublicationsCount = "Число публікацій",
|
statisticsPublicationsCount = "Число публікацій",
|
||||||
statisticsReviewsCount = "Число відгуків",
|
statisticsReviewsCount = "Число відгуків",
|
||||||
statisticsPopularPublication = "(Популярна публікація)",
|
statisticsPopularPublication = "(Популярна публікація)",
|
||||||
|
statisticsMessagesCount = "Число повідомленняний",
|
||||||
|
|
||||||
whatsNew = "Що нового",
|
whatsNew = "Що нового",
|
||||||
whatsNewInVersion = "Що нового у версії",
|
whatsNewInVersion = "Що нового у версії",
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
Популярная игра "Морской бой", написанная товарищем Nezn с форума ComputerCraft.ru. Рассчитана на одного игрока, вам предстоит захватывающее сражение с флотом противника, контролируемым ИИ на Lua.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Популярная игра "Морской бой", написанная товарищем Nezn с форума ComputerCraft.ru. Рассчитана на одного игрока, вам предстоит захватывающее сражение с флотом противника, контролируемым ИИ на Lua.
|
|
||||||
@ -1,339 +0,0 @@
|
|||||||
--Реквайрики
|
|
||||||
local g = require("component").gpu
|
|
||||||
local term = require("term")
|
|
||||||
local event = require("event")
|
|
||||||
|
|
||||||
local colors = {
|
|
||||||
white = 0xffffff,
|
|
||||||
orange = 0xF2B233,
|
|
||||||
magenta = 0xE57FD8,
|
|
||||||
lightBlue = 0x99B2F2,
|
|
||||||
yellow = 0xDEDE6C,
|
|
||||||
lime = 0x7FCC19,
|
|
||||||
pink = 0xF2B2CC,
|
|
||||||
gray = 0x4C4C4C,
|
|
||||||
lightGray = 0x999999,
|
|
||||||
cyan = 0x4C99B2,
|
|
||||||
purple = 0xB266E5,
|
|
||||||
blue = 0x3366CC,
|
|
||||||
brown = 0x7F664C,
|
|
||||||
green = 0x57A64E,
|
|
||||||
red = 0xCC4C4C,
|
|
||||||
black = 0x000000,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
--Настройка экрана
|
|
||||||
local w, h = 46, 14
|
|
||||||
g.setResolution(w,h)
|
|
||||||
|
|
||||||
--Аргументы
|
|
||||||
args = {...}
|
|
||||||
|
|
||||||
--Очищаем экран
|
|
||||||
g.setBackground(colors.lightGray)
|
|
||||||
term.clear()
|
|
||||||
|
|
||||||
--Переменные для кораблей
|
|
||||||
local ships = {{3, 3, 8},
|
|
||||||
{3, 5, 6},
|
|
||||||
{11, 5, 6},
|
|
||||||
{3, 7, 4},
|
|
||||||
{9, 7, 4},
|
|
||||||
{15, 7, 4},
|
|
||||||
{3, 9, 2},
|
|
||||||
{7, 9, 2},
|
|
||||||
{11, 9, 2},
|
|
||||||
{15, 9, 2}}
|
|
||||||
local shipsE = {{0, 0, 8},
|
|
||||||
{0, 0, 6},
|
|
||||||
{0, 0, 6},
|
|
||||||
{0, 0, 4},
|
|
||||||
{0, 0, 4},
|
|
||||||
{0, 0, 4},
|
|
||||||
{0, 0, 2},
|
|
||||||
{0, 0, 2},
|
|
||||||
{0, 0, 2},
|
|
||||||
{0, 0, 2}}
|
|
||||||
|
|
||||||
--Переменные попаданий
|
|
||||||
local shots = 0
|
|
||||||
local shotsE = {{0, 0}}
|
|
||||||
local shotsE2 = 0
|
|
||||||
|
|
||||||
--Пишем заголовок
|
|
||||||
g.setBackground(colors.gray)
|
|
||||||
g.fill(1,1,w,1," ")
|
|
||||||
term.setCursor(math.floor(w/2-6),1)
|
|
||||||
g.setForeground(colors.white)
|
|
||||||
term.write("Морской Бой")
|
|
||||||
g.setBackground(colors.black)
|
|
||||||
term.setCursor(w-3,1)
|
|
||||||
term.write(" ")
|
|
||||||
|
|
||||||
--Функция определения координаты для поля
|
|
||||||
function makePixelX(x, b)
|
|
||||||
return b+math.floor((x-b)/2)*2
|
|
||||||
end
|
|
||||||
|
|
||||||
--Рисуем кораблики
|
|
||||||
function drawShips()
|
|
||||||
for i=1,10 do
|
|
||||||
g.setBackground(colors.brown)
|
|
||||||
g.fill(ships[i][1], ships[i][2], ships[i][3], 1, " ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Автоматически установить кораблики
|
|
||||||
function setShipsAuto(var)
|
|
||||||
local s = ships
|
|
||||||
if var ~= 25 then
|
|
||||||
s = shipsE
|
|
||||||
end
|
|
||||||
for i=1,10 do
|
|
||||||
local x, y = 0, 0
|
|
||||||
local yes = true
|
|
||||||
while yes do
|
|
||||||
x = math.random(var, var+19)
|
|
||||||
y = math.random(3, 12)
|
|
||||||
if x+s[i][3]-1 < var+20 then
|
|
||||||
for j=1,10 do
|
|
||||||
if i ~= j and (x < s[j][1]+s[j][3]+2 and x+s[i][3] > s[j][1]-2 and y > s[j][2]-2 and y < s[j][2]+2) then
|
|
||||||
x = math.random(var, var+19)
|
|
||||||
y = math.random(3, 12)
|
|
||||||
break
|
|
||||||
elseif i ~= j and (j == 10 or (i == 10 and j == 9)) then
|
|
||||||
s[i][1] = makePixelX(x, var)
|
|
||||||
s[i][2] = y
|
|
||||||
yes = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if var == 25 then
|
|
||||||
ships = s
|
|
||||||
else
|
|
||||||
shipsE = s
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Рисуем поле
|
|
||||||
function drawField()
|
|
||||||
g.setBackground(0xffffff)
|
|
||||||
g.fill(25,3,20,10," ")
|
|
||||||
g.setBackground(0xDDDDDD)
|
|
||||||
if args[1] ~= "fast" then
|
|
||||||
for i=1,10 do
|
|
||||||
local delta = math.fmod(i,2)
|
|
||||||
for j=1,5 do
|
|
||||||
g.fill(23+4*j-2*delta, i+2, 2, 1, " ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Рисуем поле врага
|
|
||||||
function drawFieldE()
|
|
||||||
g.setBackground(0xffffff)
|
|
||||||
g.fill(3,3,20,10," ")
|
|
||||||
g.setBackground(0xDDDDDD)
|
|
||||||
if args[1] ~= "fast" then
|
|
||||||
for i=1,10 do
|
|
||||||
local delta = math.fmod(i,2)
|
|
||||||
for j=1,5 do
|
|
||||||
g.fill(1+4*j-2*delta, i+2, 2, 1, " ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Кнопка готово после рандома
|
|
||||||
function drawButton2()
|
|
||||||
g.setBackground(colors.pink)
|
|
||||||
term.setCursor(13, 11)
|
|
||||||
term.write(" Готово ")
|
|
||||||
end
|
|
||||||
|
|
||||||
--Кнопка рандома своих кораблей
|
|
||||||
function drawButton()
|
|
||||||
g.setBackground(colors.lime)
|
|
||||||
term.setCursor(3, 11)
|
|
||||||
term.write(" Авто ")
|
|
||||||
end
|
|
||||||
|
|
||||||
--Очищаем пустое место
|
|
||||||
function clearShipsField()
|
|
||||||
g.setBackground(colors.lightGray)
|
|
||||||
g.fill(3,3,22,10," ")
|
|
||||||
end
|
|
||||||
|
|
||||||
--Гуишечка
|
|
||||||
drawField()
|
|
||||||
drawShips()
|
|
||||||
drawButton()
|
|
||||||
g.setBackground(colors.lightGray)
|
|
||||||
g.setForeground(colors.black)
|
|
||||||
term.setCursor(3,13)
|
|
||||||
term.write("Установите корабли")
|
|
||||||
|
|
||||||
--Цикл для установки своих корабликов вручную
|
|
||||||
local ship = 0
|
|
||||||
local prevX = 0
|
|
||||||
local shipCoords = {0,0}
|
|
||||||
local setting = true
|
|
||||||
local playing = true
|
|
||||||
local button2 = false
|
|
||||||
while setting do
|
|
||||||
local event, _, x, y = event.pull()
|
|
||||||
if event == "touch" then
|
|
||||||
if x > 2 and x < 13 and y == 11 then
|
|
||||||
setShipsAuto(25)
|
|
||||||
drawField()
|
|
||||||
clearShipsField()
|
|
||||||
drawShips()
|
|
||||||
drawButton()
|
|
||||||
drawButton2()
|
|
||||||
button2 = true
|
|
||||||
elseif button2 and x > 12 and x < 24 and y == 11 then
|
|
||||||
setting = false
|
|
||||||
break
|
|
||||||
elseif x > w-4 and x < w and y == 1 then
|
|
||||||
setting = false
|
|
||||||
playing = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
elseif event == "drag" then
|
|
||||||
if ship == 0 then
|
|
||||||
for i=1,10 do
|
|
||||||
if x > ships[i][1] and x < ships[i][1]+ships[i][3] and y == ships[i][2] then
|
|
||||||
ship = i
|
|
||||||
shipCoords[1] = ships[i][1]
|
|
||||||
shipCoords[2] = ships[i][2]
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
ships[ship][1] = ships[ship][1] + x - prevX
|
|
||||||
ships[ship][2] = y
|
|
||||||
if ships[ship][1] > 2 and ships[ship][1]+ships[ship][3]-1 < 45 and y > 2 and y < 13 then
|
|
||||||
drawField()
|
|
||||||
clearShipsField()
|
|
||||||
drawShips()
|
|
||||||
drawButton()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
prevX = x
|
|
||||||
elseif event == "drop" then
|
|
||||||
if ship > 0 then
|
|
||||||
if ships[ship][1] < 25 or ships[ship][1]+ships[ship][3]-1 > 45 or y < 3 or y > 13then
|
|
||||||
ships[ship][1] = shipCoords[1]
|
|
||||||
ships[ship][2] = shipCoords[2]
|
|
||||||
end
|
|
||||||
for i=1,10 do
|
|
||||||
if i ~= ship and (ships[ship][1] < ships[i][1]+ships[i][3]+1 and ships[ship][1]+ships[ship][3]-1 > ships[i][1]-2 and ships[ship][2] > ships[i][2]-2 and ships[ship][2] < ships[i][2]+2) then
|
|
||||||
ships[ship][1] = shipCoords[1]
|
|
||||||
ships[ship][2] = shipCoords[2]
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ships[ship][1] = makePixelX(ships[ship][1], 25)
|
|
||||||
end
|
|
||||||
ship = 0
|
|
||||||
drawField()
|
|
||||||
clearShipsField()
|
|
||||||
drawShips()
|
|
||||||
drawButton()
|
|
||||||
for i=1,10 do
|
|
||||||
if ships[i][1] < 25 then
|
|
||||||
break
|
|
||||||
elseif i == 10 then
|
|
||||||
setting = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Следующий цикл для игры
|
|
||||||
setShipsAuto(3)
|
|
||||||
drawFieldE()
|
|
||||||
g.setBackground(colors.lightGray)
|
|
||||||
g.setForeground(colors.black)
|
|
||||||
term.setCursor(3,13)
|
|
||||||
term.write("Противник ")
|
|
||||||
term.setCursor(25,13)
|
|
||||||
term.write("Вы")
|
|
||||||
g.setBackground(colors.magenta)
|
|
||||||
g.fill(23, 3, 2, 10, " ")
|
|
||||||
while playing do
|
|
||||||
local event, _, x, y = event.pull()
|
|
||||||
if event == "touch" then
|
|
||||||
if shots < 20 and shotsE2 < 20 and x > 2 and x < 23 and y > 2 and y < 13 then
|
|
||||||
x = makePixelX(x, 3)
|
|
||||||
for i=1,10 do
|
|
||||||
if x > shipsE[i][1]-1 and x < shipsE[i][1]+shipsE[i][3] and y == shipsE[i][2] then
|
|
||||||
shots = shots + 1
|
|
||||||
g.setBackground(colors.red)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
g.setBackground(colors.blue)
|
|
||||||
end
|
|
||||||
g.fill(x, y, 2, 1, " ")
|
|
||||||
local yes = true
|
|
||||||
local xE, yE = 0, 0
|
|
||||||
while yes do
|
|
||||||
xE = makePixelX(math.random(25,44), 3)
|
|
||||||
yE = math.random(3,12)
|
|
||||||
for i=1,#shotsE do
|
|
||||||
if xE == shotsE[i][1] and yE == shotsE[i][2] then
|
|
||||||
break
|
|
||||||
elseif i == #shotsE then
|
|
||||||
yes = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.insert(shotsE, {makePixelX(xE, 3), yE})
|
|
||||||
if args[2] ~= "notime" then
|
|
||||||
g.setBackground(colors.purple)
|
|
||||||
g.fill(23, 3, 2, 10, " ")
|
|
||||||
os.sleep(math.floor(math.random(2))-0.5)
|
|
||||||
g.setBackground(colors.magenta)
|
|
||||||
g.fill(23, 3, 2, 10, " ")
|
|
||||||
end
|
|
||||||
for i=1,10 do
|
|
||||||
if xE > ships[i][1]-1 and xE < ships[i][1]+ships[i][3] and yE == ships[i][2] then
|
|
||||||
shotsE2 = shotsE2 + 1
|
|
||||||
g.setBackground(colors.red)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
g.setBackground(colors.blue)
|
|
||||||
end
|
|
||||||
g.fill(xE, yE, 2, 1, " ")
|
|
||||||
if shots == 20 or shotsE2 == 20 then
|
|
||||||
g.setBackground(colors.lightGray)
|
|
||||||
g.fill(2, 3, 43, 12, " ")
|
|
||||||
g.setBackground(colors.white)
|
|
||||||
g.fill(15, 5, 16, 3, " ")
|
|
||||||
|
|
||||||
if shots == 20 then
|
|
||||||
term.setCursor(20, 6)
|
|
||||||
term.write("Победа")
|
|
||||||
elseif shotsE2 == 20 then
|
|
||||||
term.setCursor(18, 6)
|
|
||||||
term.write("Поражение")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif x > w-4 and x < w and y == 1 then
|
|
||||||
playing = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--При выходе
|
|
||||||
g.setForeground(colors.white)
|
|
||||||
g.setBackground(colors.black)
|
|
||||||
term.clear()
|
|
||||||
g.setResolution(g.maxResolution())
|
|
||||||
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
Program that allows to draw images using Braille chars simple and quickly. At this moment default Photoshop.app doesn't have support of this awesome feature.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Программа, позволяющая быстро и просто рисовать изображения символами шрифта Брайля. На данный момент служит альтернативой системному Photoshop, в котором отсутствует поддержка подобного функционала.
|
|
||||||
Binary file not shown.
@ -1,262 +0,0 @@
|
|||||||
|
|
||||||
require("advancedLua")
|
|
||||||
local fs = require("filesystem")
|
|
||||||
local buffer = require("doubleBuffering")
|
|
||||||
local GUI = require("GUI")
|
|
||||||
local unicode = require("unicode")
|
|
||||||
local image = require("image")
|
|
||||||
local keyboard = require("keyboard")
|
|
||||||
local MineOSInterface = require("MineOSInterface")
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
local newButton = layout:addChild(GUI.button(1, 1, 3, 1, 0x444444, 0xE1E1E1, 0xE1E1E1, 0x444444, "N"))
|
|
||||||
local saveButton = layout:addChild(GUI.button(1, 1, 3, 1, 0x444444, 0xE1E1E1, 0xE1E1E1, 0x444444, "S"))
|
|
||||||
local openButton = layout:addChild(GUI.button(1, 1, 3, 1, 0x444444, 0xE1E1E1, 0xE1E1E1, 0x444444, "O"))
|
|
||||||
local colorSelector1 = layout:addChild(GUI.colorSelector(1, 1, 3, 1, 0xFF4940, "B"))
|
|
||||||
local colorSelector2 = layout:addChild(GUI.colorSelector(1, 1, 3, 1, 0x9924FF, "F"))
|
|
||||||
local keepSwitch = layout:addChild(GUI.switchAndLabel(1, 1, 16, 5, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0x888888, "Replace: ", true)).switch
|
|
||||||
|
|
||||||
local function newCell(x, y, shaded)
|
|
||||||
local object = GUI.object(x, y, 4, 4)
|
|
||||||
object.shaded = shaded
|
|
||||||
object.pixels = {}
|
|
||||||
object.background = 0xFF0000
|
|
||||||
object.foreground = 0x0000FF
|
|
||||||
for y = 1, 4 do
|
|
||||||
object.pixels[y] = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
object.draw = function(object)
|
|
||||||
local step = false
|
|
||||||
for y = 1, 4 do
|
|
||||||
for x = 1, 2 do
|
|
||||||
if object.pixels[y][x] then
|
|
||||||
buffer.drawRectangle(object.x + x * 2 - 2, object.y + y - 1, 2, 1, object.pixels[y][x] == 1 and object.foreground or object.background, 0x0, " ")
|
|
||||||
else
|
|
||||||
buffer.drawRectangle(object.x + x * 2 - 2, object.y + y - 1, 2, 1, 0xFFFFFF, object.shaded and (step and 0xC3C3C3 or 0xB4B4B4) or (step and 0xE1E1E1 or 0xD2D2D2), "▒")
|
|
||||||
end
|
|
||||||
step = not step
|
|
||||||
end
|
|
||||||
step = not step
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
if (object.background ~= colorSelector1.color and keepSwitch.state) or object.background == colorSelector1.color then
|
|
||||||
object.background = colorSelector1.color
|
|
||||||
end
|
|
||||||
|
|
||||||
if (object.foreground ~= colorSelector2.color and keepSwitch.state) or object.foreground == colorSelector2.color then
|
|
||||||
object.foreground = colorSelector2.color
|
|
||||||
end
|
|
||||||
|
|
||||||
-- CTRL or CMD or ALT
|
|
||||||
if keyboard.isKeyDown(29) or keyboard.isKeyDown(219) or keyboard.isKeyDown(56) then
|
|
||||||
object.pixels[y][x] = nil
|
|
||||||
else
|
|
||||||
object.pixels[y][x] = e5 == 0 and 1 or 0
|
|
||||||
end
|
|
||||||
|
|
||||||
application:draw()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return object
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local drawingArea = window:addChild(GUI.container(1, 4, 1, 1))
|
|
||||||
local overrideDraw = drawingArea.draw
|
|
||||||
drawingArea.draw = function(...)
|
|
||||||
GUI.drawShadow(drawingArea.x, drawingArea.y, drawingArea.width, drawingArea.height, GUI.CONTEXT_MENU_SHADOW_TRANSPARENCY, true)
|
|
||||||
overrideDraw(...)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getBrailleChar(a, b, c, d, e, f, g, h)
|
|
||||||
return unicode.char(10240 + 128*h + 64*g + 32*f + 16*d + 8*b + 4*e + 2*c + a)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function newNoGUI(width, height)
|
|
||||||
drawingArea.width, drawingArea.height = width * 4, height * 4
|
|
||||||
|
|
||||||
window.width = math.max(50, drawingArea.width)
|
|
||||||
window.height = drawingArea.height + 4
|
|
||||||
|
|
||||||
drawingArea.localX = math.floor(window.width / 2 - drawingArea.width / 2)
|
|
||||||
|
|
||||||
window.backgroundPanel.width = window.width
|
|
||||||
window.backgroundPanel.height = window.height
|
|
||||||
|
|
||||||
layout.width = window.backgroundPanel.width
|
|
||||||
|
|
||||||
|
|
||||||
drawingArea:removeChildren()
|
|
||||||
|
|
||||||
local x, y, step = 1, 1, false
|
|
||||||
for j = 1, height do
|
|
||||||
for i = 1, width do
|
|
||||||
drawingArea:addChild(newCell(x, y, step))
|
|
||||||
x, step = x + 4, not step
|
|
||||||
end
|
|
||||||
x, y, step = 1, y + 4, not step
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function new()
|
|
||||||
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)
|
|
||||||
return tonumber(text)
|
|
||||||
end
|
|
||||||
|
|
||||||
local heightTextBox = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xEEEEEE, 0x666666, 0x666666, 0xEEEEEE, 0x262626, "4", "Height", true))
|
|
||||||
heightTextBox.validator = function(text)
|
|
||||||
return tonumber(text)
|
|
||||||
end
|
|
||||||
|
|
||||||
container.panel.eventHandler = function(application, object, e1)
|
|
||||||
if e1 == "touch" then
|
|
||||||
container:remove()
|
|
||||||
|
|
||||||
newNoGUI(tonumber(widthTextBox.text), tonumber(heightTextBox.text))
|
|
||||||
|
|
||||||
application:draw()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
application:draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function fillBrailleArray(source, inverted)
|
|
||||||
local brailleArray, transparencyCyka, backgroundCyka, foregroundCyka = {}
|
|
||||||
|
|
||||||
for j = 1, 4 do
|
|
||||||
for i = 1, 2 do
|
|
||||||
if not source[j][i] then
|
|
||||||
transparencyCyka = true
|
|
||||||
table.insert(brailleArray, 0)
|
|
||||||
elseif source[j][i] == 1 then
|
|
||||||
foregroundCyka = true
|
|
||||||
table.insert(brailleArray, inverted and 0 or 1)
|
|
||||||
else
|
|
||||||
backgroundCyka = true
|
|
||||||
table.insert(brailleArray, inverted and 1 or 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return brailleArray, transparencyCyka, backgroundCyka, foregroundCyka
|
|
||||||
end
|
|
||||||
|
|
||||||
newButton.onTouch = function()
|
|
||||||
new()
|
|
||||||
end
|
|
||||||
|
|
||||||
saveButton.onTouch = function()
|
|
||||||
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")
|
|
||||||
filesystemDialog:addExtensionFilter(".braiile")
|
|
||||||
|
|
||||||
filesystemDialog.onSubmit = function(path)
|
|
||||||
if fs.extension(path) == ".pic" then
|
|
||||||
local picture = {drawingArea.width / 4, drawingArea.height / 4, {}, {}, {}, {}}
|
|
||||||
|
|
||||||
local x, y = 1, 1
|
|
||||||
for childIndex = 1, #drawingArea.children do
|
|
||||||
local background, foreground = drawingArea.children[childIndex].background, drawingArea.children[childIndex].foreground
|
|
||||||
|
|
||||||
local brailleArray, transparencyCyka, backgroundCyka, foregroundCyka = fillBrailleArray(drawingArea.children[childIndex].pixels)
|
|
||||||
if transparencyCyka then
|
|
||||||
if backgroundCyka and foregroundCyka then
|
|
||||||
GUI.alert("Пиксель " .. x .. "x" .. y .. " имеет два цвета и прозрачность. Убирай любой из цветов и наслаждайся")
|
|
||||||
return
|
|
||||||
else
|
|
||||||
background = 0x0
|
|
||||||
if backgroundCyka then
|
|
||||||
foreground = drawingArea.children[childIndex].background
|
|
||||||
brailleArray = fillBrailleArray(drawingArea.children[childIndex].pixels, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
image.set(
|
|
||||||
picture, x, y, background, foreground,
|
|
||||||
transparencyCyka and 1 or 0,
|
|
||||||
string.brailleChar(table.unpack(brailleArray))
|
|
||||||
)
|
|
||||||
|
|
||||||
x = x + 1
|
|
||||||
if x > picture[1] then
|
|
||||||
x, y = 1, y + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
image.save(path, picture)
|
|
||||||
else
|
|
||||||
local pizda = {
|
|
||||||
width = drawingArea.width / 4,
|
|
||||||
height = drawingArea.height / 4,
|
|
||||||
}
|
|
||||||
|
|
||||||
for i = 1, #drawingArea.children do
|
|
||||||
table.insert(pizda, {
|
|
||||||
background = drawingArea.children[i].background,
|
|
||||||
foreground = drawingArea.children[i].foreground,
|
|
||||||
pixels = drawingArea.children[i].pixels,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
table.toFile(path, pizda, true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
filesystemDialog:show()
|
|
||||||
end
|
|
||||||
|
|
||||||
openButton.onTouch = function()
|
|
||||||
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")
|
|
||||||
|
|
||||||
filesystemDialog.onSubmit = function(path)
|
|
||||||
local pizda = table.fromFile(path)
|
|
||||||
drawingArea:removeChildren()
|
|
||||||
|
|
||||||
newNoGUI(pizda.width, pizda.height)
|
|
||||||
|
|
||||||
for i = 1, #drawingArea.children do
|
|
||||||
drawingArea.children[i].background = pizda[i].background
|
|
||||||
drawingArea.children[i].foreground = pizda[i].foreground
|
|
||||||
drawingArea.children[i].pixels = pizda[i].pixels
|
|
||||||
end
|
|
||||||
|
|
||||||
application:draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
filesystemDialog:show()
|
|
||||||
end
|
|
||||||
|
|
||||||
window.actionButtons.minimize:remove()
|
|
||||||
window.actionButtons.maximize:remove()
|
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
newNoGUI(8, 4)
|
|
||||||
application:draw()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Программа-демонстратор возможностей нашей библиотеки двойной буферизации изображения. Вся ОС работает именно на этой библиотеке.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Программа-демонстратор возможностей нашей библиотеки двойной буферизации изображения. Вся ОС работает именно на этой библиотеке.
|
|
||||||
@ -1,160 +0,0 @@
|
|||||||
|
|
||||||
local buffer = require("doubleBuffering")
|
|
||||||
local event = require("event")
|
|
||||||
local image = require("image")
|
|
||||||
|
|
||||||
local currentBackground = 0x990000
|
|
||||||
local risovatKartinku = true
|
|
||||||
local showPanel = true
|
|
||||||
local transparency = 0.25
|
|
||||||
local xWindow, yWindow = 5, 5
|
|
||||||
|
|
||||||
local fon = image.load("MineOS/Applications/BufferDemo.app/Resources/Wallpaper.pic")
|
|
||||||
|
|
||||||
buffer.flush()
|
|
||||||
local bufferWidth, bufferHeight = buffer.getResolution()
|
|
||||||
|
|
||||||
local function drawBackground()
|
|
||||||
--Заполним весь наш экран цветом фона 0x262626, цветом текста 0xFFFFFF и символом " "
|
|
||||||
if not risovatKartinku then
|
|
||||||
buffer.square(1, 1, bufferWidth, bufferHeight, currentBackground, 0xFFFFFF, " ")
|
|
||||||
else
|
|
||||||
buffer.image(1, 1, fon)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Создаем переменные с координатами начала и размерами нашего окна
|
|
||||||
local width, height = 82, 25
|
|
||||||
|
|
||||||
-- local cykaPicture = image.load("System/OS/Icons/Steve.pic")
|
|
||||||
-- local cykaPicture2 = image.load("System/OS/Icons/Love.pic")
|
|
||||||
|
|
||||||
local function drawWindow(x, y)
|
|
||||||
|
|
||||||
--Тени
|
|
||||||
local shadowTransparency = 0.6
|
|
||||||
buffer.square(x + width, y + 1, 2, height, 0x000000, 0xFFFFFF, " ", shadowTransparency)
|
|
||||||
buffer.square(x + 2, y + height, width - 2, 1, 0x000000, 0xFFFFFF, " ", shadowTransparency)
|
|
||||||
|
|
||||||
--Создаем прозрачную часть окна, где отображается "Избранное"
|
|
||||||
buffer.square(x, y, 20, height, 0xFFFFFF, 0xFFFFFF, " ", transparency)
|
|
||||||
|
|
||||||
--Создаем непрозрачную часть окна для отображения всяких файлов и т.п.
|
|
||||||
buffer.square(x + 20, y, width - 20, height, 0xFFFFFF, 0xFFFFFF, " ")
|
|
||||||
|
|
||||||
--Создаем три более темных полоски вверху окна, имитируя объем
|
|
||||||
buffer.square(x, y, width, 1, 0xDDDDDD, 0xFFFFFF, " ")
|
|
||||||
buffer.square(x, y + 1, width, 1, 0xCCCCCC, 0xFFFFFF, " ")
|
|
||||||
buffer.square(x, y + 2, width, 1, 0xBBBBBB, 0xFFFFFF, " ")
|
|
||||||
|
|
||||||
--Рисуем заголовок нашего окошка
|
|
||||||
buffer.text(x + 30, y, 0x000000, "Тестовое окно")
|
|
||||||
|
|
||||||
--Создаем три кнопки в левом верхнем углу для закрытия, разворачивания и сворачивания окна
|
|
||||||
buffer.set(x + 1, y, 0xDDDDDD, 0xFF4940, "⬤")
|
|
||||||
buffer.set(x + 3, y, 0xDDDDDD, 0xFFB640, "⬤")
|
|
||||||
buffer.set(x + 5, y, 0xDDDDDD, 0x00B640, "⬤")
|
|
||||||
|
|
||||||
--Рисуем элементы "Избранного" чисто для демонстрации
|
|
||||||
buffer.text(x + 1, y + 3, 0x000000, "Избранное")
|
|
||||||
for i = 1, 6 do buffer.text(x + 2, y + 3 + i, 0x555555, "Вариант " .. i) end
|
|
||||||
|
|
||||||
--Рисуем "Файлы" в виде желтых квадратиков. Нам без разницы, а выглядит красиво
|
|
||||||
for j = 1, 3 do
|
|
||||||
for i = 1, 5 do
|
|
||||||
local xPos, yPos = x + 22 + i*12 - 12, y + 4 + j*7 - 7
|
|
||||||
buffer.square(xPos, yPos, 8, 4, 0xFFFF80, 0xFFFFFF, " ")
|
|
||||||
buffer.text(xPos, yPos + 5, 0x262626, "Файл " .. i .. "x" .. j)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Ну, и наконец рисуем голубой скроллбар справа
|
|
||||||
buffer.square(x + width - 1, y + 3, 1, height - 3, 0xBBBBBB, 0xFFFFFF, " ")
|
|
||||||
buffer.square(x + width - 1, y + 3, 1, 4, 0x3366CC, 0xFFFFFF, " ")
|
|
||||||
|
|
||||||
--Изображения!
|
|
||||||
-- buffer.image(x + 23, y + 6, cykaPicture)
|
|
||||||
-- buffer.image(x + 33, y + 12, cykaPicture2)
|
|
||||||
|
|
||||||
if showPanel then
|
|
||||||
xPos, yPos = x, y + height + 2
|
|
||||||
buffer.square(xPos, yPos, width, 10, 0xFFFFFF, 0xFFFFFF, " ", transparency)
|
|
||||||
|
|
||||||
--Тень
|
|
||||||
buffer.square(xPos + width, yPos + 1, 2, 10, 0x000000, 0xFFFFFF, " ", shadowTransparency)
|
|
||||||
buffer.square(xPos + 2, yPos + 10, width - 2, 1, 0x000000, 0xFFFFFF, " ", shadowTransparency)
|
|
||||||
|
|
||||||
yPos = yPos + 1
|
|
||||||
xPos = xPos + 2
|
|
||||||
buffer.text(xPos + 2, yPos, 0x262626, "Клик левой кнопкой мыши: изменить позицию окошка"); yPos = yPos + 1
|
|
||||||
buffer.text(xPos + 2, yPos, 0x262626, "Клик правой кнопкой: нарисовать еще одно такое же окошко"); yPos = yPos + 1
|
|
||||||
buffer.text(xPos + 2, yPos, 0x262626, "Колесо мыши: изменить прозрачность окна"); yPos = yPos + 2
|
|
||||||
buffer.text(xPos + 2, yPos, 0x262626, "Space: переключить фон между картинкой и статичным цветом"); yPos = yPos + 1
|
|
||||||
buffer.text(xPos + 2, yPos, 0x262626, "Shift: изменить цвет фона на рандомный"); yPos = yPos + 1
|
|
||||||
buffer.text(xPos + 2, yPos, 0x262626, "Tab: включить или отключить данную информационную панель"); yPos = yPos + 1
|
|
||||||
buffer.text(xPos + 2, yPos, 0x262626, "Enter: выйти отсудова на хер"); yPos = yPos + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
drawBackground()
|
|
||||||
drawWindow(xWindow, yWindow)
|
|
||||||
buffer.draw()
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull()}
|
|
||||||
if e[1] == "touch" then
|
|
||||||
if e[5] == 0 then
|
|
||||||
drawBackground()
|
|
||||||
xWindow, yWindow = e[3], e[4]
|
|
||||||
drawWindow(xWindow, yWindow)
|
|
||||||
buffer.draw()
|
|
||||||
else
|
|
||||||
xWindow, yWindow = e[3], e[4]
|
|
||||||
drawWindow(xWindow, yWindow)
|
|
||||||
buffer.draw()
|
|
||||||
end
|
|
||||||
elseif e[1] == "key_down" then
|
|
||||||
if e[4] == 42 then
|
|
||||||
currentBackground = math.random(0x000000, 0xFFFFFF)
|
|
||||||
drawBackground()
|
|
||||||
drawWindow(xWindow, yWindow)
|
|
||||||
buffer.draw()
|
|
||||||
elseif e[4] == 28 then
|
|
||||||
buffer.square(1, 1, bufferWidth, bufferHeight, 0x262626, 0xFFFFFF, " ")
|
|
||||||
buffer.draw()
|
|
||||||
return
|
|
||||||
elseif e[4] == 57 then
|
|
||||||
risovatKartinku = not risovatKartinku
|
|
||||||
drawBackground()
|
|
||||||
drawWindow(xWindow, yWindow)
|
|
||||||
buffer.draw()
|
|
||||||
elseif e[4] == 15 then
|
|
||||||
showPanel = not showPanel
|
|
||||||
drawBackground()
|
|
||||||
drawWindow(xWindow, yWindow)
|
|
||||||
buffer.draw()
|
|
||||||
end
|
|
||||||
elseif e[1] == "scroll" then
|
|
||||||
if e[5] == 1 then
|
|
||||||
if transparency > 0.05 then
|
|
||||||
transparency = transparency - 0.05
|
|
||||||
drawBackground()
|
|
||||||
drawWindow(xWindow, yWindow)
|
|
||||||
buffer.draw()
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if transparency < 1 then
|
|
||||||
transparency = transparency + 0.05
|
|
||||||
drawBackground()
|
|
||||||
drawWindow(xWindow, yWindow)
|
|
||||||
buffer.draw()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
@ -1,61 +0,0 @@
|
|||||||
local c = require("component")
|
|
||||||
local gpu = c.gpu
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local colors = {
|
|
||||||
usualButton = 0xeeeeee,
|
|
||||||
actionButton = 0xF69332,
|
|
||||||
usualButtonText = 0x262626,
|
|
||||||
actionButtonText = 0xffffff,
|
|
||||||
equal = 0x363636,
|
|
||||||
equalText = 0xffffff,
|
|
||||||
}
|
|
||||||
|
|
||||||
local buttons = {
|
|
||||||
{{"C", colors.usualButton, colors.usualButtonText}, {"sin", colors.usualButton, colors.usualButtonText}, {"cos", colors.usualButton, colors.usualButtonText}, {"/", colors.actionButton, colors.actionButtonText}},
|
|
||||||
{{"7", colors.usualButton, colors.usualButtonText}, {"8", colors.usualButton, colors.usualButtonText}, {"9", colors.usualButton, colors.usualButtonText}, {"*", colors.actionButton, colors.actionButtonText}},
|
|
||||||
{{"4", colors.usualButton, colors.usualButtonText}, {"5", colors.usualButton, colors.usualButtonText}, {"6", colors.usualButton, colors.usualButtonText}, {"-", colors.actionButton, colors.actionButtonText}},
|
|
||||||
{{"1", colors.usualButton, colors.usualButtonText}, {"2", colors.usualButton, colors.usualButtonText}, {"3", colors.usualButton, colors.usualButtonText}, {"+", colors.actionButton, colors.actionButtonText}},
|
|
||||||
{{"0", colors.usualButton, colors.usualButtonText}, {".", colors.usualButton, colors.usualButtonText}, {"rnd", colors.usualButton, colors.usualButtonText}, {"=", colors.actionButton, colors.actionButtonText}},
|
|
||||||
}
|
|
||||||
|
|
||||||
local buttonWidth, buttonHeight, equalHeight = 7, 3, 3
|
|
||||||
local calcWidth = #buttons[1] * buttonWidth
|
|
||||||
local calcHeight = #buttons * buttonHeight + equalHeight
|
|
||||||
|
|
||||||
local equal, number1, number2 = 0, 0, 0
|
|
||||||
|
|
||||||
local function drawButtons(x, y)
|
|
||||||
local yPos, xPos = y, x
|
|
||||||
for i = 1, #buttons do
|
|
||||||
xPos = x
|
|
||||||
for j = 1, #buttons[i] do
|
|
||||||
ecs.drawButton(xPos, yPos, buttonWidth, buttonHeight, buttons[i][j][1], buttons[i][j][2], buttons[i][j][3])
|
|
||||||
xPos = xPos + buttonWidth
|
|
||||||
end
|
|
||||||
yPos = yPos + buttonHeight
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawEqual(x, y)
|
|
||||||
ecs.square(x, y, calcWidth, equalHeight, colors.equal)
|
|
||||||
ecs.colorText(x + 1, y, ecs.colors.red, "⬤")
|
|
||||||
ecs.colorText(x + 3, y, ecs.colors.orange, "⬤")
|
|
||||||
ecs.colorText(x + 5, y, ecs.colors.green, "⬤")
|
|
||||||
--
|
|
||||||
local limit = calcWidth - 4
|
|
||||||
local strEqual = ecs.stringLimit("start", tostring(equal), limit)
|
|
||||||
local sEqual = #strEqual
|
|
||||||
local xPos, yPos = x + calcWidth - sEqual - 3, y + 1
|
|
||||||
ecs.colorText(xPos, yPos, colors.equalText, strEqual)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawCalc(x, y)
|
|
||||||
drawEqual(x, y)
|
|
||||||
drawButtons(x, y + equalHeight)
|
|
||||||
end
|
|
||||||
|
|
||||||
--ecs.prepareToExit()
|
|
||||||
drawCalc(2, 2)
|
|
||||||
ecs.waitForTouchOrClick()
|
|
||||||
Binary file not shown.
@ -1,13 +1,9 @@
|
|||||||
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local bit32 = require("bit32")
|
local system = require("System")
|
||||||
local MineOSCore = require("MineOSCore")
|
local color = require("Color")
|
||||||
local fs = require("filesystem")
|
local screen = require("Screen")
|
||||||
local unicode = require("unicode")
|
local paths = require("Paths")
|
||||||
local color = require("color")
|
|
||||||
local buffer = require("doubleBuffering")
|
|
||||||
local MineOSPaths = require("MineOSPaths")
|
|
||||||
local MineOSInterface = require("MineOSInterface")
|
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
@ -29,7 +25,7 @@ local digitDecimalButtons = {}
|
|||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
|
|
||||||
local application, window, menu = MineOSInterface.addWindow(GUI.window(1, 1, buttonWidth * 12, buttonHeight * 5 + displayHeight + binaryHeight))
|
local workspace, window, menu = system.addWindow(GUI.window(1, 1, buttonWidth * 12, buttonHeight * 5 + displayHeight + binaryHeight))
|
||||||
|
|
||||||
local displayContainer = window:addChild(GUI.container(1, 1, window.width, displayHeight + binaryHeight))
|
local displayContainer = window:addChild(GUI.container(1, 1, window.width, displayHeight + binaryHeight))
|
||||||
|
|
||||||
@ -38,7 +34,7 @@ local displayPanel = displayContainer:addChild(GUI.panel(1, 1, window.width, dis
|
|||||||
local actionButtons = window:addChild(GUI.actionButtons(3, 3, true))
|
local actionButtons = window:addChild(GUI.actionButtons(3, 3, true))
|
||||||
|
|
||||||
actionButtons.close.onTouch = function()
|
actionButtons.close.onTouch = function()
|
||||||
window:close()
|
window:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
actionButtons.minimize.onTouch = function()
|
actionButtons.minimize.onTouch = function()
|
||||||
@ -122,27 +118,27 @@ displayWidget.draw = function()
|
|||||||
|
|
||||||
-- Result
|
-- Result
|
||||||
x = x - #result
|
x = x - #result
|
||||||
buffer.drawText(x, y, 0xFFFFFF, result)
|
screen.drawText(x, y, 0xFFFFFF, result)
|
||||||
|
|
||||||
-- Digit mode
|
-- Digit mode
|
||||||
if modeList.selectedItem == 2 and integerLength then
|
if modeList.selectedItem == 2 and integerLength then
|
||||||
if floatingList.selectedItem == 1 then
|
if floatingList.selectedItem == 1 then
|
||||||
buffer.drawText(x, y + 1, 0x696969, string.rep("─", integerLength))
|
screen.drawText(x, y + 1, 0x696969, string.rep("─", integerLength))
|
||||||
else
|
else
|
||||||
buffer.drawText(x + integerLength + 1, y + 1, 0x696969, string.rep("─", #result - integerLength - 1))
|
screen.drawText(x + integerLength + 1, y + 1, 0x696969, string.rep("─", #result - integerLength - 1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Action and old value
|
-- Action and old value
|
||||||
if oldValue then
|
if oldValue then
|
||||||
local oldValueText = format(oldValue) .. " " .. action.button.text .. " "
|
local oldValueText = format(oldValue) .. " " .. action.button.text .. " "
|
||||||
buffer.drawText(x - #oldValueText, y, 0xA5A5A5, oldValueText)
|
screen.drawText(x - #oldValueText, y, 0xA5A5A5, oldValueText)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Char
|
-- Char
|
||||||
buffer.drawText(displayWidget.x, y, 0x696969, "\"")
|
screen.drawText(displayWidget.x, y, 0x696969, "\"")
|
||||||
buffer.drawText(displayWidget.x + 1, y, 0xFFFFFF, charList.selectedItem == 1 and unicode.char(absValue) or (absValue < 256 and string.char(absValue) or "?"))
|
screen.drawText(displayWidget.x + 1, y, 0xFFFFFF, charList.selectedItem == 1 and unicode.char(absValue) or (absValue < 256 and string.char(absValue) or "?"))
|
||||||
buffer.drawText(displayWidget.x + 2, y, 0x696969, "\"")
|
screen.drawText(displayWidget.x + 2, y, 0x696969, "\"")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setValueRaw(v)
|
local function setValueRaw(v)
|
||||||
@ -182,7 +178,7 @@ modeList:addItem("8").onTouch = function()
|
|||||||
floatingList.selectedItem = 1
|
floatingList.selectedItem = 1
|
||||||
setValue(math.floor(value))
|
setValue(math.floor(value))
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
modeList:addItem("10").onTouch = function()
|
modeList:addItem("10").onTouch = function()
|
||||||
@ -190,7 +186,7 @@ modeList:addItem("10").onTouch = function()
|
|||||||
setButtonsDisabled(digitDecimalButtons, false)
|
setButtonsDisabled(digitDecimalButtons, false)
|
||||||
setButtonsDisabled(digitHexadecimalButtons, true)
|
setButtonsDisabled(digitHexadecimalButtons, true)
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
modeList:addItem("16").onTouch = function()
|
modeList:addItem("16").onTouch = function()
|
||||||
@ -201,7 +197,7 @@ modeList:addItem("16").onTouch = function()
|
|||||||
floatingList.selectedItem = 1
|
floatingList.selectedItem = 1
|
||||||
setValue(math.floor(value))
|
setValue(math.floor(value))
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function binaryToNumber()
|
local function binaryToNumber()
|
||||||
@ -1 +0,0 @@
|
|||||||
Calendar - a simple program that needs no special introduction. The beautiful interface makes it easy to find out the day of the week a particular date every year.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Calendar - простая программа, не нуждающаяся в особом представлении. Красивый интерфейс позволяет легко узнать день недели конкретной даты любого года.
|
|
||||||
Binary file not shown.
@ -1,379 +0,0 @@
|
|||||||
local ecs = require("ECSAPI")
|
|
||||||
local fs = require("filesystem")
|
|
||||||
local event = require("event")
|
|
||||||
local component = require("component")
|
|
||||||
local gpu = component.gpu
|
|
||||||
|
|
||||||
--Список месяцев
|
|
||||||
local months = {
|
|
||||||
"Январь",
|
|
||||||
"Февраль",
|
|
||||||
"Март",
|
|
||||||
"Апрель",
|
|
||||||
"Май",
|
|
||||||
"Июнь",
|
|
||||||
"Июль",
|
|
||||||
"Август",
|
|
||||||
"Сентябрь",
|
|
||||||
"Октябрь",
|
|
||||||
"Ноябрь",
|
|
||||||
"Декабрь",
|
|
||||||
}
|
|
||||||
|
|
||||||
--Количество дней в месяцах
|
|
||||||
local countOfDays = {
|
|
||||||
31,
|
|
||||||
28,
|
|
||||||
31,
|
|
||||||
30,
|
|
||||||
31,
|
|
||||||
30,
|
|
||||||
31,
|
|
||||||
31,
|
|
||||||
30,
|
|
||||||
31,
|
|
||||||
30,
|
|
||||||
31,
|
|
||||||
}
|
|
||||||
|
|
||||||
--Сдвиг дня недели по дате в каждом месяце
|
|
||||||
local monthDateMove = {
|
|
||||||
3,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
3,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
}
|
|
||||||
|
|
||||||
--Графика
|
|
||||||
local numbers = {
|
|
||||||
["1"] = {
|
|
||||||
{0, 1, 0},
|
|
||||||
{0, 1, 0},
|
|
||||||
{0, 1, 0},
|
|
||||||
{0, 1, 0},
|
|
||||||
{0, 1, 0},
|
|
||||||
},
|
|
||||||
["2"] = {
|
|
||||||
{1, 1, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
{1, 0, 0},
|
|
||||||
{1, 1, 1},
|
|
||||||
},
|
|
||||||
["3"] = {
|
|
||||||
{1, 1, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
},
|
|
||||||
["4"] = {
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
},
|
|
||||||
["5"] = {
|
|
||||||
{1, 1, 1},
|
|
||||||
{1, 0, 0},
|
|
||||||
{1, 1, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
},
|
|
||||||
["6"] = {
|
|
||||||
{1, 1, 1},
|
|
||||||
{1, 0, 0},
|
|
||||||
{1, 1, 1},
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
},
|
|
||||||
["7"] = {
|
|
||||||
{1, 1, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
},
|
|
||||||
["8"] = {
|
|
||||||
{1, 1, 1},
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
},
|
|
||||||
["9"] = {
|
|
||||||
{1, 1, 1},
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
{0, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
},
|
|
||||||
["0"] = {
|
|
||||||
{1, 1, 1},
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 0, 1},
|
|
||||||
{1, 1, 1},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
--Всякие переменные
|
|
||||||
local constants = {
|
|
||||||
xSpaceBetweenNumbers = 2,
|
|
||||||
ySpaceBetweenNumbers = 1,
|
|
||||||
xSpaceBetweenMonths = 4,
|
|
||||||
ySpaceBetweenMonths = 1,
|
|
||||||
currentYear = 2015,
|
|
||||||
currentMonth = 9,
|
|
||||||
currentDay = 26,
|
|
||||||
programYear = 2015,
|
|
||||||
programMonth = 1,
|
|
||||||
proramDay = 1,
|
|
||||||
usualDayColor = 0x262626,
|
|
||||||
weekendColor = 0x880000,
|
|
||||||
backgroundColor = 0xEEEEEE,
|
|
||||||
dayNamesColor = 0x888888,
|
|
||||||
monthsColor = 0xCC0000,
|
|
||||||
currentDayColor = 0xFFFFFF,
|
|
||||||
bigNumberColor = 0x262626,
|
|
||||||
}
|
|
||||||
|
|
||||||
local xMax, yMax = gpu.maxResolution()
|
|
||||||
|
|
||||||
--Объекты для тача
|
|
||||||
local obj = {}
|
|
||||||
local function newObj(class, name, ...)
|
|
||||||
obj[class] = obj[class] or {}
|
|
||||||
obj[class][name] = {...}
|
|
||||||
end
|
|
||||||
|
|
||||||
--Проверка года на "високосность"
|
|
||||||
local function visokosniy(year)
|
|
||||||
if year % 4 == 0 or year % 400 == 0 then return true else return false end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Отрисовать месяц
|
|
||||||
local function drawMonth(x, y, firstDay, countOfDays, year, month)
|
|
||||||
|
|
||||||
local xPos, yPos = x, y + 4
|
|
||||||
local counter = 1
|
|
||||||
local startDrawing = false
|
|
||||||
local separator = string.rep(" ", constants.xSpaceBetweenNumbers)
|
|
||||||
ecs.colorText(x, y, constants.monthsColor, months[month])
|
|
||||||
ecs.colorText(x, y + 2, constants.dayNamesColor,"Пн"..separator.."Вт"..separator.."Ср"..separator.."Чт"..separator.."Пт"..separator.."Сб"..separator.."Вс")
|
|
||||||
for j = 1, 6 do
|
|
||||||
xPos = x
|
|
||||||
for i = 1, 7 do
|
|
||||||
if i < 6 then gpu.setForeground(constants.usualDayColor) else gpu.setForeground(constants.weekendColor) end
|
|
||||||
if counter == constants.currentDay and year == constants.currentYear and month == constants.currentMonth then ecs.square(xPos-1, yPos, 4, 1, constants.weekendColor); gpu.setForeground(constants.currentDayColor) else gpu.setBackground(constants.backgroundColor) end
|
|
||||||
if counter > countOfDays then break end
|
|
||||||
if i >= firstDay then startDrawing = true end
|
|
||||||
if startDrawing then gpu.set(xPos, yPos, tostring(counter)); counter = counter + 1 end
|
|
||||||
xPos = xPos + constants.xSpaceBetweenNumbers + 2
|
|
||||||
end
|
|
||||||
yPos = yPos + constants.ySpaceBetweenNumbers + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Получить номер следующего дня
|
|
||||||
local function getNextDay(day)
|
|
||||||
if day < 7 then
|
|
||||||
return (day + 1)
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Просчитать данные о годе
|
|
||||||
local function calculateYear(year, dayOf1Jan)
|
|
||||||
local massivGoda = {}
|
|
||||||
local visokosniy = visokosniy(year)
|
|
||||||
|
|
||||||
local firstDayPosition = dayOf1Jan
|
|
||||||
|
|
||||||
--Получаем количество дней в каждом месяце
|
|
||||||
for month = 1, 12 do
|
|
||||||
--Создаем подмассив месяца в массиве года
|
|
||||||
massivGoda[month] = {}
|
|
||||||
--Если это февраль
|
|
||||||
if month == 2 then
|
|
||||||
--Если год високосный
|
|
||||||
if visokosniy then
|
|
||||||
massivGoda[month].countOfDays = 29
|
|
||||||
massivGoda[month].firstDayPosition = firstDayPosition
|
|
||||||
firstDayPosition = getNextDay(firstDayPosition)
|
|
||||||
--Если не високосный
|
|
||||||
else
|
|
||||||
massivGoda[month].countOfDays = 28
|
|
||||||
massivGoda[month].firstDayPosition = firstDayPosition
|
|
||||||
end
|
|
||||||
--Если не февраль
|
|
||||||
else
|
|
||||||
massivGoda[month].countOfDays = countOfDays[month]
|
|
||||||
massivGoda[month].firstDayPosition = firstDayPosition
|
|
||||||
for i = 1, monthDateMove[month] do
|
|
||||||
firstDayPosition = getNextDay(firstDayPosition)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return massivGoda
|
|
||||||
end
|
|
||||||
|
|
||||||
--Получить день недели первого января указанного года
|
|
||||||
local function polu4itDenNedeliPervogoJanvarja(year, debug)
|
|
||||||
local den = 0
|
|
||||||
|
|
||||||
local difference = math.abs(year - 1010)
|
|
||||||
local koli4estvoVisokosnih
|
|
||||||
|
|
||||||
if difference % 4 == 0 then
|
|
||||||
koli4estvoVisokosnih = difference / 4
|
|
||||||
elseif difference % 4 == 1 then
|
|
||||||
koli4estvoVisokosnih = math.floor(difference / 4)
|
|
||||||
elseif difference % 4 == 2 then
|
|
||||||
koli4estvoVisokosnih = math.floor(difference / 4)
|
|
||||||
elseif difference % 4 == 3 then
|
|
||||||
koli4estvoVisokosnih = math.floor(difference / 4) + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local sdvig = difference + koli4estvoVisokosnih
|
|
||||||
|
|
||||||
if sdvig % 7 == 0 then
|
|
||||||
den = 1
|
|
||||||
else
|
|
||||||
den = sdvig % 7 + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if debug then
|
|
||||||
print("Год: "..year)
|
|
||||||
print("Разница в годах: "..difference)
|
|
||||||
print("Кол-во високосных: "..koli4estvoVisokosnih)
|
|
||||||
print("Сдвиг по дням: "..sdvig)
|
|
||||||
print("День недели: "..den)
|
|
||||||
print(" ")
|
|
||||||
end
|
|
||||||
|
|
||||||
return den
|
|
||||||
end
|
|
||||||
|
|
||||||
--Нарисовать календарь
|
|
||||||
local function drawCalendar(xPos, yPos, year)
|
|
||||||
ecs.square(xPos, yPos, 120, 48, constants.backgroundColor)
|
|
||||||
--Получаем позицию первого января указанного года
|
|
||||||
local janFirst = polu4itDenNedeliPervogoJanvarja(year)
|
|
||||||
--Получаем массив года
|
|
||||||
local massivGoda = calculateYear(year, janFirst)
|
|
||||||
|
|
||||||
--Перебираем массив года
|
|
||||||
for i = 1, #massivGoda do
|
|
||||||
--Рисуем месяц
|
|
||||||
drawMonth(xPos, yPos, massivGoda[i].firstDayPosition, massivGoda[i].countOfDays, year, i)
|
|
||||||
--Корректируем коорды
|
|
||||||
xPos = xPos + constants.xSpaceBetweenMonths + 27
|
|
||||||
if i % 4 == 0 then xPos = 3; yPos = yPos + constants.ySpaceBetweenMonths + 15 end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawSymbol(x, y, symbol)
|
|
||||||
local xPos, yPos = x, y
|
|
||||||
for j = 1, #numbers[symbol] do
|
|
||||||
xPos = x
|
|
||||||
for i = 1, #numbers[symbol][j] do
|
|
||||||
if numbers[symbol][j][i] ~= 0 then
|
|
||||||
gpu.set(xPos, yPos, " ")
|
|
||||||
end
|
|
||||||
xPos = xPos + 2
|
|
||||||
end
|
|
||||||
yPos = yPos + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawYear(x, y, year)
|
|
||||||
year = tostring(year)
|
|
||||||
for i = 1, #year do
|
|
||||||
drawSymbol(x, y, string.sub(year, i, i))
|
|
||||||
x = x + 8
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local next, prev
|
|
||||||
|
|
||||||
local function drawInfo()
|
|
||||||
local xPos, yPos = 127, 4
|
|
||||||
ecs.square(xPos, yPos, 30, 5, constants.backgroundColor)
|
|
||||||
gpu.setBackground(constants.bigNumberColor)
|
|
||||||
drawYear(xPos, yPos, constants.programYear)
|
|
||||||
yPos = yPos + 6
|
|
||||||
|
|
||||||
local name = "Следующий год"; newObj("Buttons", name, ecs.drawButton(xPos, yPos, 30, 3, name, 0xDDDDDD, 0x262626)); yPos = yPos + 4
|
|
||||||
name = "Предыдущий год"; newObj("Buttons", name, ecs.drawButton(xPos, yPos, 30, 3, name, 0xDDDDDD, 0x262626)); yPos = yPos + 4
|
|
||||||
name = "Выйти"; newObj("Buttons", name, ecs.drawButton(xPos, yPos, 30, 3, name, 0xDDDDDD, 0x262626)); yPos = yPos + 4
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawAll()
|
|
||||||
--Очищаем экран
|
|
||||||
ecs.square(1, 1, xMax, yMax, constants.backgroundColor)
|
|
||||||
--Рисуем календарик
|
|
||||||
drawCalendar(3, 2, constants.programYear)
|
|
||||||
--Рисуем парашу
|
|
||||||
drawInfo()
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if xMax < 150 then error("This program requires Tier 3 GPU and Tier 3 Screen.") end
|
|
||||||
--Запоминаем старое разрешение экрана
|
|
||||||
local xOld, yOld = gpu.getResolution()
|
|
||||||
--Ставим максимальное
|
|
||||||
gpu.setResolution(xMax, yMax)
|
|
||||||
--Получаем данные о текущей дате (os.date выдает неверную дату и месяц, забавно)
|
|
||||||
constants.currentDay, constants.currentMonth, constants.currentYear = ecs.getHostTime(2)
|
|
||||||
constants.programDay, constants.programMonth, constants.programYear = constants.currentDay, constants.currentMonth, constants.currentYear
|
|
||||||
--Рисуем все
|
|
||||||
drawAll()
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull()}
|
|
||||||
if e[1] == "touch" then
|
|
||||||
for key in pairs(obj["Buttons"]) do
|
|
||||||
if ecs.clickedAtArea(e[3], e[4], obj["Buttons"][key][1], obj["Buttons"][key][2], obj["Buttons"][key][3], obj["Buttons"][key][4]) then
|
|
||||||
ecs.drawButton(obj["Buttons"][key][1], obj["Buttons"][key][2], 30, 3, key, constants.weekendColor, constants.currentDayColor)
|
|
||||||
os.sleep(0.2)
|
|
||||||
|
|
||||||
if key == "Следующий год" then
|
|
||||||
constants.programYear = constants.programYear + 1
|
|
||||||
elseif key == "Предыдущий год" then
|
|
||||||
constants.programYear = constants.programYear - 1
|
|
||||||
elseif key == "Выйти" then
|
|
||||||
gpu.setResolution(xOld, yOld)
|
|
||||||
ecs.prepareToExit()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
drawInfo()
|
|
||||||
drawCalendar(3, 2, constants.programYear)
|
|
||||||
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,18 +1,16 @@
|
|||||||
|
|
||||||
local computer = require("computer")
|
|
||||||
local component = require("component")
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local MineOSInterface = require("MineOSInterface")
|
local system = require("System")
|
||||||
local buffer = require("doubleBuffering")
|
local screen = require("Screen")
|
||||||
local image = require("image")
|
local image = require("Image")
|
||||||
local fs = require("filesystem")
|
local filesystem = require("Filesystem")
|
||||||
|
|
||||||
if not component.isAvailable("camera") then
|
if not component.isAvailable("camera") then
|
||||||
GUI.alert("This program reqiures camera from computronix mod")
|
GUI.alert("This program reqiures camera from computronix mod")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local cameraProxy = component.camera
|
local cameraProxy = component.get("camera")
|
||||||
|
|
||||||
local grayscale = {
|
local grayscale = {
|
||||||
0xF0F0F0,
|
0xF0F0F0,
|
||||||
@ -58,7 +56,7 @@ local thermal = {
|
|||||||
}
|
}
|
||||||
local palette = grayscale
|
local palette = grayscale
|
||||||
|
|
||||||
local application, window = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 100, 25, 0x2D2D2D))
|
local workspace, window = system.addWindow(GUI.filledWindow(1, 1, 100, 25, 0x2D2D2D))
|
||||||
|
|
||||||
window.backgroundPanel.width = 22
|
window.backgroundPanel.width = 22
|
||||||
window.backgroundPanel.height = window.height
|
window.backgroundPanel.height = window.height
|
||||||
@ -101,38 +99,38 @@ local function takePicture()
|
|||||||
x, y = 1, y + 1
|
x, y = 1, y + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
MineOSInterface.application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local buttonImage = image.load(fs.path(getCurrentScript()) .. "Icon.pic")
|
local buttonImage = image.load(filesystem.path(system.getCurrentScript()) .. "Icon.pic")
|
||||||
local buttonImagePressed = image.blend(buttonImage, 0x0, 0.6)
|
local buttonImagePressed = image.blend(buttonImage, 0x0, 0.6)
|
||||||
local shootButton = window:addChild(GUI.object(1, 1, 8, 4))
|
local shootButton = window:addChild(GUI.object(1, 1, 8, 4))
|
||||||
shootButton.draw = function()
|
shootButton.draw = function()
|
||||||
buffer.drawImage(shootButton.x, shootButton.y, shootButton.pressed and buttonImagePressed or buttonImage)
|
screen.drawImage(shootButton.x, shootButton.y, shootButton.pressed and buttonImagePressed or buttonImage)
|
||||||
end
|
end
|
||||||
|
|
||||||
shootButton.eventHandler = function(application, object, e1)
|
shootButton.eventHandler = function(workspace, object, e1)
|
||||||
if e1 == "touch" then
|
if e1 == "touch" then
|
||||||
shootButton.pressed = true
|
shootButton.pressed = true
|
||||||
MineOSInterface.application:draw()
|
workspace:draw()
|
||||||
|
|
||||||
takePicture()
|
takePicture()
|
||||||
|
|
||||||
shootButton.pressed = false
|
shootButton.pressed = false
|
||||||
MineOSInterface.application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
cameraView.draw = function(cameraView)
|
cameraView.draw = function(cameraView)
|
||||||
buffer.drawRectangle(cameraView.x, cameraView.y, cameraView.width, cameraView.height, 0xF0F0F0, 0x878787, " ")
|
screen.drawRectangle(cameraView.x, cameraView.y, cameraView.width, cameraView.height, 0xF0F0F0, 0x878787, " ")
|
||||||
local x, y = 0, 0
|
local x, y = 0, 0
|
||||||
for y = 1, #cameraView.pixels do
|
for y = 1, #cameraView.pixels do
|
||||||
for x = 1, #cameraView.pixels[y] do
|
for x = 1, #cameraView.pixels[y] do
|
||||||
local color = palette[math.ceil(cameraView.pixels[y][x] / rangeSlider.value * #palette)] or 0x0
|
local color = palette[math.ceil(cameraView.pixels[y][x] / rangeSlider.value * #palette)] or 0x0
|
||||||
if semiPixelSwitch.state then
|
if semiPixelSwitch.state then
|
||||||
buffer.semiPixelSet(cameraView.x + x - 1, cameraView.y * 2 + y - 2, color)
|
screen.semiPixelSet(cameraView.x + x - 1, cameraView.y * 2 + y - 2, color)
|
||||||
else
|
else
|
||||||
buffer.set(cameraView.x + x - 1, cameraView.y + y - 2, color, 0x0, " ")
|
screen.set(cameraView.x + x - 1, cameraView.y + y - 2, color, 0x0, " ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -156,12 +154,12 @@ FOVSlider.onValueChanged = takePicture
|
|||||||
|
|
||||||
paletteSwitch.onStateChanged = function()
|
paletteSwitch.onStateChanged = function()
|
||||||
palette = paletteSwitch.state and thermal or grayscale
|
palette = paletteSwitch.state and thermal or grayscale
|
||||||
MineOSInterface.application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
autoupdateSwitch.onStateChanged = function()
|
autoupdateSwitch.onStateChanged = function()
|
||||||
autoupdateSlider.hidden = not autoupdateSwitch.state
|
autoupdateSlider.hidden = not autoupdateSwitch.state
|
||||||
MineOSInterface.application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
for address in component.list("camera") do
|
for address in component.list("camera") do
|
||||||
@ -180,7 +178,7 @@ window.onResize = function(width, height)
|
|||||||
shootButton.localX = math.floor(1 + window.backgroundPanel.width / 2 - shootButton.width / 2)
|
shootButton.localX = math.floor(1 + window.backgroundPanel.width / 2 - shootButton.width / 2)
|
||||||
shootButton.localY = window.height - shootButton.height
|
shootButton.localY = window.height - shootButton.height
|
||||||
|
|
||||||
MineOSInterface.application:draw()
|
workspace:draw()
|
||||||
takePicture()
|
takePicture()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1 +0,0 @@
|
|||||||
БЕТА, СУКА, НЕ ТРОГАЙ! РУКИ ПРОЧЬ!!!
|
|
||||||
@ -1 +0,0 @@
|
|||||||
БЕТА, СУКА, НЕ ТРОГАЙ! РУКИ ПРОЧЬ!!!
|
|
||||||
@ -1,777 +0,0 @@
|
|||||||
|
|
||||||
local event = require("event")
|
|
||||||
local modemConnection = require("modemConnection")
|
|
||||||
local ecs = require("ECSAPI")
|
|
||||||
local fs = require("filesystem")
|
|
||||||
local serialization = require("serialization")
|
|
||||||
local buffer = require("doubleBuffering")
|
|
||||||
local context = require("context")
|
|
||||||
local image = require("image")
|
|
||||||
local unicode = require("unicode")
|
|
||||||
local component = require("component")
|
|
||||||
local computer = require("computer")
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if not component.isAvailable("modem") then ecs.error("This program requires wireless modem to work!"); return end
|
|
||||||
|
|
||||||
local colors = {
|
|
||||||
leftBar = 0x262626,
|
|
||||||
leftBarSelection = 0x00A8FF,
|
|
||||||
leftBarAlternative = 0x383838,
|
|
||||||
leftBarText = 0xFFFFFF,
|
|
||||||
leftBarSelectionText = 0xFFFFFF,
|
|
||||||
leftBarSearchButton = 0x555555,
|
|
||||||
leftBarSearchButtonText = 0xFFFFFF,
|
|
||||||
|
|
||||||
scrollBar = 0xCCCCCC,
|
|
||||||
scrollBarPipe = 0x666666,
|
|
||||||
|
|
||||||
topBar = 0xEEEEEE,
|
|
||||||
topBarName = 0x000000,
|
|
||||||
topBarAddress = 0x555555,
|
|
||||||
|
|
||||||
topMenu = 0xFFFFFF,
|
|
||||||
|
|
||||||
chatZone = 0xFFFFFF,
|
|
||||||
senderCloudColor = 0x3392FF,
|
|
||||||
senderCloudTextColor = 0xFFFFFF,
|
|
||||||
yourCloudColor = 0x55BBFF,
|
|
||||||
yourCloudTextColor = 0xFFFFFF,
|
|
||||||
systemMessageColor = 0x555555,
|
|
||||||
|
|
||||||
sendButtonColor = 0x555555,
|
|
||||||
sendButtonTextColor = 0xFFFFFF,
|
|
||||||
|
|
||||||
messageInputBarColor = 0xEEEEEE,
|
|
||||||
messageInputBarInputBackgroundColor = 0xFFFFFF,
|
|
||||||
messsageInputBarButtonColor = 0x3392FF,
|
|
||||||
messsageInputBarButtonTextColor = 0xFFFFFF,
|
|
||||||
messsageInputBarTextColor = 0x262626,
|
|
||||||
}
|
|
||||||
|
|
||||||
local chatHistory = {}
|
|
||||||
local avatars = {}
|
|
||||||
local port = 899
|
|
||||||
local modem = component.modem
|
|
||||||
modem.open(port)
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local pathToApplication = "/MineOS/Applications/Chat.app/"
|
|
||||||
local pathToSaveSendedFiles = "/MineOS/Downloads/"
|
|
||||||
local contactsAvatarsPath = pathToApplication .. "Resources/Avatars/"
|
|
||||||
local personalAvatarPath = contactsAvatarsPath .. "MyAvatar.pic"
|
|
||||||
local chatHistoryPath = "MineOS/System/Chat/History.cfg"
|
|
||||||
local avatarWidthLimit = 6
|
|
||||||
local avatarHeightLimit = 3
|
|
||||||
|
|
||||||
local currentChatID = 1
|
|
||||||
local currentChatMessage = 1
|
|
||||||
local currentMessageText
|
|
||||||
|
|
||||||
buffer.start()
|
|
||||||
local messageInputHeight = 5
|
|
||||||
local leftBarHeight = buffer.screen.height - 9
|
|
||||||
local leftBarWidth = math.floor(buffer.screen.width * 0.2)
|
|
||||||
local chatZoneWidth = buffer.screen.width - leftBarWidth
|
|
||||||
local heightOfTopBar = 2 + avatarHeightLimit
|
|
||||||
local yLeftBar = 2 + heightOfTopBar
|
|
||||||
local chatZoneX = leftBarWidth + 1
|
|
||||||
local bottom
|
|
||||||
local chatZoneHeight = buffer.screen.height - yLeftBar - messageInputHeight + 1
|
|
||||||
local cloudWidth = chatZoneWidth - 2 * (avatarWidthLimit + 9)
|
|
||||||
local cloudTextWidth = cloudWidth - 4
|
|
||||||
local yMessageInput = buffer.screen.height - messageInputHeight + 1
|
|
||||||
local sendButtonWidth = 7
|
|
||||||
local messageInputWidth = chatZoneWidth - sendButtonWidth - 6
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
--Объекты для тача
|
|
||||||
local obj = {}
|
|
||||||
local function newObj(class, name, ...)
|
|
||||||
obj[class] = obj[class] or {}
|
|
||||||
obj[class][name] = {...}
|
|
||||||
end
|
|
||||||
|
|
||||||
local function saveChatHistory()
|
|
||||||
fs.makeDirectory(fs.path(chatHistoryPath) or "")
|
|
||||||
local file = io.open(chatHistoryPath, "w")
|
|
||||||
file:write(serialization.serialize(chatHistory))
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function loadChatHistory()
|
|
||||||
if fs.exists(chatHistoryPath) then
|
|
||||||
local file = io.open(chatHistoryPath, "r")
|
|
||||||
chatHistory = serialization.unserialize(file:read("*a"))
|
|
||||||
file:close()
|
|
||||||
else
|
|
||||||
chatHistory = {myName = "Аноним №" .. math.random(1, 1000)}
|
|
||||||
saveChatHistory()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function loadAvatarFromFile(path)
|
|
||||||
local avatar = image.load(path)
|
|
||||||
local widthDifference = avatar.width - avatarWidthLimit
|
|
||||||
local heightDifference = avatar.height - avatarHeightLimit
|
|
||||||
|
|
||||||
if widthDifference > 0 then
|
|
||||||
avatar = image.crop(avatar, "fromRight", widthDifference)
|
|
||||||
end
|
|
||||||
if heightDifference > 0 then
|
|
||||||
avatar = image.crop(avatar, "fromBottom", heightDifference)
|
|
||||||
end
|
|
||||||
|
|
||||||
return avatar
|
|
||||||
end
|
|
||||||
|
|
||||||
local function loadPersonalAvatar()
|
|
||||||
avatars.personal = loadAvatarFromFile(personalAvatarPath)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function loadContactAvatar(ID)
|
|
||||||
avatars.contact = loadAvatarFromFile(contactsAvatarsPath .. ID .. ".pic")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function saveContactAvatar(ID, data)
|
|
||||||
local file = io.open(contactsAvatarsPath .. ID .. ".pic", "w")
|
|
||||||
file:write(data)
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function switchToContact(ID)
|
|
||||||
currentChatID = ID
|
|
||||||
currentChatMessage = #chatHistory[currentChatID]
|
|
||||||
loadContactAvatar(currentChatID)
|
|
||||||
chatHistory[currentChatID].unreadedMessages = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawLeftBar()
|
|
||||||
buffer.square(1, yLeftBar, leftBarWidth, leftBarHeight, colors.leftBar, 0xFFFFFF, " ")
|
|
||||||
|
|
||||||
local howMuchContactsCanBeShown = math.floor(leftBarHeight / 3)
|
|
||||||
obj.Contacts = {}
|
|
||||||
|
|
||||||
local yPos = yLeftBar
|
|
||||||
local counter = 1
|
|
||||||
local text, textColor
|
|
||||||
|
|
||||||
for i = 1, #chatHistory do
|
|
||||||
textColor = colors.leftBarText
|
|
||||||
|
|
||||||
--Рисуем подложку
|
|
||||||
if i == currentChatID then
|
|
||||||
buffer.square(1, yPos, leftBarWidth, 3, colors.leftBarSelection, 0xFFFFFF, " ")
|
|
||||||
textColor = 0xFFFFFF
|
|
||||||
elseif counter % 2 ~= 0 then
|
|
||||||
buffer.square(1, yPos, leftBarWidth, 3, colors.leftBarAlternative, 0xFFFFFF, " ")
|
|
||||||
end
|
|
||||||
|
|
||||||
--Создаем объекты для клика
|
|
||||||
newObj("Contacts", i, 1, yPos, leftBarWidth, yPos + 2)
|
|
||||||
|
|
||||||
--Рендерим корректное имя
|
|
||||||
text = chatHistory[i].name or address
|
|
||||||
text = ecs.stringLimit("end", text, leftBarWidth - 4)
|
|
||||||
|
|
||||||
--Рисуем имя
|
|
||||||
yPos = yPos + 1
|
|
||||||
buffer.text(2, yPos, textColor, text)
|
|
||||||
|
|
||||||
--Если имеются непрочитанные сообщения, то показать их
|
|
||||||
if chatHistory[i].unreadedMessages then
|
|
||||||
local stringCount = tostring(chatHistory[i].unreadedMessages)
|
|
||||||
local stringCountLength = unicode.len(stringCount)
|
|
||||||
local x = leftBarWidth - 3 - stringCountLength
|
|
||||||
buffer.square(x, yPos, stringCountLength + 2, 1, colors.leftBarText, 0xFFFFFF, " ")
|
|
||||||
buffer.text(x + 1, yPos, colors.leftBar, stringCount)
|
|
||||||
end
|
|
||||||
|
|
||||||
yPos = yPos + 2
|
|
||||||
counter = counter + 1
|
|
||||||
if counter > howMuchContactsCanBeShown or yPos > buffer.screen.height then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Кнопочка поиска юзеров
|
|
||||||
obj.search = {buffer.button(1, buffer.screen.height - 2, leftBarWidth, 3, colors.leftBarSearchButton, colors.leftBarSearchButtonText, "Поиск")}
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawTopBar()
|
|
||||||
buffer.square(1, 2, buffer.screen.width, heightOfTopBar, colors.topBar, 0xFFFFFF, " ")
|
|
||||||
|
|
||||||
buffer.image(3, 3, avatars.personal)
|
|
||||||
buffer.text(11, 3, colors.topBarName, chatHistory.myName)
|
|
||||||
buffer.text(11, 4, colors.topBarAddress, modemConnection.localAddress)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawTopMenu()
|
|
||||||
obj.TopMenu = buffer.menu(1, 1, buffer.screen.width, colors.topMenu, 0, {"Чат", 0x000099}, {"История", 0x000000}, {"О программе", 0x000000})
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawEmptyCloud(x, y, cloudWidth, cloudHeight, cloudColor, fromYou)
|
|
||||||
local upperPixel = "▀"
|
|
||||||
local lowerPixel = "▄"
|
|
||||||
|
|
||||||
--Рисуем финтифлюшечки
|
|
||||||
if not fromYou then
|
|
||||||
buffer.set(x, y - cloudHeight + 2, colors.chatZone, cloudColor, upperPixel)
|
|
||||||
buffer.set(x + 1, y - cloudHeight + 2, cloudColor, 0xFFFFFF, " ")
|
|
||||||
x = x + 2
|
|
||||||
else
|
|
||||||
buffer.set(x + cloudWidth + 3, y - cloudHeight + 2, colors.chatZone, cloudColor, upperPixel)
|
|
||||||
buffer.set(x + cloudWidth + 2, y - cloudHeight + 2, cloudColor, 0xFFFFFF, " ")
|
|
||||||
end
|
|
||||||
|
|
||||||
--Заполняшечки
|
|
||||||
buffer.square(x + 1, y - cloudHeight + 1, cloudWidth, cloudHeight, cloudColor, 0xFFFFFF, " ")
|
|
||||||
buffer.square(x, y - cloudHeight + 2, cloudWidth + 2, cloudHeight - 2, cloudColor, 0xFFFFFF, " ")
|
|
||||||
|
|
||||||
--Сгругленные краешки
|
|
||||||
buffer.set(x, y - cloudHeight + 1, colors.chatZone, cloudColor, lowerPixel)
|
|
||||||
buffer.set(x + cloudWidth + 1, y - cloudHeight + 1, colors.chatZone, cloudColor, lowerPixel)
|
|
||||||
buffer.set(x, y, colors.chatZone, cloudColor, upperPixel)
|
|
||||||
buffer.set(x + cloudWidth + 1, y, colors.chatZone, cloudColor, upperPixel)
|
|
||||||
|
|
||||||
return y - cloudHeight + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawTextCloud(x, y, cloudColor, textColor, fromYou, text)
|
|
||||||
local y = drawEmptyCloud(x, y, cloudTextWidth, #text + 2, cloudColor, fromYou)
|
|
||||||
x = fromYou and x + 2 or x + 4
|
|
||||||
|
|
||||||
for i = 1, #text do
|
|
||||||
buffer.text(x, y + i, textColor, text[i])
|
|
||||||
end
|
|
||||||
|
|
||||||
return y
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawFileCloud(x, y, cloudColor, textColor, fromYou, fileName)
|
|
||||||
local y = drawEmptyCloud(x, y, 14, 8, cloudColor, fromYou)
|
|
||||||
x = fromYou and x + 2 or x + 4
|
|
||||||
|
|
||||||
ecs.drawOSIcon(x, y + 1, fileName, true, textColor)
|
|
||||||
|
|
||||||
return y
|
|
||||||
end
|
|
||||||
|
|
||||||
local function stringWrap(text, limit)
|
|
||||||
local strings = {}
|
|
||||||
local textLength = unicode.len(text)
|
|
||||||
local subFrom = 1
|
|
||||||
while subFrom <= textLength do
|
|
||||||
table.insert(strings, unicode.sub(text, subFrom, subFrom + limit - 1))
|
|
||||||
subFrom = subFrom + limit
|
|
||||||
end
|
|
||||||
return strings
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawChat()
|
|
||||||
|
|
||||||
local x, y = chatZoneX, yLeftBar
|
|
||||||
buffer.square(x, y, chatZoneWidth, chatZoneHeight, colors.chatZone, 0xFFFFFF, " ")
|
|
||||||
|
|
||||||
--Если отстутствуют контакты, то отобразить стартовое сообщение
|
|
||||||
if not chatHistory[currentChatID] then
|
|
||||||
local text = ecs.stringLimit("start", "Добавьте контакты с помощью кнопки \"Поиск\"", chatZoneWidth - 2)
|
|
||||||
local x, y = math.floor(chatZoneX + chatZoneWidth / 2 - unicode.len(text) / 2), math.floor(yLeftBar + chatZoneHeight / 2)
|
|
||||||
buffer.text(x, y, 0x555555, text)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Ставим ограничение отрисовки буфера, чтобы облачка сообщений не ебошили
|
|
||||||
-- За края верхней зоны чатзоны, ну ты понял, да?
|
|
||||||
buffer.setDrawLimit(x, y, chatZoneWidth, chatZoneHeight)
|
|
||||||
|
|
||||||
-- Стартовая точка
|
|
||||||
y = buffer.screen.height - messageInputHeight - 1
|
|
||||||
local xYou, xSender = x + 2, buffer.screen.width - 8
|
|
||||||
-- Отрисовка облачков
|
|
||||||
for i = currentChatMessage, 1, -1 do
|
|
||||||
--Если не указан тип сообщения, то ренедрим дефолтные облачка
|
|
||||||
if not chatHistory[currentChatID][i].type then
|
|
||||||
--Если сообщенька от тебя, то цвет меняем
|
|
||||||
if chatHistory[currentChatID][i].fromYou then
|
|
||||||
y = drawTextCloud(xSender - cloudWidth - 2, y, colors.yourCloudColor, colors.yourCloudTextColor, chatHistory[currentChatID][i].fromYou, stringWrap(chatHistory[currentChatID][i].message, cloudTextWidth - 2))
|
|
||||||
buffer.image(xSender, y, avatars.personal)
|
|
||||||
else
|
|
||||||
y = drawTextCloud(xYou + 8, y, colors.senderCloudColor, colors.senderCloudTextColor, chatHistory[currentChatID][i].fromYou, stringWrap(chatHistory[currentChatID][i].message, cloudTextWidth))
|
|
||||||
buffer.image(xYou, y, avatars.contact)
|
|
||||||
end
|
|
||||||
--Если сообщение имеет тип "Файл"
|
|
||||||
elseif chatHistory[currentChatID][i].type == "file" then
|
|
||||||
if chatHistory[currentChatID][i].fromYou then
|
|
||||||
y = drawFileCloud(xSender - 20, y, colors.yourCloudColor, colors.yourCloudTextColor, chatHistory[currentChatID][i].fromYou, chatHistory[currentChatID][i].message)
|
|
||||||
buffer.image(xSender, y, avatars.personal)
|
|
||||||
else
|
|
||||||
y = drawFileCloud(xYou + 8, y, colors.senderCloudColor, colors.senderCloudTextColor, chatHistory[currentChatID][i].fromYou, chatHistory[currentChatID][i].message)
|
|
||||||
buffer.image(xYou, y, avatars.contact)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
for i = chatZoneX, buffer.screen.width - 2 do
|
|
||||||
buffer.set(i, y, colors.chatZone, colors.systemMessageColor, "─")
|
|
||||||
end
|
|
||||||
local x = math.floor(chatZoneX + (chatZoneWidth - 2) / 2 - unicode.len(chatHistory[currentChatID][i].message) / 2)
|
|
||||||
buffer.text(x, y, colors.systemMessageColor, " " .. chatHistory[currentChatID][i].message .. " ")
|
|
||||||
end
|
|
||||||
|
|
||||||
y = y - 2
|
|
||||||
if y <= yLeftBar then break end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Убираем ограничение отроисовки буфера
|
|
||||||
buffer.resetDrawLimit()
|
|
||||||
|
|
||||||
buffer.scrollBar(buffer.screen.width, yLeftBar, 1, chatZoneHeight, #chatHistory[currentChatID], currentChatMessage, colors.scrollBar, colors.scrollBarPipe)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawMessageInputBar()
|
|
||||||
local x, y = chatZoneX, yMessageInput
|
|
||||||
buffer.square(x, y, chatZoneWidth, messageInputHeight, colors.messageInputBarColor, 0xFFFFFF, " ")
|
|
||||||
y = y + 1
|
|
||||||
buffer.square(x + 2, y, messageInputWidth, 3, colors.messageInputBarInputBackgroundColor, 0xFFFFFF, " ")
|
|
||||||
buffer.text(x + 3, y + 1, colors.messsageInputBarTextColor, ecs.stringLimit("start", currentMessageText or "Введите сообщение", messageInputWidth - 2))
|
|
||||||
|
|
||||||
obj.send = {buffer.button(chatZoneX + messageInputWidth + 4, y, sendButtonWidth, 3, colors.sendButtonColor, colors.sendButtonTextColor, "⇪")}
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawAll(force)
|
|
||||||
drawTopBar()
|
|
||||||
drawLeftBar()
|
|
||||||
drawTopMenu()
|
|
||||||
drawChat()
|
|
||||||
drawMessageInputBar()
|
|
||||||
buffer.draw(force)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function scrollChat(direction)
|
|
||||||
if direction == 1 then
|
|
||||||
if currentChatMessage > 1 then
|
|
||||||
currentChatMessage = currentChatMessage - 1
|
|
||||||
drawChat()
|
|
||||||
drawMessageInputBar()
|
|
||||||
buffer.draw()
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if currentChatMessage < #chatHistory[currentChatID] then
|
|
||||||
currentChatMessage = currentChatMessage + 1
|
|
||||||
drawChat()
|
|
||||||
drawMessageInputBar()
|
|
||||||
buffer.draw()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function addMessageToArray(ID, type, fromYou, message)
|
|
||||||
table.insert(chatHistory[ID], {type = type, fromYou = fromYou, message = message})
|
|
||||||
saveChatHistory()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function sendMessage(type, message)
|
|
||||||
modem.send(chatHistory[currentChatID].address, port, "HereIsMessageToYou", type, message)
|
|
||||||
|
|
||||||
addMessageToArray(currentChatID, nil, true, currentMessageText)
|
|
||||||
|
|
||||||
currentChatMessage = #chatHistory[currentChatID]
|
|
||||||
currentMessageText = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local function checkAddressExists(address)
|
|
||||||
for i = 1, #chatHistory do
|
|
||||||
if chatHistory[i].address == address then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function addNewContact(address, name, avatarData)
|
|
||||||
if not checkAddressExists(address) then
|
|
||||||
table.insert(chatHistory,
|
|
||||||
{
|
|
||||||
address = address,
|
|
||||||
name = name,
|
|
||||||
{
|
|
||||||
type = "system",
|
|
||||||
message = "Здесь будет показана история чата"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
saveChatHistory()
|
|
||||||
saveContactAvatar(#chatHistory, avatarData)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function askForAddToContacts(address)
|
|
||||||
--Загружаем авку
|
|
||||||
local file = io.open(personalAvatarPath, "r")
|
|
||||||
local avatarData = file:read("*a")
|
|
||||||
file:close()
|
|
||||||
--Отсылаем свое имечко и аватарку
|
|
||||||
modem.send(address, port, "AddMeToContactsPlease", chatHistory.myName, avatarData)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getNameAndIDOfAddress(address)
|
|
||||||
for i = 1, #chatHistory do
|
|
||||||
if chatHistory[i].address == address then
|
|
||||||
return chatHistory[i].name, i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return nil, nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local function autoScroll()
|
|
||||||
--Если мы никуда не скроллили и находимся в конце истории чата с этим юзером
|
|
||||||
--То автоматически проскроллить на конец
|
|
||||||
if currentChatMessage == (#chatHistory[currentChatID] - 1) then
|
|
||||||
currentChatMessage = #chatHistory[currentChatID]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function receiveFile(remoteAddress, fileName)
|
|
||||||
--Чекаем, есть ли он в контактах
|
|
||||||
if checkAddressExists(remoteAddress) then
|
|
||||||
--Создаем директорию под файлики, а то мало ли
|
|
||||||
fs.makeDirectory(pathToSaveSendedFiles)
|
|
||||||
--Получаем имя отправителя из контактов
|
|
||||||
local senderName, senderID = getNameAndIDOfAddress(remoteAddress)
|
|
||||||
--Открываем файл для записи
|
|
||||||
local file = io.open(pathToSaveSendedFiles .. fileName, "w")
|
|
||||||
--Запоминаем пиксели под окошком прогресса
|
|
||||||
local oldPixels = ecs.progressWindow("auto", "auto", 40, 0, "Прием файла", true)
|
|
||||||
--Начинаем ожидать беспроводных сообщений в течение 10 секунд
|
|
||||||
while true do
|
|
||||||
local fileReceiveEvent = { event.pull(10, "modem_message") }
|
|
||||||
--Это сообщение несет в себе процентаж передачи и сами данные пакета
|
|
||||||
if fileReceiveEvent[6] == "FILESEND" then
|
|
||||||
--Рисуем окошко прогресса
|
|
||||||
ecs.progressWindow("auto", "auto", 40, fileReceiveEvent[7], "Прием файла")
|
|
||||||
file:write(fileReceiveEvent[8])
|
|
||||||
--Если нам присылают сообщение о завершении передачи, то закрываем файл
|
|
||||||
elseif fileReceiveEvent[6] == "FILESENDEND" then
|
|
||||||
ecs.progressWindow("auto", "auto", 40, 100, "Прием файла")
|
|
||||||
file:close()
|
|
||||||
ecs.drawOldPixels(oldPixels)
|
|
||||||
|
|
||||||
--Вставляем сообщение с файликом-иконочкой
|
|
||||||
addMessageToArray(senderID, "file", nil, fileName)
|
|
||||||
autoScroll()
|
|
||||||
drawAll()
|
|
||||||
|
|
||||||
--Выдаем окошечко о том, что файл успешно передан
|
|
||||||
ecs.universalWindow("auto", "auto", 30, 0x262626, true,
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", ecs.colors.orange, "Прием данных завершен"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", 0xFFFFFF, "Файл от " .. senderName .. " сохранен как"},
|
|
||||||
{"CenterText", 0xFFFFFF, "\"" .. pathToSaveSendedFiles .. fileName .. "\""},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Button", {ecs.colors.orange, 0x262626, "OK"}}
|
|
||||||
)
|
|
||||||
|
|
||||||
break
|
|
||||||
--Если не получали в течение указанного промежутка сообщений, то выдать сообщение об ошибке и удалить файл
|
|
||||||
elseif not fileReceiveEvent[1] then
|
|
||||||
file:close()
|
|
||||||
ecs.drawOldPixels(oldPixels)
|
|
||||||
fs.remove(pathToSaveSendedFiles .. fileName)
|
|
||||||
ecs.error("Ошибка при передаче файла: клиент не отвечает")
|
|
||||||
drawAll()
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Обработчик сообщений
|
|
||||||
local function dro4er(_, localAddress, remoteAddress, remotePort, distance, ...)
|
|
||||||
local messages = { ... }
|
|
||||||
|
|
||||||
if remotePort == port then
|
|
||||||
if messages[1] == "AddMeToContactsPlease" then
|
|
||||||
if modemConnection.remoteAddress and modemConnection.remoteAddress == remoteAddress then
|
|
||||||
-- ecs.error("Сообщение о добавлении получил, адрес: " .. modemConnection.remoteAddress .. ", имя:" .. messages[2] .. ", авка: " .. type(messages[3]))
|
|
||||||
--Добавляем пидорка к себе в контакты
|
|
||||||
addNewContact(modemConnection.remoteAddress, messages[2], messages[3])
|
|
||||||
--Просим того пидорка, чтобы он добавил нас к себе в контакты
|
|
||||||
askForAddToContacts(modemConnection.remoteAddress)
|
|
||||||
--Чтобы не было всяких соблазнов!
|
|
||||||
modemConnection.availableUsers = {}
|
|
||||||
modemConnection.remoteAddress = nil
|
|
||||||
--Переключаемся на добавленный контакт
|
|
||||||
switchToContact(#chatHistory)
|
|
||||||
drawAll()
|
|
||||||
end
|
|
||||||
--Если какой-то чувак просит нас принять файл
|
|
||||||
elseif messages[1] == "FAYLPRIMI" then
|
|
||||||
receiveFile(remoteAddress, messages[2])
|
|
||||||
elseif messages[1] == "HereIsMessageToYou" then
|
|
||||||
for i = 1, #chatHistory do
|
|
||||||
--Если в массиве истории чата найден юзер, отославший такое сообщение
|
|
||||||
if chatHistory[i].address == remoteAddress then
|
|
||||||
--То вставляем само сообщение в историю чата
|
|
||||||
addMessageToArray(i, messages[2], nil, messages[3])
|
|
||||||
--Если текущая открытая история чата является именно вот этой, с этим отправителем
|
|
||||||
if currentChatID == i then
|
|
||||||
autoScroll()
|
|
||||||
--Обязательно отрисовываем измененную историю чата с этим отправителем
|
|
||||||
drawChat()
|
|
||||||
buffer.draw()
|
|
||||||
--Увеличиваем количество непрочитанных сообщений от отправителя
|
|
||||||
else
|
|
||||||
chatHistory[i].unreadedMessages = chatHistory[i].unreadedMessages and chatHistory[i].unreadedMessages + 1 or 1
|
|
||||||
drawLeftBar()
|
|
||||||
buffer.draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
--Бип!
|
|
||||||
computer.beep(1700)
|
|
||||||
|
|
||||||
--А это небольшой костыльчик, чтобы не сбивался цвет курсора Term API
|
|
||||||
component.gpu.setBackground(colors.messageInputBarInputBackgroundColor)
|
|
||||||
component.gpu.setForeground(colors.messsageInputBarTextColor)
|
|
||||||
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function enableDro4er()
|
|
||||||
event.listen("modem_message", dro4er)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function disableDro4er()
|
|
||||||
event.ignore("modem_message", dro4er)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function deleteAvatar(ID)
|
|
||||||
fs.remove(contactsAvatarsPath .. ID .. ".pic")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function clearChatHistory()
|
|
||||||
for i = 1, #chatHistory do
|
|
||||||
deleteAvatar(i)
|
|
||||||
chatHistory[i] = nil
|
|
||||||
end
|
|
||||||
saveChatHistory()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function sendFile(path)
|
|
||||||
local data = ecs.universalWindow("auto", "auto", 30, 0x262626, true,
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", ecs.colors.orange, "Отправить файл"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Input", 0xFFFFFF, ecs.colors.orange, "Путь"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Button", {ecs.colors.orange, 0x262626, "OK"}, {0x666666, 0xffffff, "Отмена"}}
|
|
||||||
)
|
|
||||||
|
|
||||||
if data[2] == "OK" then
|
|
||||||
if fs.exists(data[1]) then
|
|
||||||
--Отправляем сообщение о том, что мы собираемся отправить файл
|
|
||||||
modem.send(chatHistory[currentChatID].address, port, "FAYLPRIMI", fs.name(data[1]))
|
|
||||||
--Открываем файл и отправляем его по количеству пакетов
|
|
||||||
local maxPacketSize = modem.maxPacketSize() - 32
|
|
||||||
local file = io.open(data[1], "rb")
|
|
||||||
local fileSize = fs.size(data[1])
|
|
||||||
local percent = 0
|
|
||||||
local sendedBytes = 0
|
|
||||||
local dataToSend
|
|
||||||
|
|
||||||
while true do
|
|
||||||
dataToSend = file:read(maxPacketSize)
|
|
||||||
if dataToSend then
|
|
||||||
modem.send(chatHistory[currentChatID].address, port, "FILESEND", percent, dataToSend)
|
|
||||||
sendedBytes = sendedBytes + maxPacketSize
|
|
||||||
percent = math.floor(sendedBytes / fileSize * 100)
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
file:close()
|
|
||||||
--Репортуем об окончании передачи файла
|
|
||||||
modem.send(chatHistory[currentChatID].address, port, "FILESENDEND")
|
|
||||||
--Вставляем в чат инфу об обтправленном файле
|
|
||||||
addMessageToArray(currentChatID, "file", true, fs.name(data[1]))
|
|
||||||
autoScroll()
|
|
||||||
drawAll()
|
|
||||||
else
|
|
||||||
ecs.error("Файл \"" .. data[1] .. "\" не существует.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function deleteContact(ID)
|
|
||||||
table.remove(chatHistory, ID)
|
|
||||||
deleteAvatar(ID)
|
|
||||||
if #chatHistory > 0 then
|
|
||||||
switchToContact(1)
|
|
||||||
else
|
|
||||||
currentChatID = 1
|
|
||||||
currentChatMessage = 1
|
|
||||||
end
|
|
||||||
saveChatHistory()
|
|
||||||
end
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
--Отключаем принудительное завершение программы
|
|
||||||
ecs.disableInterrupting()
|
|
||||||
--Загружаем историю чата и свою аватарку
|
|
||||||
loadChatHistory()
|
|
||||||
loadPersonalAvatar()
|
|
||||||
--Если история не пуста, то переключаемся на указанный контакт
|
|
||||||
if chatHistory[currentChatID] then
|
|
||||||
switchToContact(currentChatID)
|
|
||||||
end
|
|
||||||
--Включаем прием данных по модему для подключения
|
|
||||||
modemConnection.startReceivingData()
|
|
||||||
--Отсылаем всем модемам сигнал о том, чтобы они удалили нас из своего списка
|
|
||||||
modemConnection.disconnect()
|
|
||||||
--Отправляем свои данные, чтобы нас заново внесли в список
|
|
||||||
modemConnection.sendPersonalData()
|
|
||||||
--Активируем прием сообщений чата
|
|
||||||
enableDro4er()
|
|
||||||
--Рисуем весь интерфейс
|
|
||||||
drawAll()
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = { event.pull() }
|
|
||||||
if e[1] == "touch" then
|
|
||||||
-- Клик на поле ввода сообщения
|
|
||||||
if #chatHistory > 0 and ecs.clickedAtArea(e[3], e[4], chatZoneX + 2, yMessageInput, chatZoneX + messageInputWidth + 2, yMessageInput + 3) then
|
|
||||||
local text = ecs.inputText(chatZoneX + 3, yMessageInput + 2, messageInputWidth - 2, currentMessageText, colors.messageInputBarInputBackgroundColor, colors.messsageInputBarTextColor)
|
|
||||||
if text ~= nil and text ~= "" then
|
|
||||||
currentMessageText = text
|
|
||||||
sendMessage(nil, currentMessageText)
|
|
||||||
buffer.square(chatZoneX + 2, yMessageInput + 1, messageInputWidth, 3, colors.messageInputBarInputBackgroundColor, 0xFFFFFF, " ")
|
|
||||||
buffer.draw()
|
|
||||||
drawMessageInputBar()
|
|
||||||
drawChat()
|
|
||||||
buffer.draw()
|
|
||||||
end
|
|
||||||
-- Жмякаем на кнопочку "Отправить"
|
|
||||||
elseif #chatHistory > 0 and ecs.clickedAtArea(e[3], e[4], obj.send[1], obj.send[2], obj.send[3], obj.send[4]) then
|
|
||||||
buffer.button(obj.send[1], obj.send[2], sendButtonWidth, 3, colors.sendButtonTextColor, colors.sendButtonColor, "⇪")
|
|
||||||
buffer.draw()
|
|
||||||
os.sleep(0.2)
|
|
||||||
drawMessageInputBar()
|
|
||||||
buffer.draw()
|
|
||||||
sendFile()
|
|
||||||
-- Кнопа поиска
|
|
||||||
elseif ecs.clickedAtArea(e[3], e[4], obj.search[1], obj.search[2], obj.search[3], obj.search[4]) then
|
|
||||||
buffer.button(obj.search[1], obj.search[2], leftBarWidth, 3, colors.leftBarSearchButtonText, colors.leftBarSearchButton, "Поиск")
|
|
||||||
buffer.draw()
|
|
||||||
os.sleep(0.2)
|
|
||||||
|
|
||||||
modemConnection.search()
|
|
||||||
|
|
||||||
--Если после поиска мы подключились к какому-либо адресу
|
|
||||||
if modemConnection.remoteAddress then
|
|
||||||
--Просим адрес добавить нас в свой список контактов
|
|
||||||
askForAddToContacts(modemConnection.remoteAddress)
|
|
||||||
end
|
|
||||||
|
|
||||||
drawAll(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
--Клик на контакты
|
|
||||||
for key in pairs(obj.Contacts) do
|
|
||||||
if ecs.clickedAtArea(e[3], e[4], obj.Contacts[key][1], obj.Contacts[key][2], obj.Contacts[key][3], obj.Contacts[key][4]) then
|
|
||||||
if e[5] == 0 then
|
|
||||||
switchToContact(key)
|
|
||||||
drawAll()
|
|
||||||
else
|
|
||||||
local action = context.menu(e[3], e[4], {"Переименовать"}, {"Удалить"})
|
|
||||||
if action == "Переименовать" then
|
|
||||||
local data = ecs.universalWindow("auto", "auto", 30, 0x262626, true,
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", ecs.colors.orange, "Переименовать контакт"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Input", 0xFFFFFF, ecs.colors.orange, chatHistory[key].name},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Button", {ecs.colors.orange, 0x262626, "OK"}, {0x666666, 0xffffff, "Отмена"}}
|
|
||||||
)
|
|
||||||
|
|
||||||
if data[2] == "OK" then
|
|
||||||
chatHistory[key].name = data[1] or chatHistory[key].name
|
|
||||||
drawAll()
|
|
||||||
end
|
|
||||||
elseif action == "Удалить" then
|
|
||||||
deleteContact(key)
|
|
||||||
drawAll()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for key in pairs(obj.TopMenu) do
|
|
||||||
if ecs.clickedAtArea(e[3], e[4], obj.TopMenu[key][1], obj.TopMenu[key][2], obj.TopMenu[key][3],obj.TopMenu[key][4]) then
|
|
||||||
buffer.button(obj.TopMenu[key][1] - 1, obj.TopMenu[key][2], unicode.len(key) + 2, 1, ecs.colors.blue, 0xFFFFFF, key)
|
|
||||||
buffer.draw()
|
|
||||||
|
|
||||||
local action
|
|
||||||
if key == "Чат" then
|
|
||||||
action = context.menu(obj.TopMenu[key][1] - 1, obj.TopMenu[key][2] + 1, {"Изменить имя"}, {"Изменить аватар"}, {"Очистить историю"},"-", {"Выход"})
|
|
||||||
elseif key == "О программе" then
|
|
||||||
ecs.universalWindow("auto", "auto", 36, 0x262626, true,
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", ecs.colors.orange, "Chat v1.0"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", 0xFFFFFF, "Автор:"},
|
|
||||||
{"CenterText", 0xBBBBBB, "Тимофеев Игорь"},
|
|
||||||
{"CenterText", 0xBBBBBB, "vk.com/id7799889"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", 0xFFFFFF, "Тестеры:"},
|
|
||||||
{"CenterText", 0xBBBBBB, "Егор Палиев"},
|
|
||||||
{"CenterText", 0xBBBBBB, "vk.com/mrherobrine"},
|
|
||||||
{"CenterText", 0xBBBBBB, "Максим Хлебников"},
|
|
||||||
{"CenterText", 0xBBBBBB, "vk.com/mskalash"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Button", {ecs.colors.orange, 0x262626, "OK"}}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
if action == "Выход" then
|
|
||||||
disableDro4er()
|
|
||||||
modemConnection.stopReceivingData()
|
|
||||||
modemConnection.disconnect()
|
|
||||||
ecs.enableInterrupting()
|
|
||||||
modem.close(port)
|
|
||||||
buffer.clear()
|
|
||||||
ecs.prepareToExit()
|
|
||||||
return
|
|
||||||
elseif action == "Очистить историю" then
|
|
||||||
clearChatHistory()
|
|
||||||
drawAll()
|
|
||||||
end
|
|
||||||
|
|
||||||
drawTopMenu()
|
|
||||||
buffer.draw()
|
|
||||||
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif e[1] == "scroll" then
|
|
||||||
if #chatHistory > 0 and ecs.clickedAtArea(e[3], e[4], chatZoneX, yLeftBar, chatZoneX + chatZoneWidth - 1, yLeftBar + chatZoneHeight - 1) then
|
|
||||||
scrollChat(e[5])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
BIN
Applications/Christmas Tree.app/Icon.pic
Executable file
BIN
Applications/Christmas Tree.app/Icon.pic
Executable file
Binary file not shown.
160
Applications/Christmas Tree.app/Main.lua
Executable file
160
Applications/Christmas Tree.app/Main.lua
Executable file
@ -0,0 +1,160 @@
|
|||||||
|
|
||||||
|
-- Copyright (c) Totoro, ComputerCraft.ru
|
||||||
|
|
||||||
|
local system = require("System")
|
||||||
|
local GUI = require("GUI")
|
||||||
|
local filesystem = require("Filesystem")
|
||||||
|
local image = require("Image")
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local hologram
|
||||||
|
|
||||||
|
-- создаем модель елки
|
||||||
|
local tSpruce = {3, 2, 2, 2, 2, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 4, 6, 8, 7, 6, 5, 4, 3, 6, 5, 4, 3, 2, 3, 2, 1}
|
||||||
|
-- создаем таблицу с падающими снежинками
|
||||||
|
local tSnow = {}
|
||||||
|
|
||||||
|
if not component.isAvailable("hologram") then
|
||||||
|
GUI.alert("This program requires Tier 2 holographic projector")
|
||||||
|
return
|
||||||
|
else
|
||||||
|
hologram = component.get("hologram")
|
||||||
|
end
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
local workspace, window = system.addWindow(GUI.filledWindow(1, 1, 36, 18, 0x2D2D2D))
|
||||||
|
|
||||||
|
local layout = window:addChild(GUI.layout(1, 1, window.width, window.height, 1, 1))
|
||||||
|
|
||||||
|
local picture = layout:addChild(GUI.image(1, 1, image.load(filesystem.path(system.getCurrentScript()) .. "Icon.pic")))
|
||||||
|
picture.height = picture.height + 1
|
||||||
|
|
||||||
|
local function addSlider(min, max, value, ...)
|
||||||
|
return layout:addChild(GUI.slider(1, 1, layout.width - 10, 0x66DB80, 0x0, 0xE1E1E1, 0x969696, min, max, value, false, ...))
|
||||||
|
end
|
||||||
|
|
||||||
|
local speedSlider = addSlider(0.1, 1, 0.8, "Speed: ", "")
|
||||||
|
local rotationSlider = addSlider(0, 100, 0, "Rotation: ", "")
|
||||||
|
local translationSlider = addSlider(0, 1, select(2, hologram.getTranslation()), "Translation: ", "")
|
||||||
|
local scaleSlider = addSlider(0.33, 3, hologram.getScale(), "Scale: ", "")
|
||||||
|
scaleSlider.height = 2
|
||||||
|
|
||||||
|
scaleSlider.onValueChanged = function()
|
||||||
|
hologram.setScale(scaleSlider.value)
|
||||||
|
end
|
||||||
|
|
||||||
|
rotationSlider.onValueChanged = function()
|
||||||
|
hologram.setRotationSpeed(rotationSlider.value, 0, 23, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
translationSlider.onValueChanged = function()
|
||||||
|
hologram.setTranslation(0, translationSlider.value, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
window.onResize = function(width, height)
|
||||||
|
window.backgroundPanel.width = width
|
||||||
|
window.backgroundPanel.height = height
|
||||||
|
|
||||||
|
layout.width = width
|
||||||
|
layout.height = height
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Главный йоба-цикл
|
||||||
|
local deadline = 0
|
||||||
|
layout.eventHandler = function(workspace, panel, e1)
|
||||||
|
if computer.uptime() > deadline then
|
||||||
|
-- генерируем снежинку
|
||||||
|
local x, y, z, pixel = math.random(1, 46), 32, math.random(1, 46)
|
||||||
|
table.insert(tSnow, {x = x, y = y, z = z})
|
||||||
|
hologram.set(x, y, z, 1)
|
||||||
|
|
||||||
|
-- сдвигаем снежинки вниз
|
||||||
|
local i = 1
|
||||||
|
while i <= #tSnow do
|
||||||
|
if tSnow[i].y > 1 then
|
||||||
|
x, y, z = tSnow[i].x + math.random(-1, 1), tSnow[i].y - 1, tSnow[i].z + math.random(-1, 1)
|
||||||
|
|
||||||
|
if x < 1 then
|
||||||
|
x = 1
|
||||||
|
elseif x > 46 then
|
||||||
|
x = 46
|
||||||
|
end
|
||||||
|
|
||||||
|
if z < 1 then
|
||||||
|
z = 1
|
||||||
|
elseif z > 46 then
|
||||||
|
z = 46
|
||||||
|
end
|
||||||
|
|
||||||
|
pixel = hologram.get(x, y, z)
|
||||||
|
|
||||||
|
if pixel == 0 or pixel == 1 then
|
||||||
|
hologram.set(tSnow[i].x, tSnow[i].y, tSnow[i].z, 0)
|
||||||
|
hologram.set(x, y, z, 1)
|
||||||
|
|
||||||
|
tSnow[i].x, tSnow[i].y, tSnow[i].z = x, y, z
|
||||||
|
i = i + 1
|
||||||
|
else
|
||||||
|
table.remove(tSnow,i)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.remove(tSnow,i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
deadline = computer.uptime() + 1 - speedSlider.value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
-- Сначала интерфейс
|
||||||
|
workspace:draw()
|
||||||
|
|
||||||
|
-- очищаем прожектор
|
||||||
|
hologram.clear()
|
||||||
|
scaleSlider.onValueChanged()
|
||||||
|
rotationSlider.onValueChanged()
|
||||||
|
|
||||||
|
-- создаем палитру цветов
|
||||||
|
hologram.setPaletteColor(1, 0xFFFFFF) -- снег
|
||||||
|
hologram.setPaletteColor(2, 0x221100) -- ствол
|
||||||
|
hologram.setPaletteColor(3, 0x005522) -- хвоя
|
||||||
|
|
||||||
|
-- задействуем алгоритм Брезенхэма для рисования кругов
|
||||||
|
local function cricle(x0, y, z0, R, i)
|
||||||
|
local x = R
|
||||||
|
local z = 0
|
||||||
|
local err = -R
|
||||||
|
while z <= x do
|
||||||
|
hologram.set(x + x0, y, z + z0, i)
|
||||||
|
hologram.set(z + x0, y, x + z0, i)
|
||||||
|
hologram.set(-x + x0, y, z + z0, i)
|
||||||
|
hologram.set(-z + x0, y, x + z0, i)
|
||||||
|
hologram.set(-x + x0, y, -z + z0, i)
|
||||||
|
hologram.set(-z + x0, y, -x + z0, i)
|
||||||
|
hologram.set(x + x0, y, -z + z0, i)
|
||||||
|
hologram.set(z + x0, y, -x + z0, i)
|
||||||
|
z = z + 1
|
||||||
|
if err <= 0 then
|
||||||
|
err = err + (2 * z + 1)
|
||||||
|
else
|
||||||
|
x = x - 1
|
||||||
|
err = err + (2 * (z - x) + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- отрисовываем основание ствола
|
||||||
|
for i = 1, 5 do
|
||||||
|
cricle(23, i, 23, tSpruce[i], 2)
|
||||||
|
cricle(23, i, 23, tSpruce[i]-1, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- отрисовываем хвою
|
||||||
|
for j = 5, #tSpruce do
|
||||||
|
cricle(23, j, 23, tSpruce[j]-1, 3)
|
||||||
|
cricle(23, j, 23, tSpruce[j]-2, 3)
|
||||||
|
end
|
||||||
@ -1 +0,0 @@
|
|||||||
Красивая новогодняя программа, написанная разработчиком Doob, сотворяющая атмосферу праздника в любом месте, где бы вы ни находились.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Красивая новогодняя программа, написанная разработчиком Doob, сотворяющая атмосферу праздника в любом месте, где бы вы ни находились.
|
|
||||||
@ -1,148 +0,0 @@
|
|||||||
local component = require("component")
|
|
||||||
local ecs = require("ECSAPI")
|
|
||||||
local hologram
|
|
||||||
local c = 23
|
|
||||||
|
|
||||||
-----------------------------------------------------------
|
|
||||||
|
|
||||||
if not component.isAvailable("hologram") then
|
|
||||||
ecs.error("Этой программе необходим голографический проектор 2 уровня.")
|
|
||||||
return
|
|
||||||
else
|
|
||||||
hologram = component.hologram
|
|
||||||
end
|
|
||||||
|
|
||||||
-----------------------------------------------------------
|
|
||||||
|
|
||||||
local data = ecs.universalWindow("auto", "auto", 36, 0x262626, true,
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", ecs.colors.orange, "Настройки анимации"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Selector", 0xFFFFFF, ecs.colors.orange, "Снегопад", "Легкий снежок", "Что-то сыпется", "Без осадков"},
|
|
||||||
{"Selector", 0xFFFFFF, ecs.colors.orange, "Легкое вращение", "Быстрое вращение", "Турбина", "Дюраселл", "Без вращения"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", ecs.colors.orange, "Размер елочки"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Slider", ecs.colors.white, ecs.colors.orange, 1, 100, 50, "", ""},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", ecs.colors.white, "Программа закрывается через"},
|
|
||||||
{"CenterText", ecs.colors.white, "CTRL + ALT + C"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Button", {ecs.colors.orange, 0xffffff, "OK"}, {0x999999, 0xffffff, "Отмена"}}
|
|
||||||
)
|
|
||||||
|
|
||||||
local snowMode, rotationMode, scale, buttonPress = data[1], data[2], data[3], data[4]
|
|
||||||
|
|
||||||
scale = scale * 4 / 100
|
|
||||||
|
|
||||||
if snowMode == "Снегопад" then
|
|
||||||
snowMode = 0
|
|
||||||
elseif snowMode == "Легкий снежок" then
|
|
||||||
snowMode = 0.2
|
|
||||||
elseif snowMode == "Что-то сыпется" then
|
|
||||||
snowMode = 0.5
|
|
||||||
end
|
|
||||||
|
|
||||||
if rotationMode == "Легкое вращение" then
|
|
||||||
rotationMode = 5
|
|
||||||
elseif rotationMode == "Быстрое вращение" then
|
|
||||||
rotationMode = 15
|
|
||||||
elseif rotationMode == "Турбина" then
|
|
||||||
rotationMode = 25
|
|
||||||
elseif rotationMode == "Дюраселл" then
|
|
||||||
rotationMode = 35
|
|
||||||
elseif rotationMode == "Без вращения" then
|
|
||||||
rotationMode = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
if buttonPress == "Отмена" then return end
|
|
||||||
|
|
||||||
-----------------------------------------------------------
|
|
||||||
|
|
||||||
-- создаем модель елки
|
|
||||||
local tSpruce = {3, 2, 2, 2, 2, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 4, 6, 8, 7, 6, 5, 4, 3, 6, 5, 4, 3, 2, 3, 2, 1}
|
|
||||||
|
|
||||||
-- создаем таблицу с падающими снежинками
|
|
||||||
local tSnow = {}
|
|
||||||
|
|
||||||
-- создаем палитру цветов
|
|
||||||
hologram.setPaletteColor(1, 0xFFFFFF) -- снег
|
|
||||||
hologram.setPaletteColor(2, 0x221100) -- ствол
|
|
||||||
hologram.setPaletteColor(3, 0x005522) -- хвоя
|
|
||||||
|
|
||||||
local function cricle(x0, y, z0, R, i) -- задействуем алгоритм Брезенхэма для рисования кругов
|
|
||||||
local x = R
|
|
||||||
local z = 0
|
|
||||||
local err = -R
|
|
||||||
while z <= x do
|
|
||||||
hologram.set(x + x0, y, z + z0, i)
|
|
||||||
hologram.set(z + x0, y, x + z0, i)
|
|
||||||
hologram.set(-x + x0, y, z + z0, i)
|
|
||||||
hologram.set(-z + x0, y, x + z0, i)
|
|
||||||
hologram.set(-x + x0, y, -z + z0, i)
|
|
||||||
hologram.set(-z + x0, y, -x + z0, i)
|
|
||||||
hologram.set(x + x0, y, -z + z0, i)
|
|
||||||
hologram.set(z + x0, y, -x + z0, i)
|
|
||||||
z = z + 1
|
|
||||||
if err <= 0 then
|
|
||||||
err = err + (2 * z + 1)
|
|
||||||
else
|
|
||||||
x = x - 1
|
|
||||||
err = err + (2 * (z - x) + 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function spruce() -- рисуем ель
|
|
||||||
for i = 1, 5 do
|
|
||||||
cricle(c, i, c, tSpruce[i], 2) -- отрисовываем основание ствола
|
|
||||||
cricle(c, i, c, tSpruce[i]-1, 2)
|
|
||||||
end
|
|
||||||
for j = 5, #tSpruce do
|
|
||||||
cricle(c, j, c, tSpruce[j]-1, 3) -- отрисовываем хвою
|
|
||||||
cricle(c, j, c, tSpruce[j]-2, 3)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function gen_snow() -- генерируем снежинку
|
|
||||||
local x, y, z = math.random(1, 46), 32, math.random(1, 46)
|
|
||||||
table.insert(tSnow,{x=x,y=y,z=z})
|
|
||||||
hologram.set(x, y, z, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function falling_snow() -- сдвигаем снежинки вниз
|
|
||||||
local i=1
|
|
||||||
while i<=#tSnow do
|
|
||||||
if tSnow[i].y>1 then
|
|
||||||
local x,y,z=tSnow[i].x+math.random(-1, 1), tSnow[i].y-1, tSnow[i].z+math.random(-1, 1)
|
|
||||||
if x<1 then x=1 end
|
|
||||||
if x>46 then x=46 end
|
|
||||||
if z<1 then z=1 end
|
|
||||||
if z>46 then z=46 end
|
|
||||||
c=hologram.get(x, y, z)
|
|
||||||
if c==0 or c==1 then
|
|
||||||
hologram.set(tSnow[i].x, tSnow[i].y, tSnow[i].z, 0)
|
|
||||||
tSnow[i].x, tSnow[i].y, tSnow[i].z=x,y,z
|
|
||||||
hologram.set(x, y, z, 1)
|
|
||||||
i=i+1
|
|
||||||
else
|
|
||||||
table.remove(tSnow,i)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
table.remove(tSnow,i)
|
|
||||||
end
|
|
||||||
os.sleep(snowMode)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ecs.info("auto", "auto", "", "Счастливого нового года!")
|
|
||||||
|
|
||||||
hologram.clear()
|
|
||||||
hologram.setScale(scale)
|
|
||||||
hologram.setRotationSpeed(rotationMode, 0, 23, 0)
|
|
||||||
|
|
||||||
spruce()
|
|
||||||
while 1 do
|
|
||||||
gen_snow()
|
|
||||||
falling_snow()
|
|
||||||
end
|
|
||||||
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
Программа для защиты вашего жилища от нежелательных гостей. При старте вы указываете желаемый пароль, а как только вы или ваш друг его корректно ввели, система автоматически вносит вас в список доверенных пользователей, так что вы сможете пользоваться биометрической защитой, не тратя время на ввод пароля. Крайне красивая и полезная программа.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Программа для защиты вашего жилища от нежелательных гостей. При старте вы указываете желаемый пароль, а как только вы или ваш друг его корректно ввели, система автоматически вносит вас в список доверенных пользователей, так что вы сможете пользоваться биометрической защитой, не тратя время на ввод пароля. Крайне красивая и полезная программа.
|
|
||||||
@ -1,276 +0,0 @@
|
|||||||
local rs
|
|
||||||
local component = require("component")
|
|
||||||
local gpu = component.gpu
|
|
||||||
local unicode = require("unicode")
|
|
||||||
local ecs = require("ECSAPI")
|
|
||||||
local sides = require("sides")
|
|
||||||
local event = require("event")
|
|
||||||
local fs = require("filesystem")
|
|
||||||
local serialization = require("serialization")
|
|
||||||
|
|
||||||
if not component.isAvailable("redstone") then
|
|
||||||
ecs.error("This program requires Redstone I/O block or Redstone Card to work.")
|
|
||||||
return
|
|
||||||
else
|
|
||||||
rs = component.redstone
|
|
||||||
end
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local colors = {
|
|
||||||
background = 0x202020,
|
|
||||||
borders = 0xFFDD00,
|
|
||||||
}
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local keyPad = {
|
|
||||||
{"1", "2", "3"},
|
|
||||||
{"4", "5", "6"},
|
|
||||||
{"7", "8", "9"},
|
|
||||||
{"*", "0", "#"},
|
|
||||||
}
|
|
||||||
|
|
||||||
local xSize, ySize
|
|
||||||
local buttons = {}
|
|
||||||
local biometry = {}
|
|
||||||
local input
|
|
||||||
|
|
||||||
local password = "12345"
|
|
||||||
|
|
||||||
local showPassword = true
|
|
||||||
local showKeyPresses = true
|
|
||||||
|
|
||||||
local nicknames = {
|
|
||||||
"IgorTimofeev"
|
|
||||||
}
|
|
||||||
|
|
||||||
local pathToConfig = "System/CodeDoor/Config.cfg"
|
|
||||||
local function saveConfig()
|
|
||||||
local file = io.open(pathToConfig, "w")
|
|
||||||
local massiv = {["password"] = password, ["nicknames"] = nicknames, ["showPassword"] = showPassword, ["showKeyPresses"] = showKeyPresses}
|
|
||||||
file:write(serialization.serialize(massiv))
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function loadConfig()
|
|
||||||
if fs.exists(pathToConfig) then
|
|
||||||
local massiv = {}
|
|
||||||
local file = io.open(pathToConfig, "r")
|
|
||||||
local stroka = file:read("*a")
|
|
||||||
massiv = serialization.unserialize(stroka)
|
|
||||||
file:close()
|
|
||||||
nicknames = massiv.nicknames
|
|
||||||
password = massiv.password
|
|
||||||
showPassword = massiv.showPassword
|
|
||||||
showKeyPresses = massiv.showKeyPresses
|
|
||||||
else
|
|
||||||
fs.makeDirectory(fs.path(pathToConfig))
|
|
||||||
local data = ecs.universalWindow("auto", "auto", 30, 0xEEEEEE, true, {"EmptyLine"}, {"CenterText", 0x880000, "Добро пожаловать в программу"}, {"CenterText", 0x880000, "конфигурации кодовой двери!"}, {"EmptyLine"}, {"CenterText", 0x262626, "Введите ваш пароль:"}, {"Input", 0x262626, 0x880000, "12345"}, {"EmptyLine"}, {"Switch", 0xF2B233, 0xffffff, 0x262626, "Показывать вводимый пароль", true}, {"EmptyLine"}, {"Switch", 0x3366CC, 0xffffff, 0x262626, "Показывать нажатие клавиш", true}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}})
|
|
||||||
if data[1] == "" or tonumber(data[1]) == nil then ecs.error("Указан неверный пароль. По умолчанию он будет 12345."); password = "12345" else password = data[1] end
|
|
||||||
showPassword = data[2]
|
|
||||||
showKeyPresses = data[3]
|
|
||||||
saveConfig()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawKeyPad(x, y)
|
|
||||||
local xPos, yPos = x, y
|
|
||||||
buttons = {}
|
|
||||||
for j = 1, #keyPad do
|
|
||||||
xPos = x
|
|
||||||
for i = 1, #keyPad[j] do
|
|
||||||
ecs.drawFramedButton(xPos, yPos, 5, 3, keyPad[j][i], colors.borders)
|
|
||||||
buttons[keyPad[j][i]] = {xPos, yPos, xPos + 4, yPos + 2}
|
|
||||||
xPos = xPos + 6
|
|
||||||
end
|
|
||||||
yPos = yPos + 3
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function visualScan(x, y, timing)
|
|
||||||
local yPos = y
|
|
||||||
gpu.setBackground(colors.background)
|
|
||||||
gpu.setForeground(colors.borders)
|
|
||||||
|
|
||||||
gpu.set(x, yPos, "╞══════════╡")
|
|
||||||
yPos = yPos - 1
|
|
||||||
os.sleep(timing)
|
|
||||||
|
|
||||||
for i = 1, 3 do
|
|
||||||
gpu.set(x, yPos, "╞══════════╡")
|
|
||||||
gpu.set(x, yPos + 1, "│ │")
|
|
||||||
yPos = yPos - 1
|
|
||||||
os.sleep(timing)
|
|
||||||
end
|
|
||||||
|
|
||||||
yPos = yPos + 2
|
|
||||||
|
|
||||||
for i = 1, 3 do
|
|
||||||
gpu.set(x, yPos, "╞══════════╡")
|
|
||||||
gpu.set(x, yPos - 1, "│ │")
|
|
||||||
yPos = yPos + 1
|
|
||||||
os.sleep(timing)
|
|
||||||
end
|
|
||||||
gpu.set(x, yPos - 1, "│ │")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function infoPanel(info, background, foreground, hideData)
|
|
||||||
ecs.square(1, 1, xSize, 3, background)
|
|
||||||
local text if hideData then
|
|
||||||
text = ecs.stringLimit("start", string.rep("*", unicode.len(info)), xSize - 4)
|
|
||||||
else
|
|
||||||
text = ecs.stringLimit("start", info, xSize - 4)
|
|
||||||
end
|
|
||||||
ecs.colorText(math.ceil(xSize / 2 - unicode.len(text) / 2) + 1 , 2, foreground, text)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawAll()
|
|
||||||
local xPos, yPos = 3, 5
|
|
||||||
|
|
||||||
--Как прописывать знаки типа © § ® ™
|
|
||||||
|
|
||||||
--кейпад
|
|
||||||
gpu.setBackground(colors.background)
|
|
||||||
drawKeyPad(xPos, yPos)
|
|
||||||
|
|
||||||
--Био
|
|
||||||
xPos = xPos + 18
|
|
||||||
ecs.border(xPos, yPos, 12, 6, colors.background, colors.borders)
|
|
||||||
ecs.square(xPos + 5, yPos + 2, 2, 2, colors.borders)
|
|
||||||
gpu.setBackground(colors.background)
|
|
||||||
biometry = {xPos, yPos, xPos + 11, yPos + 5}
|
|
||||||
|
|
||||||
--Био текст
|
|
||||||
yPos = yPos + 7
|
|
||||||
xPos = xPos + 1
|
|
||||||
gpu.set(xPos + 3, yPos, "ECS®")
|
|
||||||
gpu.set(xPos + 1, yPos + 1, "Security")
|
|
||||||
gpu.set(xPos + 1, yPos + 2, "Systems™")
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
local function checkNickname(name)
|
|
||||||
for i = 1, #nicknames do
|
|
||||||
if name == nicknames[i] then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function pressButton(x, y, name)
|
|
||||||
ecs.square(x, y, 5, 3, colors.borders)
|
|
||||||
gpu.setForeground(colors.background)
|
|
||||||
gpu.set(x + 2, y + 1, name)
|
|
||||||
os.sleep(0.2)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function waitForExit()
|
|
||||||
local e2 = {event.pull(3, "touch")}
|
|
||||||
if #e2 > 0 then
|
|
||||||
if ecs.clickedAtArea(e2[3], e2[4], buttons["*"][1], buttons["*"][2], buttons["*"][3], buttons["*"][4]) then
|
|
||||||
pressButton(buttons["*"][1], buttons["*"][2], "*")
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function redstone(go)
|
|
||||||
if go then
|
|
||||||
rs.setOutput(sides.top, 15)
|
|
||||||
local goexit = waitForExit()
|
|
||||||
rs.setOutput(sides.top, 0)
|
|
||||||
rs.setOutput(sides.bottom, 0)
|
|
||||||
return goexit
|
|
||||||
else
|
|
||||||
rs.setOutput(sides.bottom, 15)
|
|
||||||
os.sleep(2)
|
|
||||||
rs.setOutput(sides.top, 0)
|
|
||||||
rs.setOutput(sides.bottom, 0)
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ecs.prepareToExit(colors.background)
|
|
||||||
loadConfig()
|
|
||||||
|
|
||||||
local oldWidth, oldHeight = gpu.getResolution()
|
|
||||||
gpu.setResolution(34, 17)
|
|
||||||
xSize, ySize = 34, 17
|
|
||||||
|
|
||||||
drawAll()
|
|
||||||
infoPanel("Введите пароль", colors.borders, colors.background)
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull()}
|
|
||||||
if e[1] == "touch" then
|
|
||||||
for key in pairs(buttons) do
|
|
||||||
if ecs.clickedAtArea(e[3], e[4], buttons[key][1], buttons[key][2], buttons[key][3], buttons[key][4]) then
|
|
||||||
|
|
||||||
if showKeyPresses then
|
|
||||||
pressButton(buttons[key][1], buttons[key][2], key)
|
|
||||||
end
|
|
||||||
|
|
||||||
if key == "*" then
|
|
||||||
input = nil
|
|
||||||
infoPanel("Поле ввода очищено", colors.borders, colors.background)
|
|
||||||
elseif key == "#" then
|
|
||||||
drawAll()
|
|
||||||
if input == password then
|
|
||||||
infoPanel("Доступ разрешён!", ecs.colors.green, 0xFFFFFF)
|
|
||||||
local goexit = redstone(true)
|
|
||||||
for i = 1, #nicknames do
|
|
||||||
if nicknames[i] == e[6] then nicknames[i] = nil end
|
|
||||||
end
|
|
||||||
table.insert(nicknames, e[6])
|
|
||||||
saveConfig()
|
|
||||||
|
|
||||||
if goexit then
|
|
||||||
ecs.prepareToExit()
|
|
||||||
gpu.setResolution(oldWidth, oldHeight)
|
|
||||||
ecs.prepareToExit()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
else
|
|
||||||
infoPanel("Доступ запрещён!", ecs.colors.red, 0xFFFFFF)
|
|
||||||
redstone(false)
|
|
||||||
end
|
|
||||||
infoPanel("Введите пароль", colors.borders, colors.background)
|
|
||||||
input = nil
|
|
||||||
else
|
|
||||||
input = (input or "") .. key
|
|
||||||
|
|
||||||
infoPanel(input, colors.borders, colors.background, not showPassword)
|
|
||||||
end
|
|
||||||
drawAll()
|
|
||||||
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if ecs.clickedAtArea(e[3], e[4], biometry[1], biometry[2], biometry[3], biometry[4]) then
|
|
||||||
visualScan(biometry[1], biometry[2] + 4, 0.08)
|
|
||||||
if checkNickname(e[6]) then
|
|
||||||
infoPanel("Привет, " .. e[6], ecs.colors.green, 0xFFFFFF)
|
|
||||||
redstone(true)
|
|
||||||
else
|
|
||||||
infoPanel("В доступе отказано!", ecs.colors.red, 0xFFFFFF)
|
|
||||||
redstone(false)
|
|
||||||
end
|
|
||||||
infoPanel("Введите пароль", colors.borders, colors.background)
|
|
||||||
drawAll()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
BIN
Applications/Control.app/Icon.pic
Normal file
BIN
Applications/Control.app/Icon.pic
Normal file
Binary file not shown.
58
Applications/Control.app/Main.lua
Normal file
58
Applications/Control.app/Main.lua
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
local image = require("Image")
|
||||||
|
local screen = require("Screen")
|
||||||
|
local GUI = require("GUI")
|
||||||
|
local filesystem = require("Filesystem")
|
||||||
|
local paths = require("Paths")
|
||||||
|
local system = require("System")
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local currentScriptDirectory = filesystem.path(system.getCurrentScript())
|
||||||
|
local modulesPath = currentScriptDirectory .. "Modules/"
|
||||||
|
local localization = system.getLocalization(currentScriptDirectory .. "Localizations/")
|
||||||
|
|
||||||
|
local workspace, window = system.addWindow(GUI.tabbedWindow(1, 1, 80, 25))
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
window.contentContainer = window:addChild(GUI.container(1, 4, window.width, window.height - 3))
|
||||||
|
|
||||||
|
local function loadModules()
|
||||||
|
local fileList = filesystem.list(modulesPath)
|
||||||
|
for i = 1, #fileList do
|
||||||
|
if filesystem.extension(fileList[i]) == ".lua" then
|
||||||
|
local loadedFile, reason = loadfile(modulesPath .. fileList[i])
|
||||||
|
if loadedFile then
|
||||||
|
local pcallSuccess, reason = pcall(loadedFile, workspace, window, localization)
|
||||||
|
if pcallSuccess then
|
||||||
|
window.tabBar:addItem(reason.name).onTouch = function()
|
||||||
|
reason.onTouch()
|
||||||
|
workspace:draw()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
error("Failed to call loaded module \"" .. tostring(fileList[i]) .. "\": " .. tostring(reason))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
error("Failed to load module \"" .. tostring(fileList[i]) .. "\": " .. tostring(reason))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
window.onResize = function(width, height)
|
||||||
|
window.tabBar.width = width
|
||||||
|
window.backgroundPanel.width = width
|
||||||
|
window.backgroundPanel.height = height - 3
|
||||||
|
window.contentContainer.width = width
|
||||||
|
window.contentContainer.height = window.backgroundPanel.height
|
||||||
|
|
||||||
|
window.tabBar:getItem(window.tabBar.selectedItem).onTouch()
|
||||||
|
end
|
||||||
|
|
||||||
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
loadModules()
|
||||||
|
window.onResize(80, 25)
|
||||||
|
|
||||||
|
|
||||||
@ -1,16 +1,12 @@
|
|||||||
|
|
||||||
local args = {...}
|
local args = {...}
|
||||||
local application, window, localization = args[1], args[2], args[3]
|
local workspace, window, localization = args[1], args[2], args[3]
|
||||||
|
|
||||||
require("advancedLua")
|
|
||||||
local component = require("component")
|
|
||||||
local computer = require("computer")
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local buffer = require("doubleBuffering")
|
local screen = require("Screen")
|
||||||
local image = require("image")
|
local image = require("Image")
|
||||||
local MineOSPaths = require("MineOSPaths")
|
local paths = require("Paths")
|
||||||
local MineOSInterface = require("MineOSInterface")
|
local text = require("Text")
|
||||||
local unicode = require("unicode")
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -22,9 +18,6 @@ module.name = localization.moduleLua
|
|||||||
module.onTouch = function()
|
module.onTouch = function()
|
||||||
window.contentContainer:removeChildren()
|
window.contentContainer:removeChildren()
|
||||||
|
|
||||||
_G.component = require("component")
|
|
||||||
_G.computer = require("computer")
|
|
||||||
|
|
||||||
local textBox = window.contentContainer:addChild(GUI.textBox(1, 1, window.contentContainer.width, window.contentContainer.height - 3, nil, 0x444444, localization.luaInfo, 1, 2, 1))
|
local textBox = window.contentContainer:addChild(GUI.textBox(1, 1, window.contentContainer.width, window.contentContainer.height - 3, nil, 0x444444, localization.luaInfo, 1, 2, 1))
|
||||||
textBox.scrollBarEnabled = true
|
textBox.scrollBarEnabled = true
|
||||||
|
|
||||||
@ -33,7 +26,7 @@ module.onTouch = function()
|
|||||||
|
|
||||||
input.textDrawMethod = function(x, y, color, text)
|
input.textDrawMethod = function(x, y, color, text)
|
||||||
if text == placeholder then
|
if text == placeholder then
|
||||||
buffer.drawText(x, y, color, text)
|
screen.drawText(x, y, color, text)
|
||||||
else
|
else
|
||||||
GUI.highlightString(x, y, input.width - 2, 1, 2, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, text)
|
GUI.highlightString(x, y, input.width - 2, 1, 2, GUI.LUA_SYNTAX_PATTERNS, GUI.LUA_SYNTAX_COLOR_SCHEME, text)
|
||||||
end
|
end
|
||||||
@ -41,7 +34,7 @@ module.onTouch = function()
|
|||||||
|
|
||||||
local function add(data, color)
|
local function add(data, color)
|
||||||
for line in data:gmatch("[^\n]+") do
|
for line in data:gmatch("[^\n]+") do
|
||||||
local wrappedLine = string.wrap(line, textBox.textWidth)
|
local wrappedLine = text.wrap(line, textBox.textWidth)
|
||||||
for i = 1, #wrappedLine do
|
for i = 1, #wrappedLine do
|
||||||
table.insert(textBox.lines, color and {color = color, text = wrappedLine[i]} or wrappedLine[i])
|
table.insert(textBox.lines, color and {color = color, text = wrappedLine[i]} or wrappedLine[i])
|
||||||
end
|
end
|
||||||
@ -61,7 +54,7 @@ module.onTouch = function()
|
|||||||
local args = {...}
|
local args = {...}
|
||||||
for i = 1, #args do
|
for i = 1, #args do
|
||||||
if type(args[i]) == "table" then
|
if type(args[i]) == "table" then
|
||||||
args[i] = table.toString(args[i], true, 2, false, 2)
|
args[i] = text.serialize(args[i], true, 2, false, 2)
|
||||||
else
|
else
|
||||||
args[i] = tostring(args[i])
|
args[i] = tostring(args[i])
|
||||||
end
|
end
|
||||||
@ -1,23 +1,20 @@
|
|||||||
|
|
||||||
local args = {...}
|
local args = {...}
|
||||||
local application, window, localization = args[1], args[2], args[3]
|
local workspace, window, localization = args[1], args[2], args[3]
|
||||||
|
|
||||||
require("advancedLua")
|
|
||||||
local component = require("component")
|
|
||||||
local computer = require("computer")
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local buffer = require("doubleBuffering")
|
local screen = require("Screen")
|
||||||
local image = require("image")
|
local image = require("Image")
|
||||||
local MineOSPaths = require("MineOSPaths")
|
local paths = require("Paths")
|
||||||
local MineOSInterface = require("MineOSInterface")
|
local number = require("Number")
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
module.name = localization.moduleDisk
|
module.name = localization.moduleDisk
|
||||||
|
|
||||||
local HDDImage = image.load(MineOSPaths.icons .. "HDD.pic")
|
local HDDImage = image.load(paths.system.icons .. "HDD.pic")
|
||||||
local floppyImage = image.load(MineOSPaths.icons .. "Floppy.pic")
|
local floppyImage = image.load(paths.system.icons .. "Floppy.pic")
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -25,17 +22,19 @@ module.onTouch = function()
|
|||||||
window.contentContainer:removeChildren()
|
window.contentContainer:removeChildren()
|
||||||
local container = window.contentContainer:addChild(GUI.container(1, 1, window.contentContainer.width, window.contentContainer.height))
|
local container = window.contentContainer:addChild(GUI.container(1, 1, window.contentContainer.width, window.contentContainer.height))
|
||||||
|
|
||||||
|
local eeprom = component.proxy(component.list("eeprom")())
|
||||||
|
|
||||||
local y = 2
|
local y = 2
|
||||||
for address in component.list("filesystem") do
|
for address in component.list("filesystem") do
|
||||||
local proxy = component.proxy(address)
|
local proxy = component.proxy(address)
|
||||||
local isBoot = computer.getBootAddress() == proxy.address
|
local isBoot = eeprom.getData() == proxy.address
|
||||||
local isReadOnly = proxy.isReadOnly()
|
local isReadOnly = proxy.isReadOnly()
|
||||||
|
|
||||||
local diskContainer = container:addChild(GUI.container(1, y, container.width, 4))
|
local diskContainer = container:addChild(GUI.container(1, y, container.width, 4))
|
||||||
|
|
||||||
local button = diskContainer:addChild(GUI.adaptiveRoundedButton(1, 3, 2, 0, 0x2D2D2D, 0xE1E1E1, 0x0, 0xE1E1E1, localization.options))
|
local button = diskContainer:addChild(GUI.adaptiveRoundedButton(1, 3, 2, 0, 0x2D2D2D, 0xE1E1E1, 0x0, 0xE1E1E1, localization.options))
|
||||||
button.onTouch = function()
|
button.onTouch = function()
|
||||||
local container = MineOSInterface.addBackgroundContainer(application, localization.options)
|
local container = system.addBackgroundContainer(workspace, localization.options)
|
||||||
local inputField = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, proxy.getLabel() or "", localization.diskLabel))
|
local inputField = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x666666, 0x666666, 0xE1E1E1, 0x2D2D2D, proxy.getLabel() or "", localization.diskLabel))
|
||||||
inputField.onInputFinished = function()
|
inputField.onInputFinished = function()
|
||||||
if inputField.text and inputField.text:len() > 0 then
|
if inputField.text and inputField.text:len() > 0 then
|
||||||
@ -61,14 +60,14 @@ module.onTouch = function()
|
|||||||
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0xBBBBBB, localization.bootable .. ":", isBoot)).switch
|
local switch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x1E1E1E, 0xE1E1E1, 0xBBBBBB, localization.bootable .. ":", isBoot)).switch
|
||||||
switch.onStateChanged = function()
|
switch.onStateChanged = function()
|
||||||
if switch.state then
|
if switch.state then
|
||||||
computer.setBootAddress(proxy.address)
|
eeprom.setData(proxy.address)
|
||||||
|
|
||||||
container:remove()
|
container:remove()
|
||||||
module.onTouch()
|
module.onTouch()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
button.localX = diskContainer.width - button.width - 1
|
button.localX = diskContainer.width - button.width - 1
|
||||||
|
|
||||||
@ -80,19 +79,19 @@ module.onTouch = function()
|
|||||||
diskContainer:addChild(GUI.image(3, 1, isReadOnly and floppyImage or HDDImage))
|
diskContainer:addChild(GUI.image(3, 1, isReadOnly and floppyImage or HDDImage))
|
||||||
diskContainer:addChild(GUI.label(x, 1, width, 1, 0x2D2D2D, (proxy.getLabel() or "Unknown") .. " (" .. (isBoot and (localization.bootable .. ", ") or "") .. proxy.address .. ")"))
|
diskContainer:addChild(GUI.label(x, 1, width, 1, 0x2D2D2D, (proxy.getLabel() or "Unknown") .. " (" .. (isBoot and (localization.bootable .. ", ") or "") .. proxy.address .. ")"))
|
||||||
diskContainer:addChild(GUI.progressBar(x, 3, width, 0x66DB80, 0xD2D2D2, 0xD2D2D2, spaceUsed / spaceTotal * 100, true))
|
diskContainer:addChild(GUI.progressBar(x, 3, width, 0x66DB80, 0xD2D2D2, 0xD2D2D2, spaceUsed / spaceTotal * 100, true))
|
||||||
diskContainer:addChild(GUI.label(x, 4, width, 1, 0xBBBBBB, localization.free .. " " .. math.roundToDecimalPlaces((spaceTotal - spaceUsed) / 1024 / 1024, 2) .. " MB " .. localization.of .. " " .. math.roundToDecimalPlaces(spaceTotal / 1024 / 1024, 2) .. " MB")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
diskContainer:addChild(GUI.label(x, 4, width, 1, 0xBBBBBB, localization.free .. " " .. number.roundToDecimalPlaces((spaceTotal - spaceUsed) / 1024 / 1024, 2) .. " MB " .. localization.of .. " " .. number.roundToDecimalPlaces(spaceTotal / 1024 / 1024, 2) .. " MB")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
||||||
|
|
||||||
y = y + diskContainer.height + 1
|
y = y + diskContainer.height + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
container.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
container.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
|
||||||
if e1 == "scroll" then
|
if e1 == "scroll" then
|
||||||
if e5 < 0 or container.children[1].localY < 2 then
|
if e5 < 0 or container.children[1].localY < 2 then
|
||||||
for i = 1, #container.children do
|
for i = 1, #container.children do
|
||||||
container.children[i].localY = container.children[i].localY + e5
|
container.children[i].localY = container.children[i].localY + e5
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
elseif e1 == "component_added" or e1 == "component_removed" and e3 == "filesystem" then
|
elseif e1 == "component_added" or e1 == "component_removed" and e3 == "filesystem" then
|
||||||
module.onTouch()
|
module.onTouch()
|
||||||
@ -1,16 +1,12 @@
|
|||||||
|
|
||||||
local args = {...}
|
local args = {...}
|
||||||
local application, window, localization = args[1], args[2], args[3]
|
local workspace, window, localization = args[1], args[2], args[3]
|
||||||
|
|
||||||
require("advancedLua")
|
|
||||||
local component = require("component")
|
|
||||||
local computer = require("computer")
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local buffer = require("doubleBuffering")
|
local screen = require("Screen")
|
||||||
local image = require("image")
|
local image = require("Image")
|
||||||
local MineOSPaths = require("MineOSPaths")
|
local paths = require("Paths")
|
||||||
local MineOSInterface = require("MineOSInterface")
|
local text = require("Text")
|
||||||
local unicode = require("unicode")
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -76,8 +72,8 @@ module.onTouch = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function out(text)
|
local function out(t)
|
||||||
local wrappedLines = string.wrap(text, outputTextBox.width - 2)
|
local wrappedLines = text.wrap(t, outputTextBox.width - 2)
|
||||||
for i = 1, #wrappedLines do
|
for i = 1, #wrappedLines do
|
||||||
table.insert(outputTextBox.lines, wrappedLines[i])
|
table.insert(outputTextBox.lines, wrappedLines[i])
|
||||||
end
|
end
|
||||||
@ -114,7 +110,7 @@ module.onTouch = function()
|
|||||||
local success, reason = pcall(success, tree.selectedItem.value)
|
local success, reason = pcall(success, tree.selectedItem.value)
|
||||||
if success then
|
if success then
|
||||||
if type(reason) == "table" then
|
if type(reason) == "table" then
|
||||||
local serialized = table.toString(reason, true, 2, false, 3)
|
local serialized = text.serialize(reason, true, 2, false, 3)
|
||||||
for line in serialized:gmatch("[^\n]+") do
|
for line in serialized:gmatch("[^\n]+") do
|
||||||
out(line)
|
out(line)
|
||||||
end
|
end
|
||||||
@ -128,7 +124,7 @@ module.onTouch = function()
|
|||||||
out("Failed to load string \"" .. data .. "\": " .. reason)
|
out("Failed to load string \"" .. data .. "\": " .. reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -1,15 +1,12 @@
|
|||||||
|
|
||||||
local args = {...}
|
local args = {...}
|
||||||
local application, window, localization = args[1], args[2], args[3]
|
local workspace, window, localization = args[1], args[2], args[3]
|
||||||
|
|
||||||
require("advancedLua")
|
|
||||||
local component = require("component")
|
|
||||||
local computer = require("computer")
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local buffer = require("doubleBuffering")
|
local screen = require("Screen")
|
||||||
local image = require("image")
|
local image = require("Image")
|
||||||
local MineOSPaths = require("MineOSPaths")
|
local paths = require("Paths")
|
||||||
local MineOSInterface = require("MineOSInterface")
|
local text = require("Text")
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -30,17 +27,17 @@ module.onTouch = function()
|
|||||||
local textBox = layout:addChild(GUI.textBox(1, 1, container.width - 4, container.height - 4, nil, 0x888888, {localization.waitingEvents .. "..."}, 1, 0, 0))
|
local textBox = layout:addChild(GUI.textBox(1, 1, container.width - 4, container.height - 4, nil, 0x888888, {localization.waitingEvents .. "..."}, 1, 0, 0))
|
||||||
local switch = layout:addChild(GUI.switchAndLabel(1, 1, 27, 6, 0x66DB80, 0x1E1E1E, 0xFFFFFF, 0x2D2D2D, localization.processingEnabled .. ": ", true)).switch
|
local switch = layout:addChild(GUI.switchAndLabel(1, 1, 27, 6, 0x66DB80, 0x1E1E1E, 0xFFFFFF, 0x2D2D2D, localization.processingEnabled .. ": ", true)).switch
|
||||||
|
|
||||||
textBox.eventHandler = function(application, object, ...)
|
textBox.eventHandler = function(workspace, object, ...)
|
||||||
local eventData = {...}
|
local eventData = {...}
|
||||||
if switch.state and eventData[1] then
|
if switch.state and eventData[1] then
|
||||||
local lines = table.concat(eventData, " ")
|
local lines = table.concat(eventData, " ")
|
||||||
lines = string.wrap(lines, textBox.width)
|
lines = text.wrap(lines, textBox.width)
|
||||||
for i = 1, #lines do
|
for i = 1, #lines do
|
||||||
table.insert(textBox.lines, lines[i])
|
table.insert(textBox.lines, lines[i])
|
||||||
end
|
end
|
||||||
textBox:scrollToEnd()
|
textBox:scrollToEnd()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Binary file not shown.
@ -1,61 +0,0 @@
|
|||||||
|
|
||||||
require("advancedLua")
|
|
||||||
local component = require("component")
|
|
||||||
local computer = require("computer")
|
|
||||||
local image = require("image")
|
|
||||||
local buffer = require("doubleBuffering")
|
|
||||||
local GUI = require("GUI")
|
|
||||||
local fs = require("filesystem")
|
|
||||||
local unicode = require("unicode")
|
|
||||||
local MineOSPaths = require("MineOSPaths")
|
|
||||||
local MineOSCore = require("MineOSCore")
|
|
||||||
local MineOSInterface = require("MineOSInterface")
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local resourcesPath = MineOSCore.getCurrentScriptDirectory()
|
|
||||||
local modulesPath = resourcesPath .. "Modules/"
|
|
||||||
local localization = MineOSCore.getLocalization(resourcesPath .. "Localizations/")
|
|
||||||
|
|
||||||
local application, window = MineOSInterface.addWindow(GUI.tabbedWindow(1, 1, 80, 25))
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
window.contentContainer = window:addChild(GUI.container(1, 4, window.width, window.height - 3))
|
|
||||||
|
|
||||||
local function loadModules()
|
|
||||||
local fileList = fs.sortedList(modulesPath, "name", false)
|
|
||||||
for i = 1, #fileList do
|
|
||||||
local loadedFile, reason = loadfile(modulesPath .. fileList[i])
|
|
||||||
if loadedFile then
|
|
||||||
local pcallSuccess, reason = pcall(loadedFile, application, window, localization)
|
|
||||||
if pcallSuccess then
|
|
||||||
window.tabBar:addItem(reason.name).onTouch = function()
|
|
||||||
reason.onTouch()
|
|
||||||
MineOSInterface.application:draw()
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error("Failed to call loaded module \"" .. tostring(fileList[i]) .. "\": " .. tostring(reason))
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error("Failed to load module \"" .. tostring(fileList[i]) .. "\": " .. tostring(reason))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
window.onResize = function(width, height)
|
|
||||||
window.tabBar.width = width
|
|
||||||
window.backgroundPanel.width = width
|
|
||||||
window.backgroundPanel.height = height - 3
|
|
||||||
window.contentContainer.width = width
|
|
||||||
window.contentContainer.height = window.backgroundPanel.height
|
|
||||||
|
|
||||||
window.tabBar:getItem(window.tabBar.selectedItem).onTouch()
|
|
||||||
end
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
loadModules()
|
|
||||||
window.onResize(80, 25)
|
|
||||||
|
|
||||||
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Программа для автоматического решения кроссворда, где вам необходимо искать среди букв указанные слова. Сам файл кроссворда располагается в папке приложения.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Программа для автоматического решения кроссворда, где вам необходимо искать среди букв указанные слова. Сам файл кроссворда располагается в папке приложения.
|
|
||||||
@ -1,294 +0,0 @@
|
|||||||
local component = require("component")
|
|
||||||
local term = require("term")
|
|
||||||
local unicode = require("unicode")
|
|
||||||
local event = require("event")
|
|
||||||
local fs = require("filesystem")
|
|
||||||
local ecs = require("ECSAPI")
|
|
||||||
local gpu = component.gpu
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local arg = {...}
|
|
||||||
|
|
||||||
local crossword = {}
|
|
||||||
local keyWords = {}
|
|
||||||
local keyWordsColors = {}
|
|
||||||
|
|
||||||
local temporaryWordTrace = {}
|
|
||||||
local globalWordTrace = {}
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local function readFile(path)
|
|
||||||
--ЧИТАЕМ И ЗАПОЛНЯЕМ МАССИВ
|
|
||||||
local lines = {}
|
|
||||||
local f = io.open(path, "r")
|
|
||||||
while true do
|
|
||||||
local line = f:read("*l")
|
|
||||||
if line then
|
|
||||||
table.insert(lines, unicode.upper(line))
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
return lines
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function getCrosswordFromFile(pathToCrossword)
|
|
||||||
|
|
||||||
--ЧИТАЕМ ФАЙЛ КРОССВОРДА
|
|
||||||
local readedCrossword = readFile(pathToCrossword)
|
|
||||||
|
|
||||||
--ЕСЛИ ПЕРВАЯ ФРАЗА В ФАЙЛЕ НЕ РАВНА НУЖНОЙ, ТО КИНУТЬ ОШИБКУ, А ТО МАЛО ЛИ
|
|
||||||
if readedCrossword[1] ~= "--КРОССВОРД" then ecs.error("Ошибка чтения файла кроссворда: скорее всего, он хуево составлен. Давай заново.") end
|
|
||||||
|
|
||||||
--ПАРСИМ КРОССВОРД НА БУКОВКИ
|
|
||||||
local keyWordsStarted = false
|
|
||||||
for i = 2, #readedCrossword do
|
|
||||||
--ЕСЛИ НАЙДЕНА ФРАЗА НУЖНАЯ, ТО ВКЛЮЧИТЬ РЕЖИМ ЧТЕНИЯ КЛЮЧЕВЫХ СЛОВ
|
|
||||||
if readedCrossword[i] == "--КЛЮЧЕВЫЕ СЛОВА" then
|
|
||||||
keyWordsStarted = true
|
|
||||||
end
|
|
||||||
--ВЫБОР МЕЖДУ РЕЖИМАМИ КРОССВОРДА И КЛЮЧЕВЫХ СЛОВ
|
|
||||||
if not keyWordsStarted then
|
|
||||||
local position = #crossword + 1
|
|
||||||
crossword[position] = {}
|
|
||||||
for j = 1, unicode.len( readedCrossword[i] ) do
|
|
||||||
crossword[position][j] = { unicode.sub(readedCrossword[i], j, j) }
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local yPos = i + 1
|
|
||||||
if readedCrossword[yPos] then
|
|
||||||
local position = #keyWords + 1
|
|
||||||
keyWords[position] = {}
|
|
||||||
for j = 1, unicode.len( readedCrossword[yPos] ) do
|
|
||||||
table.insert( keyWords[position], unicode.sub(readedCrossword[yPos], j, j) )
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawCrossword(x, y, background, foreground, xSpaceBetween, ySpaceBetween)
|
|
||||||
|
|
||||||
--ЗАДАНИЕ СТАРТОВЫХ АРГУМЕНТОВ, А ТО МАЛО ЛИ ЧЁ
|
|
||||||
x = x or 1
|
|
||||||
y = y or 1
|
|
||||||
|
|
||||||
background = background or 0xffffff
|
|
||||||
foreground = foreground or 0x000000
|
|
||||||
|
|
||||||
local barsColor = 0xaaaaaa
|
|
||||||
local barsTextColor = 0xffffff
|
|
||||||
|
|
||||||
xSpaceBetween = 3
|
|
||||||
ySpaceBetween = 1
|
|
||||||
|
|
||||||
--КОРРЕКЦИЯ КООРДИНАТ
|
|
||||||
local xPos = x
|
|
||||||
local yPos = y
|
|
||||||
|
|
||||||
--РИСУЕМ РЯДЫ
|
|
||||||
ecs.square(xPos, yPos, xSpaceBetween + #crossword[1] + xSpaceBetween * #crossword[1] - 1, 1, barsColor)
|
|
||||||
ecs.square(xPos, yPos, 2, ySpaceBetween + #crossword + ySpaceBetween * #crossword, barsColor)
|
|
||||||
|
|
||||||
xPos = x + xSpaceBetween + 1
|
|
||||||
yPos = yPos + ySpaceBetween + 1
|
|
||||||
|
|
||||||
--РИСУЕМ САМ КРОССВОРД
|
|
||||||
|
|
||||||
for i = 1, #crossword do
|
|
||||||
|
|
||||||
for j = 1, #crossword[i] do
|
|
||||||
local cvet1 = background
|
|
||||||
local cvet2 = foreground
|
|
||||||
if crossword[i][j][2] then
|
|
||||||
cvet1 = crossword[i][j][2]
|
|
||||||
cvet2 = 0xffffff - cvet1
|
|
||||||
end
|
|
||||||
|
|
||||||
gpu.setBackground(cvet1)
|
|
||||||
gpu.setForeground(cvet2)
|
|
||||||
|
|
||||||
gpu.set(xPos, yPos, crossword[i][j][1])
|
|
||||||
|
|
||||||
--РИСУЕМ ТЕКСТ НА ПОЛОСОЧКАХ С НОМЕРАМИ
|
|
||||||
gpu.setForeground(barsTextColor)
|
|
||||||
gpu.setBackground(barsColor)
|
|
||||||
|
|
||||||
gpu.set(xPos, y, tostring(j))
|
|
||||||
gpu.set(x, yPos, tostring(i))
|
|
||||||
|
|
||||||
xPos = xPos + xSpaceBetween + 1
|
|
||||||
--event.pull("key_down")
|
|
||||||
end
|
|
||||||
xPos = x + xSpaceBetween + 1
|
|
||||||
yPos = yPos + ySpaceBetween + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
--СЛОВЕЧКИ РИСУЕМ
|
|
||||||
|
|
||||||
gpu.setBackground(background)
|
|
||||||
gpu.setForeground(foreground)
|
|
||||||
|
|
||||||
--ЛИНИЮ РИСУЕМ
|
|
||||||
xPos = x + xSpaceBetween
|
|
||||||
gpu.set(1, yPos, string.rep("-", 100))
|
|
||||||
yPos = yPos + ySpaceBetween + 1
|
|
||||||
|
|
||||||
for i = 1, #keyWords do
|
|
||||||
|
|
||||||
local color1, color2 = background, foreground
|
|
||||||
if keyWordsColors[i] then color1 = keyWordsColors[i]; color2 = 0xffffff - color1 end
|
|
||||||
|
|
||||||
local slovo = ""
|
|
||||||
for j = 1, #keyWords[i] do
|
|
||||||
slovo = slovo .. keyWords[i][j]
|
|
||||||
end
|
|
||||||
|
|
||||||
gpu.setBackground(color1)
|
|
||||||
gpu.setForeground(color2)
|
|
||||||
|
|
||||||
gpu.set(xPos, yPos, slovo)
|
|
||||||
--ecs.error("Слово = "..slovo)
|
|
||||||
|
|
||||||
yPos = yPos + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function findWord(x, y, wordCyka, uspeh )
|
|
||||||
|
|
||||||
if #wordCyka <= 1 then return uspeh end
|
|
||||||
|
|
||||||
local word = {}
|
|
||||||
for i = 1, #wordCyka do
|
|
||||||
word[i] = wordCyka[i]
|
|
||||||
end
|
|
||||||
|
|
||||||
uspeh = false
|
|
||||||
|
|
||||||
table.remove(word, 1)
|
|
||||||
|
|
||||||
--ecs.error("#wordCyka="..#wordCyka..", #word="..#word)
|
|
||||||
|
|
||||||
--ecs.error("Рассматриваю х="..x..", y="..y..", word[1]="..word[1]..", xOtkuda="..xOtkuda..", yOtkuda="..yOtkuda)
|
|
||||||
|
|
||||||
local function cyka(xMod, yMod)
|
|
||||||
--ecs.error(word[1] .." ".. crossword[y + yMod][x + xMod][1])
|
|
||||||
if word[1] == crossword[y + yMod][x + xMod][1] and not uspeh then
|
|
||||||
--ecs.error("Смотрю на ("..x..","..y..","..crossword[y][x][1].."), ищу вокруг букву \""..word[1].."\", #свет="..#temporaryWordTrace)
|
|
||||||
|
|
||||||
uspeh = true
|
|
||||||
table.insert(temporaryWordTrace, {xMod, yMod})
|
|
||||||
|
|
||||||
uspeh = findWord( x + xMod, y + yMod, word, uspeh )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if crossword[y - 1] then cyka(0, -1) end
|
|
||||||
if crossword[y][x + 1] then cyka(1, 0) end
|
|
||||||
if crossword[y + 1] then cyka(0, 1) end
|
|
||||||
if crossword[y][x - 1] then cyka(-1, 0) end
|
|
||||||
|
|
||||||
--УБИРАЕМ ЭЛЕМЕНТИК ИЗ ПОДСВЕТКИ
|
|
||||||
if not uspeh then temporaryWordTrace[#temporaryWordTrace] = nil end
|
|
||||||
|
|
||||||
--ecs.error("Успех в конце = "..tostring(uspeh))
|
|
||||||
return uspeh
|
|
||||||
end
|
|
||||||
|
|
||||||
local function trace(massivSuda)
|
|
||||||
local nomerSlova, x, y, track = massivSuda[1], massivSuda[2], massivSuda[3], massivSuda[4]
|
|
||||||
|
|
||||||
local color = math.random(0x000000, 0xffffff)
|
|
||||||
--ecs.error("x="..x..", y="..y)
|
|
||||||
|
|
||||||
keyWordsColors[nomerSlova] = color
|
|
||||||
|
|
||||||
crossword[y][x][2] = color
|
|
||||||
|
|
||||||
for i = 1, #track do
|
|
||||||
x = x + track[i][1]
|
|
||||||
y = y + track[i][2]
|
|
||||||
|
|
||||||
crossword[y][x][2] = color
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function reshitCrossword()
|
|
||||||
for ySimvol = 1, #crossword do
|
|
||||||
for xSimvol = 1, #crossword[ySimvol] do
|
|
||||||
|
|
||||||
local yKeyWord = 1
|
|
||||||
while yKeyWord <= #keyWords do
|
|
||||||
|
|
||||||
--ЕСЛИ ПЕРВАЯ БУКВА КЛЮЧЕВОГО СЛОВА РАВНА СИМВОЛУ РАССМАТРИВАЕМОМУ
|
|
||||||
if keyWords[yKeyWord][1] == crossword[ySimvol][xSimvol][1] then
|
|
||||||
|
|
||||||
--ДУБЛИРОВАНИЕ МАССИВА, ПОТОМУШТО ТАК НУЖНО!!! ВОТ
|
|
||||||
-- local cyka = {}
|
|
||||||
-- for i = 1, #keyWords do
|
|
||||||
-- cyka[i] = {}
|
|
||||||
-- for j = 1, #keyWords[i] do
|
|
||||||
-- cyka[i][j] = keyWords[i][j]
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
--table.remove(cyka[yKeyWord], 1)
|
|
||||||
|
|
||||||
--ecs.error("#cyka[yKeyWord] = "..#cyka[yKeyWord]..", #keyWords[yKeyWord] = "..#keyWords[yKeyWord])
|
|
||||||
|
|
||||||
--yKeyWord = 3
|
|
||||||
|
|
||||||
temporaryWordTrace = {}
|
|
||||||
--ecs.error("Начинаю поиск слова №"..yKeyWord.." на x = "..xSimvol..", y = "..ySimvol)
|
|
||||||
if findWord(xSimvol, ySimvol, keyWords[yKeyWord], true ) then
|
|
||||||
|
|
||||||
|
|
||||||
--ecs.error("УСПЕХ! НАШЛО СЛОВО НОМЕР " .. yKeyWord .. ", его размер="..#keyWords[yKeyWord]..", #свет="..#temporaryWordTrace)
|
|
||||||
|
|
||||||
table.insert(globalWordTrace, {yKeyWord, xSimvol, ySimvol, temporaryWordTrace})
|
|
||||||
|
|
||||||
trace(globalWordTrace[#globalWordTrace])
|
|
||||||
|
|
||||||
--drawCrossword(2, 2, 0xeeeeee, 0x333333, 3, 1)
|
|
||||||
|
|
||||||
yKeyWord = yKeyWord + 1
|
|
||||||
|
|
||||||
--event.pull("key_down")
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
yKeyWord = yKeyWord + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ecs.clearScreen(0x262626)
|
|
||||||
|
|
||||||
local vvod = ecs.universalWindow("auto", "auto", 40, 0xeeeeee, true, {"EmptyLine"}, {"CenterText", 0x262626, "Путь к файлу кроссворда"}, {"EmptyLine"}, {"Input", 0x262626, ecs.colors.green, "MineOS/Applications/Crossword.app/Resources/CrosswordFile.txt"}, {"EmptyLine"}, {"Button", {ecs.colors.green, 0xffffff, "OK"}})
|
|
||||||
local pathToCrossword = vvod[1]
|
|
||||||
local mode = vvod[2]
|
|
||||||
|
|
||||||
ecs.clearScreen(0xeeeeee)
|
|
||||||
getCrosswordFromFile(pathToCrossword)
|
|
||||||
drawCrossword(2, 2, 0xeeeeee, 0x333333, 3, 1)
|
|
||||||
reshitCrossword()
|
|
||||||
|
|
||||||
event.pull("key_down")
|
|
||||||
drawCrossword(2, 2, 0xeeeeee, 0x333333, 3, 1)
|
|
||||||
|
|
||||||
os.sleep(1)
|
|
||||||
event.pull("key_down")
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
--КРОССВОРД
|
|
||||||
черттевпосетедсанморпм
|
|
||||||
лиеёиосьлетинжассиапко
|
|
||||||
окижтельоицеирмуньттек
|
|
||||||
ваннкомспзиябоотносьра
|
|
||||||
кодиломопотаобпонрфунк
|
|
||||||
--КЛЮЧЕВЫЕ СЛОВА
|
|
||||||
чертёж
|
|
||||||
осветитель
|
|
||||||
посетитель
|
|
||||||
компромисс
|
|
||||||
насаждение
|
|
||||||
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
Виртуальный танцпол, реагирующий на хождение по экрану и на клики по нему. Отлично войдет в интерьер какого-нибудь ночного клуба, если, конечно, в майне с его юной аудиторией вообще может быть пиздатый ночной клуб. Ну да ладно, пользуйтесь на здоровье. Кстати, прога частично спизжена с русской майн-вики.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Виртуальный танцпол, реагирующий на хождение по экрану и на клики по нему. Отлично войдет в интерьер какого-нибудь ночного клуба, если, конечно, в майне с его юной аудиторией вообще может быть пиздатый ночной клуб. Ну да ладно, пользуйтесь на здоровье. Кстати, прога частично спизжена с русской майн-вики.
|
|
||||||
@ -1,212 +0,0 @@
|
|||||||
local component = require("component")
|
|
||||||
local event = require("event")
|
|
||||||
local gpu = component.gpu
|
|
||||||
local ecs = require("ECSAPI")
|
|
||||||
|
|
||||||
local xOld, yOld = gpu.getResolution()
|
|
||||||
local xSize, ySize
|
|
||||||
local circles = {}
|
|
||||||
local bg, fg, mode, speed
|
|
||||||
|
|
||||||
--============================ Ф У Н К Ц И И ==============================--
|
|
||||||
|
|
||||||
local function tanci()
|
|
||||||
-- отрисовка кругов
|
|
||||||
local function draw()
|
|
||||||
gpu.setBackground(bg)
|
|
||||||
gpu.fill(1, 1, xSize*2, ySize, " ")
|
|
||||||
|
|
||||||
for i=#circles, 1, -1 do
|
|
||||||
local x = circles[i][1]+1
|
|
||||||
local y = circles[i][2]-circles[i][4]+2
|
|
||||||
gpu.setBackground(circles[i][3])
|
|
||||||
|
|
||||||
for c=1, (circles[i][4]-1)*4 do
|
|
||||||
if x>0 and x<=(xSize*2) then
|
|
||||||
if y>0 and y<=ySize then
|
|
||||||
gpu.set((x)*2 - 1, y, " ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- следующий "пиксель" круга
|
|
||||||
if x>circles[i][1] then
|
|
||||||
if y<circles[i][2] then
|
|
||||||
x = x+1
|
|
||||||
else
|
|
||||||
x = x-1
|
|
||||||
end
|
|
||||||
y = y+1
|
|
||||||
else
|
|
||||||
if y>circles[i][2] then
|
|
||||||
x = x-1
|
|
||||||
else
|
|
||||||
x = x+1
|
|
||||||
end
|
|
||||||
y = y-1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
circles[i][4] = circles[i][4] + 1
|
|
||||||
if circles[i][4] > xSize then table.remove(circles, i) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
while true do
|
|
||||||
-- обработка сигналов
|
|
||||||
local e = {event.pull(speed)}
|
|
||||||
|
|
||||||
if e[1] == "touch" then
|
|
||||||
table.insert(circles, {e[3] / 2, e[4], math.random(0xffffff), 1})
|
|
||||||
elseif e[1] == "walk" then
|
|
||||||
table.insert(circles, {e[3], e[4], math.random(0xffffff), 1})
|
|
||||||
elseif e[1] == "key_down" then
|
|
||||||
if e[4] == 28 then break end
|
|
||||||
end
|
|
||||||
|
|
||||||
draw()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function shahmati()
|
|
||||||
local c1 = 0x000000
|
|
||||||
local c2 = 0xffffff
|
|
||||||
for j = 1, ySize do
|
|
||||||
for i = 1, xSize do
|
|
||||||
circles[j] = circles[j] or {}
|
|
||||||
if j % 2 == 0 then
|
|
||||||
if i % 2 == 0 then
|
|
||||||
circles[j][i] = c1
|
|
||||||
else
|
|
||||||
circles[j][i] = c2
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if i % 2 == 0 then
|
|
||||||
circles[j][i] = c2
|
|
||||||
else
|
|
||||||
circles[j][i] = c1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function cyka()
|
|
||||||
for j = 1, #circles do
|
|
||||||
for i = 1, #circles[j] do
|
|
||||||
circles[j][i] = 0xffffff - circles[j][i]
|
|
||||||
gpu.setBackground(circles[j][i])
|
|
||||||
gpu.set(i*2 - 1, j, " ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
cyka()
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull(speed)}
|
|
||||||
|
|
||||||
if e[1] == "touch" then
|
|
||||||
circles[e[4]][e[3] / 2] = math.random(0xffffff)
|
|
||||||
elseif e[1] == "walk" then
|
|
||||||
circles[e[4]][e[3]] = math.random(0xffffff)
|
|
||||||
elseif e[1] == "key_down" then
|
|
||||||
if e[4] == 28 then break end
|
|
||||||
end
|
|
||||||
|
|
||||||
cyka()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function spidi()
|
|
||||||
local function cyka()
|
|
||||||
for j = 1, ySize do
|
|
||||||
for i = 1, xSize do
|
|
||||||
gpu.setBackground(math.random(0xffffff))
|
|
||||||
gpu.set(i*2 - 1, j, " ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
cyka()
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull(speed)}
|
|
||||||
|
|
||||||
if e[1] == "key_down" then
|
|
||||||
if e[4] == 28 then break end
|
|
||||||
end
|
|
||||||
|
|
||||||
cyka()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function beg()
|
|
||||||
local function cyka()
|
|
||||||
local cyka2 = {bg, fg}
|
|
||||||
gpu.copy(1,1,xSize*2,ySize, 2, 0)
|
|
||||||
for j = 1, ySize do
|
|
||||||
gpu.setBackground(cyka2[math.random(1, 2)])
|
|
||||||
gpu.set(1, j, " ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
cyka()
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull(speed)}
|
|
||||||
|
|
||||||
if e[1] == "key_down" then
|
|
||||||
if e[4] == 28 then break end
|
|
||||||
end
|
|
||||||
|
|
||||||
cyka()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--===========================================================================--
|
|
||||||
|
|
||||||
local data = ecs.universalWindow("auto", "auto", 36, 0xeeeeee, true,
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", 0x880000, "Танцпол v1.0"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", 0x262626, "Реагинует на хождение"},
|
|
||||||
{"CenterText", 0x262626, "по экрану и прикосновение к нему,"},
|
|
||||||
{"CenterText", 0x262626, "для выхода удерживайте Enter"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Selector", 0x262626, 0x880000, "ШАХМАТЫ", "СПИДЫ", "ТАНЦЫ", "БЕГ"},
|
|
||||||
{"Color", "Цвет 1", 0x000000},
|
|
||||||
{"Color", "Цвет 2", 0xFFFFFF},
|
|
||||||
{"Slider", 0x262626, 0x880000, 1, 100, 100, "Скорость ", " FPS"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Button", {0x888888, 0xffffff, "OK"}, {0xaaaaaa, 0xffffff, "Отмена"}}
|
|
||||||
)
|
|
||||||
|
|
||||||
if data[5] == "OK" then
|
|
||||||
mode = data[1]
|
|
||||||
bg = data[2]
|
|
||||||
fg = data[3]
|
|
||||||
speed = (102 - tonumber(data[4])) / 100
|
|
||||||
else
|
|
||||||
ecs.prepareToExit()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
xSize, ySize = component.screen.getAspectRatio()
|
|
||||||
gpu.setResolution(xSize * 2, ySize)
|
|
||||||
gpu.fill(1, 1, 16, 6, " ")
|
|
||||||
|
|
||||||
if mode == "СПИДЫ" then
|
|
||||||
spidi()
|
|
||||||
elseif mode == "ТАНЦЫ" then
|
|
||||||
tanci()
|
|
||||||
elseif mode == "ШАХМАТЫ" then
|
|
||||||
shahmati()
|
|
||||||
elseif mode == "БЕГ" then
|
|
||||||
beg()
|
|
||||||
end
|
|
||||||
|
|
||||||
gpu.setResolution(xOld, yOld)
|
|
||||||
ecs.prepareToExit()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@ -1,43 +0,0 @@
|
|||||||
|
|
||||||
drone = component.proxy(component.list("drone")())
|
|
||||||
eeprom = component.proxy(component.list("eeprom")())
|
|
||||||
modem = component.proxy(component.list("modem")())
|
|
||||||
port = 512
|
|
||||||
modem.open(port)
|
|
||||||
|
|
||||||
local function executeCode(code)
|
|
||||||
local loadSuccess, loadReason = load(code)
|
|
||||||
if loadSuccess then
|
|
||||||
local xpcallSuccess, xpcallReason = xpcall(loadSuccess, debug.traceback)
|
|
||||||
if xpcallSuccess then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false, xpcallReason
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return false, loadReason
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local eventData = {computer.pullSignal()}
|
|
||||||
if eventData[1] == "modem_message" then
|
|
||||||
if eventData[6] == "executeCode" and eventData[7] then
|
|
||||||
local success, reason = executeCode(table.unpack(eventData, 8))
|
|
||||||
if eventData[7] == true then
|
|
||||||
modem.send(eventData[3], port, "executionResult", success, reason)
|
|
||||||
end
|
|
||||||
elseif eventData[6] == "flashEEPROM" and eventData[7] then
|
|
||||||
local success = load(eventData[7])
|
|
||||||
if success then
|
|
||||||
eeprom.set(eventData[7])
|
|
||||||
computer.beep(1000, 1)
|
|
||||||
computer.stop()
|
|
||||||
computer.start()
|
|
||||||
else
|
|
||||||
for i = 1, 3 do computer.beep(800, 0.3) end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@ -1,150 +0,0 @@
|
|||||||
|
|
||||||
local position = {x = 0, y = 0, z = 0}
|
|
||||||
local rotation = 0
|
|
||||||
local movePrecision = 0.5
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local function sleep(timeout)
|
|
||||||
local deadline = computer.uptime() + (timeout or 0)
|
|
||||||
while computer.uptime() < deadline do
|
|
||||||
computer.pullSignal(deadline - computer.uptime())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function absoluteSwing(...)
|
|
||||||
while true do
|
|
||||||
local success, reason = drone.swing(...)
|
|
||||||
if success or reason == "air" then break end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function absoluteMove(x, y, z)
|
|
||||||
drone.move(x, y, z)
|
|
||||||
while drone.getOffset() > movePrecision do
|
|
||||||
sleep(0.05)
|
|
||||||
end
|
|
||||||
position.x, position.y, position.z = position.x + x, position.y + y, position.z + z
|
|
||||||
end
|
|
||||||
|
|
||||||
local function relativeMove(x, y, z)
|
|
||||||
if rotation == 0 then
|
|
||||||
absoluteMove(x, y, -z)
|
|
||||||
elseif rotation == 1 then
|
|
||||||
absoluteMove(z, y, x)
|
|
||||||
elseif rotation == 2 then
|
|
||||||
absoluteMove(-x, y, z)
|
|
||||||
else
|
|
||||||
absoluteMove(-z, y, -x)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function relativeSwing(preferredRotation)
|
|
||||||
local front, right, back, left = 4, 2, 5, 3
|
|
||||||
if rotation == 0 then
|
|
||||||
front, right, back, left = 2, 5, 3, 4
|
|
||||||
elseif rotation == 1 then
|
|
||||||
front, right, back, left = 5, 3, 4, 2
|
|
||||||
elseif rotation == 2 then
|
|
||||||
front, right, back, left = 3, 4, 2, 5
|
|
||||||
end
|
|
||||||
|
|
||||||
absoluteSwing(select((preferredRotation or 0) + 1, front, right, back, left))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function swingForward()
|
|
||||||
relativeSwing(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function moveForward(distance)
|
|
||||||
relativeMove(0, 0, distance or 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function moveBackward(distance)
|
|
||||||
relativeMove(0, 0, distance and -distance or -1)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function turnLeft()
|
|
||||||
rotation = rotation - 1
|
|
||||||
if rotation < 0 then rotation = 3 end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function turnRight()
|
|
||||||
rotation = rotation + 1
|
|
||||||
if rotation > 3 then rotation = 0 end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function moveToPoint(x, y, z)
|
|
||||||
absoluteMove(x - position.x, y - position.y, z - position.z)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function returnToStartPoint()
|
|
||||||
moveToPoint(0, position.y, 0)
|
|
||||||
moveToPoint(0, 0, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local fieldWidth = 18
|
|
||||||
local fieldHeight = 18
|
|
||||||
|
|
||||||
local function dropShitOnBase()
|
|
||||||
returnToStartPoint()
|
|
||||||
moveBackward(1)
|
|
||||||
|
|
||||||
computer.beep(1500, 0.3)
|
|
||||||
for slot = 1, drone.inventorySize() do
|
|
||||||
drone.select(slot)
|
|
||||||
drone.drop(0)
|
|
||||||
end
|
|
||||||
drone.select(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function checkInventory()
|
|
||||||
if drone.count(drone.inventorySize()) > 0 then
|
|
||||||
local xOld, yOld, zOld = position.x, position.y, position.z
|
|
||||||
dropShitOnBase()
|
|
||||||
moveToPoint(xOld, yOld, zOld)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function doHeight()
|
|
||||||
for y = 1, fieldHeight do
|
|
||||||
swingForward()
|
|
||||||
sleep(0.1)
|
|
||||||
moveForward(1)
|
|
||||||
end
|
|
||||||
checkInventory()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function doWidth()
|
|
||||||
for x = 1, fieldWidth / 2 do
|
|
||||||
doHeight()
|
|
||||||
turnRight()
|
|
||||||
swingForward()
|
|
||||||
moveForward(1)
|
|
||||||
turnRight()
|
|
||||||
|
|
||||||
doHeight()
|
|
||||||
turnLeft()
|
|
||||||
swingForward()
|
|
||||||
moveForward(1)
|
|
||||||
turnLeft()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
rotation = 3
|
|
||||||
drone.setAcceleration(1)
|
|
||||||
|
|
||||||
absoluteMove(0, 0.5, 0)
|
|
||||||
doWidth()
|
|
||||||
dropShitOnBase()
|
|
||||||
returnToStartPoint()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
local component = require("component")
|
|
||||||
local event = require("event")
|
|
||||||
local modem = component.modem
|
|
||||||
local port = 512
|
|
||||||
modem.open(port)
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull()}
|
|
||||||
if e[1] == "key_down" then
|
|
||||||
if e[4] == 28 then
|
|
||||||
local file = io.open("/DroneCode.lua", "r")
|
|
||||||
local data = file:read("*a")
|
|
||||||
file:close()
|
|
||||||
modem.broadcast(port, "executeCode", true, data)
|
|
||||||
elseif e[4] == 14 then
|
|
||||||
local file = io.open("/DroneBIOS.lua", "r")
|
|
||||||
local data = file:read("*a")
|
|
||||||
file:close()
|
|
||||||
modem.broadcast(port, "flashEEPROM", data)
|
|
||||||
end
|
|
||||||
elseif e[1] == "modem_message" then
|
|
||||||
if e[6] == "executionResult" then
|
|
||||||
print("Резултат выполнения кода: " .. tostring(e[7]) .. ", " .. tostring(e[8]))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,139 +0,0 @@
|
|||||||
|
|
||||||
local drone = component.proxy(component.list("drone")())
|
|
||||||
local modem = component.proxy(component.list("modem")())
|
|
||||||
local inventory = component.proxy(component.list("inventory_controller")())
|
|
||||||
local port = 512
|
|
||||||
local moveSpeed = 1.0
|
|
||||||
local suckSide = 0
|
|
||||||
local direction = 0
|
|
||||||
local acceleration = 0.5
|
|
||||||
local autoDrop = true
|
|
||||||
local leashed = false
|
|
||||||
|
|
||||||
modem.open(port)
|
|
||||||
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
local function move(forward)
|
|
||||||
if direction == 0 then
|
|
||||||
drone.move(1 * forward, 0, 0)
|
|
||||||
elseif direction == 1 then
|
|
||||||
drone.move(0, 0, 1 * forward)
|
|
||||||
elseif direction == 2 then
|
|
||||||
drone.move(-1 * forward, 0, 0)
|
|
||||||
else
|
|
||||||
drone.move(0, 0, -1 * forward)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function printSpeed()
|
|
||||||
drone.setStatusText("SPD " .. tostring(moveSpeed))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function printDirection()
|
|
||||||
drone.setStatusText("DIR " .. tostring(direction))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function printAcceleration()
|
|
||||||
drone.setStatusText("ACC " .. tostring(acceleration))
|
|
||||||
end
|
|
||||||
|
|
||||||
local function sendInfo()
|
|
||||||
modem.broadcast(port, "ECSDrone", "DroneInfo", moveSpeed, acceleration, direction)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function dropAll()
|
|
||||||
for i = 1, drone.inventorySize() do
|
|
||||||
drone.select(i)
|
|
||||||
drone.drop(1)
|
|
||||||
end
|
|
||||||
drone.select(1)
|
|
||||||
drone.setStatusText("DROPPED")
|
|
||||||
end
|
|
||||||
|
|
||||||
drone.setStatusText("STARTED")
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = { computer.pullSignal() }
|
|
||||||
if e[1] == "modem_message" then
|
|
||||||
if e[4] == port then
|
|
||||||
if e[6] == "ECSDrone" then
|
|
||||||
drone.setStatusText(e[7])
|
|
||||||
if e[7] == "moveUp" then
|
|
||||||
drone.move(0, moveSpeed, 0)
|
|
||||||
elseif e[7] == "moveDown" then
|
|
||||||
drone.move(0, -moveSpeed, 0)
|
|
||||||
elseif e[7] == "moveForward" then
|
|
||||||
move(1)
|
|
||||||
elseif e[7] == "moveBack" then
|
|
||||||
move(-1)
|
|
||||||
elseif e[7] == "turnLeft" then
|
|
||||||
direction = direction - 1
|
|
||||||
if direction < 0 then direction = 3 end
|
|
||||||
printDirection()
|
|
||||||
sendInfo()
|
|
||||||
elseif e[7] == "turnRight" then
|
|
||||||
direction = direction + 1
|
|
||||||
if direction > 3 then direction = 0 end
|
|
||||||
printDirection()
|
|
||||||
sendInfo()
|
|
||||||
elseif e[7] == "changeColor" then
|
|
||||||
drone.setLightColor(math.random(0x0, 0xFFFFFF))
|
|
||||||
elseif e[7] == "OTSOS" then
|
|
||||||
for i = 1, (inventory.getInventorySize(0) or 1) do
|
|
||||||
inventory.suckFromSlot(0, i)
|
|
||||||
end
|
|
||||||
drone.setStatusText("SUCKED")
|
|
||||||
elseif e[7] == "swing" then
|
|
||||||
drone.swing(0)
|
|
||||||
elseif e[7] == "dropAll" then
|
|
||||||
dropAll()
|
|
||||||
elseif e[7] == "changeAutoDrop" then
|
|
||||||
changeAutoDrop = not changeAutoDrop
|
|
||||||
drone.setStatusText("DROP: " .. tostring(changeAutoDrop))
|
|
||||||
elseif e[7] == "moveSpeedUp" then
|
|
||||||
moveSpeed = moveSpeed + 0.1
|
|
||||||
if moveSpeed >= 8 then moveSpeed = 8 end
|
|
||||||
printSpeed()
|
|
||||||
sendInfo()
|
|
||||||
elseif e[7] == "moveSpeedDown" then
|
|
||||||
moveSpeed = moveSpeed - 0.1
|
|
||||||
if moveSpeed <= 0.1 then moveSpeed = 0.1 end
|
|
||||||
printSpeed()
|
|
||||||
sendInfo()
|
|
||||||
elseif e[7] == "accelerationUp" then
|
|
||||||
acceleration = acceleration + 0.1
|
|
||||||
if acceleration >= 5 then acceleration = 5 end
|
|
||||||
drone.setAcceleration(acceleration)
|
|
||||||
printAcceleration()
|
|
||||||
sendInfo()
|
|
||||||
elseif e[7] == "accelerationDown" then
|
|
||||||
acceleration = acceleration - 0.1
|
|
||||||
if acceleration <= 0.1 then acceleration = 0.1 end
|
|
||||||
drone.setAcceleration(acceleration)
|
|
||||||
printAcceleration()
|
|
||||||
sendInfo()
|
|
||||||
elseif e[7] == "toggleLeash" then
|
|
||||||
if leashed then
|
|
||||||
component.proxy(component.list("leash")()).unleash()
|
|
||||||
leashed = false
|
|
||||||
else
|
|
||||||
component.proxy(component.list("leash")()).leash(suckSide)
|
|
||||||
leashed = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,69 +0,0 @@
|
|||||||
|
|
||||||
local component = require("component")
|
|
||||||
local modem = component.modem
|
|
||||||
local event = require("event")
|
|
||||||
local keyboard = require("keyboard")
|
|
||||||
local port = 512
|
|
||||||
modem.open(port)
|
|
||||||
|
|
||||||
local keys = {
|
|
||||||
[17] = "moveForward",
|
|
||||||
[31] = "moveBack",
|
|
||||||
[30] = "turnLeft",
|
|
||||||
[32] = "turnRight",
|
|
||||||
[42] = "moveDown",
|
|
||||||
[57] = "moveUp",
|
|
||||||
[46] = "changeColor",
|
|
||||||
[18] = "OTSOS",
|
|
||||||
[16] = "dropAll",
|
|
||||||
[33] = "toggleLeash",
|
|
||||||
}
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
print(" ")
|
|
||||||
print("Добро пожаловать в программу DroneGrief. Используйте клавиши W и S для перемещения дрона, а A и D для смены направления движения. По нажатию SHIFT дрон опустится ниже, а по SPACE - выше. Кнопка E заставит дрона высосать предметы из инвентаря под и над ним, а кнопка C сменит цвет его свечения. При скроллинге колесиком мыши изменяется скорость движения робота, а скроллинг с зажатым ALT изменяет его ускорение.")
|
|
||||||
print(" ")
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull()}
|
|
||||||
if e[1] == "key_down" then
|
|
||||||
if keys[e[4]] then
|
|
||||||
print("Команда дрону: " .. keys[e[4]])
|
|
||||||
modem.broadcast(port, "ECSDrone", keys[e[4]])
|
|
||||||
end
|
|
||||||
elseif e[1] == "scroll" then
|
|
||||||
if e[5] == 1 then
|
|
||||||
if keyboard.isAltDown() then
|
|
||||||
modem.broadcast(port, "ECSDrone", "accelerationUp")
|
|
||||||
print("Команда дрону: accelerationUp")
|
|
||||||
else
|
|
||||||
modem.broadcast(port, "ECSDrone", "moveSpeedUp")
|
|
||||||
print("Команда дрону: moveSpeedUp")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if keyboard.isAltDown() then
|
|
||||||
modem.broadcast(port, "ECSDrone", "accelerationDown")
|
|
||||||
print("Команда дрону: accelerationDown")
|
|
||||||
else
|
|
||||||
modem.broadcast(port, "ECSDrone", "moveSpeedDown")
|
|
||||||
print("Команда дрону: moveSpeedDown")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif e[1] == "modem_message" then
|
|
||||||
if e[6] == "ECSDrone" and e[7] == "DroneInfo" then
|
|
||||||
print(" ")
|
|
||||||
print("Скорость дрона: " .. tostring(e[8]))
|
|
||||||
print("Ускорение дрона: " .. tostring(e[9]))
|
|
||||||
print("Направление дрона: " .. tostring(e[10]))
|
|
||||||
print(" ")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,322 +0,0 @@
|
|||||||
|
|
||||||
local virusPath = "bin/virus.lua"
|
|
||||||
local EEPROMLabel = "EEPROM (Lua BIOS)"
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local EEPROMCode = [[
|
|
||||||
|
|
||||||
local textLines = {
|
|
||||||
"Поздравляем!",
|
|
||||||
"Вы стали одним из первых счастливых обладателей вируса на OpenComputers.",
|
|
||||||
"Попытайтесь его удалить - посмотрим, что у вас выйдет. ",
|
|
||||||
"Ну, а нубикам советую обращаться к ECS для разблокировки компа.",
|
|
||||||
" ",
|
|
||||||
"Хех)"
|
|
||||||
}
|
|
||||||
|
|
||||||
local component_invoke = component.invoke
|
|
||||||
function boot_invoke(address, method, ...)
|
|
||||||
local result = table.pack(pcall(component_invoke, address, method, ...))
|
|
||||||
if not result[1] then
|
|
||||||
return nil, result[2]
|
|
||||||
else
|
|
||||||
return table.unpack(result, 2, result.n)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
---------------------------------------------------------------
|
|
||||||
local eeprom = component.list("eeprom")()
|
|
||||||
computer.getBootAddress = function()
|
|
||||||
return boot_invoke(eeprom, "getData")
|
|
||||||
end
|
|
||||||
computer.setBootAddress = function(address)
|
|
||||||
return boot_invoke(eeprom, "setData", address)
|
|
||||||
end
|
|
||||||
|
|
||||||
do
|
|
||||||
_G.screen = component.list("screen")()
|
|
||||||
_G.gpu = component.list("gpu")()
|
|
||||||
if gpu and screen then
|
|
||||||
boot_invoke(gpu, "bind", screen)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
---------------------------------------------------------------
|
|
||||||
|
|
||||||
local function centerText(mode,coord,text)
|
|
||||||
local dlina = unicode.len(text)
|
|
||||||
local xSize,ySize = boot_invoke(gpu, "getResolution")
|
|
||||||
|
|
||||||
if mode == "x" then
|
|
||||||
boot_invoke(gpu, "set", math.floor(xSize/2-dlina/2),coord,text)
|
|
||||||
elseif mode == "y" then
|
|
||||||
boot_invoke(gpu, "set", coord, math.floor(ySize/2),text)
|
|
||||||
else
|
|
||||||
boot_invoke(gpu, "set", math.floor(xSize/2-dlina/2),math.floor(ySize/2),text)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function virus()
|
|
||||||
local background, foreground = 0x0000AA, 0xCCCCCC
|
|
||||||
local xSize, ySize = boot_invoke(gpu, "getResolution")
|
|
||||||
boot_invoke(gpu, "setBackground", background)
|
|
||||||
boot_invoke(gpu, "fill", 1, 1, xSize, ySize, " ")
|
|
||||||
|
|
||||||
boot_invoke(gpu, "setBackground", foreground)
|
|
||||||
boot_invoke(gpu, "setForeground", background)
|
|
||||||
|
|
||||||
local y = math.floor(ySize / 2 - (#textLines + 2) / 2)
|
|
||||||
centerText("x", y, " OpenOS заблокирована! ")
|
|
||||||
y = y + 2
|
|
||||||
|
|
||||||
boot_invoke(gpu, "setBackground", background)
|
|
||||||
boot_invoke(gpu, "setForeground", foreground)
|
|
||||||
|
|
||||||
for i = 1, #textLines do
|
|
||||||
centerText("x", y, textLines[i])
|
|
||||||
y = y + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
while true do
|
|
||||||
computer.pullSignal()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if gpu then virus() end
|
|
||||||
]]
|
|
||||||
|
|
||||||
local INITCode = [[
|
|
||||||
|
|
||||||
local backgroundColor = 0x262626
|
|
||||||
local foregroundColor = 0xcccccc
|
|
||||||
|
|
||||||
do
|
|
||||||
|
|
||||||
_G._OSVERSION = "OpenOS 1.5"
|
|
||||||
|
|
||||||
local component = component
|
|
||||||
local computer = computer
|
|
||||||
local unicode = unicode
|
|
||||||
|
|
||||||
-- Runlevel information.
|
|
||||||
local runlevel, shutdown = "S", computer.shutdown
|
|
||||||
computer.runlevel = function() return runlevel end
|
|
||||||
computer.shutdown = function(reboot)
|
|
||||||
runlevel = reboot and 6 or 0
|
|
||||||
if os.sleep then
|
|
||||||
computer.pushSignal("shutdown")
|
|
||||||
os.sleep(0.1) -- Allow shutdown processing.
|
|
||||||
end
|
|
||||||
shutdown(reboot)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Low level dofile implementation to read filesystem libraries.
|
|
||||||
local rom = {}
|
|
||||||
function rom.invoke(method, ...)
|
|
||||||
return component.invoke(computer.getBootAddress(), method, ...)
|
|
||||||
end
|
|
||||||
function rom.open(file) return rom.invoke("open", file) end
|
|
||||||
function rom.read(handle) return rom.invoke("read", handle, math.huge) end
|
|
||||||
function rom.close(handle) return rom.invoke("close", handle) end
|
|
||||||
function rom.inits() return ipairs(rom.invoke("list", "boot")) end
|
|
||||||
function rom.isDirectory(path) return rom.invoke("isDirectory", path) end
|
|
||||||
|
|
||||||
local screen = component.list('screen',true)()
|
|
||||||
for address in component.list('screen',true) do
|
|
||||||
if #component.invoke(address, 'getKeyboards') > 0 then
|
|
||||||
screen = address
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Report boot progress if possible.
|
|
||||||
local gpu = component.list("gpu", true)()
|
|
||||||
local w, h
|
|
||||||
if gpu and screen then
|
|
||||||
component.invoke(gpu, "bind", screen)
|
|
||||||
w, h = component.invoke(gpu, "getResolution")
|
|
||||||
component.invoke(gpu, "setResolution", w, h)
|
|
||||||
component.invoke(gpu, "setBackground", backgroundColor)
|
|
||||||
component.invoke(gpu, "setForeground", foregroundColor)
|
|
||||||
component.invoke(gpu, "fill", 1, 1, w, h, " ")
|
|
||||||
end
|
|
||||||
local y = 1
|
|
||||||
local function status(msg)
|
|
||||||
|
|
||||||
|
|
||||||
local yPos = math.floor(h / 2)
|
|
||||||
local length = #msg
|
|
||||||
local xPos = math.floor(w / 2 - length / 2)
|
|
||||||
|
|
||||||
component.invoke(gpu, "fill", 1, yPos, w, 1, " ")
|
|
||||||
component.invoke(gpu, "set", xPos, yPos, msg)
|
|
||||||
|
|
||||||
-- if gpu and screen then
|
|
||||||
-- component.invoke(gpu, "set", 1, y, msg)
|
|
||||||
-- if y == h then
|
|
||||||
-- component.invoke(gpu, "copy", 1, 2, w, h - 1, 0, -1)
|
|
||||||
-- component.invoke(gpu, "fill", 1, h, w, 1, " ")
|
|
||||||
-- else
|
|
||||||
-- y = y + 1
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
end
|
|
||||||
|
|
||||||
status("Booting " .. _OSVERSION .. "...")
|
|
||||||
|
|
||||||
-- Custom low-level loadfile/dofile implementation reading from our ROM.
|
|
||||||
local function loadfile(file)
|
|
||||||
status("> " .. file)
|
|
||||||
local handle, reason = rom.open(file)
|
|
||||||
if not handle then
|
|
||||||
error(reason)
|
|
||||||
end
|
|
||||||
local buffer = ""
|
|
||||||
repeat
|
|
||||||
local data, reason = rom.read(handle)
|
|
||||||
if not data and reason then
|
|
||||||
error(reason)
|
|
||||||
end
|
|
||||||
buffer = buffer .. (data or "")
|
|
||||||
until not data
|
|
||||||
rom.close(handle)
|
|
||||||
return load(buffer, "=" .. file)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function dofile(file)
|
|
||||||
local program, reason = loadfile(file)
|
|
||||||
if program then
|
|
||||||
local result = table.pack(pcall(program))
|
|
||||||
if result[1] then
|
|
||||||
return table.unpack(result, 2, result.n)
|
|
||||||
else
|
|
||||||
error(result[2])
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error(reason)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
status("Initializing package management...")
|
|
||||||
|
|
||||||
-- Load file system related libraries we need to load other stuff moree
|
|
||||||
-- comfortably. This is basically wrapper stuff for the file streams
|
|
||||||
-- provided by the filesystem components.
|
|
||||||
local package = dofile("/lib/package.lua")
|
|
||||||
|
|
||||||
do
|
|
||||||
-- Unclutter global namespace now that we have the package module.
|
|
||||||
--_G.component = nil
|
|
||||||
_G.computer = nil
|
|
||||||
_G.process = nil
|
|
||||||
_G.unicode = nil
|
|
||||||
|
|
||||||
-- Initialize the package module with some of our own APIs.
|
|
||||||
package.preload["buffer"] = loadfile("/lib/buffer.lua")
|
|
||||||
package.preload["component"] = function() return component end
|
|
||||||
package.preload["computer"] = function() return computer end
|
|
||||||
package.preload["filesystem"] = loadfile("/lib/filesystem.lua")
|
|
||||||
package.preload["io"] = loadfile("/lib/io.lua")
|
|
||||||
package.preload["unicode"] = function() return unicode end
|
|
||||||
|
|
||||||
-- Inject the package and io modules into the global namespace, as in Lua.
|
|
||||||
_G.package = package
|
|
||||||
_G.io = require("io")
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
status("Initializing file system...")
|
|
||||||
|
|
||||||
-- Mount the ROM and temporary file systems to allow working on the file
|
|
||||||
-- system module from this point on.
|
|
||||||
local filesystem = require("filesystem")
|
|
||||||
filesystem.mount(computer.getBootAddress(), "/")
|
|
||||||
|
|
||||||
status("Running boot scripts...")
|
|
||||||
|
|
||||||
-- Run library startup scripts. These mostly initialize event handlers.
|
|
||||||
local scripts = {}
|
|
||||||
for _, file in rom.inits() do
|
|
||||||
local path = "boot/" .. file
|
|
||||||
if not rom.isDirectory(path) then
|
|
||||||
table.insert(scripts, path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.sort(scripts)
|
|
||||||
for i = 1, #scripts do
|
|
||||||
dofile(scripts[i])
|
|
||||||
end
|
|
||||||
|
|
||||||
status("Initializing components...")
|
|
||||||
|
|
||||||
local primaries = {}
|
|
||||||
for c, t in component.list() do
|
|
||||||
local s = component.slot(c)
|
|
||||||
if (not primaries[t] or (s >= 0 and s < primaries[t].slot)) and t ~= "screen" then
|
|
||||||
primaries[t] = {address=c, slot=s}
|
|
||||||
end
|
|
||||||
computer.pushSignal("component_added", c, t)
|
|
||||||
end
|
|
||||||
for t, c in pairs(primaries) do
|
|
||||||
component.setPrimary(t, c.address)
|
|
||||||
end
|
|
||||||
os.sleep(0.5) -- Allow signal processing by libraries.
|
|
||||||
--computer.pushSignal("init") -- so libs know components are initialized.
|
|
||||||
|
|
||||||
-- status("Initializing system...")
|
|
||||||
--require("term").clear()
|
|
||||||
os.sleep(0.1) -- Allow init processing.
|
|
||||||
runlevel = 1
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
|
|
||||||
local component = require("component")
|
|
||||||
local args = { ... }
|
|
||||||
|
|
||||||
local function flashEEPROM()
|
|
||||||
local eeprom = component.getPrimary("eeprom")
|
|
||||||
eeprom.set(EEPROMCode)
|
|
||||||
eeprom.setLabel(EEPROMLabel)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function rewriteInit()
|
|
||||||
local file = io.open("init.lua", "w")
|
|
||||||
file:write(INITCode, "\n", "\n")
|
|
||||||
file:write("pcall(loadfile(\"" .. virusPath .. "\"), \"flashEEPROM\")", "\n", "\n")
|
|
||||||
file:write("require(\"computer\").shutdown(true)")
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
if args[1] == "flashEEPROM" then
|
|
||||||
flashEEPROM()
|
|
||||||
else
|
|
||||||
print(" ")
|
|
||||||
print("Перепрошиваю BIOS...")
|
|
||||||
flashEEPROM()
|
|
||||||
print("Перезаписываю кастомный init.lua...")
|
|
||||||
rewriteInit()
|
|
||||||
print(" ")
|
|
||||||
print("Вирус успешно установлен!")
|
|
||||||
print(" ")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,49 +1,47 @@
|
|||||||
|
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local buffer = require("doubleBuffering")
|
local screen = require("Screen")
|
||||||
local computer = require("computer")
|
local filesystem = require("Filesystem")
|
||||||
local filesystem = require("filesystem")
|
local event = require("Event")
|
||||||
local event = require("event")
|
local system = require("System")
|
||||||
local unicode = require("unicode")
|
local paths = require("Paths")
|
||||||
local MineOSCore = require("MineOSCore")
|
local network = require("Network")
|
||||||
local MineOSPaths = require("MineOSPaths")
|
local text = require("Text")
|
||||||
local MineOSNetwork = require("MineOSNetwork")
|
|
||||||
local MineOSInterface = require("MineOSInterface")
|
|
||||||
|
|
||||||
local args, options = require("shell").parse(...)
|
local args, options = system.parseArguments(...)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local configPath = MineOSPaths.applicationData .. "Finder/Config.cfg"
|
local configPath = paths.user.applicationData .. "Finder/Config.cfg"
|
||||||
local config = {
|
local config = {
|
||||||
favourites = {
|
favourites = {
|
||||||
{ name = "Root", path = "/" },
|
{ name = "Root", path = "/" },
|
||||||
{ name = "Desktop", path = MineOSPaths.desktop },
|
{ name = "Desktop", path = paths.user.desktop },
|
||||||
{ name = "Applications", path = MineOSPaths.applications },
|
{ name = "Applications", path = paths.system.applications },
|
||||||
{ name = "Pictures", path = MineOSPaths.pictures },
|
{ name = "Pictures", path = paths.system.pictures },
|
||||||
{ name = "System", path = MineOSPaths.system },
|
{ name = "Libraries", path = paths.system.libraries },
|
||||||
{ name = "Libraries", path = "/lib/" },
|
{ name = "User", path = paths.user.home },
|
||||||
{ name = "Trash", path = MineOSPaths.trash },
|
{ name = "Trash", path = paths.user.trash },
|
||||||
},
|
},
|
||||||
sidebarWidth = 20,
|
sidebarWidth = 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
if filesystem.exists(configPath) then
|
if filesystem.exists(configPath) then
|
||||||
config = table.fromFile(configPath)
|
config = filesystem.readTable(configPath)
|
||||||
end
|
end
|
||||||
|
|
||||||
local sidebarTitleColor = 0xC3C3C3
|
local sidebarTitleColor = 0xC3C3C3
|
||||||
local sidebarItemColor = 0x696969
|
local sidebarItemColor = 0x696969
|
||||||
|
|
||||||
local iconFieldYOffset = 2
|
local iconFieldYOffset = 2
|
||||||
local scrollTimerID
|
local scrollTimerHandler
|
||||||
|
|
||||||
local workpathHistory = {}
|
local workpathHistory = {}
|
||||||
local workpathHistoryCurrent = 0
|
local workpathHistoryCurrent = 0
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local application, window, menu = MineOSInterface.addWindow(GUI.filledWindow(1, 1, 100, 26, 0xE1E1E1))
|
local workspace, window, menu = system.addWindow(GUI.filledWindow(1, 1, 100, 26, 0xE1E1E1))
|
||||||
|
|
||||||
local titlePanel = window:addChild(GUI.panel(1, 1, 1, 3, 0x3C3C3C))
|
local titlePanel = window:addChild(GUI.panel(1, 1, 1, 3, 0x3C3C3C))
|
||||||
|
|
||||||
@ -57,12 +55,12 @@ nextButton.colors.disabled = prevButton.colors.disabled
|
|||||||
local FTPButton = window:addChild(GUI.adaptiveRoundedButton(nextButton.localX + nextButton.width + 2, 2, 1, 0, 0x5A5A5A, 0xC3C3C3, 0xE1E1E1, 0x3C3C3C, "FTP"))
|
local FTPButton = window:addChild(GUI.adaptiveRoundedButton(nextButton.localX + nextButton.width + 2, 2, 1, 0, 0x5A5A5A, 0xC3C3C3, 0xE1E1E1, 0x3C3C3C, "FTP"))
|
||||||
|
|
||||||
FTPButton.colors.disabled = prevButton.colors.disabled
|
FTPButton.colors.disabled = prevButton.colors.disabled
|
||||||
FTPButton.disabled = not MineOSNetwork.internetProxy
|
FTPButton.disabled = not network.internetProxy
|
||||||
|
|
||||||
local sidebarContainer = window:addChild(GUI.container(1, 4, config.sidebarWidth, 1))
|
local sidebarContainer = window:addChild(GUI.container(1, 4, config.sidebarWidth, 1))
|
||||||
local sidebarPanel = sidebarContainer:addChild(GUI.object(1, 1, 1, 1, 0xFFFFFF))
|
local sidebarPanel = sidebarContainer:addChild(GUI.object(1, 1, 1, 1, 0xFFFFFF))
|
||||||
sidebarPanel.draw = function(object)
|
sidebarPanel.draw = function(object)
|
||||||
buffer.drawRectangle(object.x, object.y, object.width, object.height, 0x2D2D2D, sidebarItemColor, " ")
|
screen.drawRectangle(object.x, object.y, object.width, object.height, 0x2D2D2D, sidebarItemColor, " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
local itemsLayout = sidebarContainer:addChild(GUI.layout(1, 1, 1, 1, 1, 1))
|
local itemsLayout = sidebarContainer:addChild(GUI.layout(1, 1, 1, 1, 1, 1))
|
||||||
@ -70,9 +68,9 @@ itemsLayout:setAlignment(1, 1, GUI.ALIGNMENT_HORIZONTAL_LEFT, GUI.ALIGNMENT_VERT
|
|||||||
itemsLayout:setSpacing(1, 1, 0)
|
itemsLayout:setSpacing(1, 1, 0)
|
||||||
itemsLayout:setMargin(1, 1, 0, 0)
|
itemsLayout:setMargin(1, 1, 0, 0)
|
||||||
|
|
||||||
local searchInput = window:addChild(GUI.input(1, 2, 20, 1, 0x4B4B4B, 0xC3C3C3, 0x878787, 0x4B4B4B, 0xE1E1E1, nil, MineOSCore.localization.search, true))
|
local searchInput = window:addChild(GUI.input(1, 2, 20, 1, 0x4B4B4B, 0xC3C3C3, 0x878787, 0x4B4B4B, 0xE1E1E1, nil, system.localization.search, true))
|
||||||
|
|
||||||
local iconField = window:addChild(MineOSInterface.iconField(1, 4, 1, 1, 2, 2, 0x3C3C3C, 0x969696, MineOSPaths.desktop))
|
local iconField = window:addChild(system.iconField(1, 4, 1, 1, 2, 2, 0x3C3C3C, 0x969696, paths.user.desktop))
|
||||||
|
|
||||||
local scrollBar = window:addChild(GUI.scrollBar(1, 4, 1, 1, 0xC3C3C3, 0x4B4B4B, iconFieldYOffset, 1, 1, 1, 1, true))
|
local scrollBar = window:addChild(GUI.scrollBar(1, 4, 1, 1, 0xC3C3C3, 0x4B4B4B, iconFieldYOffset, 1, 1, 1, 1, true))
|
||||||
scrollBar.eventHandler = nil
|
scrollBar.eventHandler = nil
|
||||||
@ -89,12 +87,12 @@ window.actionButtons:moveToFront()
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local function saveConfig()
|
local function saveConfig()
|
||||||
table.toFile(configPath, config)
|
filesystem.writeTable(configPath, config)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateFileListAndDraw()
|
local function updateFileListAndDraw()
|
||||||
iconField:updateFileList()
|
iconField:updateFileList()
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function workpathHistoryButtonsUpdate()
|
local function workpathHistoryButtonsUpdate()
|
||||||
@ -136,19 +134,19 @@ end
|
|||||||
local function sidebarItemDraw(object)
|
local function sidebarItemDraw(object)
|
||||||
local textColor, limit = object.textColor, object.width - 2
|
local textColor, limit = object.textColor, object.width - 2
|
||||||
if object.path == iconField.workpath then
|
if object.path == iconField.workpath then
|
||||||
textColor = 0x3C3C3C
|
textColor = 0x5A5A5A
|
||||||
buffer.drawRectangle(object.x, object.y, object.width, 1, 0xE1E1E1, textColor, " ")
|
screen.drawRectangle(object.x, object.y, object.width, 1, 0xE1E1E1, textColor, " ")
|
||||||
|
|
||||||
if object.onRemove then
|
if object.onRemove then
|
||||||
limit = limit - 2
|
limit = limit - 2
|
||||||
buffer.drawText(object.x + object.width - 2, object.y, 0x969696, "x")
|
screen.drawText(object.x + object.width - 2, object.y, 0x969696, "x")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
buffer.drawText(object.x + 1, object.y, textColor, string.limit(object.text, limit, "center"))
|
screen.drawText(object.x + 1, object.y, textColor, text.limit(object.text, limit, "center"))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function sidebarItemEventHandler(application, object, e1, e2, e3, ...)
|
local function sidebarItemEventHandler(workspace, object, e1, e2, e3, ...)
|
||||||
if e1 == "touch" then
|
if e1 == "touch" then
|
||||||
if object.onRemove and e3 == object.x + object.width - 2 then
|
if object.onRemove and e3 == object.x + object.width - 2 then
|
||||||
object.onRemove()
|
object.onRemove()
|
||||||
@ -184,25 +182,21 @@ local function addSidebarSeparator()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function onFavouriteTouch(path)
|
local function onFavouriteTouch(path)
|
||||||
if filesystem.exists(path) then
|
|
||||||
addWorkpath(path)
|
addWorkpath(path)
|
||||||
updateFileListAndDraw()
|
updateFileListAndDraw()
|
||||||
else
|
|
||||||
GUI.alert("Path doesn't exists: " .. path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local openFTP, updateSidebar
|
local openFTP, updateSidebar
|
||||||
|
|
||||||
openFTP = function(...)
|
openFTP = function(...)
|
||||||
local mountPath = MineOSNetwork.mountPaths.FTP .. MineOSNetwork.getFTPProxyName(...) .. "/"
|
local mountPath = network.mountPaths.FTP .. network.getFTPProxyName(...) .. "/"
|
||||||
|
|
||||||
addWorkpath(mountPath)
|
addWorkpath(mountPath)
|
||||||
application:draw()
|
workspace:draw()
|
||||||
|
|
||||||
local proxy, reason = MineOSNetwork.connectToFTP(...)
|
local proxy, reason = network.connectToFTP(...)
|
||||||
if proxy then
|
if proxy then
|
||||||
MineOSNetwork.umountFTPs()
|
network.unmountFTPs()
|
||||||
filesystem.mount(proxy, mountPath)
|
filesystem.mount(proxy, mountPath)
|
||||||
updateSidebar()
|
updateSidebar()
|
||||||
updateFileListAndDraw()
|
updateFileListAndDraw()
|
||||||
@ -215,7 +209,7 @@ updateSidebar = function()
|
|||||||
itemsLayout:removeChildren()
|
itemsLayout:removeChildren()
|
||||||
|
|
||||||
-- Favourites
|
-- Favourites
|
||||||
addSidebarTitle(MineOSCore.localization.favourite)
|
addSidebarTitle(system.localization.favourite)
|
||||||
|
|
||||||
for i = 1, #config.favourites do
|
for i = 1, #config.favourites do
|
||||||
local object = addSidebarItem(" " .. filesystem.name(config.favourites[i].name), config.favourites[i].path)
|
local object = addSidebarItem(" " .. filesystem.name(config.favourites[i].name), config.favourites[i].path)
|
||||||
@ -227,7 +221,7 @@ updateSidebar = function()
|
|||||||
object.onRemove = function()
|
object.onRemove = function()
|
||||||
table.remove(config.favourites, i)
|
table.remove(config.favourites, i)
|
||||||
updateSidebar()
|
updateSidebar()
|
||||||
application:draw()
|
workspace:draw()
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -237,14 +231,14 @@ updateSidebar = function()
|
|||||||
-- Modem connections
|
-- Modem connections
|
||||||
local added = false
|
local added = false
|
||||||
for proxy, path in filesystem.mounts() do
|
for proxy, path in filesystem.mounts() do
|
||||||
if proxy.MineOSNetworkModem then
|
if proxy.networkModem then
|
||||||
if not added then
|
if not added then
|
||||||
addSidebarTitle(MineOSCore.localization.network)
|
addSidebarTitle(system.localization.network)
|
||||||
added = true
|
added = true
|
||||||
end
|
end
|
||||||
|
|
||||||
addSidebarItem(" " .. MineOSNetwork.getModemProxyName(proxy), path .. "/").onTouch = function()
|
addSidebarItem(" " .. network.getModemProxyName(proxy), path).onTouch = function()
|
||||||
addWorkpath(path .. "/")
|
addWorkpath(path)
|
||||||
updateFileListAndDraw()
|
updateFileListAndDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -255,13 +249,13 @@ updateSidebar = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- FTP connections
|
-- FTP connections
|
||||||
if MineOSNetwork.internetProxy and #MineOSCore.properties.FTPConnections > 0 then
|
if network.internetProxy and #system.properties.networkFTPConnections > 0 then
|
||||||
addSidebarTitle(MineOSCore.localization.networkFTPConnections)
|
addSidebarTitle(system.localization.networkFTPConnections)
|
||||||
|
|
||||||
for i = 1, #MineOSCore.properties.FTPConnections do
|
for i = 1, #system.properties.networkFTPConnections do
|
||||||
local connection = MineOSCore.properties.FTPConnections[i]
|
local connection = system.properties.networkFTPConnections[i]
|
||||||
local name = MineOSNetwork.getFTPProxyName(connection.address, connection.port, connection.user)
|
local name = network.getFTPProxyName(connection.address, connection.port, connection.user)
|
||||||
local mountPath = MineOSNetwork.mountPaths.FTP .. name .. "/"
|
local mountPath = network.mountPaths.FTP .. name .. "/"
|
||||||
|
|
||||||
local object = addSidebarItem(" " .. name, mountPath)
|
local object = addSidebarItem(" " .. name, mountPath)
|
||||||
|
|
||||||
@ -270,10 +264,10 @@ updateSidebar = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
object.onRemove = function()
|
object.onRemove = function()
|
||||||
table.remove(MineOSCore.properties.FTPConnections, i)
|
table.remove(system.properties.networkFTPConnections, i)
|
||||||
updateSidebar()
|
updateSidebar()
|
||||||
application:draw()
|
workspace:draw()
|
||||||
MineOSCore.saveProperties()
|
system.saveProperties()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -281,18 +275,20 @@ updateSidebar = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Mounts
|
-- Mounts
|
||||||
addSidebarTitle(MineOSCore.localization.mounts)
|
addSidebarTitle(system.localization.mounts)
|
||||||
|
|
||||||
for proxy, path in filesystem.mounts() do
|
for proxy, path in filesystem.mounts() do
|
||||||
if path ~= "/" and not proxy.MineOSNetworkModem and not proxy.MineOSNetworkFTP then
|
if not proxy.networkModem and not proxy.networkFTP then
|
||||||
addSidebarItem(" " .. (proxy.getLabel() or filesystem.name(path)), path .. "/").onTouch = function()
|
if proxy ~= filesystem.getProxy() then
|
||||||
onFavouriteTouch(path .. "/")
|
addSidebarItem(" " .. (proxy.getLabel() or filesystem.name(path)), path).onTouch = function()
|
||||||
|
onFavouriteTouch(path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
itemsLayout.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
itemsLayout.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
|
||||||
if e1 == "scroll" then
|
if e1 == "scroll" then
|
||||||
local cell = itemsLayout.cells[1][1]
|
local cell = itemsLayout.cells[1][1]
|
||||||
local from = 0
|
local from = 0
|
||||||
@ -305,15 +301,15 @@ itemsLayout.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
|||||||
cell.verticalMargin = to
|
cell.verticalMargin = to
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
elseif e1 == "component_added" or e1 == "component_removed" then
|
elseif e1 == "component_added" or e1 == "component_removed" then
|
||||||
FTPButton.disabled = not MineOSNetwork.internetProxy
|
FTPButton.disabled = not network.internetProxy
|
||||||
updateSidebar()
|
updateSidebar()
|
||||||
application:draw()
|
workspace:draw()
|
||||||
elseif e1 == "MineOSNetwork" then
|
elseif e1 == "network" then
|
||||||
if e2 == "updateProxyList" or e2 == "timeout" then
|
if e2 == "updateProxyList" or e2 == "timeout" then
|
||||||
updateSidebar()
|
updateSidebar()
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -322,7 +318,7 @@ local function updateScrollBar()
|
|||||||
local shownFilesCount = #iconField.fileList - iconField.fromFile + 1
|
local shownFilesCount = #iconField.fileList - iconField.fromFile + 1
|
||||||
|
|
||||||
local horizontalLines = math.ceil(shownFilesCount / iconField.iconCount.horizontal)
|
local horizontalLines = math.ceil(shownFilesCount / iconField.iconCount.horizontal)
|
||||||
local minimumOffset = 3 - (horizontalLines - 1) * (MineOSCore.properties.iconHeight + MineOSCore.properties.iconVerticalSpaceBetween) - MineOSCore.properties.iconVerticalSpaceBetween
|
local minimumOffset = 3 - (horizontalLines - 1) * (system.properties.iconHeight + system.properties.iconVerticalSpace) - system.properties.iconVerticalSpace
|
||||||
|
|
||||||
if iconField.yOffset > iconFieldYOffset then
|
if iconField.yOffset > iconFieldYOffset then
|
||||||
iconField.yOffset = iconFieldYOffset
|
iconField.yOffset = iconFieldYOffset
|
||||||
@ -356,30 +352,30 @@ prevButton.onTouch = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
FTPButton.onTouch = function()
|
FTPButton.onTouch = function()
|
||||||
local container = MineOSInterface.addBackgroundContainer(application, MineOSCore.localization.networkFTPNewConnection)
|
local container = GUI.addBackgroundContainer(workspace, true, true, system.localization.networkFTPNewConnection)
|
||||||
|
|
||||||
local ad, po, us, pa, la = "ftp.example.com", "21", "root", "1234"
|
local ad, po, us, pa
|
||||||
if #MineOSCore.properties.FTPConnections > 0 then
|
if #system.properties.networkFTPConnections > 0 then
|
||||||
local la = MineOSCore.properties.FTPConnections[#MineOSCore.properties.FTPConnections]
|
local la = system.properties.networkFTPConnections[#system.properties.networkFTPConnections]
|
||||||
ad, po, us, pa = la.address, tostring(la.port), la.user, la.password
|
ad, po, us, pa = la.address, tostring(la.port), la.user, la.password
|
||||||
end
|
end
|
||||||
|
|
||||||
local addressInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, 0x2D2D2D, ad, MineOSCore.localization.networkFTPAddress, true))
|
local addressInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x969696, 0xE1E1E1, 0x2D2D2D, ad, system.localization.networkFTPAddress, true))
|
||||||
local portInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, 0x2D2D2D, po, MineOSCore.localization.networkFTPPort, true))
|
local portInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x969696, 0xE1E1E1, 0x2D2D2D, po, system.localization.networkFTPPort, true))
|
||||||
local userInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, 0x2D2D2D, us, MineOSCore.localization.networkFTPUser, true))
|
local userInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x969696, 0xE1E1E1, 0x2D2D2D, us, system.localization.networkFTPUser, true))
|
||||||
local passwordInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x696969, 0xE1E1E1, 0x2D2D2D, pa, MineOSCore.localization.networkFTPPassword, true, "*"))
|
local passwordInput = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x969696, 0xE1E1E1, 0x2D2D2D, pa, system.localization.networkFTPPassword, true, "*"))
|
||||||
container.layout:addChild(GUI.button(1, 1, 36, 3, 0xA5A5A5, 0xFFFFFF, 0x2D2D2D, 0xE1E1E1, "OK")).onTouch = function()
|
container.layout:addChild(GUI.button(1, 1, 36, 3, 0x5A5A5A, 0xE1E1E1, 0x2D2D2D, 0xE1E1E1, "OK")).onTouch = function()
|
||||||
container:remove()
|
container:remove()
|
||||||
|
|
||||||
local port = tonumber(portInput.text)
|
local port = tonumber(portInput.text)
|
||||||
if port then
|
if port then
|
||||||
local found = false
|
local found = false
|
||||||
for i = 1, #MineOSCore.properties.FTPConnections do
|
for i = 1, #system.properties.networkFTPConnections do
|
||||||
if
|
if
|
||||||
MineOSCore.properties.FTPConnections[i].address == addressInput.text and
|
system.properties.networkFTPConnections[i].address == addressInput.text and
|
||||||
MineOSCore.properties.FTPConnections[i].port == port and
|
system.properties.networkFTPConnections[i].port == port and
|
||||||
MineOSCore.properties.FTPConnections[i].user == userInput.text and
|
system.properties.networkFTPConnections[i].user == userInput.text and
|
||||||
MineOSCore.properties.FTPConnections[i].password == passwordInput.text
|
system.properties.networkFTPConnections[i].password == passwordInput.text
|
||||||
then
|
then
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
@ -387,26 +383,26 @@ FTPButton.onTouch = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not found then
|
if not found then
|
||||||
table.insert(MineOSCore.properties.FTPConnections, {
|
table.insert(system.properties.networkFTPConnections, {
|
||||||
address = addressInput.text,
|
address = addressInput.text,
|
||||||
port = port,
|
port = port,
|
||||||
user = userInput.text,
|
user = userInput.text,
|
||||||
password = passwordInput.text
|
password = passwordInput.text
|
||||||
})
|
})
|
||||||
MineOSCore.saveProperties()
|
system.saveProperties()
|
||||||
|
|
||||||
updateSidebar()
|
updateSidebar()
|
||||||
application:draw()
|
workspace:draw()
|
||||||
|
|
||||||
openFTP(addressInput.text, port, userInput.text, passwordInput.text)
|
openFTP(addressInput.text, port, userInput.text, passwordInput.text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
iconField.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
iconField.eventHandler = function(workspace, object, e1, e2, e3, e4, e5)
|
||||||
if e1 == "scroll" then
|
if e1 == "scroll" then
|
||||||
iconField.yOffset = iconField.yOffset + e5 * 2
|
iconField.yOffset = iconField.yOffset + e5 * 2
|
||||||
|
|
||||||
@ -417,19 +413,19 @@ iconField.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
|||||||
iconField.iconsContainer.children[i].localY = iconField.iconsContainer.children[i].localY + delta
|
iconField.iconsContainer.children[i].localY = iconField.iconsContainer.children[i].localY + delta
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
|
|
||||||
if scrollTimerID then
|
if scrollTimerHandler then
|
||||||
event.cancel(scrollTimerID)
|
event.removeHandler(scrollTimerHandler)
|
||||||
scrollTimerID = nil
|
scrollTimerHandler = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
scrollTimerID = event.timer(0.3, function()
|
scrollTimerHandler = event.addHandler(function()
|
||||||
computer.pushSignal("Finder", "updateFileList")
|
computer.pushSignal("Finder", "updateFileList")
|
||||||
end, 1)
|
end, 0.3, 1)
|
||||||
elseif e1 == "MineOSCore" or e1 == "Finder" then
|
elseif e1 == "system" or e1 == "Finder" then
|
||||||
if e2 == "updateFileList" then
|
if e2 == "updateFileList" then
|
||||||
if e1 == "MineOSCore" then
|
if e1 == "system" then
|
||||||
iconField.yOffset = iconFieldYOffset
|
iconField.yOffset = iconFieldYOffset
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -441,7 +437,7 @@ iconField.eventHandler = function(application, object, e1, e2, e3, e4, e5)
|
|||||||
|
|
||||||
saveConfig()
|
saveConfig()
|
||||||
updateSidebar()
|
updateSidebar()
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -457,7 +453,7 @@ iconField.launchers.showPackageContent = function(icon)
|
|||||||
end
|
end
|
||||||
|
|
||||||
iconField.launchers.showContainingFolder = function(icon)
|
iconField.launchers.showContainingFolder = function(icon)
|
||||||
addWorkpath(filesystem.path(MineOSCore.readShortcut(icon.path)))
|
addWorkpath(filesystem.path(system.readShortcut(icon.path)))
|
||||||
updateFileListAndDraw()
|
updateFileListAndDraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -492,7 +488,7 @@ iconField.updateFileList = function(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
overrideUpdateFileList(...)
|
overrideUpdateFileList(...)
|
||||||
updateScrollBar()
|
updateScrollBar()
|
||||||
end
|
end
|
||||||
@ -510,7 +506,7 @@ gotoButton.onTouch = function()
|
|||||||
iconField:updateFileList()
|
iconField:updateFileList()
|
||||||
end
|
end
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
statusContainer.hidden = true
|
statusContainer.hidden = true
|
||||||
@ -524,7 +520,7 @@ window.actionButtons.maximize.onTouch = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
window.actionButtons.close.onTouch = function()
|
window.actionButtons.close.onTouch = function()
|
||||||
window:close()
|
window:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function calculateSizes()
|
local function calculateSizes()
|
||||||
@ -569,7 +565,7 @@ window.onResize = function(width, height)
|
|||||||
window.height = height
|
window.height = height
|
||||||
calculateSizes()
|
calculateSizes()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
updateFileListAndDraw()
|
updateFileListAndDraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -577,7 +573,7 @@ resizer.onResize = function(deltaX)
|
|||||||
sidebarContainer.width = sidebarContainer.width + deltaX
|
sidebarContainer.width = sidebarContainer.width + deltaX
|
||||||
calculateSizes()
|
calculateSizes()
|
||||||
|
|
||||||
application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
resizer.onResizeFinished = function()
|
resizer.onResizeFinished = function()
|
||||||
Binary file not shown.
@ -1,294 +0,0 @@
|
|||||||
local image = require("image")
|
|
||||||
local buffer = require("doubleBuffering")
|
|
||||||
local keyboard = require("keyboard")
|
|
||||||
local bigLetters = require("bigLetters")
|
|
||||||
local fs = require("filesystem")
|
|
||||||
local serialization = require("serialization")
|
|
||||||
local ecs = require("ECSAPI")
|
|
||||||
local event = require("event")
|
|
||||||
local MineOSCore = require("MineOSCore")
|
|
||||||
local MineOSPaths = require("MineOSPaths")
|
|
||||||
--afaefa
|
|
||||||
|
|
||||||
buffer.flush()
|
|
||||||
local bufferWidth, bufferHeight = buffer.getResolution()
|
|
||||||
|
|
||||||
local config = {
|
|
||||||
FPS = 0.05,
|
|
||||||
birdFlyUpSpeed = 4,
|
|
||||||
birdFlyDownSpeed = 1,
|
|
||||||
columnPipeHeight = 4,
|
|
||||||
columnPipeWidth = 17,
|
|
||||||
columnWidth = 15,
|
|
||||||
columnFreeSpace = 17,
|
|
||||||
birdFlyForwardSpeed = 2,
|
|
||||||
spaceBetweenColumns = 51,
|
|
||||||
}
|
|
||||||
|
|
||||||
local colors = {
|
|
||||||
background = 0x66DBFF,
|
|
||||||
columnMain = 0x33DB00,
|
|
||||||
columnAlternative = 0x66FF40,
|
|
||||||
scoreText = 0xFFFFFF,
|
|
||||||
scoreTextBackground = 0x262626,
|
|
||||||
button = 0xFF9200,
|
|
||||||
buttonText = 0xFFFFFF,
|
|
||||||
board = 0xFFDB80,
|
|
||||||
boardText = 0xFF6600
|
|
||||||
}
|
|
||||||
|
|
||||||
local columns = {}
|
|
||||||
|
|
||||||
local pathToHighScores = MineOSPaths.applicationData .. "/FlappyBird/Scores.cfg"
|
|
||||||
local pathToFlappyImage = MineOSCore.getCurrentScriptDirectory() .. "Flappy.pic"
|
|
||||||
local bird = image.load(pathToFlappyImage)
|
|
||||||
local xBird, yBird = 8, math.floor(bufferHeight / 2 - 3)
|
|
||||||
local birdIsAlive = true
|
|
||||||
|
|
||||||
local scores = {}
|
|
||||||
local currentScore, currentUser = 0, 0
|
|
||||||
local xScore, yScore = math.floor(bufferWidth / 2 - 6), math.floor(bufferHeight * 0.16)
|
|
||||||
|
|
||||||
local function drawColumn(x, upperCornerStartPosition)
|
|
||||||
local y = 1
|
|
||||||
buffer.drawRectangle(x + 1, y, config.columnWidth, upperCornerStartPosition - config.columnPipeHeight, colors.columnMain, 0x0, " ")
|
|
||||||
buffer.drawRectangle(x, upperCornerStartPosition - config.columnPipeHeight, config.columnPipeWidth, config.columnPipeHeight, colors.columnAlternative, 0x0, " ")
|
|
||||||
|
|
||||||
y = upperCornerStartPosition + config.columnFreeSpace
|
|
||||||
buffer.drawRectangle(x, y, config.columnPipeWidth, config.columnPipeHeight, colors.columnAlternative, 0x0, " ")
|
|
||||||
y = y + config.columnPipeHeight
|
|
||||||
buffer.drawRectangle(x + 1, y, config.columnWidth, bufferHeight - y + 1, colors.columnMain, 0x0, " ")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function dieBirdDie()
|
|
||||||
if birdIsAlive then
|
|
||||||
bird = image.blend(bird, 0x880000, 0.5)
|
|
||||||
birdIsAlive = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function generateColumn()
|
|
||||||
local yFreeZone = math.random(config.columnPipeHeight + 2, bufferHeight - config.columnPipeHeight - config.columnFreeSpace)
|
|
||||||
table.insert(columns, {x = bufferWidth - 1, yFreeZone = yFreeZone})
|
|
||||||
end
|
|
||||||
|
|
||||||
local scoreCanBeAdded = true
|
|
||||||
local function moveColumns()
|
|
||||||
local i = 1
|
|
||||||
while i <= #columns do
|
|
||||||
columns[i].x = columns[i].x - 1
|
|
||||||
|
|
||||||
if (columns[i].x >= xBird and columns[i].x <= xBird + 13) then
|
|
||||||
if ((yBird >= columns[i].yFreeZone) and (yBird + 6 <= columns[i].yFreeZone + config.columnFreeSpace - 1)) then
|
|
||||||
if scoreCanBeAdded == true then currentScore = currentScore + 1; scoreCanBeAdded = false end
|
|
||||||
else
|
|
||||||
dieBirdDie()
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- scoreCanBeAdded = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if columns[i].x < -(config.columnPipeWidth) then
|
|
||||||
scoreCanBeAdded = true
|
|
||||||
table.remove(columns, i)
|
|
||||||
i = i - 1
|
|
||||||
end
|
|
||||||
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawColumns()
|
|
||||||
for i = 1, #columns do
|
|
||||||
drawColumn(columns[i].x, columns[i].yFreeZone)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawBackground()
|
|
||||||
buffer.clear(colors.background)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawBird()
|
|
||||||
buffer.drawImage(xBird, yBird, bird)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawBigCenterText(y, textColor, usePseudoShadow, text)
|
|
||||||
local width = bigLetters.getTextSize(text)
|
|
||||||
local x = math.floor(bufferWidth / 2 - width / 2)
|
|
||||||
|
|
||||||
if usePseudoShadow then buffer.drawRectangle(x - 2, y - 1, width + 4, 7, colors.scoreTextBackground, 0x0, " ") end
|
|
||||||
bigLetters.drawText(x, y, textColor, text)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawAll(force)
|
|
||||||
drawBackground()
|
|
||||||
drawColumns()
|
|
||||||
drawBird()
|
|
||||||
drawBigCenterText(yScore, colors.scoreText, true,tostring(currentScore))
|
|
||||||
|
|
||||||
buffer.drawChanges(force)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function saveHighScores()
|
|
||||||
fs.makeDirectory(fs.path(pathToHighScores))
|
|
||||||
local file = io.open(pathToHighScores, "w")
|
|
||||||
file:write(serialization.serialize(scores))
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function loadHighScores()
|
|
||||||
if fs.exists(pathToHighScores) then
|
|
||||||
local file = io.open(pathToHighScores, "r")
|
|
||||||
scores = serialization.unserialize(file:read("*a"))
|
|
||||||
file:close()
|
|
||||||
else
|
|
||||||
scores = {}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function clicked(x, y, object)
|
|
||||||
if x >= object[1] and y >= object[2] and x <= object[3] and y <= object[4] then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function wait()
|
|
||||||
while true do
|
|
||||||
local e = {event.pull()}
|
|
||||||
if e[1] == "touch" or e[1] == "key_down" then
|
|
||||||
currentUser = e[6]
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function showPlayers(x, y)
|
|
||||||
local width = 40
|
|
||||||
local nicknameLimit = 20
|
|
||||||
local mode = false
|
|
||||||
local counter = 1
|
|
||||||
local stro4ka = string.rep(" ", nicknameLimit).."│"..string.rep(" ", width - nicknameLimit)
|
|
||||||
ecs.colorTextWithBack(x, y, 0xffffff, ecs.colors.blue, stro4ka)
|
|
||||||
gpu.set(x + 1, y, "Имя игрока")
|
|
||||||
gpu.set(x + nicknameLimit + 2, y, "Очки")
|
|
||||||
|
|
||||||
for key, val in pairs(players) do
|
|
||||||
local color = 0xffffff
|
|
||||||
|
|
||||||
if mode then
|
|
||||||
color = color - 0x222222
|
|
||||||
end
|
|
||||||
|
|
||||||
gpu.setForeground(0x262626)
|
|
||||||
gpu.setBackground(color)
|
|
||||||
gpu.set(x, y + counter, stro4ka)
|
|
||||||
gpu.set(x + 3, y + counter, ecs.stringLimit("end", key, nicknameLimit - 4))
|
|
||||||
gpu.set(x + nicknameLimit + 2, y + counter, tostring(players[key][1]))
|
|
||||||
ecs.colorTextWithBack(x + 1, y + counter, players[key][2], color, "●")
|
|
||||||
|
|
||||||
counter = counter + 1
|
|
||||||
mode = not mode
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function finalGUI()
|
|
||||||
local obj = {}
|
|
||||||
local widthOfBoard = 56
|
|
||||||
local heightOfBoard = 40
|
|
||||||
|
|
||||||
local function draw()
|
|
||||||
local y = math.floor(bufferHeight / 2 - 19)
|
|
||||||
local x = math.floor(bufferWidth / 2 - widthOfBoard / 2)
|
|
||||||
|
|
||||||
drawAll()
|
|
||||||
|
|
||||||
buffer.drawRectangle(x, y, widthOfBoard, heightOfBoard, colors.board, 0xFFFFFF, " ", 0.3)
|
|
||||||
|
|
||||||
y = y + 2
|
|
||||||
drawBigCenterText(y, colors.boardText, false, "score")
|
|
||||||
y = y + 8
|
|
||||||
drawBigCenterText(y, 0xFFFFFF, true, tostring(currentScore))
|
|
||||||
y = y + 8
|
|
||||||
drawBigCenterText(y, colors.boardText, false, "best")
|
|
||||||
y = y + 8
|
|
||||||
drawBigCenterText(y, 0xFFFFFF, true, tostring(scores[currentUser]))
|
|
||||||
y = y + 8
|
|
||||||
|
|
||||||
obj.retry = { buffer.button(x, y, widthOfBoard, 3, 0xFF6600, colors.buttonText, "Заново") }; y = y + 3
|
|
||||||
-- obj.records = { buffer.button(x, y, widthOfBoard, 3, 0xFF9900, colors.buttonText, "Таблица рекордов") }; y = y + 3
|
|
||||||
obj.exit = { buffer.button(x, y, widthOfBoard, 3, 0x262626, colors.buttonText, "Выход") }; y = y + 3
|
|
||||||
|
|
||||||
buffer.drawChanges()
|
|
||||||
end
|
|
||||||
|
|
||||||
draw()
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local e = {event.pull("touch")}
|
|
||||||
if clicked(e[3], e[4], obj.retry) then
|
|
||||||
buffer.button(obj.retry[1], obj.retry[2], widthOfBoard, 3, 0xFFFFFF, 0x000000, "Заново")
|
|
||||||
buffer.drawChanges()
|
|
||||||
os.sleep(0.2)
|
|
||||||
currentScore = 0
|
|
||||||
birdIsAlive = true
|
|
||||||
scoreCanBeAdded = true
|
|
||||||
columns = {}
|
|
||||||
bird = image.load(pathToFlappyImage)
|
|
||||||
yBird = math.floor(bufferHeight / 2 - 3)
|
|
||||||
drawAll()
|
|
||||||
wait()
|
|
||||||
return
|
|
||||||
|
|
||||||
elseif clicked(e[3], e[4], obj.exit) then
|
|
||||||
buffer.button(obj.exit[1], obj.exit[2], widthOfBoard, 3, 0xFFFFFF, 0x000000, "Выход")
|
|
||||||
buffer.drawChanges()
|
|
||||||
os.sleep(0.2)
|
|
||||||
buffer.clear(0x262626)
|
|
||||||
ecs.prepareToExit()
|
|
||||||
os.exit()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
loadHighScores()
|
|
||||||
drawAll()
|
|
||||||
wait()
|
|
||||||
|
|
||||||
local xNewColumnGenerationVariable = config.spaceBetweenColumns
|
|
||||||
while true do
|
|
||||||
local somethingHappend = false
|
|
||||||
|
|
||||||
local e = {event.pull(config.FPS)}
|
|
||||||
if birdIsAlive and (e[1] == "touch" or e[1] == "key_down") then
|
|
||||||
yBird = yBird - config.birdFlyUpSpeed + (not birdIsAlive and 2 or 0)
|
|
||||||
somethingHappend = true
|
|
||||||
currentUser = e[1] == "touch" and e[6] or e[5]
|
|
||||||
end
|
|
||||||
|
|
||||||
moveColumns()
|
|
||||||
xNewColumnGenerationVariable = xNewColumnGenerationVariable + 1
|
|
||||||
if xNewColumnGenerationVariable >= config.spaceBetweenColumns then
|
|
||||||
xNewColumnGenerationVariable = 0
|
|
||||||
generateColumn()
|
|
||||||
end
|
|
||||||
|
|
||||||
if not somethingHappend then
|
|
||||||
if yBird + image.getHeight(bird) - 1 < bufferHeight then
|
|
||||||
yBird = yBird + config.birdFlyDownSpeed
|
|
||||||
else
|
|
||||||
scores[currentUser] = math.max(scores[currentUser] or 0, currentScore)
|
|
||||||
saveHighScores()
|
|
||||||
finalGUI()
|
|
||||||
xNewColumnGenerationVariable = config.spaceBetweenColumns
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
drawAll()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
Программа-симулятор популярной игры Flappy Bird, написанная товарищем Newbie с форума ComputerCraft.ru.
|
|
||||||
@ -1,309 +0,0 @@
|
|||||||
--Floppy Block v.0.2
|
|
||||||
--Автор: newbie
|
|
||||||
|
|
||||||
local term = require("term")
|
|
||||||
local event = require("event")
|
|
||||||
local computer = require("computer")
|
|
||||||
local component = require("component")
|
|
||||||
local fs = require("filesystem")
|
|
||||||
local gpu = component.gpu
|
|
||||||
local serialization = require("serialization")
|
|
||||||
local xSize, ySize = gpu.getResolution()
|
|
||||||
local width = 30
|
|
||||||
local height = 22
|
|
||||||
local startXPosPlayer = 8
|
|
||||||
local tempPosPlayer = 10
|
|
||||||
local nicknames
|
|
||||||
local records
|
|
||||||
local name
|
|
||||||
local count = 0
|
|
||||||
local tCount = 0
|
|
||||||
local colors = {
|
|
||||||
player = 0xffea00,
|
|
||||||
bg = 0x71c5cf,
|
|
||||||
floor = 0xddd894,
|
|
||||||
walls = 0x74bf2e,
|
|
||||||
text = 0xefb607,
|
|
||||||
button = 0x000000
|
|
||||||
}
|
|
||||||
local quit = false
|
|
||||||
local game = true
|
|
||||||
local fin = false
|
|
||||||
local function start()
|
|
||||||
term.clear()
|
|
||||||
gpu.setForeground(colors.player)
|
|
||||||
gpu.set(6, 10, "Кликни чтоб начать")
|
|
||||||
gpu.set(5, 11, "Жми кнопки чтоб жить")
|
|
||||||
gpu.setForeground(colors.text)
|
|
||||||
local e = {event.pull("touch")}
|
|
||||||
name = e[6]
|
|
||||||
computer.addUser(name)--Эту строку лучше коментить если игру ставите на личный комп
|
|
||||||
end
|
|
||||||
local function paintWall()
|
|
||||||
local function up() --cлушалка
|
|
||||||
if tempPosPlayer <= 2 then --проверка на удар сверху
|
|
||||||
fin = true
|
|
||||||
game = false
|
|
||||||
event.ignore("key_down", up)
|
|
||||||
end
|
|
||||||
gpu.set(startXPosPlayer, tempPosPlayer, " ")
|
|
||||||
tempPosPlayer = tempPosPlayer - 1
|
|
||||||
gpu.setBackground(colors.player)
|
|
||||||
gpu.set(startXPosPlayer, tempPosPlayer, " ")
|
|
||||||
gpu.setBackground(colors.bg)
|
|
||||||
os.sleep(0.2)
|
|
||||||
end
|
|
||||||
tempPosPlayer = 10
|
|
||||||
while game do
|
|
||||||
gpu.set(2, 3, tostring(tCount))
|
|
||||||
--Делает нам на случайной высоте отвертие в 5 блоков
|
|
||||||
local randomY = math.modf(math.random(2,15))
|
|
||||||
for i = 1, 29 do
|
|
||||||
local a = 29 - i
|
|
||||||
gpu.setBackground(colors.walls)
|
|
||||||
for i=2, randomY do
|
|
||||||
gpu.set(a, i, " ")
|
|
||||||
end
|
|
||||||
for i = randomY + 5, 21 do
|
|
||||||
gpu.set(a, i, " ")
|
|
||||||
end
|
|
||||||
local function checkWall()
|
|
||||||
rand = randomY + 5
|
|
||||||
if startXPosPlayer + 1 == a then --лобовое столкновение сверху
|
|
||||||
if randomY>= tempPosPlayer -1 then
|
|
||||||
tempPosPlayer = 21
|
|
||||||
end
|
|
||||||
elseif startXPosPlayer == a then --удар в верхний угол задним пикселем
|
|
||||||
if randomY>= tempPosPlayer - 1 then
|
|
||||||
tempPosPlayer = 21
|
|
||||||
end
|
|
||||||
elseif startXPosPlayer == a+1 then --совпадение второго пикселя с задним вверху
|
|
||||||
if randomY>= tempPosPlayer-1 then
|
|
||||||
tempPosPlayer = 21
|
|
||||||
end
|
|
||||||
elseif startXPosPlayer == a+2 then --совпадение второго пикселя с задним вверху
|
|
||||||
if randomY>= tempPosPlayer-1 then
|
|
||||||
tempPosPlayer = 21
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if startXPosPlayer + 1 == a then --лобовое столкновение снизу
|
|
||||||
if tempPosPlayer+1 >= rand then
|
|
||||||
tempPosPlayer = 21
|
|
||||||
end
|
|
||||||
elseif startXPosPlayer == a then --удар в нижний угол задним пикселем
|
|
||||||
if tempPosPlayer+1 >= rand then
|
|
||||||
tempPosPlayer = 21
|
|
||||||
end
|
|
||||||
elseif startXPosPlayer == a+1 then --совпадение второго пикселя с задним сверху
|
|
||||||
if tempPosPlayer +1 >= rand then
|
|
||||||
tempPosPlayer = 21
|
|
||||||
end
|
|
||||||
elseif startXPosPlayer == a+2 then --совпадение второго пикселя с задним сверху
|
|
||||||
if tempPosPlayer +1 >= rand then
|
|
||||||
tempPosPlayer = 21
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
checkWall()
|
|
||||||
if tempPosPlayer>=21 then --проверка на удар снизу
|
|
||||||
fin = true
|
|
||||||
game = false
|
|
||||||
event.ignore("key_down", up)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
--отрисовка, перерисовка игрока
|
|
||||||
gpu.setBackground(colors.bg)
|
|
||||||
gpu.set(startXPosPlayer, tempPosPlayer, " ")
|
|
||||||
tempPosPlayer = tempPosPlayer + 1
|
|
||||||
gpu.setBackground(colors.player)
|
|
||||||
gpu.set(startXPosPlayer, tempPosPlayer, " ")
|
|
||||||
gpu.setBackground(colors.bg)
|
|
||||||
os.sleep(0.3)
|
|
||||||
event.listen("key_down", up)
|
|
||||||
if startXPosPlayer == a then
|
|
||||||
tCount = tCount + 1
|
|
||||||
gpu.set(2, 3, tostring(tCount))
|
|
||||||
end
|
|
||||||
gpu.setBackground(colors.bg)
|
|
||||||
for i=2, randomY do
|
|
||||||
gpu.set(a, i, " ")
|
|
||||||
end
|
|
||||||
for i = randomY + 5, 21 do
|
|
||||||
gpu.set(a, i, " ")
|
|
||||||
end
|
|
||||||
if fin then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local pathToRecords = "records.txt" --путь к файлу с рекордами
|
|
||||||
local function saveRecord() --Сохраняем рекорды
|
|
||||||
local file = io.open(pathToRecords, "w")
|
|
||||||
local array = {["nicknames"] = nicknames, ["records"] = records}
|
|
||||||
file:write(serialization.serialize(array))
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
local function loadRecord() --Загружаем рекорды
|
|
||||||
if fs.exists(pathToRecords) then
|
|
||||||
local array = {}
|
|
||||||
local file = io.open(pathToRecords, "r")
|
|
||||||
local str = file:read("*a")
|
|
||||||
array = serialization.unserialize(str)
|
|
||||||
file:close()
|
|
||||||
nicknames = array.nicknames
|
|
||||||
records = array.records
|
|
||||||
else --или создаем новые дефолтные пустые таблицы
|
|
||||||
fs.makeDirectory(fs.path(pathToRecords))
|
|
||||||
nicknames = {}
|
|
||||||
records = {}
|
|
||||||
saveRecord()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function checkName(name) --Проверка на наличие имени в базе
|
|
||||||
for i =1, #nicknames do
|
|
||||||
if name == nicknames[i] then
|
|
||||||
count = records[i]
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
local function addPlayer() --Создаем учетку пользователю если его нет в базе
|
|
||||||
if checkName(name) then
|
|
||||||
table.insert(nicknames, name)
|
|
||||||
table.insert(records, count)
|
|
||||||
saveRecord()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local function gameOver() --Игра окончена
|
|
||||||
gpu.setBackground(colors.bg)
|
|
||||||
term.clear()
|
|
||||||
gpu.setForeground(colors.player)
|
|
||||||
gpu.set(10,11,"GAME OVER!")
|
|
||||||
gpu.set(8,14,"You count: "..tostring(tCount))
|
|
||||||
gpu.setForeground(colors.text)
|
|
||||||
count = 0
|
|
||||||
tCount = 0
|
|
||||||
game = true
|
|
||||||
fin = false
|
|
||||||
computer.removeUser(name) --опять же коментим эту строку если комп не публичный
|
|
||||||
end
|
|
||||||
local function saveCount() --сохраняем наши заработанные очки
|
|
||||||
for i = 1, #nicknames do
|
|
||||||
if name == nicknames[i] then
|
|
||||||
count = records[i]
|
|
||||||
if tCount > count then
|
|
||||||
records[i] = tCount
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
saveRecord()
|
|
||||||
end
|
|
||||||
local function sortTop() --Сортируем Топ игроков
|
|
||||||
for i=1, #records do
|
|
||||||
for j=1, #records-1 do
|
|
||||||
if records[j] < records[j+1] then
|
|
||||||
local r = records[j+1]
|
|
||||||
local n = nicknames[j+1]
|
|
||||||
records[j+1] = records[j]
|
|
||||||
nicknames[j+1] = nicknames[j]
|
|
||||||
records[j] = r
|
|
||||||
nicknames[j] = n
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
saveRecord()
|
|
||||||
end
|
|
||||||
function paintScene() --Рисуем сцену
|
|
||||||
term.clear()
|
|
||||||
gpu.setBackground(colors.floor)
|
|
||||||
gpu.set(0,1," ")
|
|
||||||
gpu.set(0,22," ")
|
|
||||||
gpu.setBackground(colors.bg)
|
|
||||||
end
|
|
||||||
local function printRecords() --Выводим рекорды на экран
|
|
||||||
term.clear()
|
|
||||||
local xPosName = 5
|
|
||||||
local xPosRecord = 20
|
|
||||||
local yPos = 1
|
|
||||||
loadRecord()
|
|
||||||
gpu.setForeground(colors.player)
|
|
||||||
gpu.set(11,1,"Top - 15")
|
|
||||||
if #nicknames <= 15 then
|
|
||||||
for i = 1, #nicknames do
|
|
||||||
yPos= yPos+1
|
|
||||||
gpu.set(xPosName, yPos, nicknames[i] )
|
|
||||||
gpu.set(xPosRecord, yPos, tostring(records[i]))
|
|
||||||
end
|
|
||||||
else
|
|
||||||
for i = 1, 15 do
|
|
||||||
yPos= yPos+1
|
|
||||||
gpu.set(xPosName, yPos, nicknames[i] )
|
|
||||||
gpu.set(xPosRecord, yPos, tostring(records[i]))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
gpu.setForeground(colors.text)
|
|
||||||
os.sleep(3)
|
|
||||||
floppyBlock()
|
|
||||||
end
|
|
||||||
function main()
|
|
||||||
start()
|
|
||||||
addPlayer()
|
|
||||||
paintScene()
|
|
||||||
paintWall()
|
|
||||||
saveCount()
|
|
||||||
gameOver()
|
|
||||||
os.sleep(3)
|
|
||||||
floppyBlock()
|
|
||||||
end
|
|
||||||
function floppyBlock()
|
|
||||||
term.clear()
|
|
||||||
event.shouldInterrupt = function() return false end --Alt+ Ctrl + C не пашет, так же на ваше усмотрение
|
|
||||||
gpu.setResolution(width, height)
|
|
||||||
gpu.setForeground(colors.player)
|
|
||||||
loadRecord()
|
|
||||||
gpu.set(9,5,"Flappy Block")
|
|
||||||
gpu.setBackground(colors.button)
|
|
||||||
gpu.set(12,15," Play ")
|
|
||||||
gpu.set(11,17," Top-15 ")
|
|
||||||
gpu.set(12,20," Quit ")
|
|
||||||
gpu.setBackground(colors.bg)
|
|
||||||
while true do
|
|
||||||
local e = {event.pull("touch")}
|
|
||||||
if e[4] == 15 then
|
|
||||||
if e[3]>12 then
|
|
||||||
if e[3]<18 then main() end
|
|
||||||
end
|
|
||||||
elseif e[4] == 17 then
|
|
||||||
if e[3]>11 then
|
|
||||||
if e[3]<19 then
|
|
||||||
sortTop()
|
|
||||||
printRecords()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif e[4] == 20 then
|
|
||||||
if e[3]>12 then
|
|
||||||
if e[3]<18 then
|
|
||||||
if e[6] == "newbie" then --В эту строку заносим ник того кто может закрыть игру, если ненужно,
|
|
||||||
--коментим ее
|
|
||||||
gpu.setForeground(colors.text)
|
|
||||||
gpu.setResolution(xSize,ySize)
|
|
||||||
term.clear()
|
|
||||||
quit = true
|
|
||||||
break
|
|
||||||
end --и тут
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if quit then break end
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
floppyBlock()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
Данная программа предназначена для игроков, которым каким-то образом попал в руки командный блок. Если это произошло - подключайте его через адаптер к компьютеру, запускайте программу и наслаждайтесь полными привилегиями администратора. Работает только на серверах с плагином PermissionsEx и включенной поддержкой командных блоков в конфиге мода.
|
|
||||||
@ -1 +0,0 @@
|
|||||||
Данная программа предназначена для игроков, которым каким-то образом попал в руки командный блок. Если это произошло - подключайте его через адаптер к компьютеру, запускайте программу и наслаждайтесь полными привилегиями администратора. Работает только на серверах с плагином PermissionsEx и включенной поддержкой командных блоков в конфиге мода.
|
|
||||||
@ -1,93 +0,0 @@
|
|||||||
|
|
||||||
local component = require("component")
|
|
||||||
local commandBlock
|
|
||||||
local event = require("event")
|
|
||||||
local gpu = component.gpu
|
|
||||||
local ecs = require("ECSAPI")
|
|
||||||
|
|
||||||
if not component.isAvailable("command_block") then
|
|
||||||
ecs.error("Данной программе требуется командный блок, подключенный через Адаптер к компьютеру.")
|
|
||||||
return
|
|
||||||
else
|
|
||||||
commandBlock = component.command_block
|
|
||||||
end
|
|
||||||
|
|
||||||
local function execute(command)
|
|
||||||
commandBlock.setCommand(command)
|
|
||||||
commandBlock.executeCommand()
|
|
||||||
commandBlock.setCommand("")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function info(width, text1, text2)
|
|
||||||
ecs.universalWindow("auto", "auto", width, 0xdddddd, true,
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", 0x880000, "ForceOP"},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"CenterText", 0x262626, text1},
|
|
||||||
{"CenterText", 0x262626, text2},
|
|
||||||
{"EmptyLine"},
|
|
||||||
{"Button", {0x880000, 0xffffff, "Спасибо!"}}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function op(nickname)
|
|
||||||
execute("/pex user " .. nickname .. " add *")
|
|
||||||
info(40, "Вы успешно стали администратором", "этого сервера. Наслаждайтесь!")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function deop(nickname)
|
|
||||||
execute("/pex user " .. nickname .. " remove *")
|
|
||||||
info(40, "Права админстратора удалены.", "Никто ничего не видел, тс-с-с!")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function main()
|
|
||||||
ecs.setScale(0.8)
|
|
||||||
ecs.prepareToExit(0xeeeeee, 0x262626)
|
|
||||||
local xSize, ySize = gpu.getResolution()
|
|
||||||
local yCenter = math.floor(ySize / 2)
|
|
||||||
local xCenter = math.floor(xSize / 2)
|
|
||||||
local yPos = yCenter - 9
|
|
||||||
|
|
||||||
ecs.centerText("x", yPos, "Поздравляем! Вы каким-то образом получили командный блок,"); yPos = yPos + 1
|
|
||||||
ecs.centerText("x", yPos, "и настало время проказничать. Данная программа работает"); yPos = yPos + 1
|
|
||||||
ecs.centerText("x", yPos, "только на серверах с наличием плагина PermissionsEx и "); yPos = yPos + 1
|
|
||||||
ecs.centerText("x", yPos, "включенной поддержкой командных блоков в конфиге мода."); yPos = yPos + 2
|
|
||||||
ecs.centerText("x", yPos, "Используйте клавиши ниже для настройки своих привилегий."); yPos = yPos + 3
|
|
||||||
|
|
||||||
local button1 = { ecs.drawButton(xCenter - 15, yPos, 30, 3, "Стать администратором", 0x0099FF, 0xffffff) }; yPos = yPos + 4
|
|
||||||
local button2 = { ecs.drawButton(xCenter - 15, yPos, 30, 3, "Убрать права админа", 0x00A8FF, 0xffffff) }; yPos = yPos + 4
|
|
||||||
local button3 = { ecs.drawButton(xCenter - 15, yPos, 30, 3, "Выйти", 0x00CCFF, 0xffffff) }; yPos = yPos + 4
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local eventData = { event.pull() }
|
|
||||||
if eventData[1] == "touch" then
|
|
||||||
if ecs.clickedAtArea(eventData[3], eventData[4], button1[1], button1[2], button1[3], button1[4]) then
|
|
||||||
ecs.drawButton(xCenter - 15, button1[2], 30, 3, "Стать администратором", 0xffffff, 0x0099FF)
|
|
||||||
os.sleep(0.2)
|
|
||||||
op(eventData[6])
|
|
||||||
ecs.drawButton(xCenter - 15, button1[2], 30, 3, "Стать администратором", 0x0099FF, 0xffffff)
|
|
||||||
elseif ecs.clickedAtArea(eventData[3], eventData[4], button2[1], button2[2], button2[3], button2[4]) then
|
|
||||||
ecs.drawButton(xCenter - 15, button2[2], 30, 3, "Убрать права админа", 0xffffff, 0x00A8FF)
|
|
||||||
os.sleep(0.2)
|
|
||||||
deop(eventData[6])
|
|
||||||
ecs.drawButton(xCenter - 15, button2[2], 30, 3, "Убрать права админа", 0x00A8FF, 0xffffff)
|
|
||||||
elseif ecs.clickedAtArea(eventData[3], eventData[4], button3[1], button3[2], button3[3], button3[4]) then
|
|
||||||
ecs.drawButton(xCenter - 15, button3[2], 30, 3, "Выйти", 0xffffff, 0x00CCFF)
|
|
||||||
os.sleep(0.2)
|
|
||||||
ecs.prepareToExit()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@ -1,25 +1,26 @@
|
|||||||
local MineOSInterface = require("MineOSInterface")
|
|
||||||
|
local system = require("System")
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
local event = require("event")
|
local event = require("Event")
|
||||||
local component = require("component")
|
local text = require("Text")
|
||||||
local computer = require("computer")
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
local world
|
local world
|
||||||
if component.isAvailable("debug") then
|
if component.isAvailable("debug") then
|
||||||
world = component.debug.getWorld()
|
world = component.get("debug").getWorld()
|
||||||
else
|
else
|
||||||
GUI.alert("This program requires debug card to run")
|
GUI.alert("This program requires debug card to run")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local container = MineOSInterface.addBackgroundContainer(MineOSInterface.application, "Fuck The Rain")
|
local workspace = system.getWorkspace()
|
||||||
|
local container = GUI.addBackgroundContainer(workspace, true, true, "Fuck The Rain")
|
||||||
|
|
||||||
local lines = string.wrap("This script works as background daemon and checks rain condition in specified interval", 36)
|
local lines = text.wrap("This script works as background daemon and checks rain condition in specified interval", 36)
|
||||||
container.layout:addChild(GUI.textBox(1, 1, 36, #lines, nil, 0xA5A5A5, lines, 1, 0, 0))
|
container.layout:addChild(GUI.textBox(1, 1, 36, #lines, nil, 0xA5A5A5, lines, 1, 0, 0))
|
||||||
|
|
||||||
local daemonSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x696969, "Daemon enabled:", _G.fuckTheRainTimerID and true or false)).switch
|
local daemonSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 6, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x696969, "Daemon enabled:", _G.fuckTheRainTimerID and true or false)).switch
|
||||||
local signalSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x696969, "Sound signal:", _G.fuckTheRainSignal)).switch
|
local signalSwitch = container.layout:addChild(GUI.switchAndLabel(1, 1, 36, 8, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x696969, "Sound signal:", _G.fuckTheRainSignal)).switch
|
||||||
|
|
||||||
local intervalSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x696969, 1, 10, 2, false, "Interval: ", " s"))
|
local intervalSlider = container.layout:addChild(GUI.slider(1, 1, 36, 0x66DB80, 0x2D2D2D, 0xE1E1E1, 0x696969, 1, 10, 2, false, "Interval: ", " s"))
|
||||||
@ -30,8 +31,8 @@ container.layout:addChild(GUI.button(1, 1, 36, 3, 0x444444, 0xFFFFFF, 0x2D2D2D,
|
|||||||
_G.fuckTheRainSignal = signalSwitch.state and true or nil
|
_G.fuckTheRainSignal = signalSwitch.state and true or nil
|
||||||
|
|
||||||
if daemonSwitch.state then
|
if daemonSwitch.state then
|
||||||
if not _G.fuckTheRainTimerID then
|
if not _G.fuckTheRainHandler then
|
||||||
_G.fuckTheRainTimerID = event.timer(intervalSlider.value, function()
|
_G.fuckTheRainHandler = event.addHandler(function()
|
||||||
if world.isRaining() or world.isThundering() then
|
if world.isRaining() or world.isThundering() then
|
||||||
world.setThundering(false)
|
world.setThundering(false)
|
||||||
world.setRaining(false)
|
world.setRaining(false)
|
||||||
@ -40,17 +41,17 @@ container.layout:addChild(GUI.button(1, 1, 36, 3, 0x444444, 0xFFFFFF, 0x2D2D2D,
|
|||||||
computer.beep(1500)
|
computer.beep(1500)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end, math.huge)
|
end, intervalSlider.value)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if _G.fuckTheRainTimerID then
|
if _G.fuckTheRainHandler then
|
||||||
event.cancel(_G.fuckTheRainTimerID)
|
event.removeHandler(_G.fuckTheRainHandler)
|
||||||
_G.fuckTheRainTimerID = nil
|
_G.fuckTheRainHandler = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
container:remove()
|
container:remove()
|
||||||
MineOSInterface.application:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
@ -1,217 +0,0 @@
|
|||||||
|
|
||||||
local component = require("component")
|
|
||||||
local color = require("color")
|
|
||||||
local image = require("image")
|
|
||||||
local buffer = require("doubleBuffering")
|
|
||||||
local GUI = require("GUI")
|
|
||||||
local MineOSCore = require("MineOSCore")
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if not component.isAvailable("geolyzer") then
|
|
||||||
GUI.alert("This program requires a geolyzer to work!"); return
|
|
||||||
end
|
|
||||||
|
|
||||||
if not component.isAvailable("hologram") then
|
|
||||||
GUI.alert("This program requires a hologram projector to work!"); return
|
|
||||||
end
|
|
||||||
|
|
||||||
component.gpu.setResolution(component.gpu.maxResolution())
|
|
||||||
buffer.flush()
|
|
||||||
local bufferWidth, bufferHeight = buffer.getResolution()
|
|
||||||
|
|
||||||
local resourcesDirectory = MineOSCore.getCurrentScriptDirectory()
|
|
||||||
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 application = GUI.application()
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
local function getOpenGLValidColorChannels(cykaColor)
|
|
||||||
local r, g, b = color.integerToRGB(cykaColor)
|
|
||||||
return r / 255, g / 255, b / 255
|
|
||||||
end
|
|
||||||
|
|
||||||
local function createCube(x, y, z, cykaColor, isVisThrObj)
|
|
||||||
local cube = component.glasses.addCube3D()
|
|
||||||
cube.set3DPos(x, y, z)
|
|
||||||
cube.setVisibleThroughObjects(isVisThrObj)
|
|
||||||
cube.setColor(getOpenGLValidColorChannels(cykaColor))
|
|
||||||
cube.setAlpha(0.23)
|
|
||||||
return cube
|
|
||||||
end
|
|
||||||
|
|
||||||
local function glassesCreateCube(x, y, z, cykaColor, text)
|
|
||||||
local cube = createCube(x, y, z, cykaColor, true)
|
|
||||||
cube.setVisibleThroughObjects(true)
|
|
||||||
|
|
||||||
local floatingText = component.glasses.addFloatingText()
|
|
||||||
floatingText.set3DPos(x + 0.5, y + 0.5, z + 0.5)
|
|
||||||
floatingText.setColor(1, 1, 1)
|
|
||||||
floatingText.setAlpha(0.6)
|
|
||||||
floatingText.setText(text)
|
|
||||||
floatingText.setScale(0.015)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function createDick(x, y, z, chance, isVisThrObj)
|
|
||||||
if component.isAvailable("glasses") and math.random(1, 100) <= chance then
|
|
||||||
createCube(x, y, z, 0xFFFFFF, isVisThrObj)
|
|
||||||
createCube(x + 1, y, z, 0xFFFFFF, isVisThrObj)
|
|
||||||
createCube(x + 2, y, z, 0xFFFFFF, isVisThrObj)
|
|
||||||
createCube(x + 1, y + 1, z, 0xFFFFFF, isVisThrObj)
|
|
||||||
createCube(x + 1, y + 2, z, 0xFFFFFF, isVisThrObj)
|
|
||||||
createCube(x + 1, y + 3, z, 0xFFFFFF, isVisThrObj)
|
|
||||||
createCube(x + 1, y + 5, z, 0xFF8888, isVisThrObj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function progressReport(value, text)
|
|
||||||
local width = 40
|
|
||||||
local x, y = math.floor(bufferWidth / 2 - width / 2), math.floor(bufferHeight / 2)
|
|
||||||
GUI.progressBar(x, y, width, 0x00B6FF, 0xFFFFFF, 0xEEEEEE, value, true, true, text, "%"):draw()
|
|
||||||
buffer.drawChanges()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function updateData(onScreen, onProjector, onGlasses)
|
|
||||||
local glassesAvailable = component.isAvailable("glasses")
|
|
||||||
|
|
||||||
if onScreen then buffer.clear(0xEEEEEE) end
|
|
||||||
if onProjector then component.hologram.clear() end
|
|
||||||
if onGlasses and glassesAvailable then component.glasses.removeAll() end
|
|
||||||
|
|
||||||
local min, max = tonumber(application.minimumHardnessTextBox.text), tonumber(application.maximumHardnessTextBox.text)
|
|
||||||
if min and max then
|
|
||||||
local horizontalRange, verticalRange = math.floor(application.horizontalScanRangeSlider.value), math.floor(application.verticalScanRangeSlider.value)
|
|
||||||
|
|
||||||
for x = -horizontalRange, horizontalRange do
|
|
||||||
for z = -horizontalRange, horizontalRange do
|
|
||||||
for y = 32 - verticalRange, 32 + verticalRange do
|
|
||||||
if scanResult[x] and scanResult[x][z] and scanResult[x][z][y] and scanResult[x][z][y] >= min and scanResult[x][z][y] <= max then
|
|
||||||
if onScreen then
|
|
||||||
buffer.semiPixelSet(onScreenDataXOffset + x, onScreenDataYOffset + 32 - y, 0x454545)
|
|
||||||
end
|
|
||||||
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 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
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local oldDraw = application.draw
|
|
||||||
application.draw = function()
|
|
||||||
updateData(true, false, false)
|
|
||||||
oldDraw(application)
|
|
||||||
end
|
|
||||||
|
|
||||||
local panelWidth = 30
|
|
||||||
local panelX = bufferWidth - panelWidth + 1
|
|
||||||
local buttonX, objectY = panelX + 2, 2
|
|
||||||
local buttonWidth = panelWidth - 4
|
|
||||||
application:addChild(GUI.panel(panelX, 1, panelWidth, bufferHeight, 0x444444))
|
|
||||||
|
|
||||||
application.planetImage = application:addChild(GUI.image(buttonX, objectY, earthImage))
|
|
||||||
objectY = objectY + application.planetImage.image[2] + 1
|
|
||||||
|
|
||||||
application:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xFFFFFF, "GeoScan v2.0")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
|
||||||
objectY = objectY + 2
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
application:addChild(GUI.label(buttonX, objectY, buttonWidth, 1, 0xFFFFFF, "Rendering properties")):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)
|
|
||||||
objectY = objectY + 2
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
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(application.width / 2 - 35), math.floor(application.height / 2 - 12), button.colors.default.background):show()
|
|
||||||
if selectedColor then button.colors.default.background = selectedColor end
|
|
||||||
application:draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function updateProjectorColors()
|
|
||||||
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)
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
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
|
|
||||||
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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
application:addChild(GUI.button(panelX, bufferHeight - 5, panelWidth, 3, 0x353535, 0xEEEEEE, 0xAAAAAA, 0x262626, "Update")).onTouch = function()
|
|
||||||
updateData(false, true, true)
|
|
||||||
end
|
|
||||||
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(application.horizontalScanRangeSlider.value), math.floor(application.verticalScanRangeSlider.value)
|
|
||||||
local total, current = (horizontalRange * 2 + 1) ^ 2, 0
|
|
||||||
|
|
||||||
buffer.clear(0x0, 0.48)
|
|
||||||
for x = -horizontalRange, horizontalRange do
|
|
||||||
scanResult[x] = {}
|
|
||||||
for z = -horizontalRange, horizontalRange do
|
|
||||||
scanResult[x][z] = component.geolyzer.scan(x, z)
|
|
||||||
current = current + 1
|
|
||||||
progressReport(math.ceil(current / total * 100), "Scan progress: ")
|
|
||||||
buffer.drawChanges()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
application:draw()
|
|
||||||
updateData(false, true, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
buffer.clear(0x0)
|
|
||||||
application:draw()
|
|
||||||
application:start()
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user