Advertisement
thegreatstudio

gui

Mar 21st, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.76 KB | None | 0 0
  1. --Vars
  2. build = 3
  3.  
  4. --Functions
  5. function drawMenu()
  6. os.sleep(0.1)
  7. while true do
  8. term.setBackgroundColor(colors.white)
  9. term.clear()
  10. drawBackgroundDesktop(1, 3)
  11. paintutils.drawLine(1, 1, screenX, 1, colors.blue)
  12. term.setTextColor(colors.black)
  13. term.setCursorPos(1, 1)
  14. print("[Programs]")
  15. local event, button, x ,y = os.pullEvent("mouse_click")
  16. if event == "mouse_click" then
  17. if x >= 1 and x <= 9 then
  18. if y == 1 then
  19. paintutils.drawLine(1, 1, 6, 1, colors.lightBlue)
  20. paintutils.drawLine(1, 2, 8, 2, colors.lightBlue)
  21. paintutils.drawLine(1, 3, 8, 3, colors.lightBlue)
  22. paintutils.drawLine(1, 4, 8, 4, colors.lightBlue)
  23. paintutils.drawLine(1, 5, 8, 4, colors.lightBlue)
  24. term.setCursorPos(1, 1)
  25. print("[Programs]")
  26. print("File Browser")
  27. print("Taco")
  28. print("Paint")
  29. print("[Home]")
  30.  
  31. b = false
  32.  
  33. local event, button, x, y = os.pullEvent("mouse_click")
  34. if event == "mouse_click" then
  35. if x >= 1 and x <= 8 then
  36. term.setBackgroundColor(colors.white)
  37. term.clear()
  38. paintutils.drawLine(1, 1, screenX, 1, colors.blue)
  39. term.setTextColor(colors.black)
  40. term.setBackgroundColor(colors.white)
  41. if y == 2 then
  42. shell.run("gliese/gfb")
  43.  
  44. elseif y == 3 then
  45. shell.run("gliese/taco")
  46.  
  47. elseif y == 4 then
  48. print("You Must enter a Filename Before you can start Painting.")
  49. write("Filename: ")
  50. cmd =read()
  51. shell.run("paint", cmd)
  52.  
  53. elseif y == 5 then
  54. break
  55. end
  56. end
  57. end
  58. end
  59. end
  60. end
  61. end
  62. end
  63.  
  64. function drawCloseMenu()
  65. os.sleep(0.1)
  66. while true do
  67. paintutils.drawLine(1, 1, screenX, 1, colors.blue)
  68. term.setCursorPos(1, 7)
  69. term.setTextColor(colors.black)
  70. print("[Close]")
  71. _, but, x, y = os.pullEvent("mouse_click")
  72. if x >= 1 and x <=7 then
  73. if y == 1 then
  74. break
  75. end
  76. end
  77. end
  78. end
  79.  
  80. function closeMenu()
  81. term.clear()
  82. while true do
  83. local event, button, x, y = os.pullEvent("mouse_click")
  84. if x >= 12 and x <= 7 then
  85. if y == 1 then
  86. break
  87. end
  88. end
  89. end
  90. end
  91.  
  92. function drawBackgroundDesktop(x, y)
  93. drawBackground = paintutils.loadImage("/gliese/sysfiles/background")
  94. paintutils.drawImage(drawBackground, x, y)
  95. end
  96.  
  97. screenX, screenY = term.getSize()
  98.  
  99. term.setBackgroundColor(colors.white)
  100. term.clear()
  101. term.setCursorPos(1, 1)
  102. os.sleep(0.1)
  103. while true do
  104. term.setBackgroundColor(colors.white)
  105. term.clear()
  106. drawBackgroundDesktop(1, 3)
  107. paintutils.drawLine(1, 1, screenX, 1, colors.blue)
  108. term.setTextColor(colors.black)
  109. term.setCursorPos(1, 1)
  110. print("[Menu]")
  111. local event, button, x, y = os.pullEvent("mouse_click")
  112.  
  113. if event == "mouse_click" then
  114. if x >= 1 and x <= 6 then
  115. if y == 1 then
  116. paintutils.drawLine(1, 1, 6, 1, colors.lightBlue)
  117. paintutils.drawLine(1, 2, 8, 2, colors.lightBlue)
  118. paintutils.drawLine(1, 3, 8, 4, colors.lightBlue)
  119. paintutils.drawLine(1, 4, 8, 4, colors.lightBlue)
  120. paintutils.drawLine(1, 5, 8, 5, colors.lightBlue)
  121. paintutils.drawLine(1, 6, 8, 6, colors.lightBlue)
  122. paintutils.drawLine(1, 7, 8, 7, colors.lightBlue)
  123. term.setCursorPos(1, 1)
  124. print("[Menu]")
  125. print("Run")
  126. print("Shell")
  127. print("Shutdown")
  128. print("Restart")
  129. print("Settings")
  130. print("[Programs]")
  131.  
  132. b = false
  133.  
  134. local event, button, x, y = os.pullEvent("mouse_click")
  135. if event == "mouse_click" then
  136. if x >= 1 and x <= 8 then
  137. term.setBackgroundColor(colors.white)
  138. term.clear()
  139. paintutils.drawLine(1, 1, screenX, 1, colors.blue)
  140. term.setTextColor(colors.black)
  141. term.setBackgroundColor(colors.white)
  142. if y == 2 then -- run
  143. term.setCursorPos(1, 3)
  144. print("Run")
  145. cmd = read()
  146. shell.run(cmd)
  147.  
  148. elseif y == 3 then
  149. term.setCursorPos(1, 4)
  150. print("Shell")
  151.  
  152.  term.setBackgroundColor(colors.black)
  153.  term.clear()
  154.  term.setTextColor(colors.white)
  155.  term.setCursorPos(1, 1)
  156.  print("Gliese OS Beta 2")
  157.  print("Type help for help.")
  158. while true do
  159.  write(">")
  160.  sr = read()
  161.  if sr == "exit" then
  162.  break
  163.  elseif sr == "help" then
  164.  print("Help -- Print this help list.")
  165.  print("Exit -- exit the shell.")
  166.  print("clrs -- Clears the screen")
  167.  print("edit -- edits a file..")
  168.  print("cd -- changes the directory/folder")
  169.  print("mkdir -- makes a directory/folder")
  170.  print("delete -- deletes a file or a folder/directory")
  171.  print("cp -- Copies a file or folder")
  172.  print("move -- moves a folder.")
  173.  elseif sr == "clrs" then
  174.  term.clear()
  175.  term.setCursorPos(1, 1)
  176.  print("Gliese OS Dev2")
  177.  print("Type help for help.")
  178.  else
  179.  shell.run(sr)
  180. end
  181. end
  182.  
  183. elseif y == 4 then
  184. term.setCursorPos(1, 6)
  185. print("Shutdown")
  186. while true do
  187. term.setBackgroundColor(colors.black)
  188. term.setTextColor(colors.white)
  189. term.setCursorPos(1, 1)
  190. print("Shutting Down the computer..")
  191. os.sleep(2)
  192. os.shutdown()
  193. end
  194.  
  195. elseif y == 5 then
  196. term.setCursorPos(1, 7)
  197. print("Restart")
  198. os.reboot()
  199.  
  200. elseif y == 6 then
  201. term.setTextColor(colors.black)
  202. term.setCursorPos(4, 3)
  203. print("Coming Soon!")
  204. drawCloseMenu()
  205.  
  206. elseif y == 7 then
  207. term.setTextColor(colors.black)
  208. drawMenu()
  209. end
  210. end
  211. end
  212. end
  213. end
  214. end
  215. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement