Advertisement
TaZeOS

os/desktop.lua

Nov 3rd, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.74 KB | None | 0 0
  1.  
  2. function getOSVersion()
  3. readosversion = http.get("https://pastebin.com/raw/PaMrgmxM")
  4. osversion = readosversion.readLine()
  5. forceupdate = readosversion.readLine()
  6. if forceupdate == "true" then
  7.  
  8. end
  9.  
  10. end
  11.  
  12. function appError(String)
  13.  
  14. errormessage = window.create(term.current(),15,7,25,6)
  15. errormessage.setBackgroundColor(colors.white)
  16. errormessage.clear()
  17. errormessage.setCursorPos(1,1)
  18. errormessage.setBackgroundColor(colors.red)
  19. errormessage.write(" Error ")
  20. errormessage.setTextColor(colors.black)
  21. errormessage.setCursorPos(2,2)
  22. errormessage.setBackgroundColor(colors.white)
  23. errormessage.write("A error has occurred!")
  24. errormessage.setCursorPos(2,3)
  25. errormessage.write("Please check the log to")
  26. errormessage.setCursorPos(2,4)
  27. errormessage.write("find out more info.")
  28. errormessage.setCursorPos(10,5)
  29. errormessage.setBackgroundColor(colors.lightGray)
  30. errormessage.setTextColor(colors.white)
  31. errormessage.write(" Ok ")
  32. log("ERROR ==> "..String)
  33. while true do
  34.  
  35. local event, button, x, y = os.pullEvent("mouse_click")
  36.  
  37. if x >= 24 and x <= 27 and y == 11 then
  38.  
  39. shell.run('OS/desktop.lua')
  40. break
  41. end
  42. end
  43.  
  44. end
  45.  
  46. ------------------------------------------
  47. function s(...) return sleep(...) end
  48. function w(...) return write(...) end
  49. function p(...) return print(...) end
  50. function tw(...) return term.write(...) end
  51. function scp(...) return term.setCursorPos(...) end
  52. function sbc(...) return term.setBackgroundColor(...) end
  53. function stc(...) return term.setTextColor(...) end
  54. function tc(...) return term.clear(...) end
  55. function tcl(...) return term.clearLine() end
  56. function scb(...) return term.setCursorBlink(...) end
  57. function ts(...) return term.scroll(...) end
  58. function r(...) return shell.run(...) end
  59. function para(...) return parallel.waitForAny(...) end
  60. function sw(...) return textutils.slowWrite(...) end
  61. function sp(...) return textutils.slowPrint(...) end
  62.  
  63. -- OS VERSION
  64.  
  65. getOSVersion()
  66.  
  67. --------------
  68. -- Define the windows properties ----
  69. desktopproperties = {1,2,51,18,colors.white}
  70. taskbarproperties = {1,1,51,1,colors.lightGray}
  71. userinfoproperties = {3,15,20,4,colors.cyan}
  72. shell.run("OS/desktopconfig.lua")
  73. -- Create the windows ---------------
  74. desktop = window.create(term.current(), desktopproperties[1],desktopproperties[2],desktopproperties[3],desktopproperties[4])
  75. userinfo = window.create(term.current(), userinfoproperties[1],userinfoproperties[2],userinfoproperties[3],userinfoproperties[4])
  76. taskbar = window.create(term.current(), taskbarproperties[1],taskbarproperties[2],taskbarproperties[3],taskbarproperties[4])
  77.  
  78. taskbar.setBackgroundColor(taskbarproperties[5])
  79. taskbar.clear()
  80. taskbar.setCursorPos(taskbarproperties[1],taskbarproperties[1])
  81. taskbar.write("Start Menu")
  82. desktop.setBackgroundColor(colors.white)
  83. desktop.clear()
  84. userinfo.setBackgroundColor(userinfoproperties[5])
  85. userinfo.clear()
  86.  
  87. -------------------------------------
  88. desktop.setBackgroundColor(colors.white)
  89.  
  90. path1 = iconproperties[1][2]
  91. path2 = iconproperties[2][2]
  92. path3 = iconproperties[3][2]
  93. path4 = iconproperties[4][2]
  94. path5 = iconproperties[5][2]
  95.  
  96.  
  97. icon1 = {path1,name1,2,13}
  98. icon2 = {path2,name2,17,27}
  99. icon3 = {path3,name3,30,41}
  100. icon4 = {path4,name4,2,13}
  101. icon5 = {path5,name5,17,27}
  102.  
  103. -- Page Arrows
  104. desktop.setCursorPos(25,15)
  105. desktop.setBackgroundColor(colors.lightGray)
  106. desktop.write(" < ")
  107. desktop.setCursorPos(30,15)
  108. desktop.write(" > ")
  109.  
  110. --- User info box
  111.  
  112. checkCurrentUserId()
  113.  
  114. if admin1 == "true" and userid == 1 then
  115. admin = "true"
  116. elseif admin2 == "true" and userid == 2 then
  117. admin = "true"
  118. elseif admin3 == "true" and userid == 3 then
  119. admin = "true"
  120. elseif admin4 == "true" and userid == 4 then
  121. admin = "true"
  122.  
  123.  
  124.  
  125.  
  126. end
  127.  
  128.  
  129. userinfo.setCursorPos(2,2)
  130. userinfo.write("User: "..CurrentUser)
  131. userinfo.setCursorPos(2,3)
  132. if admin == "true" then
  133. userinfo.write("Admin Privliages")
  134. end
  135.  
  136.  
  137.  
  138. desktop.setBackgroundColor(colors.white)
  139.  
  140.  
  141.  
  142. iconimage1 = paintutils.loadImage(icon1[1])
  143. iconimage2 = paintutils.loadImage(icon2[1])
  144. iconimage3 = paintutils.loadImage(icon3[1])
  145. iconimage4 = paintutils.loadImage(icon4[1])
  146. iconimage5 = paintutils.loadImage(icon5[1])
  147. paintutils.drawImage(iconimage1, 2, 3 )
  148. paintutils.drawImage(iconimage2,16, 3 )
  149. paintutils.drawImage(iconimage3,30, 3 )
  150.  
  151. desktop.setCursorPos(4,12)
  152.  
  153. desktop.setTextColor(colors.black)
  154.  
  155. desktop.write(iconproperties[1][1])
  156. desktop.setCursorPos(18,12)
  157. desktop.write(iconproperties[2][1])
  158. desktop.setCursorPos(32,12)
  159. desktop.write(iconproperties[3][1])
  160. page = 1
  161. while true do
  162.  
  163. if page == 2 then
  164. desktop.setCursorPos(2,12)
  165.  
  166. desktop.setTextColor(colors.black)
  167.  
  168. desktop.write(iconproperties[4][1])
  169. desktop.setTextColor(colors.black)
  170. desktop.setCursorPos(18,12)
  171. desktop.write(iconproperties[5][1])
  172.  
  173. end
  174.  
  175. event, button, x, y = os.pullEvent("mouse_click")
  176.  
  177.  
  178. ----------- DETECT ICON 1 ----------------
  179. if button == 1 and x >= icon1[3] and x <= icon1[4] and y >= 3 and y <= 10 then
  180.  
  181. if iconproperties[1][1] == "Log Viewer" and page == iconproperties[1][3] then
  182.  
  183. logviewer()
  184. elseif iconproperties[4][1] == "Log Viewer" and page == iconproperties[4][3] then
  185.  
  186. logviewer()
  187.  
  188. elseif iconproperties[1][1] == "Terminal" and page == iconproperties[1][3] then
  189.  
  190. terminal()
  191. elseif iconproperties[4][1] == "Terminal" and page == iconproperties[4][3] then
  192.  
  193. terminal()
  194.  
  195. elseif iconproperties[1][1] == "Settings" and page == iconproperties[1][3] then
  196.  
  197. settingsapp()
  198. elseif iconproperties[4][1] == "Settings" and page == iconproperties[4][3] then
  199.  
  200. settingsapp()
  201.  
  202. elseif iconproperties[1][1] == "Admin Control" and page == iconproperties[1][3] then
  203.  
  204. adminControl()
  205. elseif iconproperties[4][1] == "Admin Control" and page == iconproperties[4][3] then
  206.  
  207. adminControl()
  208. elseif iconproperties[4][1] == "Ink" and page == iconproperties[5][3] then
  209.  
  210. ink()
  211. elseif iconproperties[4][1] == "Ink" and page == iconproperties[5][3] then
  212.  
  213. ink()
  214.  
  215. end
  216. appError("App exited unexpectedly, near LN 209 in desktop.lua")
  217. ----------- DETECT ICON 2 ----------------
  218.  
  219. elseif button == 1 and x >= icon2[3] and x <= icon2[4] and y >= 3 and y <= 10 then
  220.  
  221. if iconproperties[2][1] == "Log Viewer" and page == iconproperties[2][3] then
  222.  
  223. logviewer()
  224. elseif iconproperties[2][1] == "Terminal" and page == iconproperties[2][3] then
  225.  
  226. terminal()
  227.  
  228. elseif iconproperties[2][1] == "Settings" and page == iconproperties[2][3] then
  229.  
  230. settingsapp()
  231.  
  232. elseif iconproperties[2][1] == "Admin Control" and page == iconproperties[2][3] then
  233.  
  234. adminControl()
  235. elseif iconproperties[2][1] == "Admin Control" and page == iconproperties[2][3] then
  236.  
  237. adminControl()
  238.  
  239. elseif iconproperties[2][1] == "Ink" and page == iconproperties[2][3] then
  240.  
  241. ink()
  242. elseif iconproperties[5][1] == "Ink" and page == iconproperties[5][3] then
  243.  
  244. ink()
  245.  
  246. end
  247.  
  248. appError("App exited unexpectedly, near LN 130 in desktop.lua")
  249.  
  250. ----------- DETECT ICON 3 ----------------
  251. elseif button == 1 and x >= icon3[3] and x <= icon3[4] and y >= 3 and y <= 10 then
  252.  
  253. if iconproperties[3][1] == "Log Viewer" and page == iconproperties[3][3] then
  254.  
  255. logviewer()
  256. elseif iconproperties[3][1] == "Terminal" and page == iconproperties[3][3] then
  257.  
  258. terminal()
  259.  
  260. elseif iconproperties[3][1] == "Settings" and page == iconproperties[3][3] then
  261.  
  262. settingsapp()
  263. elseif iconproperties[4][1] == "Admin Control" and page == iconproperties[3][3] then
  264.  
  265. adminControl()
  266.  
  267. end
  268. appError("App exited unexpectedly, near LN 130 in desktop.lua")
  269.  
  270.  
  271. elseif button == 1 and x >= 25 and x <= 28 and y == 16 then
  272. shell.run('os/desktop.lua')
  273. elseif button == 1 and x >= 30 and x <= 33 and y == 16 then
  274. page = 2
  275. desktop.setBackgroundColor(colors.white)
  276. desktop.setCursorPos(1,1)
  277. desktop.write(" ")
  278. desktop.setCursorPos(1,2)
  279. desktop.write(" ")
  280.  
  281. desktop.setCursorPos(1,3)
  282. desktop.write(" ")
  283. desktop.setCursorPos(1,4)
  284. desktop.write(" ")
  285. desktop.setCursorPos(1,5)
  286. desktop.write(" ")
  287. desktop.setCursorPos(1,6)
  288. desktop.write(" ")
  289. desktop.setCursorPos(1,7)
  290. desktop.write(" ")
  291. desktop.setCursorPos(1,8)
  292. desktop.write(" ")
  293. desktop.setCursorPos(1,9)
  294. desktop.write(" ")
  295. desktop.setCursorPos(1,10)
  296. desktop.write(" ")
  297. desktop.setCursorPos(1,11)
  298. desktop.write(" ")
  299. desktop.setCursorPos(1,12)
  300. desktop.write(" ")
  301. paintutils.drawImage(iconimage4, 2, 3 )
  302. paintutils.drawImage(iconimage5, 16, 3 )
  303.  
  304. end
  305. end
  306.  
  307.  
  308.  
  309.  
  310. sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement