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()
- os.loadAPI("TouchPad")
- 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"}
- --Display Var
- local TimeSpot = #ProgramNames + 5
- local TaskBarSettings = {1,h-3,w,h,colors.lightGray}
- local Shortcuts = {}
- local TaskbarItems = {}
- local ExtrasStates = {false,false,false} --show Searchbar, show
- 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 BetaAppsLoad()
- 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 GetMenuFiles()
- local data
- local file = fs.open(shell.resolve("/MenuFiles/Shortcuts"),"r")
- while true do
- data = {file.readLine()}
- if data[1] == "end" then
- break
- else
- ShortcutCreator( data[1],data[2],data[3],data[4],data[5])
- end
- end
- file.close()
- data = {}
- local TaskFile = fs.open(shell.resolve("/MenuFiles/Taskbar")
- TaskbarSettings = {TaskFile.readLine()}
- while true do
- data = {TaskFile.readLine()}
- if data[1] == "end" then
- break
- else
- TaskbarItemCreator( data[1], data[2], data[3])
- end
- end
- TaskFile.close()
- end
- local function TaskbarItemCreator (Name ,image ,Path)
- TaskbarItems[#TaskbarItems + 1] = {Name, image, Path}
- --leaving image as n will have a default image used
- end
- local function ShortcutCreator(Name ,image , Path ,x ,y )
- Shortcuts[#Shortcuts + 1] = {Name, image, Path, x, y}
- --x and y are the cords for top left corner, leaving image as n will have a default image used
- end
- local function DisplaySystem()
- MenuDrawer()
- DrawTaskbar()
- DrawShortcuts()
- end
- local function DrawTaskbar()
- paintutils.drawFilledBox(TaskBarSettings)
- paintutils.drawFilledBox(1, h - 4, 4, h, colors.blue)
- DrawNetworkStatus()
- local X1
- local X2
- for i = 1, #TaskbarItems do
- X1 = i * 6
- X2 = i * 6 + 5
- paintutils.drawFilledBox(X1, h - 5, X2, h, colors.yellow)
- end
- end
- local function DrawShortcuts()
- for i = 1, #Shortcuts do
- paintutils.drawFilledBox(Shortcuts[i][4],Shortcuts[i][5],Shortcuts[i][4] + 7, Shortcuts[i][5] + 12, colors.gray)
- term.setTextColor(colors.white)
- term.setCursorPos((Shortcuts[i][4] + 7) - string.len(Shortcuts[i][1], Shortcuts[i][5] + 10)
- term.write(Shortcuts[i][1])
- end
- end
- local function MenuDrawer()
- term.setBackgroundColor(colors.cyan)
- Clear()
- term.setBackgroundColor(colors.cyan)
- CenterText(1,"==Desktop==version"..version.."==")
- CenterText(3,"-=Applications=-")
- 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-5,h-3,w,h,colors.lightGray)
- if NetworkState == 0 then
- paintutils.drawPixel(w,h,colors.gray)
- elseif NetworkState == 1 then
- paintutils.drawPixel(w,h,colors.white)
- elseif NetworkState == 2 then
- paintutils.drawPixel(w,h,colors.white)
- paintutils.drawFilledBox(w-2,h-1,w-2,h,colors.white)
- elseif NetworkState == 3 then
- paintutils.drawPixel(w,h,colors.white)
- paintutils.drawFilledBox(w-2,h-1,w-2,h,colors.white)
- paintutils.drawFilledBox(w-4,h-2,w-4,h,colors.white)
- end
- end
- function CUI(m) --declare function
- n=1
- local l = #m
- while true do
- 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
- 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
- end
- return n --return the value
- end
- function CheckInteractables(event,x,y)
- local Result = "n"
- local Type
- for i = 1, #Shortcuts do
- if x >= Shortcuts[i][4] and x <= Shortcuts[i][4] + 7 and y >= Shortcuts[i][5] and y <= Shortcuts[i][5] + 12 then
- Result = Shortcuts[i][3]
- Type = "Script"
- end
- end
- if Result == "n" and y > h - 5 then
- local X1
- local X2
- for i = 1, #TaskbarItems do
- X1 = i * 6
- X2 = i * 6 + 5
- if x > = X1 and x <= X2 then
- Result = TaskbarItems[i][3]
- Type = "Script"
- end
- end
- elseif Result == "n" and x < 5 and y > h - 5 then
- Result = "Home"
- Type = "button"
- end
- return (Result, Type)
- end
- function Interaction()
- Clear()
- DisplaySystem()
- local item
- while true do
- local a, b, c, d = os.pullEvent()
- if a == "key" then
- elseif a == "mouse_click" then
- item = {CheckInteractables("click",c,d)}
- if item[1] ~= "n" then break end
- elseif a == "rednet_message" then
- end
- end
- if item[2] == "Script" then
- shell.run(item[1])
- elseif item[2] == "button" then
- end
- end
- Interaction()
Add Comment
Please, Sign In to add comment