Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this script acts as the Base for CCSPS Iron
- local IconSizes = {3,5}
- local AppPaths = {}
- local AppNames = {}
- local AppImages = {}
- local ShortcutCords = {}
- local PopItems = {}
- local PopPaths = {}
- local TaskbarItems = {}
- local TaskbarPaths = {}
- local TaskbarImages = {}
- local BImagePath = "n"
- local w, h = term.getSize()
- local function GetApps()
- local Path = "os/System/Saved/Shortcuts"
- local Shortcuts = fs.list(Path)
- for i = 1, #Shortcuts do
- local file = fs.open(fs.combine(Path,Shortcuts[i]),"r")
- local Name = file.readLine()
- local Path = file.readLine()
- local Image = file.readLine()
- local Type = file.readLine()
- file.close()
- if Type == "Desktop" then
- AppNames[#AppNames + 1] = Name
- AppPaths[#AppPaths + 1] = Path
- AppImages[#AppImages + 1] = Image
- elseif Type == "Taskbar" then
- TaskbarItems[#TaskbarItems + 1] = Name
- TaskbarPaths[#TaskbarPaths + 1] = Path
- TaskbarImages[#TaskbarImages + 1] = Image
- elseif Type == "Popup" then
- PopItems[#PopItems + 1] = Name
- PopPaths[#PopPaths + 1] = Path
- end
- end
- if w > 25 then
- IconSizes = {4,3}
- elseif w <= 26 then
- IconSizes = {4,3}
- end
- SetCords()
- end
- function SetCords()
- local y = 2
- local x = 3
- for i = 1, #AppNames do
- ShortcutCords[i] = {x,y}
- if x + (IconSizes[1] + 3) <= 26 then
- x = x + (IconSizes[1] + 3)
- else
- x = 3
- y = y + (IconSizes[2] + 3)
- end
- end
- end
- local function DrawShortcuts()
- local x
- local y
- for i = 1, #AppNames do
- x = ShortcutCords[i][1]
- y = ShortcutCords[i][2]
- paintutils.drawBox( x,y,x+IconSizes[1],y+IconSizes[2], colors.white)
- if AppImages[i] ~= "n" then
- local Image = paintutils.loadImage(AppImages[i])
- paintutils.drawImage(Image,x,y)
- end
- term.setBackgroundColor(colors.lightBlue)
- local lines = require "cc.strings".wrap(AppNames[i], (IconSizes[1]+4))
- for I = 1, #lines do
- term.setCursorPos(x - 1, (y + IconSizes[2]) + I)
- term.write(lines[I])
- end
- end
- end
- local function DrawTaskBar()
- paintutils.drawFilledBox(1,h, w, h, colors.blue)
- paintutils.drawFilledBox(1, h, 2, h, colors.lightGray)
- local ItemCol = {colors.blue,colors.yellow,colors.green}
- local X = 4
- for i = 1, #TaskbarItems do
- paintutils.drawBox(X, h - 2,X+2, h, ItemCol[i])
- if TaskbarImages[i] ~= "n" then
- local Image = paintutils.loadImage(TaskbarImages[i])
- paintutils.drawImage(Image,X, h - 2)
- end
- X = X + 4
- end
- end
- 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
- function CUI(m,y) --declare function
- n=0
- local l = #m
- while true do
- a, b, c, d= os.pullEvent("mouse_click") --wait for keypress
- for i = 1, #AppNames do
- if c >= ShortcutCords[i][1] and c <= ShortcutCords[i][1] + IconSizes[1] and d >= ShortcutCords[i][2] and d <= ShortcutCords[i][2] + IconSizes[2] then n = i t = "Short" end
- end
- local X = 4
- for I = 1, #TaskbarItems do
- if c >= X and c <= X + 2 and d >= h - 2 then n = I t = "Task" end
- X = X + 4
- end
- if n == 0 and c < 3 and d > h - 1 then n = 50 end
- if n > 0 then break end
- end
- return n, t --return the value
- end
- function popupCUI() --declare function
- n=0
- while true do
- a, b, c, d= os.pullEvent("mouse_click") --wait for keypress
- for i = 1, #PopItems do
- if c > 2 and c < 10 and d >= (i + (h - 15)) and d <= ( i + (h - 14)) then n = i end
- end
- if n == 0 and c <= 2 and d >= h - 2 and d <= h - 1 then n = 50 elseif n == 0 then n = 51 end
- if n > 0 then break end
- end
- return n --return the value
- end
- function PopupPanel()
- paintutils.drawFilledBox(1,h - 15 ,15,h - 1,colors.lightGray)
- paintutils.drawFilledBox(1,h - 2, 2, h - 1, colors.red)
- term.setBackgroundColor(colors.lightGray)
- for I = 1, #PopItems do
- term.setCursorPos(2,I + (h - 15))
- term.write(PopItems[I])
- end
- local n = popupCUI()
- if n == 50 then
- shell.run("os/System/Scripts/PowerOff.lua","shutdown")
- elseif n == 51 then
- else
- shell.run(PopPaths[n])
- end
- end
- function Desktop()
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.white)
- Clear()
- if BImagePath ~= "n" then
- local image = paintutils.loadImage(BImagePath)
- paintutils.drawImage(image,1,1)
- end
- DrawTaskBar()
- DrawShortcuts()
- CenterText(1,"Desktop")
- local options = AppNames
- local n, t = CUI(options)
- if n == 50 then
- PopupPanel()
- else
- if t == "Task" then
- shell.run(TaskbarPaths[n])
- else
- shell.run(AppPaths[n])
- end
- end
- Desktop()
- end
- local function Start()
- GetApps()
- term.setBackgroundColor(colors.cyan)
- Clear()
- if fs.exists("os/System/Client/Files/Password.txt") then
- local file = fs.open("os/System/Client/Files/Password.txt","r")
- local Password = file.readLine()
- file.close()
- CenterText(1,"==Login==")
- local Image = paintutils.loadImage("os/System/Saved/Images/Default_ProfileIcon.nfp")
- paintutils.drawImage(Image,10,3)
- paintutils.drawBox(8,10,18,10,colors.lightBlue)
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(8,9)
- term.write("Password")
- term.setCursorPos(8,2)
- term.write("account")
- term.setCursorPos(8,10)
- term.setBackgroundColor(colors.lightBlue)
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- if input ~= Password then
- Start()
- else
- Desktop()
- end
- else
- CenterText(1,"==Start==")
- CenterText(3,"press enter to continue")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- Desktop()
- end
- end
- Start()
Add Comment
Please, Sign In to add comment