mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
69 lines
2.1 KiB
Lua
69 lines
2.1 KiB
Lua
|
|
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.getCurrentApplicationResourcesDirectory()
|
|
local modulesPath = resourcesPath .. "Modules/"
|
|
local localization = MineOSCore.getLocalization(resourcesPath .. "Localization/")
|
|
|
|
local mainContainer, window = MineOSInterface.addWindow(GUI.tabbedWindow(nil, nil, 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 success, reason = loadfile(modulesPath .. fileList[i])
|
|
if success then
|
|
local success, reason = pcall(success, mainContainer, window, localization)
|
|
if success then
|
|
window.tabBar:addItem(reason.name).onTouch = function()
|
|
reason.onTouch()
|
|
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.children[window.tabBar.selectedItem + 1].onTouch()
|
|
end
|
|
|
|
----------------------------------------------------------------------------------------------------------------
|
|
|
|
loadModules()
|
|
window.onResize(80, 25)
|
|
|
|
mainContainer:draw()
|
|
buffer.draw()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|