Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- local w,h = term.getSize()
- --Print Centered Function
- function printCentered(y,s,c)
- local x = math.floor((w - string.len(s)) /2)
- term.setCursorPos(x,y)
- term.setTextColor(c or colors.white)
- term.clearLine()
- term.write(s)
- end
- function printC(s,c)
- term.setTextColor(c or colors.white)
- print(s)
- end
- --Draw Menu Function
- local nOption = 1
- local function drawMenu()
- term.clear()
- term.setCursorPos(1,1)
- term.write("")
- term.setCursorPos(w-11,1)
- if nOption == 1 then
- term.write("Install")
- elseif nOption == 2 then
- term.write("Uninstall")
- else
- end
- end
- --Interface
- term.clear()
- local function drawFrontend()
- term.setCursorPos(1,1)
- printC("+-------------------------------------------------+", colors.yellow)
- printC("| |", colors.yellow)
- term.setCursorPos(22,2)
- printC("CharlieOS", colors.lime)
- printC("| |", colors.yellow)
- term.setCursorPos(23,3)
- printC("dev1.0b")
- printC("+-------------------------------------------------+", colors.yellow)
- printCentered(math.floor(h/2) + 0, ((nOption == 1 and "[ Install ]") or "Install"), colors.lime)
- printCentered(math.floor(h/2) + 1, ((nOption == 2 and "[ Uninstall ]") or "Uninstall"), colors.red)
- printCentered(math.floor(h/2) + 2, ((nOption == 3 and "[ About ]") or "About"), colors.purple)
- end
- --About
- local function about()
- while true do
- term.clear()
- printCentered(math.floor(h/2) + 0, "CharlieOS is created by: Charlestone Maru")
- printCentered(math.floor(h/2) + 2, "To help me improve this OS.")
- term.setCursorPos(1,19)
- term.setTextColor(colors.yellow)
- print("Press Enter to go back...")
- local e,p = os.pullEvent()
- if e == "key" then
- local key = p
- if key == 28 then
- shell.run("setup")
- end
- end
- end
- end
- --Install
- local function install()
- while true do
- term.clear()
- term.setCursorPos(1,1)
- printC("Are you sure to install CharlieOS? (y/n)", colors.yellow)
- printC("Installation cannont be teminated...", colors.yellow)
- printC(">", colors.yellow)
- term.setCursorPos(3,3)
- term.setTextColor(colors.white)
- say = read()
- if say == "Y" or say == "y" then
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- shell.run("pastebin","run B2aetUKP")
- elseif say == "N" or say == "n" then
- printC("Installation Aborded.", colors.red)
- sleep(1)
- shell.run("setup")
- else
- printC("Invalid Choice...", colors.red)
- sleep(1)
- end
- end
- end
- --Uninstall
- local function uninstall()
- while true do
- term.clear()
- term.setCursorPos(1,1)
- printC("Are you sure to Uninstall CharlieOS? (y/n)", colors.yellow)
- printC("Uninstallation cannont be teminated...", colors.yellow)
- printC(">", colors.yellow)
- term.setCursorPos(3,3)
- term.setTextColor(colors.white)
- say = read()
- if say == "Y" or say == "y" then
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- shell.run("pastebin","run eVLZwCy1")
- elseif say == "N" or say == "n" then
- printC("Uninstallation Aborded.", colors.red)
- sleep(1)
- shell.run("setup")
- else
- printC("Invalid Choice...", colors.red)
- sleep(1)
- end
- end
- 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 < 3 then
- nOption = nOption + 1
- drawMenu()
- drawFrontend()
- end
- elseif key == 28 then
- break
- end
- end
- end
- term.clear()
- --Conditions
- if nOption == 1 then
- install()
- elseif nOption == 2 then
- uninstall()
- elseif nOption == 3 then
- about()
- end
Advertisement
Add Comment
Please, Sign In to add comment