Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this acts as main script CSP
- version = "1.0.3"
- settings.load(".settings")
- local w, h = term.getSize()
- local BaseAppsInstalled = {true,false,true}
- local IntPrograms = {"os/os_Programs/ClientApps/os_AccountPgScript","os/os_Programs/os_LinksProvider","os/os_Programs/os_SettingsMenu","os.reboot","os.shutdown"}
- local ProgramNames = {"Account","Online Items","Settings","reboot","shutdown"}
- local TimeSpot = #ProgramNames + 5
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function CenterText(y,text)
- local x = math.floor((w - string.len(text)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(text)
- end
- local function LoadInstalled()
- ProgramNames = {}
- IntPrograms = {}
- settings.load(".settings")
- ProgramNames = settings.get("ClientApps_Names")
- IntPrograms = settings.get("ClientApps_Paths")
- ProgramNames[#ProgramNames + 1] = "reboot"
- ProgramNames[#ProgramNames + 1] = "shutdown"
- IntPrograms[#IntPrograms + 1] = "reboot"
- IntPrograms[#IntPrograms + 1] = "shutdown"
- TimeSpot = #ProgramNames + 5
- end
- local function NonBetaTestMode()
- IntPrograms = {"os/os_Programs/os_AccountPgScript","os/os_Programs/os_LinksProvider","os/os_Programs/os_SettingsMenu", "os.reboot","os.shutdown"}
- ProgramNames = {"AccountPage","Online Programs","Settings","Reboot","PowerOff"}
- end
- local function MenuDrawer()
- term.setBackgroundColor(colors.cyan)
- Clear()
- local Background = paintutils.loadImage("os/os_SystemFiles/Images/MenuBackground")
- paintutils.drawImage(Background,1,1)
- term.setBackgroundColor(colors.cyan)
- CenterText(1,"==Desktop==version"..version.."==")
- CenterText(3,"-=Applications=-")
- CenterText(TimeSpot,os.date())
- if settings.get("os_BetaTest") == true then
- CenterText(TimeSpot - 1,"Experimental Mode")
- end
- DrawNetworkStatus()
- end
- function DrawNetworkStatus()
- local Modem = peripheral.find("modem")
- local NetworkState = 0
- if Modem ~= nil then
- NetworkState = 1
- else
- NetworkState = 0
- end
- if NetworkState == 1 then
- rednet.open(Modem)
- rednet.broadcast("ping")
- local id, message, protocol = rednet.receive()
- if message == "pong" then
- NetworkState = 3
- else
- NetworkState = 2
- end
- end
- paintutils.drawFilledBox(w-3,h-3,w,h,colors.lightGray)
- if NetworkState == 3 then paintutils.drawFilledBox(w-2,h-2,w,h, colors.white) end
- if NetworkState > 1 then paintutils(w-1, h-1, w, h, colors.lightGray) end
- if NetworkState == 0 then
- paintutils.drawPixel(w,h,colors.gray)
- elseif NetworkState == 1 then
- paintutils.drawPixel(w,h,colors.white)
- end
- end
- function CUI(m) --declare function
- n=1
- local l = #m
- while true do
- CenterText(TimeSpot, os.date())
- term.setCursorPos(1,5)
- for i=1, #m, 1 do --traverse the table of options
- if i==n then term.clearLine() print(i, " ["..m[i].."]") else term.clearLine() print(i, " ", m[i]) end --print them
- end
- local event = {os.pullEvent()}
- local Cat = {event[3]}
- if event[1] == "rednet_message" and event[4] == settings.get("Secure_WirelessProtocol") and Cat == "Banking" then shell.run("os/os_Programs/os_BankingApp","Request Detected",event) end
- CenterText(TimeSpot, os.date())
- a, b= os.pullEvent("key") --wait for keypress
- if b==keys.w and n>1 then n=n-1 end
- if b==keys.s and n<l then n=n+1 end
- if b==keys.enter then break end
- CenterText(TimeSpot, os.date())
- end
- return n --return the value
- end
- function MainInteraction()
- Clear()
- settings.load(".settings")
- if settings.get("os_BetaTest") == true then
- end
- LoadInstalled()
- MenuDrawer()
- local n = CUI(ProgramNames)
- if IntPrograms[n] == "reboot" then
- os.reboot()
- elseif IntPrograms[n] == "shutdown" then
- os.shutdown()
- else
- shell.run(shell.resolve(IntPrograms[n]))
- end
- end
- MainInteraction()
Add Comment
Please, Sign In to add comment