Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- local w, h = term.getSize()
- local nOption = 1
- function printCentered(y, s)
- local x = math.floor((w - string.len(s)) / 2)
- term.setCursorPos(x, y)
- term.clearLine()
- term.write(s)
- end
- local function drawMenu()
- term.clear()
- term.setCursorPos(1, 1)
- term.write("Doggy OS (13.0)")
- term.setCursorPos(1, 2)
- shell.run("id")
- term.setCursorPos(w - 11, 1)
- if nOption == 1 then
- term.write("Command")
- elseif nOption == 2 then
- term.write("Programs")
- elseif nOption == 3 then
- term.write("Shutdown")
- elseif nOption == 4 then
- term.write("Sign out")
- end
- end
- -- Icons
- local icons = {
- "[C]", -- Command icon
- "[P]", -- Programs icon
- "[S]", -- Shutdown icon
- "[O]" -- Sign out icon
- }
- -- GUI
- local function drawFrontend()
- term.clear()
- printCentered(math.floor(h / 2) - 3, "")
- printCentered(math.floor(h / 2) - 2, "Start Menu")
- printCentered(math.floor(h / 2) - 1, "")
- for i = 1, 4 do
- local label = (i == 1 and "Command" or i == 2 and "Programs" or i == 3 and "Shutdown" or "Sign out")
- local icon = (nOption == i and " " .. icons[i] .. " " or icons[i])
- printCentered(math.floor(h / 2) + i - 1, (nOption == i and "[ " or "") .. label .. (nOption == i and " ]" or "") .. icon)
- end
- printCentered(math.floor(h / 2) + 5, "")
- end
- -- Display
- drawMenu()
- drawFrontend()
- while true do
- local e, p = os.pullEvent()
- if e == "key" then
- local key = p
- if key == 17 or key == 200 then -- Up arrow
- if nOption > 1 then
- nOption = nOption - 1
- drawFrontend()
- end
- elseif key == 31 or key == 208 then -- Down arrow
- if nOption < 4 then
- nOption = nOption + 1
- drawFrontend()
- end
- elseif key == 28 then -- Enter key
- break
- end
- end
- end
- term.clear()
- -- Conditions
- if nOption == 1 then
- shell.run("/disk/os/home.lua")
- elseif nOption == 2 then
- term.clear()
- term.setCursorPos(1, 1)
- shell.run("/disk/os/programs")
- elseif nOption == 3 then
- shell.run("/disk/ACPI/shutdown")
- else
- shell.run("/disk/ACPI/logoff")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement