mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
aefaef
This commit is contained in:
parent
f9c911f37b
commit
2cc71a63ca
@ -247,7 +247,7 @@
|
||||
name="lib/MineOSCore.lua",
|
||||
url="IgorTimofeev/OpenComputers/master/lib/MineOSCore.lua",
|
||||
type="Library",
|
||||
version=1.32,
|
||||
version=1.33,
|
||||
},
|
||||
{
|
||||
name="lib/advancedLua.lua",
|
||||
@ -294,7 +294,7 @@
|
||||
name="lib/GUI.lua",
|
||||
url="IgorTimofeev/OpenComputers/master/lib/GUI.lua",
|
||||
type="Library",
|
||||
version=1.21,
|
||||
version=1.22,
|
||||
},
|
||||
{
|
||||
name="lib/windows.lua",
|
||||
@ -524,8 +524,17 @@
|
||||
type="Application",
|
||||
icon="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.25,
|
||||
version=1.26,
|
||||
resources={
|
||||
{
|
||||
name="Modules/command_block/Icon.pic",
|
||||
url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/command_block/Icon.pic",
|
||||
},
|
||||
{
|
||||
name="Modules/command_block/Main.lua",
|
||||
url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/command_block/Main.lua",
|
||||
},
|
||||
--
|
||||
{
|
||||
name="Modules/redstone/Icon.pic",
|
||||
url="IgorTimofeev/OpenComputers/master/Applications/SmartHouse/Modules/redstone/Icon.pic",
|
||||
@ -597,6 +606,20 @@
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name="MineOS/Applications/Control2",
|
||||
url="IgorTimofeev/OpenComputers/master/Applications/Control2/Control2.lua",
|
||||
type="Application",
|
||||
icon="IgorTimofeev/OpenComputers/master/Applications/Control2/Icon.pic",
|
||||
createShortcut="desktop",
|
||||
version=1.00,
|
||||
resources={
|
||||
{
|
||||
name="Modules/00_LuaConsole.lua",
|
||||
url="IgorTimofeev/OpenComputers/master/Applications/Control2/Modules/00_LuaConsole.lua",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name="MineOS/Applications/Weather",
|
||||
url="IgorTimofeev/OpenComputers/master/Applications/Weather/Weather.lua",
|
||||
|
||||
BIN
Applications/.DS_Store
vendored
BIN
Applications/.DS_Store
vendored
Binary file not shown.
61
Applications/Control2/Control2.lua
Executable file
61
Applications/Control2/Control2.lua
Executable file
@ -0,0 +1,61 @@
|
||||
|
||||
local fs = require("filesystem")
|
||||
local advancedLua = require("advancedLua")
|
||||
local buffer = require("doubleBuffering")
|
||||
local GUI = require("GUI")
|
||||
local windows = require("windows")
|
||||
local MineOSCore = require("MineOSCore")
|
||||
local event = require("event")
|
||||
local unicode = require("unicode")
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local window = {}
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function loadModule(moduleID)
|
||||
if fs.exists(window.modules[moduleID].path) then
|
||||
local success, reason = dofile(window.modules[moduleID].path)
|
||||
if success then
|
||||
window.modules[moduleID].module = success
|
||||
window.modules[moduleID].module.execute(window)
|
||||
else
|
||||
error("Error due module execution: " .. reason)
|
||||
end
|
||||
else
|
||||
error("Mudule file \"" .. window.modules[moduleID].path "\" doesn't exists")
|
||||
end
|
||||
end
|
||||
|
||||
local function createWindow()
|
||||
window = windows.empty("auto", "auto", math.floor(buffer.screen.width * 0.8), math.floor(buffer.screen.height * 0.7), 78, 24)
|
||||
window:addPanel(1, 1, window.width, window.height, 0xEEEEEE).disabled = true
|
||||
window.tabBar = window:addTabBar(1, 1, window.width, 3, 1, 0xDDDDDD, 0x262626, 0xCCCCCC, 0x262626, "Интерпретатор Lua", "События", "Память", "Диски", "BIOS")
|
||||
window:addWindowActionButtons(2, 1, false)
|
||||
window.drawingArea = window:addContainer(1, 4, window.width, window.height - 3, 0xEEEEEE)
|
||||
|
||||
window.tabBar.onTabSwitched = function(object, eventData)
|
||||
|
||||
end
|
||||
|
||||
window.resourcesPath = MineOSCore.getCurrentApplicationResourcesDirectory()
|
||||
window.modules = {}
|
||||
for file in fs.list(window.resourcesPath .. "Modules/") do
|
||||
table.insert(window.modules, {
|
||||
path = window.resourcesPath .. "Modules/" .. file
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
createWindow()
|
||||
loadModule(1)
|
||||
window.drawShadow = true
|
||||
window:draw()
|
||||
buffer.draw()
|
||||
window.drawShadow = false
|
||||
window:handleEvents()
|
||||
|
||||
|
||||
BIN
Applications/Control2/Icon.pic
Executable file
BIN
Applications/Control2/Icon.pic
Executable file
Binary file not shown.
BIN
Applications/Control2/LuaLogo.pic
Executable file
BIN
Applications/Control2/LuaLogo.pic
Executable file
Binary file not shown.
125
Applications/Control2/Modules/00_LuaConsole.lua
Normal file
125
Applications/Control2/Modules/00_LuaConsole.lua
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
local args = {...}
|
||||
local GUI = require("GUI")
|
||||
local image = require("image")
|
||||
local unicode = require("unicode")
|
||||
|
||||
local module = {
|
||||
name = "Интерпретатор Lua2"
|
||||
}
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function module.execute(window)
|
||||
local luaConsoleHistoryLimit = 50
|
||||
|
||||
local colors, printColor = {
|
||||
passive = 0x777777,
|
||||
error = 0xFF4940,
|
||||
}
|
||||
|
||||
local lines = {
|
||||
{color = 0xFFDB40, text = "Система " .. _VERSION .. " инициализирована"},
|
||||
{color = colors.passive, text = "● Введите выражение и нажимте Enter для его "},
|
||||
{color = colors.passive, text = " исполнения в виде Lua-кода"},
|
||||
{color = colors.passive, text = "● Используйте Tab для автозаполнения названий"},
|
||||
{color = colors.passive, text = " переменных"},
|
||||
{color = colors.passive, text = "● Введите \"=переменная\", чтобы узнать значение"},
|
||||
{color = colors.passive, text = " конкретной переменной"},
|
||||
" "
|
||||
}
|
||||
|
||||
window.drawingArea:deleteChildren()
|
||||
local logoPanelWidth = 20
|
||||
local consolePanelWidth = window.drawingArea.width - logoPanelWidth
|
||||
local luaLogoPanel = window.drawingArea:addPanel(1, 1, logoPanelWidth, window.drawingArea.height, 0xEEEEEE)
|
||||
local luaLogoImage = window.drawingArea:addImage(2, 1, image.load(window.resourcesPath .. "LuaLogo.pic"))
|
||||
local luaCopyrightTextBox = window.drawingArea:addTextBox(2, luaLogoImage.height + 2, luaLogoPanel.width - 2, 5, nil, 0x999999, {_G._VERSION, "(C) 1994-2016", "Lua.org, PUC-Rio", "", "GUI-based by ECS"}, 1)
|
||||
luaCopyrightTextBox:setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top)
|
||||
local consolePanel = window.drawingArea:addPanel(logoPanelWidth + 1, 1, consolePanelWidth, window.drawingArea.height, 0x1E1E1E)
|
||||
local consoleTextBox = window.drawingArea:addTextBox(logoPanelWidth + 2, 1, consolePanelWidth - 2, window.drawingArea.height - 3, nil, 0xFFFFFF, lines, 1)
|
||||
local consoleCommandInputTextBox = window.drawingArea:addInputTextBox(logoPanelWidth + 1, consolePanel.height - 2, consolePanel.width, 3, 0x333333, 0x777777, 0x333333, 0x444444, nil, "print(\"Hello, world!\")")
|
||||
consoleCommandInputTextBox.highlightLuaSyntax = true
|
||||
consoleCommandInputTextBox.autocompleteVariables = true
|
||||
|
||||
-- table.toFile("text.txt", MineOSCore, true, nil, nil, 1)
|
||||
|
||||
local function addLines(lines)
|
||||
for i = 1, #lines do
|
||||
if #consoleTextBox.lines > luaConsoleHistoryLimit then table.remove(consoleTextBox.lines, 1) end
|
||||
table.insert(consoleTextBox.lines, printColor and {color = printColor, text = lines[i]} or lines[i])
|
||||
end
|
||||
consoleTextBox:scrollDown(#lines)
|
||||
end
|
||||
|
||||
local function getStringValueOfVariable(variable)
|
||||
local type, value = type(variable), ""
|
||||
if type == "table" then
|
||||
value = table.serialize(variable, true, nil, nil, 1)
|
||||
else
|
||||
value = tostring(variable)
|
||||
end
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
local function reimplementedPrint(...)
|
||||
local args = {...}
|
||||
local resultText = {}; for i = 1, #args do table.insert(resultText, getStringValueOfVariable(args[i])) end
|
||||
if #resultText > 0 then
|
||||
local lines = {table.concat(resultText, " ")}
|
||||
lines = string.wrap(lines, consoleTextBox.width - 2)
|
||||
addLines(lines)
|
||||
end
|
||||
end
|
||||
|
||||
-- Функцию стер - хуй проглотил!
|
||||
-- abc = function(a, b, c) local d = b ^ 2 - 4 * a * c; if d < 0 then error("Сууука!!! D < 0") end; x1 = (-b + math.sqrt(d)) / (2 * a); x2 = (-b - math.sqrt(d)) / (2 * a); return x1, x2 end
|
||||
|
||||
consoleCommandInputTextBox.onInputFinished = function()
|
||||
if consoleCommandInputTextBox.text then
|
||||
-- Подменяем стандартный print() на мой пиздатый
|
||||
local oldPrint = print
|
||||
print = reimplementedPrint
|
||||
-- Пишем, че мы вообще исполняли
|
||||
printColor = colors.passive
|
||||
addLines({"> " .. consoleCommandInputTextBox.text})
|
||||
printColor = nil
|
||||
|
||||
-- Ебашим поддержку =
|
||||
if unicode.sub(consoleCommandInputTextBox.text, 1, 1) == "=" then consoleCommandInputTextBox.text = "return " .. unicode.sub(consoleCommandInputTextBox.text, 2, -1) end
|
||||
local loadSuccess, loadReason = load(consoleCommandInputTextBox.text)
|
||||
if loadSuccess then
|
||||
local xpcallResult = {xpcall(loadSuccess, debug.traceback)}
|
||||
if xpcallResult[1] then
|
||||
table.remove(xpcallResult, 1)
|
||||
reimplementedPrint(table.unpack(xpcallResult))
|
||||
else
|
||||
printColor = colors.error
|
||||
reimplementedPrint(xpcallResult[2])
|
||||
printColor = nil
|
||||
end
|
||||
else
|
||||
printColor = colors.error
|
||||
reimplementedPrint(loadReason)
|
||||
printColor = nil
|
||||
end
|
||||
|
||||
consoleCommandInputTextBox.text = nil
|
||||
print = oldPrint
|
||||
|
||||
window:draw()
|
||||
buffer.draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
return module
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
Applications/SmartHouse/Modules/command_block/Icon.pic
Normal file
BIN
Applications/SmartHouse/Modules/command_block/Icon.pic
Normal file
Binary file not shown.
@ -1,14 +1,26 @@
|
||||
|
||||
local module = {
|
||||
allowSignalConnections = false,
|
||||
allowSignalConnections = true,
|
||||
updateWhenModuleDetailsIsHidden = false,
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local function execute(moduleContainer, command)
|
||||
moduleContainer.componentProxy.setCommand(command)
|
||||
moduleContainer.componentProxy.executeCommand()
|
||||
end
|
||||
|
||||
-- This method is called once during module initialization
|
||||
function module.start(moduleContainer)
|
||||
local x, y = 2, moduleContainer.children[#moduleContainer.children].localPosition.y + 2
|
||||
|
||||
moduleContainer.commandTextBox = moduleContainer:addInputTextBox(x, y, moduleContainer.width - 2, 1, nil, 0xDDDDDD, nil, 0xFFFFFF, "/say Hello", "Type command here", false, false)
|
||||
y = y + 2
|
||||
moduleContainer.executeButton = moduleContainer:addButton(2, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xAAAAAA, 0x262626, "Execute")
|
||||
moduleContainer.executeButton.onTouch = function()
|
||||
execute(moduleContainer, moduleContainer.commandTextBox.text)
|
||||
end
|
||||
end
|
||||
|
||||
-- This method is called on each frame update (every second by default), but only if module details is not hidden or updateWhenModuleDetailsIsHidden == true
|
||||
@ -18,7 +30,8 @@ end
|
||||
|
||||
-- This method is called when a this module receives virtual signal from the another module, but only if field allowSignalConnections == true
|
||||
function module.onSignalReceived(moduleContainer, ...)
|
||||
|
||||
local data = {...}
|
||||
execute(moduleContainer, moduleContainer.commandTextBox.text)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Binary file not shown.
Binary file not shown.
@ -8,7 +8,15 @@ local module = {
|
||||
|
||||
-- This method is called once during module initialization
|
||||
function module.start(moduleContainer)
|
||||
local x, y = 2, moduleContainer.children[#moduleContainer.children].localPosition.y + 2
|
||||
|
||||
moduleContainer:addButton(2, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xAAAAAA, 0x262626, "Shutdown").onTouch = function()
|
||||
require("computer").shutdown()
|
||||
end
|
||||
y = y + 2
|
||||
moduleContainer:addButton(2, y, moduleContainer.width - 2, 1, 0xDDDDDD, 0x262626, 0xAAAAAA, 0x262626, "Reboot").onTouch = function()
|
||||
require("computer").shutdown(true)
|
||||
end
|
||||
end
|
||||
|
||||
-- This method is called on each frame update (every second by default), but only if module details is not hidden or updateWhenModuleDetailsIsHidden == true
|
||||
|
||||
BIN
Applications/SmartHouse/Modules/homePC/Server.pic
Normal file
BIN
Applications/SmartHouse/Modules/homePC/Server.pic
Normal file
Binary file not shown.
@ -17,7 +17,7 @@ end
|
||||
-- This method is called on each frame update (every second by default), but only if module details is not hidden or updateWhenModuleDetailsIsHidden == true
|
||||
function module.update(moduleContainer, eventData)
|
||||
table.insert(moduleContainer.chart.values, math.ceil(moduleContainer.componentProxy.getStored() / moduleContainer.componentProxy.getCapacity() * 100))
|
||||
if #moduleContainer.chart.values > moduleContainer.chart.width - 1 then
|
||||
if #moduleContainer.chart.values > 100 then
|
||||
table.remove(moduleContainer.chart.values, 1)
|
||||
end
|
||||
end
|
||||
|
||||
@ -26,9 +26,7 @@ function module.update(moduleContainer, eventData)
|
||||
if eventData[1] == "motion" then
|
||||
if moduleContainer.componentProxy.address == eventData[2] then
|
||||
if eventData[6] == "ECS" then
|
||||
moduleContainer:pushSignal("redstone", "setValue", 15)
|
||||
os.sleep(sleepValue)
|
||||
moduleContainer:pushSignal("redstone", "setValue", 0)
|
||||
moduleContainer:sendSignal("redstone", "pulse")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -71,7 +71,7 @@ end
|
||||
-- This method is called when a this module receives virtual signal from the another module, but only if field allowSignalConnections == true
|
||||
function module.onSignalReceived(moduleContainer, ...)
|
||||
local data = {...}
|
||||
if data[1] == "redstone" and data[2] == "setState" and type(data[3]) == "boolean" then
|
||||
if data[1] == "redstone" and data[2] == "pulse" then
|
||||
changeRedstoneState(moduleContainer, data[3])
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,28 +1,24 @@
|
||||
|
||||
local libraries = {
|
||||
sides = "sides",
|
||||
component = "component",
|
||||
advancedLua = "advancedLua",
|
||||
image = "image",
|
||||
buffer = "doubleBuffering",
|
||||
keyboard = "keyboard",
|
||||
GUI = "GUI",
|
||||
ecs = "ECSAPI",
|
||||
windows = "windows",
|
||||
MineOSCore = "MineOSCore",
|
||||
computer = "computer",
|
||||
fs = "filesystem",
|
||||
}
|
||||
|
||||
for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end; libraries = nil
|
||||
local sides = require("sides")
|
||||
local component = require("component")
|
||||
local advancedLua = require("advancedLua")
|
||||
local image = require("image")
|
||||
local buffer = require("doubleBuffering")
|
||||
local keyboard = require("keyboard")
|
||||
local GUI = require("GUI")
|
||||
local ecs = require("ECSAPI")
|
||||
local windows = require("windows")
|
||||
local MineOSCore = require("MineOSCore")
|
||||
local computer = require("computer")
|
||||
local fs = require("filesystem")
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local window
|
||||
|
||||
local paths = {}
|
||||
-- paths.resources = MineOSCore.getCurrentApplicationResourcesDirectory()
|
||||
paths.resources = "/SmartHouse/"
|
||||
paths.resources = MineOSCore.getCurrentApplicationResourcesDirectory()
|
||||
-- paths.resources = "/SmartHouse/"
|
||||
paths.modules = paths.resources .. "Modules/"
|
||||
|
||||
local colors = {
|
||||
|
||||
20
lib/GUI.lua
20
lib/GUI.lua
@ -161,7 +161,7 @@ function GUI.getClickedObject(container, xEvent, yEvent)
|
||||
if container.children[objectIndex].children and #container.children[objectIndex].children > 0 then
|
||||
clickedObject, clickedIndex = GUI.getClickedObject(container.children[objectIndex], xEvent, yEvent)
|
||||
if clickedObject then break end
|
||||
elseif not container.children[objectIndex].disableClicking and container.children[objectIndex]:isClicked(xEvent, yEvent) then
|
||||
elseif container.children[objectIndex]:isClicked(xEvent, yEvent) then
|
||||
clickedObject, clickedIndex = container.children[objectIndex], objectIndex
|
||||
break
|
||||
end
|
||||
@ -509,7 +509,7 @@ function GUI.tabBar(x, y, width, height, spaceBetweenElements, backgroundColor,
|
||||
object.reimplementedDraw = object.draw
|
||||
object.draw = drawTabBar
|
||||
|
||||
object:addPanel(1, 1, object.width, object.height, backgroundColor).disableClicking = true
|
||||
object:addPanel(1, 1, object.width, object.height, backgroundColor)
|
||||
object.tabs = object:addContainer(1, 1, object.width, object.height)
|
||||
|
||||
x = math.floor(width / 2 - object.tabsWidth / 2)
|
||||
@ -571,23 +571,13 @@ end
|
||||
|
||||
----------------------------------------- Window action buttons -----------------------------------------
|
||||
|
||||
local function drawWindowActionButton(object)
|
||||
local background = buffer.get(object.x, object.y)
|
||||
object.colors.default.background, object.colors.pressed.background, object.colors.disabled.background = background, background, background
|
||||
object:reimplementedDraw()
|
||||
return object
|
||||
end
|
||||
|
||||
function GUI.windowActionButtons(x, y, fatSymbol)
|
||||
local symbol = fatSymbol and "⬤" or "●"
|
||||
|
||||
local container = GUI.container(x, y, 5, 1)
|
||||
container.close = container:addButton(1, 1, 1, 1, 0x000000, 0xFF4940, 0x000000, 0x992400, symbol)
|
||||
container.minimize = container:addButton(3, 1, 1, 1, 0x000000, 0xFFB640, 0x000000, 0x996D00, symbol)
|
||||
container.maximize = container:addButton(5, 1, 1, 1, 0x000000, 0x00B640, 0x000000, 0x006D40, symbol)
|
||||
|
||||
container.close.reimplementedDraw, container.minimize.reimplementedDraw, container.maximize.reimplementedDraw = container.close.draw, container.minimize.draw, container.maximize.draw
|
||||
container.close.draw, container.minimize.draw, container.maximize.draw = drawWindowActionButton, drawWindowActionButton, drawWindowActionButton
|
||||
container.close = container:addButton(1, 1, 1, 1, nil, 0xFF4940, nil, 0x992400, symbol)
|
||||
container.minimize = container:addButton(3, 1, 1, 1, nil, 0xFFB640, nil, 0x996D00, symbol)
|
||||
container.maximize = container:addButton(5, 1, 1, 1, nil, 0x00B640, nil, 0x006D40, symbol)
|
||||
|
||||
return container
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user