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)
- local 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("DOS")
- elseif nOption == 2 then
- term.write("EXECUTIVE")
- elseif nOption == 3 then
- term.write("SHUTDOWN")
- elseif nOption == 4 then
- term.write("DISK")
- elseif nOption == 5 then
- term.write("SETTINGS")
- else
- end
- end
- --GUI
- term.clear()
- local function drawFrontend()
- printCentered(math.floor(h/2) -3, "")
- printCentered(math.floor(h/2) -2, "START")
- printCentered(math.floor(h/2) -1, "")
- printCentered(math.floor(h/2) + 0, (nOption == 1 and "[ DOS ]") or "DOS")
- printCentered(math.floor(h/2) + 1, (nOption == 2 and "[ EXECUTIVE ]") or "EXECUTIVE")
- printCentered(math.floor(h/2) + 2, (nOption == 3 and "[ SHUTDOWN ]") or "SHUTDOWN")
- printCentered(math.floor(h/2) + 3, (nOption == 4 and "[ DISK ]") or "DISK")
- printCentered(math.floor(h/2) + 4, (nOption == 5 and "[ SETTINGS ]") or "SETTINGS")
- end
- --Display
- drawMenu()
- drawFrontend()
- while true do
- local e,p = os.pullEvent()
- if e == "key" then
- local key = p
- if key == keys.up or key == 200 then
- if nOption > 1 then
- nOption = nOption -1
- drawMenu()
- drawFrontend()
- end
- elseif key == keys.down or key == 208 then
- if nOption < 5 then
- nOption = nOption +1
- drawMenu()
- drawFrontend()
- end
- elseif key == keys.enter then
- break
- end
- end
- end
- term.clear()
- --Conditions
- if nOption == 1 then
- term.setBackgroundColor(colors.black)
- shell.run("os/.DOS")
- elseif nOption == 2 then
- shell.run("os/.EXECUTIVE")
- elseif nOption == 3 then
- shell.run("os/.SHUTDOWN")
- elseif nOption == 4 then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- print("You are now in DOS mode. Write 'back' to return to interface")
- print("---------------------------------------------------")
- shell.run("chkdisk")
- else
- shell.run("os/.settings")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement