Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- exitProgram = false
- if not fs.exists("config/masterAppConfig") then
- shell.run("pastebin", "get", "F7Czj8j4", "config/masterAppConfig")
- end
- -- load apps from config
- local apps = require "config/masterAppConfig"
- function draw ()
- term.clear()
- local x = 2
- local y = 2
- for i = 1, #apps, 2 do
- -- 1st button in row
- paintutils.drawFilledBox(
- x,
- y,
- x + apps[i].width,
- y + apps[i].height,
- apps[i].color
- )
- -- 2nd button in row
- paintutils.drawFilledBox(
- x + apps[i + 1].width + 3,
- y,
- x + apps[i + 1].width * 2 + 3,
- y + apps[i + 1].height,
- apps[i + 1].color
- )
- -- 1st label
- term.setCursorPos(
- x + math.max(
- 0,
- math.floor((apps[i].width - #apps[i].name) / 2)
- ),
- y + math.floor(apps[i].height / 2)
- )
- term.setBackgroundColour(apps[i].color)
- term.write(apps[i].name)
- -- 2nd label
- term.setCursorPos(
- x + math.max(
- apps[i + 1].width + 3,
- apps[i + 1].width + 3 + math.floor((apps[i + 1].width - #apps[i + 1].name) / 2)
- ),
- y + math.floor(apps[i].height / 2)
- )
- term.setBackgroundColour(apps[i + 1].color)
- term.write(apps[i + 1].name)
- -- increase y position for next row
- y = y + math.max(apps[i].height, apps[i + 1].height) + 2
- end
- -- print version
- term.setCursorPos(2, 19)
- term.setBackgroundColour(colors.black)
- term.setTextColour(colors.white)
- term.write("RC7fbgX5 - masterApp 1.0")
- -- hide cursor off screen
- term.setCursorPos(26, 30)
- end
- function main ()
- draw()
- -- check clicks
- local tabN = 1
- local inactiveTab = "inactive"
- while exitProgram == false do
- if multishell.getFocus() == tabN and multishell.getTitle(tabN) == inactiveTab then
- draw()
- end
- x = 2
- y = 2
- local event, button, mx, my = os.pullEvent("mouse_click")
- if button == 1 and mx > 1 and mx < 26 and my > 1 and my < 20 then
- tabN = multishell.getCurrent()
- for i = 1, #apps, 2 do
- if mx <= x + apps[i].width and
- my >= y and
- my <= y + apps[i].height
- then
- multishell.setTitle(tabN, inactiveTab)
- apps[i].func()
- draw()
- elseif mx <= x + apps[i + 1].width * 2 + 3 and
- mx >= x + apps[i].width + 3 and
- my >= y and
- my <= y + apps[i + 1].height
- then
- multishell.setTitle(tabN, inactiveTab)
- apps[i + 1].func()
- draw()
- end
- y = y + math.max(apps[i].height, apps[i + 1].height) + 2
- end
- end
- end
- end
- if args[1] == "update" then
- masterAppConfigUpdate()
- if args[2] == "run" then
- shell.run("pastebin", "run", "FuQ3WvPs RC7fbgX5 masterApp run")
- else
- shell.run("pastebin", "run", "FuQ3WvPs RC7fbgX5 masterApp")
- end
- else
- term.clear()
- main()
- term.clear()
- term.setCursorPos(1, 1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement