Advertisement
Guest User

settings

a guest
Apr 30th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.22 KB | None | 0 0
  1. w,h = term.getSize()
  2. slc = 0
  3. isBuild = false
  4. lastSelection = 1
  5.  
  6. function titleBar()
  7. term.setCursorPos(1,h)
  8. term.setBackgroundColor(colors.lightBlue)
  9. term.setTextColor(colors.white)
  10. term.clearLine()
  11. term.setTextColor(colors.white)
  12. term.setCursorPos(1, h)
  13. write(" Menu ")
  14. end
  15.  
  16. function leftNavMenu1()
  17. term.setCursorPos(1,2)
  18. term.setBackgroundColor(colors.gray)
  19. print(" Storage ")
  20. term.setTextColor(colors.gray)
  21. term.setBackgroundColor(colors.white)
  22. print("Customize")
  23. print(" M-OS ")
  24. print(" Startup ")
  25. paintutils.drawLine(10,2,10,h-1,colors.lightGray)
  26. end
  27.  
  28. function leftNavMenu2()
  29. term.setCursorPos(1,2)
  30. term.setTextColor(colors.gray)
  31. term.setBackgroundColor(colors.white)
  32. print(" Storage ")
  33. term.setTextColor(colors.white)
  34. term.setBackgroundColor(colors.gray)
  35. print("Customize")
  36. term.setTextColor(colors.gray)
  37. term.setBackgroundColor(colors.white)
  38. print(" M-OS ")
  39. print(" Startup ")
  40. paintutils.drawLine(10,2,10,h-1,colors.lightGray)
  41. end
  42.  
  43. function leftNavMenu3()
  44. term.setCursorPos(1,2)
  45. term.setTextColor(colors.gray)
  46. term.setBackgroundColor(colors.white)
  47. print(" Storage ")
  48. print("Customize")
  49. term.setTextColor(colors.white)
  50. term.setBackgroundColor(colors.gray)
  51. print(" M-OS ")
  52. term.setTextColor(colors.gray)
  53. term.setBackgroundColor(colors.white)
  54. print(" Startup ")
  55. paintutils.drawLine(10,2,10,h-1,colors.lightGray)
  56. end
  57.  
  58. function leftNavMenu4()
  59. term.setCursorPos(1,2)
  60. term.setTextColor(colors.gray)
  61. term.setBackgroundColor(colors.white)
  62. print(" Storage ")
  63. print("Customize")
  64. print(" M-OS ")
  65. term.setTextColor(colors.white)
  66. term.setBackgroundColor(colors.gray)
  67. print(" Startup ")
  68. paintutils.drawLine(10,2,10,h-1,colors.lightGray)
  69. end
  70.  
  71. function selection1()
  72. slc = 1
  73. lastSelection = 1
  74. term.setTextColor(colors.gray)
  75. term.setBackgroundColor(colors.white)
  76. term.setCursorPos(12,2)
  77. print("Manage Storage")
  78. term.setCursorPos(12,4)
  79. local size = fs.getSize("m-os/desktop") + fs.getSize("m-os/programs/installed_programs") + fs.getSize("m-os/monitior_detected") + fs.getSize("m-os/boot") + fs.getSize("m-os/settings") + fs.getSize("m-os/logon") + fs.getSize("m-os/restore")
  80. print("OS: " .. size .. " bytes.")
  81. term.setCursorPos(12,5)
  82. local picturesSize = fs.getSize("m-os/images/bground") + fs.getSize("m-os/images/logo") + fs.getSize("m-os/images/icons/file") + fs.getSize("m-os/images/icons/paint") + fs.getSize("m-os/images/icons/shell") + fs.getSize("m-os/images/icons/unknown")
  83. print("Images: " .. picturesSize .. " bytes.")
  84. term.setCursorPos(12,6)
  85. local totalSpaceUsed = size + picturesSize
  86. print("Total space used: " .. totalSpaceUsed .. " bytes.")
  87. term.setCursorPos(12,7)
  88. local freeSpace = fs.getFreeSpace("/")
  89. print("Free space: " .. freeSpace .. " bytes.")
  90. end
  91.  
  92. function selection2()
  93. slc = 2
  94. lastSelection = 2
  95. term.setTextColor(colors.gray)
  96. term.setBackgroundColor(colors.white)
  97. term.setCursorPos(12,2)
  98. print("Customize your Computer")
  99. term.setCursorPos(12,4)
  100. term.setTextColor(colors.lightGray)
  101. term.setBackgroundColor(colors.gray)
  102. print(" Edit Desktop Background ")
  103. end
  104.  
  105.  
  106. function selection3()
  107. slc = 3
  108. lastSelection = 3
  109. term.setTextColor(colors.gray)
  110. term.setBackgroundColor(colors.white)
  111. term.setCursorPos(12,2)
  112. print("M-OS")
  113. term.setCursorPos(12,3)
  114. print("Created by MarcoPolo0306")
  115. if isBuild == true then
  116. term.setCursorPos(12,5)
  117. print("Build date: 5/29/17")
  118. term.setCursorPos(12,6)
  119. print("Build version: 6")
  120. else
  121. term.setCursorPos(12,5)
  122. print("Version realease date: 29/4/17")
  123. term.setCursorPos(12,6)
  124. print("Version: 1.1.2")
  125. term.setCursorPos(25,6)
  126. end
  127. term.setCursorPos(12,8)
  128. term.setBackgroundColor(colors.gray)
  129. term.setTextColor(colors.lightGray)
  130. print(" Reinstall ")
  131. term.setCursorPos(12,10)
  132. term.setBackgroundColor(colors.gray)
  133. term.setTextColor(colors.lightGray)
  134. print(" Uninstall ")
  135. end
  136.  
  137. function selection4()
  138. slc = 4
  139. lastSelection = 4
  140. term.setTextColor(colors.gray)
  141. term.setBackgroundColor(colors.white)
  142. term.setCursorPos(12,2)
  143. print("Startup Options")
  144. term.setBackgroundColor(colors.gray)
  145. term.setTextColor(colors.lightGray)
  146. term.setCursorPos(12,4)
  147. print(" Change Password ")
  148. end
  149.  
  150. function drawWindow()
  151. local tbarC = colors.lightBlue
  152. local tBartC = colors.white
  153. term.setBackgroundColor(colors.white)
  154. term.clear()
  155. term.setCursorPos(1,1)
  156. term.setBackgroundColor(tbarC)
  157. term.setTextColor(tBartC)
  158. term.clearLine()
  159. term.setCursorPos(2,1)
  160. write("Settings")
  161. term.setCursorPos(w,1)
  162. term.setBackgroundColor(colors.red)
  163. print("X")
  164. term.setBackgroundColor(colors.white)
  165. term.setTextColor(colors.gray)
  166. leftNavMenu1()
  167. end
  168.  
  169. function areYouSure()
  170. slc = 1
  171. local y1 = h/2-3
  172. local y2 = h/2+6
  173. paintutils.drawBox(w/2-10,h/2-3,w/2+10,h/2+4,colors.lightGray)
  174. paintutils.drawFilledBox(w/2-9,h/2-2,w/2+9,h/2+3,colors.white)
  175. paintutils.drawLine(w/2-10,h/2-3,w/2+10,h/2-3,colors.lightBlue)
  176. term.setTextColor(colors.white)
  177. term.setCursorPos(w/2-10, h/2-3)
  178. print("Are you sure?")
  179. term.setTextColor(colors.gray)
  180. term.setCursorPos(w/2-9, h/2-2)
  181. term.setBackgroundColor(colors.white)
  182. print(" Are you sure you")
  183. term.setCursorPos(w/2-9, h/2-1)
  184. print(" want to delete ")
  185. term.setCursorPos(w/2-9, h/2)
  186. print(" M-OS?")
  187. term.setCursorPos(w/2-6, h/2+2)
  188. term.setTextColor(colors.lightGray)
  189. term.setBackgroundColor(colors.gray)
  190. print(" Yes ")
  191. term.setCursorPos(w/2+3, h/2+2)
  192. print(" No ")
  193. end
  194.  
  195. function createWindow()
  196. term.setBackgroundColor(1)
  197. term.clear()
  198. term.setCursorPos(1,1)
  199. leftNavMenu1()
  200. drawWindow()
  201. titleBar()
  202. end
  203.  
  204. createWindow()
  205. selection1()
  206.  
  207. while true do
  208. createWindow()
  209. if lastSelection == 1 then
  210. leftNavMenu1()
  211. selection1()
  212. elseif lastSelection == 2 then
  213. leftNavMenu2()
  214. selection2()
  215. elseif lastSelection == 3 then
  216. leftNavMenu3()
  217. selection3()
  218. elseif lastSelection == 4 then
  219. leftNavMenu4()
  220. selection4()
  221. end
  222. local event, button, X, Y = os.pullEvent()
  223. if event == "mouse_click" then
  224. if X==w and Y==1 and button ==1 then
  225. shell.run("m-os/desktop")
  226. elseif X>=1 and X<=9 and Y==2 and button == 1 then
  227. createWindow()
  228. leftNavMenu1()
  229. selection1()
  230. elseif X>=1 and X<=9 and Y==3 and button == 1 then
  231. createWindow()
  232. leftNavMenu2()
  233. selection2()
  234. elseif X>=1 and X<=9 and Y==4 and button == 1 then
  235. createWindow()
  236. leftNavMenu3()
  237. selection3()
  238. elseif X>=1 and X<=9 and Y==5 and button == 1 then
  239. createWindow()
  240. leftNavMenu4()
  241. selection4()
  242. elseif X>=12 and X<=37 and Y==4 and slc == 2 and button == 1 then
  243. shell.run("paint","m-os/images/bground")
  244. elseif X>=12 and X<=23 and Y==8 and slc == 3 and button == 1 then
  245. term.setBackgroundColor(colors.black)
  246. term.clear()
  247. term.setCursorPos(1,1)
  248. print("Thank you for using M-OS. Your computer will reboot in 5 seconds.")
  249. fs.delete("startup")
  250. shell.run("pastebin get JuDHtxJt startup")
  251. sleep(5)
  252. os.reboot()
  253. elseif X>=12 and X<=23 and Y==10 and slc == 3 and button == 1 then
  254. term.setBackgroundColor(colors.black)
  255. term.clear()
  256. term.setCursorPos(1,1)
  257. print("Thank you for using M-OS. Your computer will reboot in 5 seconds.")
  258. fs.delete("startup")
  259. fs.delete("m-os")
  260. sleep(5)
  261. os.reboot()
  262. elseif X>=12 and X<=37 and Y==4 and slc == 4 and button == 1 then
  263. shell.run("edit","m-os/logon")
  264. end
  265. end
  266. end
  267.  
  268. local ok, err = pcall(main)
  269. if not ok then
  270. term.setBackgroundColor(colors.red)
  271. term.clear()
  272. term.setBackgroundColor(colors.gray)
  273. term.setCursorPos(1,1)
  274. term.clearLine()
  275. term.setTextColor(colors.white)
  276. print("Internal System Error")
  277. term.setBackgroundColor(colors.red)
  278. print("The following error has occured: " .. err)
  279. print("Please report this error to MarcoPolo0306. (=")
  280. print("(Your computer will restart in 15 seconds.)")
  281. sleep(15)
  282. os.reboot()
  283. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement