Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --NhUI
- nhver = "v0.4u"
- wip = 0
- --Loading
- if deskLoad==nil then
- term.clear()
- local cycles = {" ",". ",".. ","..."," .."," ."," "}
- local message = "Loading NhUI "..nhver
- for i=0,7 do
- term.setCursorPos(1,1)
- print(message..cycles[(i%#cycles)+1])
- sleep(.1)
- end
- deskLoad=false
- end
- --Unstable version detected
- local function suggestedUpdate()
- if wip==2 and sugUpdate==nil then sugUpdate=false
- term.clear()
- term.setCursorPos(1,1)
- sleep(.1)
- print("You're running an unstable WIP build.\nUpdate to the newest "..nhver.." build now?")
- print("\n1|Yes\n2|No")
- while true do
- local event, b, x, y = os.pullEventRaw()
- if event == "key" then
- if b==2 then
- term.clear()
- term.setCursorPos(1,1)
- shell.run("delete","installer")
- shell.run("pastebin","get","WCdpCaEm","installer")
- shell.run("installer")
- elseif b==3 then
- break
- end
- elseif event == "mouse_click" then
- if b==1 and x>=1 and x<=5 and y==4 then
- shell.run("delete","installer")
- shell.run("pastebin","get","WCdpCaEm","installer")
- shell.run("installer")
- elseif b==1 and x>=1 and x<=4 and y==5 then
- break
- end
- end
- end
- end
- end
- --Variables
- if not term.isColor then
- else
- tBarC = 32768
- tBartC = 1
- backColor = 32768
- end
- --Desktop prep
- local function resetScreen()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function setBackColor()
- if not term.isColor then
- elseif term.isColor() then
- term.setBackgroundColor(backColor)
- else
- term.setBackgroundColor(backColor)
- end
- end
- local function setTextWhite()
- if not term.isColor then
- elseif term.isColor() then
- term.setTextColor(1)
- else
- term.setTextColor(1)
- end
- end
- local function titleBarColor()
- if not term.isColor then
- elseif term.isColor() then
- term.setBackgroundColor(tBarC)
- term.setTextColor(tBartC)
- else
- term.setBackgroundColor(tBarC)
- term.setTextColor(tBartC)
- end
- end
- local function titleBar()
- term.setCursorPos(1,1)
- titleBarColor()
- term.clearLine()
- term.setCursorPos(2, 1)
- term.write("1|Start")
- term.setCursorPos(12, 1)
- term.write("2|Options")
- term.setCursorPos(24, 1)
- term.write("3|NhUI")
- end
- local function titleBarExt()
- term.setCursorPos(1,1)
- titleBarColor()
- term.clearLine()
- term.setCursorPos(2, 1)
- term.write("-|Start")
- term.setCursorPos(12, 1)
- term.write("-|Options")
- term.setCursorPos(24, 1)
- term.write("-|NhUI")
- end
- local function deskRun()
- if fs.exists("desktop") then
- shell.run("desktop")
- else
- shell.run("startup")
- end
- end
- local function displayTime()
- setTextWhite()
- term.setCursorPos(43, 1)
- if os.time()>=10 and os.time()<13 then
- term.write(textutils.formatTime(os.time(), false ))
- elseif os.time()>=22 and os.time()>0 then
- term.write(textutils.formatTime(os.time(), false ))
- else
- term.write(" "..textutils.formatTime(os.time(), false ))
- end
- sleep(.83)
- end
- local function displayTimeExt()
- setTextWhite()
- term.setCursorPos(43, 1)
- if os.time()>=10 and os.time()<13 then
- term.write(textutils.formatTime(os.time(), false ))
- elseif os.time()>=22 and os.time()>0 then
- term.write(textutils.formatTime(os.time(), false ))
- else
- term.write(" "..textutils.formatTime(os.time(), false ))
- end
- end
- local function drawDesktop()
- setBackColor()
- term.clear()
- term.setCursorPos(2,17)
- if wip==1 then
- if not term.isColor then
- term.write("NOTE: WIP BUILD - CURRENTLY STABLE")
- elseif term.isColor() then
- term.setTextColor(8192)
- term.write("NOTE: WIP BUILD - CURRENTLY STABLE")
- term.setTextColor(1)
- else
- term.setTextColor(1)
- term.write("NOTE: WIP BUILD - CURRENTLY STABLE")
- end
- elseif wip==2 then
- if not term.isColor then
- term.write("NOTE: WIP BUILD - CURRENTLY UNSTABLE")
- elseif term.isColor() then
- term.setTextColor(16384)
- term.write("NOTE: WIP BUILD - CURRENTLY UNSTABLE")
- else
- term.setTextColor(1)
- term.write("NOTE: WIP BUILD - CURRENTLY UNSTABLE")
- end
- end
- if not term.isColor then
- term.setCursorPos(2,18)
- term.write("(Mouse and keyboard supported.)")
- term.setCursorPos(47,17)
- term.write("NhUI")
- term.setCursorPos(46,18)
- term.write(nhver)
- else
- term.setTextColor(256)
- term.setCursorPos(2,18)
- term.write("(Mouse and keyboard supported.)")
- term.setTextColor(128)
- term.setCursorPos(47,17)
- term.write("NhUI")
- term.setCursorPos(46,18)
- term.write(nhver)
- end
- titleBar()
- disptime=1
- repeat
- displayTime()
- until disptime==0
- end
- local function menuColor()
- if not term.isColor then
- elseif term.isColor() then
- term.setTextColor(tBartC)
- term.setBackgroundColor(backColor)
- else
- term.setTextColor(tBartC)
- term.setBackgroundColor(backColor)
- end
- end
- local function drawMenu1()
- menuColor()
- term.setCursorPos(2,2)
- print("1|CraftOS")
- term.setCursorPos(2,3)
- print("---------")
- term.setCursorPos(2,4)
- print("2|Shutdown")
- term.setCursorPos(2,5)
- print("3|Restart")
- end
- local function clearMenu1()
- term.setCursorPos(2,2)
- term.clearLine()
- term.setCursorPos(2,3)
- term.clearLine()
- term.setCursorPos(2,4)
- term.clearLine()
- term.setCursorPos(2,5)
- term.clearLine()
- end
- local function drawMenu2()
- menuColor()
- term.setCursorPos(12,2)
- print("1|Password")
- end
- local function clearMenu2()
- term.setCursorPos(12,2)
- term.clearLine()
- end
- local function drawMenu3()
- menuColor()
- term.setCursorPos(24,2)
- print("1|Versions")
- term.setCursorPos(24,3)
- print("2|Components")
- term.setCursorPos(24,4)
- print("3|Uninstall")
- end
- local function clearMenu3()
- term.setCursorPos(24,2)
- term.clearLine()
- term.setCursorPos(24,3)
- term.clearLine()
- term.setCursorPos(24,4)
- term.clearLine()
- end
- --Desktop menus
- local function runShell()
- resetScreen()
- sleep(.1)
- if not term.isColor then
- elseif term.isColor() then
- term.setTextColor(16)
- else
- term.setTextColor(1)
- end
- print("CraftOS shell (Ctrl+R will reinitialize NhUI.)")
- setTextWhite()
- end
- local function passwordSetup()
- resetScreen()
- sleep(.1)
- setTextWhite()
- print("Would you like your computer to have a password?")
- print("\n[Choices]\n1|Yes\n2|No\n3|(Back)")
- while true do
- local event, b, x, y = os.pullEventRaw()
- if event == "key" then
- if b==2 then
- shell.run("rename","startup","desktop")
- shell.run("delete","startup")
- shell.run("pastebin","get","Csag1T39","startup") --v0.4u+
- shell.run("delete",".info")
- term.clear()
- sleep(.1)
- os.reboot()
- elseif b==3 then
- shell.run("rename","startup","desktop")
- shell.run("delete","startup")
- shell.run("rename","desktop","startup")
- shell.run("delete",".info")
- resetScreen()
- sleep(.1)
- print("Preferences saved.")
- term.write("Rebooting to take effect")
- textutils.slowPrint("...",2.5)
- sleep(.5)
- term.clear()
- sleep(.3)
- os.reboot()
- elseif b==4 then
- deskRun()
- break
- end
- elseif event == "mouse_click" then
- if b==1 and x>=1 and x<=5 and y==4 then
- shell.run("rename","startup","desktop")
- shell.run("delete","startup")
- shell.run("pastebin","get","Csag1T39","startup") --v0.4u+
- shell.run("delete",".info")
- term.clear()
- sleep(.1)
- os.reboot()
- elseif b==1 and x>=1 and x<=4 and y==5 then
- shell.run("rename","startup","desktop")
- shell.run("delete","startup")
- shell.run("rename","desktop","startup")
- shell.run("delete",".info")
- resetScreen()
- sleep(.1)
- print("Preferences saved.")
- term.write("Rebooting to take effect")
- textutils.slowPrint("...",2.5)
- sleep(.5)
- term.clear()
- sleep(.3)
- os.reboot()
- elseif b==1 and x>=1 and x<=8 and y==6 then
- deskRun()
- break
- end
- end
- end
- end
- local function irlInternetCheck()
- if intCheckAgain==true or intCheckAgain==nil then
- resetScreen()
- sleep(.1)
- sel=0
- print("INTERNET CHECK: Are you connected to the internet?")
- print("\n1|Yes\n2|No")
- while true do
- local event, b, x, y = os.pullEventRaw()
- if event == "key" then
- if b==2 and sel==0 then sel=1
- internet=true
- term.setCursorPos(1,3)
- print("-\n-")
- term.setCursorPos(1,6)
- print("Don't ask again until next startup?")
- print("\n1|True\n2|False")
- elseif b==3 and sel==0 then
- internet=false
- break
- elseif b==2 and sel==1 then sel=0
- intCheckAgain=false
- break
- elseif b==3 and sel==1 then sel=0
- intCheckAgain=true
- break
- end
- elseif event == "mouse_click" then
- if b==1 and x>=1 and x<=5 and y==3 and sel==0 then sel=1
- internet=true
- term.setCursorPos(1,3)
- print("-\n-")
- term.setCursorPos(1,6)
- print("Don't ask again until next startup?")
- print("\n1|True\n2|False")
- elseif b==1 and x>=1 and x<=4 and y==4 and sel==0 then
- internet=false
- break
- elseif b==1 and x>=1 and x<=5 and y==8 and sel==1 then sel=0
- intCheckAgain=false
- break
- elseif b==1 and x>=1 and x<=7 and y==9 and sel==1 then sel=0
- intCheckAgain=true
- break
- end
- end
- end
- end
- end
- local function nhuiProgList()
- resetScreen()
- sleep(.1)
- setTextWhite()
- print("Which program would you like to re-download?")
- print("\n[Choices]\n1|Updater\n2|Uninstaller\n3|(Back)")
- while true do
- local event, b, x, y = os.pullEventRaw()
- if event == "key" then
- if b==2 then
- resetScreen()
- print("Downloading program...")
- shell.run("delete","updater")
- shell.run("pastebin","get","LrBWAr2L","updater") --v0.3a+
- resetScreen()
- print("Download complete.")
- sleep(.8)
- deskRun()
- break
- elseif b==3 then
- resetScreen()
- print("Downloading program...")
- shell.run("delete","uninstaller")
- shell.run("pastebin","get","PNvB0uw4","uninstaller") --v0.2a+
- resetScreen()
- print("Download complete.")
- sleep(.8)
- deskRun()
- break
- elseif b==4 then
- deskRun()
- break
- end
- elseif event == "mouse_click" then
- if b==1 and x>=1 and x<=9 and y==4 then
- resetScreen()
- print("Downloading program...")
- shell.run("delete","updater")
- shell.run("pastebin","get","LrBWAr2L","updater") --v0.3a+
- resetScreen()
- print("Download complete.")
- sleep(.8)
- deskRun()
- break
- elseif b==1 and x>=1 and x<=13 and y==5 then
- resetScreen()
- print("Downloading program. Will reboot when finished.")
- shell.run("delete","uninstaller")
- shell.run("pastebin","get","PNvB0uw4","uninstaller") --v0.2a+
- resetScreen()
- print("Download complete.")
- sleep(.8)
- deskRun()
- break
- elseif b==1 and x>=1 and x<=8 and y==6 then
- deskRun()
- break
- end
- end
- end
- end
- local function uninstallCheck()
- resetScreen()
- sleep(.1)
- print("Would you like to uninstall NhUI "..nhver.."? ;-;")
- if not term.isColor then
- else
- term.setTextColor(256)
- end
- print("(User-created programs will *not* be deleted.)\n")
- setTextWhite()
- print("[Choices]\n1|Yes\n2|No (Back)")
- while true do
- local event, b, x, y = os.pullEventRaw()
- if event == "key" then
- if b==2 then
- resetScreen()
- sleep(.1)
- shell.run("uninstaller")
- term.write("Rebooting to complete uninstall")
- textutils.slowPrint("...",2.307)
- sleep(.2)
- os.reboot()
- elseif b==3 then
- resetScreen()
- sleep(.1)
- deskRun()
- break
- end
- elseif event == "mouse_click" then
- if b==1 and x>=1 and x<=5 and y==5 then
- resetScreen()
- sleep(.1)
- shell.run("uninstaller")
- term.write("Rebooting to complete uninstall")
- textutils.slowPrint("...",2.307)
- sleep(.2)
- os.reboot()
- elseif b==1 and x>=1 and x<=11 and y==6 then
- resetScreen()
- sleep(.1)
- deskRun()
- break
- end
- end
- end
- end
- --Desktop
- local function runDesktop()
- sel=0
- desk=1
- repeat
- local event, b, x, y = os.pullEventRaw()
- if event == "key" then
- if sel==0 and b==2 then sel=1
- clearMenu2()
- clearMenu3()
- titleBarExt()
- displayTimeExt()
- drawMenu1()
- elseif sel==0 and b==3 then sel=2
- clearMenu1()
- clearMenu3()
- titleBarExt()
- displayTimeExt()
- drawMenu2()
- elseif sel==0 and b==4 then sel=3
- clearMenu1()
- clearMenu2()
- titleBarExt()
- displayTimeExt()
- drawMenu3()
- elseif sel==1 and b==2 then sel=0
- disptime=0
- desk=0
- runShell()
- break
- elseif sel==1 and b==3 then sel=0
- os.shutdown()
- elseif sel==1 and b==4 then sel=0
- os.reboot()
- elseif sel==2 and b==2 then sel=0
- disptime=0
- term.clear()
- irlInternetCheck()
- if internet==true then
- resetScreen()
- passwordSetup()
- elseif internet==false then
- deskRun()
- break
- end
- elseif sel==3 and b==2 then sel=0
- disptime=0
- term.clear()
- irlInternetCheck()
- if internet==true then
- resetScreen()
- print("Getting newest updater build...")
- shell.run("delete","updater")
- shell.run("pastebin","get","LrBWAr2L","updater") --v0.3a+
- shell.run("updater")
- break
- elseif internet==false then
- deskRun()
- break
- end
- elseif sel==3 and b==3 then sel=0
- disptime=0
- term.clear()
- irlInternetCheck()
- if internet==true then
- resetScreen()
- nhuiProgList()
- elseif internet==false then
- deskRun()
- break
- end
- elseif sel==3 and b==4 then sel=0
- disptime=0
- uninstallCheck()
- break
- else
- sel=0
- parallel.waitForAll(drawDesktop, runDesktop)
- end
- elseif event == "mouse_click" then
- if b==1 and x>=2 and x<=8 and y==1 then sel=1
- clearMenu2()
- clearMenu3()
- titleBarExt()
- displayTimeExt()
- drawMenu1()
- elseif b==1 and x>=12 and x<=20 and y==1 then sel=2
- clearMenu1()
- clearMenu3()
- titleBarExt()
- displayTimeExt()
- drawMenu2()
- elseif b==1 and x>=24 and x<=29 and y==1 then sel=3
- clearMenu1()
- clearMenu2()
- titleBarExt()
- displayTimeExt()
- drawMenu3()
- elseif sel==1 and b==1 and x>=2 and x<=10 and y==2 then sel=0
- disptime=0
- desk=0
- runShell()
- break
- elseif sel==1 and b==1 and x>=2 and x<=9 and y==3 then sel=1
- drawMenu1()
- elseif sel==1 and b==1 and x>=2 and x<=11 and y==4 then sel=0
- os.shutdown()
- elseif sel==1 and b==1 and x>=2 and x<=10 and y==5 then sel=0
- os.reboot()
- elseif sel==2 and b==1 and x>=12 and x<=21 and y==2 then sel=0
- disptime=0
- term.clear()
- irlInternetCheck()
- if internet==true then
- resetScreen()
- passwordSetup()
- elseif internet==false then
- deskRun()
- break
- end
- elseif sel==3 and b==1 and x>=24 and x<=35 and y==2 then sel=0
- disptime=0
- term.clear()
- irlInternetCheck()
- if internet==true then
- resetScreen()
- print("Getting newest updater build...")
- shell.run("delete","updater")
- shell.run("pastebin","get","LrBWAr2L","updater") --v0.3a+
- shell.run("updater")
- break
- elseif internet==false then
- deskRun()
- break
- end
- elseif sel==3 and b==1 and x>=24 and x<=33 and y==3 then sel=0 disptime=0
- disptime=0
- term.clear()
- irlInternetCheck()
- if internet==true then
- resetScreen()
- nhuiProgList()
- elseif internet==false then
- deskRun()
- break
- end
- elseif sel==3 and b==1 and x>=24 and x<=34 and y==4 then sel=0
- disptime=0
- uninstallCheck()
- break
- else
- sel=0
- parallel.waitForAll(drawDesktop, runDesktop)
- end
- end
- until desk==0
- end
- --Run desktop
- term.clear()
- sleep(.1)
- suggestedUpdate()
- parallel.waitForAll(drawDesktop, runDesktop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement