Advertisement
optimussnorr

settings.ossf

Nov 16th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.49 KB | None | 0 0
  1. term.setBackgroundColor(colors.gray)
  2. term.clear()
  3. term.setCursorPos(1,1)
  4.  
  5. local function bar(barItem)
  6. term.setCursorPos(1,1)
  7. term.setBackgroundColor(colors.blue)
  8. term.clearLine()
  9. print("Settings | "..barItem)
  10. term.setCursorPos(49,1)
  11. print("(X)")
  12. end
  13.  
  14. local function information()
  15. term.setBackgroundColor(colors.gray)
  16. term.clear()
  17. term.setCursorPos(1,1)
  18. local diskUsage = fs.getSize("osros/")
  19. local httpOn = http
  20. bar("Computer Information")
  21. term.setCursorPos(1,2)
  22. term.setBackgroundColor(colors.gray)
  23. print("OS Version: "..ver)
  24. print("OS Disk Usage: "..diskUsage.." (Inaccurate)")
  25. if http then
  26. print("HTTP: On")
  27. else
  28. print("HTTP: Off")
  29. end
  30. print("Coder: OptimusSnorr")
  31. print("Released by: Snorrful Systems")
  32. print("")
  33. print("(C) 2013 Snorrful Systems")
  34. print("^- Back")
  35. while true do
  36. local event, button, X, Y = os.pullEventRaw()
  37. if event == "mouse_click" then
  38. if X>1 and X<7 and button == 1 and Y == 9 then
  39. shell.run("osros/system/settings.ossf")
  40. elseif X>49 and X<52 and button ==1 and Y == 1 then
  41. shell.run("osros/system/settings.ossf")
  42. else
  43. sleep(0.2)
  44. information()
  45. end
  46. end
  47. end
  48. end
  49.  
  50. local function bootBehaviour()
  51. term.setBackgroundColor(colors.gray)
  52. term.clear()
  53. term.setCursorPos(1,1)
  54. local bootOSROS = fs.exists("startup")
  55. bar("Boot Behaviour")
  56. term.setCursorPos(1,2)
  57. if bootOSROS == true then
  58. term.setBackgroundColor(colors.gray)
  59. print("Your computer boots OSROS on startup.")
  60. term.setTextColor(colors.red)
  61. print("Disable")
  62. term.setTextColor(colors.white)
  63. while true do
  64. local event, button, X, Y = os.pullEventRaw()
  65. if event == "mouse_click" then
  66. if X>1 and X<8 and button ==1 and Y==3 then
  67. shell.run("move startup osros/system/startup.suf")
  68. bootBehaviour()
  69. elseif X>49 and X<52 and button == 1 and Y == 1 then
  70. shell.run("osros/system/settings.ossf")
  71. else
  72. bootBehaviour()
  73. end
  74. end
  75. end
  76. else
  77. term.setBackgroundColor(colors.gray)
  78. print("Your computer does not boot OSROS on startup. To start OSROS, type osros/system/startup.suf")
  79. print("If you wish to boot OSROS on startup, hit enable.")
  80. term.setTextColor(colors.green)
  81. print("Enable ")
  82. term.setTextColor(colors.white)
  83. while true do
  84. local event, button, X, Y = os.pullEventRaw()
  85. if event == "mouse_click" then
  86. if X>1 and X<8 and button ==1 and Y==5 then
  87. shell.run("move osros/system/startup.suf startup")
  88. bootBehaviour()
  89. elseif X>49 and X<52 and button == 1 and Y == 1 then
  90. shell.run("osros/system/settings.ossf")
  91. else
  92. bootBehaviour()
  93. end
  94. end
  95. end
  96. end
  97. local event, button, X, Y = os.pullEventRaw()
  98. if event == "mouse_click" then
  99. if X>49 and X<52 and button == 1 and Y == 1 then
  100. shell.run("osros/system/settings.ossf")
  101. else
  102. sleep(0.2)
  103. bootBehaviour()
  104. end
  105. end
  106. end
  107.  
  108. local function safeBootSettings()
  109. term.clear()
  110. term.setCursorPos(1,1)
  111. bar("Safe Boot")
  112. term.setCursorPos(1,2)
  113. term.setBackgroundColor(colors.gray)
  114. print("What is Safe Boot?")
  115. print("SafeBoot is a little function by Snorrful Systems (and others) that boots the computer in a safe way,")
  116. print("for example; if your computer shuts down without deleting the session file, it will ask you if you wish")
  117. print("to boot normally or SHELL. (SHELL boots after 5 seconds).")
  118. print("")
  119. if safeBoot == "false" then
  120. term.setTextColor(colors.green)
  121. print("Enable SafeBoot")
  122. term.setTextColor(colors.white)
  123. while true do
  124. local event, button, X, Y = os.pullEventRaw()
  125. if event == "mouse_click" then
  126. if X>1 and X<16 and button ==1 and Y ==11 then
  127. local target = {}
  128. target.safeBoot = "true"
  129. target.dBarC = desktopBarColor
  130. local output = textutils.serialize(target)
  131. local handle = assert(fs.open("osros/system/config.osc", "w"), "Could not save configuration!")
  132. handle.write(output)
  133. handle.close()
  134. local handle = assert(fs.open("osros/system/config.osc", "r"), "Couldn't load the configuration!")
  135. local input = handle.readAll()
  136. handle.close()
  137. local conf = textutils.unserialize(input)
  138. desktopBarColor = conf.dBarC
  139. safeBoot = conf.safeBoot
  140. safeBootSettings()
  141. elseif X>49 and X<52 and button ==1 and Y==1 then
  142. shell.run("osros/system/settings.ossf")
  143. else
  144. safeBootSettings()
  145. end
  146. end
  147. end
  148. elseif safeBoot == "true" then
  149. term.setTextColor(colors.red)
  150. print("Disable SafeBoot")
  151. term.setTextColor(colors.white)
  152. while true do
  153. local event, button, X, Y = os.pullEventRaw()
  154. if event == "mouse_click" then
  155. if X>1 and X<17 and button ==1 and Y ==11 then
  156. local target = {}
  157. target.safeBoot = "false"
  158. target.dBarC = desktopBarColor
  159. local output = textutils.serialize(target)
  160. local handle = assert(fs.open("osros/system/config.osc", "w"), "Could not save configuration!")
  161. handle.write(output)
  162. handle.close()
  163. local handle = assert(fs.open("osros/system/config.osc", "r"), "Couldn't load the configuration!")
  164. local input = handle.readAll()
  165. handle.close()
  166. local conf = textutils.unserialize(input)
  167. desktopBarColor = conf.dBarC
  168. safeBoot = conf.safeBoot
  169. safeBootSettings()
  170. elseif X>49 and X<52 and button ==1 and Y==1 then
  171. shell.run("osros/system/settings.ossf")
  172. else
  173. safeBootSettings()
  174. end
  175. end
  176. end
  177. end
  178. end
  179.  
  180. local function desktopBarColorChange()
  181. term.clear()
  182. term.setCursorPos(1,1)
  183. bar("Desktop Bar Color")
  184. term.setBackgroundColor(colors.gray)
  185. print("Change your desktop bar color. (Only changes upon reboot)")
  186. print("[BLUE] [RED] [GREEN] [CYAN] [ORANGE]")
  187. while true do
  188. local event, button, X, Y = os.pullEventRaw()
  189. if event == "mouse_click" then
  190. if X>1 and X<6 and button ==1 and Y== 4 then
  191. local target = {}
  192. target.safeBoot = safeBoot
  193. target.dBarC = colors.blue
  194. local output = textutils.serialize(target)
  195. local handle = assert(fs.open("osros/system/config.osc","w"), "fail")
  196. handle.write(output)
  197. handle.close()
  198. shell.run("osros/system/settings.ossf")
  199. elseif X>8 and X<12 and button ==1 and Y==4 then
  200. local target = {}
  201. target.safeBoot = safeBoot
  202. target.dBarC = colors.red
  203. local output = textutils.serialize(target)
  204. local handle = assert(fs.open("osros/system/config.osc","w"), "fail")
  205. handle.write(output)
  206. handle.close()
  207. shell.run("osros/system/settings.ossf")
  208. elseif X>14 and X<20 and button ==1 and Y==4 then
  209. local target = {}
  210. target.safeBoot = safeBoot
  211. target.dBarC = colors.green
  212. local output = textutils.serialize(target)
  213. local handle = assert(fs.open("osros/system/config.osc","w"), "fail")
  214. handle.write(output)
  215. handle.close()
  216. shell.run("osros/system/settings.ossf")
  217. elseif X>22 and X<27 and button ==1 and Y==4 then
  218. local target = {}
  219. target.safeBoot = safeBoot
  220. target.dBarC = colors.cyan
  221. local output = textutils.serialize(target)
  222. local handle = assert(fs.open("osros/system/config.osc","w"), "fail")
  223. handle.write(output)
  224. handle.close()
  225. shell.run("osros/system/settings.ossf")
  226. elseif X>29 and X<36 and button ==1 and Y==4 then
  227. local target = {}
  228. target.safeBoot = safeBoot
  229. target.dBarC = colors.orange
  230. local output = textutils.serialize(target)
  231. local handle = assert(fs.open("osros/system/config.osc","w"), "fail")
  232. handle.write(output)
  233. handle.close()
  234. shell.run("osros/system/settings.ossf")
  235. elseif X>49 and X<52 and button ==1 and Y==1 then
  236. shell.run("osros/system/settings.ossf")
  237. else
  238. desktopBarColorChange()
  239. end
  240. end
  241. end
  242. end
  243.  
  244. local function settings()
  245. bar("Main Menu")
  246. term.setCursorPos(1,2)
  247. term.setBackgroundColor(colors.gray)
  248. print("Change Desktop Background")
  249. print("Computer Information")
  250. print("Boot Behaviour")
  251. print("SafeBoot")
  252. print("Desktop Bar Color")
  253. while true do
  254. local event, button, X, Y = os.pullEventRaw()
  255. if event == "mouse_click" then
  256. if X>49 and X<52 and button == 1 and Y ==1 then
  257. shell.run("osros/system/desktop.ossf")
  258. elseif X>1 and X<25 and button == 1 and Y ==3 then
  259. information()
  260. elseif X>1 and X<20 and button == 1 and Y ==4 then
  261. bootBehaviour()
  262. elseif X>1 and X<8 and button ==1 and Y == 5 then
  263. safeBootSettings()
  264. elseif X>1 and X<30 and button ==1 and Y==2 then
  265. shell.run("paint osros/files/desktopbg.osif")
  266. shell.run("osros/system/settings.ossf")
  267. elseif X>1 and X<24 and button ==1 and Y==6 then
  268. desktopBarColorChange()
  269. else
  270. sleep(0.2)
  271. shell.run("osros/system/settings.ossf")
  272. end
  273. end
  274. end
  275. end
  276.  
  277. settings()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement