Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local w,h = term.getSize()
- --Center Text
- function printCentered (y,s)
- local x = math.floor((w - string.len(s)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(s)
- end
- --Drawmenu
- local nOption = 1
- local function drawMenu()
- term.setBackgroundColor(colors.cyan)
- term.clear()
- term.setCursorPos(1,1)
- logo = paintutils.loadImage("os/.logo")
- paintutils.drawImage(logo, 1, 1)
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(w-11,1)
- if nOption == 1 then
- term.write("Shutdown")
- elseif nOption == 2 then
- term.write("Reboot")
- elseif nOption == 3 then
- term.write("Log off")
- elseif nOption == 4 then
- term.write("Exit")
- else
- end
- end
- --GUI
- term.clear()
- local function drawFrontend()
- printCentered(math.floor(h/2) -3, "")
- printCentered(math.floor(h/2) -2, "SHUTDOWN")
- printCentered(math.floor(h/2) -1, "")
- printCentered(math.floor(h/2) + 0, (nOption == 1 and "[ Shutdown ]") or "Shutdown")
- printCentered(math.floor(h/2) + 1, (nOption == 2 and "[ Reboot ]") or "Reboot")
- printCentered(math.floor(h/2) + 2, (nOption == 3 and "[ Log off ]") or "Log off")
- printCentered(math.floor(h/2) + 3, (nOption == 4 and "[ Exit ]") or "Exit")
- 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
- if nOption > 1 then
- nOption = nOption -1
- drawMenu()
- drawFrontend()
- end
- elseif key == 31 or key == 208 then
- if nOption < 4 then
- nOption = nOption +1
- drawMenu()
- drawFrontend()
- end
- elseif key == 28 then
- break
- end
- end
- end
- term.clear()
- --Conditions
- if nOption == 1 then
- shell.run("shutdown")
- elseif nOption == 2 then
- term.setCursorPos(1,1)
- shell.run("reboot")
- elseif nOption == 3 then
- term.setCursorPos(1,1)
- shell.run("os/Starter")
- else
- shell.run("os/.functions")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement