Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. --desktop
  2. slc = 0
  3. tBarC = 128
  4. tBaTC = 1
  5. backColor = 8
  6. term.setBackgroundColor(backColor)
  7. term.clear()
  8.  
  9. function titleBar()
  10. term.setCursorPos(1,1)
  11. term.setBackgroundColor(tBarC)
  12. term.setTextColor(tBaTC)
  13. term.clearLine()
  14. term.setCursorPos(2,1)
  15. print("[System]")
  16. term.setCursorPos(11,1)
  17. print("[Programs]")
  18. end
  19.  
  20. function drawDesktop()
  21. term.setBackgroundColor(backColor)
  22. term.clear()
  23. bground = paintutils.loadImage(".background")
  24. if bground == nil then
  25. paintutils.drawPixel(15,10,16384)
  26. paintutils.drawPixel(16,10,16384)
  27. paintutils.drawPixel(17,10,16384)
  28. paintutils.drawPixel(15,11,16384)
  29. paintutils.drawPixel(15,12,16384)
  30. paintutils.drawPixel(15,13,16384)
  31. paintutils.drawPixel(15,14,16384)
  32. paintutils.drawPixel(16,14,16384)
  33. paintutils.drawPixel(17,14,16384)
  34. paintutils.drawPixel(18,14,16384)
  35. paintutils.drawPixel(19,14,16384)
  36. paintutils.drawPixel(19,13,16384)
  37.  
  38. paintutils.drawPixel(22,10,512)
  39. paintutils.drawPixel(22,12,512)
  40. paintutils.drawPixel(22,11,512)
  41. paintutils.drawPixel(22,13,512)
  42. paintutils.drawPixel(22,14,512)
  43. paintutils.drawPixel(23,10,512)
  44. paintutils.drawPixel(24,10,512)
  45. paintutils.drawPixel(25,10,512)
  46. paintutils.drawPixel(23,14,512)
  47. paintutils.drawPixel(24,14,512)
  48. paintutils.drawPixel(25,14,512)
  49.  
  50. paintutils.drawPixel(28,10,2)
  51. paintutils.drawPixel(28,11,2)
  52. paintutils.drawPixel(28,12,2)
  53. paintutils.drawPixel(28,13,2)
  54. paintutils.drawPixel(28,14,2)
  55. paintutils.drawPixel(29,10,2)
  56. paintutils.drawPixel(30,10,2)
  57. paintutils.drawPixel(30,11,2)
  58. paintutils.drawPixel(30,12,2)
  59. paintutils.drawPixel(30,13,2)
  60. paintutils.drawPixel(30,14,2)
  61. paintutils.drawPixel(29,14,2)
  62. paintutils.drawPixel(28,14,2)
  63.  
  64. paintutils.drawPixel(33,10,2)
  65. paintutils.drawPixel(33,11,2)
  66. paintutils.drawPixel(34,10,2)
  67. paintutils.drawPixel(34,12,2)
  68. paintutils.drawPixel(34,13,2)
  69. paintutils.drawPixel(33,14,2)
  70. paintutils.drawPixel(34,14,2)
  71. else
  72. paintutils.drawImage(bground,2,2)
  73. end
  74. titleBar()
  75. end
  76.  
  77. function drawMenu1()
  78. term.setTextColor(256)
  79. term.setBackgroundColor(128)
  80. term.setCursorPos(1,2)
  81. print(" ")
  82. term.setCursorPos(1,3)
  83. print(" Shutdown ")
  84. term.setCursorPos(1,4)
  85. print(" Restart ")
  86. term.setCursorPos(1,5)
  87. print(" ")
  88. end
  89.  
  90. function drawMenu2()
  91. term.setTextColor(256)
  92. term.setBackgroundColor(128)
  93. term.setCursorPos(11,2)
  94. print(" ")
  95. term.setCursorPos(11,3)
  96. print(" Paint ")
  97. term.setCursorPos(11,4)
  98. print(" ")
  99. end
  100.  
  101. function drawPaintMenu()
  102. term.setTextColor(256)
  103. term.setBackgroundColor(128)
  104. term.setCursorPos(10,10)
  105. print(" ")
  106. term.setCursorPos(10,11)
  107. print("File Name: ")
  108. term.setCursorPos(10,12)
  109. print(" ")
  110. end
  111.  
  112. drawDesktop()
  113. while true do
  114. local event, button, X, Y = os.pullEventRaw()
  115.  
  116. if slc == 0 then
  117. if event == "mouse_click" then
  118. if X >=1 and X <=10 and Y == 1 and button == 1 then --Clicking the System
  119. drawMenu1()
  120. slc = 1
  121. elseif X >=11 and X <=20 and Y == 1 and button == 1 then --Clicking on Programs
  122. drawMenu2()
  123. slc = 2
  124. else
  125. drawDesktop()
  126. end
  127. end
  128. elseif slc == 1 then
  129. if X >=1 and X<=11 and button == 1 and Y == 3 then slc = 0
  130. os.shutdown()
  131. elseif X>=1 and X<=11 and Y==4 and button == 1 then slc = 0
  132. os.reboot()
  133. else
  134. slc = 0
  135. drawDesktop()
  136. end
  137.  
  138. elseif slc == 2 then
  139. if X >=11 and X<=15 and button == 1 and Y == 3 then slc = 0
  140. drawPaintMenu()
  141. slc = 3
  142. else
  143. slc = 0
  144. drawDesktop()
  145. end
  146. elseif slc == 3 then
  147. term.setCursorPos(10,11)
  148. term.setTextColor(2)
  149. local input = read("")
  150. if input ~= nil
  151. shell.paint(input)
  152. end
  153. end
  154. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement