Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --main file ver 13--
- os.pullEvent = os.pullEventRaw
- local w,h = term.getSize()
- function printCentered( y,s )
- local x = math.floor((w - string.len(s)) / 2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write( s )
- end
- local nOption = 1
- local function drawMenu()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Diamond OS // 1.2.1 // ")
- term.setCursorPos(1,2)
- shell.run("id")
- term.setCursorPos(w-11,1)
- if nOption == 1 then
- term.write("Terminal")
- elseif nOption == 2 then
- term.write("Programs")
- elseif nOption == 3 then
- term.write("Shutdown")
- elseif nOption == 4 then
- term.write("Uninstall")
- elseif nOption == 5 then
- term.write("About")
- else
- end
- end
- --GUI
- term.clear()
- local function drawFrontend()
- printCentered( math.floor(h/2) - 3, "")
- printCentered( math.floor(h/2) - 2, "Start Menu" )
- printCentered( math.floor(h/2) - 1, "")
- printCentered( math.floor(h/2) + 0, ((nOption == 1) and "[ Terminal ]") or "Terminal" )
- printCentered( math.floor(h/2) + 1, ((nOption == 2) and "[ Programs ]") or "Programs" )
- printCentered( math.floor(h/2) + 2, ((nOption == 3) and "[ Shutdown ]") or "Shutdown" )
- printCentered( math.floor(h/2) + 3, ((nOption == 4) and "[ Uninstall]") or " Uninstall" )
- printCentered( math.floor(h/2) + 4, ((nOption == 5) and "[ About ]") or " About" )
- printCentered( math.floor(h/2) + 5, "")
- end
- --Display
- drawMenu()
- drawFrontend()
- while true do
- local e,p = os.pullEvent("key")
- if p == keys.up then
- if nOption > 1 then
- nOption = nOption - 1
- drawMenu()
- drawFrontend()
- end
- elseif p == keys.down then
- if nOption < 5 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif p == keys.enter then
- break
- end
- end
- term.clear()
- --Conditions
- if nOption == 1 then
- shell.run("/bin/.command")
- elseif nOption == 2 then
- shell.run("/bin/.programs")
- elseif nOption == 3 then
- shell.run("/bin/.shutdown")
- elseif nOption == 4 then
- shell.run("/bin/.UninstallDialog")
- elseif nOption == 5 then
- shell.run("/bin/.about")
- end
Advertisement
Add Comment
Please, Sign In to add comment