Advertisement
Marlingaming

CCSPS IRON 2.5.0 - Desktop Primary

Jun 15th, 2023 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. --this script acts as the Base for CCSPS Iron
  2. local User
  3. local IconSizes = {3,5}
  4. local AppPaths = {}
  5. local AppNames = {}
  6. local AppImages = {}
  7. local ShortcutCords = {}
  8. local PopItems = {}
  9. local PopPaths = {}
  10. local TaskbarItems = {}
  11. local TaskbarPaths = {}
  12. local TaskbarImages = {}
  13. local BImagePath = "n"
  14. local w, h = term.getSize()
  15.  
  16. local function GetApps()
  17. local Path = "os/System/Saved/Shortcuts"
  18. local Shortcuts = fs.list(Path)
  19. for i = 1, #Shortcuts do
  20. local file = fs.open(fs.combine(Path,Shortcuts[i]),"r")
  21. local Name = file.readLine()
  22. local Path = file.readLine()
  23. local Image = file.readLine()
  24. local Type = file.readLine()
  25. file.close()
  26. if Type == "Desktop" then
  27. AppNames[#AppNames + 1] = Name
  28. AppPaths[#AppPaths + 1] = Path
  29. AppImages[#AppImages + 1] = Image
  30. elseif Type == "Taskbar" then
  31. TaskbarItems[#TaskbarItems + 1] = Name
  32. TaskbarPaths[#TaskbarPaths + 1] = Path
  33. TaskbarImages[#TaskbarImages + 1] = Image
  34. elseif Type == "Popup" then
  35. PopItems[#PopItems + 1] = Name
  36. PopPaths[#PopPaths + 1] = Path
  37. end
  38. end
  39.  
  40. if w > 25 then
  41. IconSizes = {4,3}
  42. elseif w <= 26 then
  43. IconSizes = {4,3}
  44. end
  45.  
  46. SetCords()
  47. end
  48.  
  49. function SetCords()
  50. local y = 2
  51. local x = 3
  52. for i = 1, #AppNames do
  53. ShortcutCords[i] = {x,y}
  54. if x + (IconSizes[1] + 3) <= 26 then
  55. x = x + (IconSizes[1] + 3)
  56. else
  57. x = 3
  58. y = y + (IconSizes[2] + 3)
  59. end
  60. end
  61. end
  62.  
  63. local function DrawShortcuts()
  64. local x
  65. local y
  66. for i = 1, #AppNames do
  67. x = ShortcutCords[i][1]
  68. y = ShortcutCords[i][2]
  69. paintutils.drawBox( x,y,x+IconSizes[1],y+IconSizes[2], colors.white)
  70. if AppImages[i] ~= "n" then
  71. local Image = paintutils.loadImage(AppImages[i])
  72. paintutils.drawImage(Image,x,y)
  73. end
  74. term.setBackgroundColor(colors.lightBlue)
  75. local lines = require "cc.strings".wrap(AppNames[i], (IconSizes[1]+4))
  76. for I = 1, #lines do
  77. term.setCursorPos(x - 1, (y + IconSizes[2]) + I)
  78. term.write(lines[I])
  79. end
  80. end
  81. end
  82.  
  83. local function DrawTaskBar()
  84. paintutils.drawFilledBox(1,h, w, h, colors.blue)
  85. paintutils.drawFilledBox(1, h, 2, h, colors.lightGray)
  86. local ItemCol = {colors.blue,colors.yellow,colors.green}
  87. local X = 4
  88. for i = 1, #TaskbarItems do
  89. paintutils.drawBox(X, h - 2,X+2, h, ItemCol[i])
  90. if TaskbarImages[i] ~= "n" then
  91. local Image = paintutils.loadImage(TaskbarImages[i])
  92. paintutils.drawImage(Image,X, h - 2)
  93. end
  94. X = X + 4
  95. end
  96. end
  97.  
  98. local function Clear()
  99. term.clear()
  100. term.setCursorPos(1,1)
  101. end
  102.  
  103. local function CenterText(y,text)
  104. local x = math.floor((w - string.len(text)) /2)
  105. term.setCursorPos(x,y)
  106. term.clearLine()
  107. term.write(text)
  108. end
  109.  
  110. function CUI(m,y) --declare function
  111. n=0
  112. local l = #m
  113. while true do
  114. a, b, c, d= os.pullEvent("mouse_click") --wait for keypress
  115. for i = 1, #AppNames do
  116. 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
  117. end
  118. local X = 4
  119. for I = 1, #TaskbarItems do
  120. if c >= X and c <= X + 2 and d >= h - 2 then n = I t = "Task" end
  121. X = X + 4
  122. end
  123. if n == 0 and c < 3 and d > h - 1 then n = 50 end
  124. if n > 0 then break end
  125. end
  126. return n, t --return the value
  127. end
  128.  
  129. function popupCUI() --declare function
  130. n=0
  131. while true do
  132. a, b, c, d= os.pullEvent("mouse_click") --wait for keypress
  133. for i = 1, #PopItems do
  134. if c > 2 and c < 10 and d >= (i + (h - 15)) and d <= ( i + (h - 14)) then n = i end
  135. end
  136. if n == 0 and c <= 12 and c>=10 and d >= h - 2 and d <= h - 1 then n = 50 elseif n == 0 then n = 51 end
  137. if n > 0 then break end
  138. end
  139. return n --return the value
  140. end
  141.  
  142. function PopupPanel()
  143. paintutils.drawFilledBox(1,h - 15 ,15,h - 1,colors.lightGray)
  144. paintutils.drawFilledBox(10,h - 2, 12, h - 1, colors.red)
  145. term.setBackgroundColor(colors.lightGray)
  146. term.setCursorPos(1,h-15)
  147. term.write("hello, "..User)
  148. for I = 1, #PopItems do
  149. term.setCursorPos(2,I + (h - 15))
  150. term.write(PopItems[I])
  151. end
  152.  
  153. local n = popupCUI()
  154. if n == 50 then
  155. shell.run("os/System/Scripts/PowerOff.lua","shutdown")
  156. elseif n == 51 then
  157.  
  158. else
  159. shell.run(PopPaths[n])
  160. end
  161. end
  162.  
  163. function Desktop()
  164. term.setBackgroundColor(colors.lightBlue)
  165. term.setTextColor(colors.white)
  166. Clear()
  167. if BImagePath ~= "n" then
  168. local image = paintutils.loadImage(BImagePath)
  169. paintutils.drawImage(image,1,1)
  170. end
  171. DrawTaskBar()
  172. DrawShortcuts()
  173. CenterText(1,"Desktop")
  174. local options = AppNames
  175. local n, t = CUI(options)
  176. if n == 50 then
  177. PopupPanel()
  178. else
  179. if t == "Task" then
  180. shell.run(TaskbarPaths[n])
  181. else
  182. shell.run(AppPaths[n])
  183. end
  184. end
  185. Desktop()
  186. end
  187.  
  188. local function Start()--change load order to: screen requesting swipe up, then lockscreen or continue
  189. local U = fs.open("os/System/Client/Files/.UserFile.txt","r")
  190. User = U.readLine()
  191. U.close()
  192. GetApps()
  193. term.setBackgroundColor(colors.cyan)
  194. Clear()
  195.  
  196. CenterText(3,"press any button to continue")
  197. local a, b = os.pullEvent("key")
  198. Clear()
  199. if fs.exists("os/System/Client/Files/Password.txt") then
  200. local file = fs.open("os/System/Client/Files/Password.txt","r")
  201. local Password = file.readLine()
  202. file.close()
  203. CenterText(1,"==Login==")
  204. local Image = paintutils.loadImage("os/System/Saved/Images/Default_ProfileIcon.nfp")
  205. paintutils.drawImage(Image,10,3)
  206. paintutils.drawBox(8,10,18,10,colors.lightBlue)
  207. term.setBackgroundColor(colors.cyan)
  208. term.setCursorPos(8,9)
  209. term.write("Password")
  210. term.setCursorPos(8,2)
  211. term.write("account")
  212. term.setCursorPos(8,10)
  213. term.setBackgroundColor(colors.lightBlue)
  214. local input
  215. while true do
  216. local event = {os.pullEvent("key")}
  217. if event[2] == keys.enter then break end
  218. input = read()
  219. end
  220. if input ~= Password then
  221. Start()
  222. else
  223. Desktop()
  224. end
  225. else
  226. Desktop()
  227. end
  228. end
  229.  
  230. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement