Legebatterie

maxintosh2--desktop

Dec 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.29 KB | None | 0 0
  1. --Variables
  2. os.loadAPI("maxintosh/mAPI")
  3.  
  4. --Desgin
  5. file=fs.open("maxintosh/"..currentUser.."/color","r")
  6. col=file.readLine()
  7. colWind=file.readLine()
  8. colText=file.readLine()
  9. file.close()
  10.  
  11. term.setBackgroundColor(colors[col])
  12. term.clear()
  13. p=paintutils.loadImage("maxintosh/"..currentUser.."/desktopBackground")
  14. paintutils.drawImage(p,2,1)
  15.  
  16. term.setCursorPos(7,1)
  17. term.setTextColor(colors.orange)
  18. write(" Apps ")
  19.  
  20. term.setCursorPos(44,1)
  21. term.setBackgroundColor(colors.white)
  22. term.setTextColor(colors[colText])
  23. term.write("Settings")
  24. paintutils.drawBox(18,1,18,20,colors[colWind])
  25.  
  26. term.setCursorPos(51,19)
  27. term.setBackgroundColor(colors[colWind])
  28. term.setTextColor(colors[colText])
  29. write("M")
  30.  
  31. --Loading Apps
  32.  
  33. for x=1,18 do
  34. for y=2,20 do
  35. if fs.exists("maxintosh/"..currentUser.."/apps/"..x..","..y) then
  36. file=fs.open("maxintosh/"..currentUser.."/apps/"..x..","..y,"r")
  37. appProgram=file.readLine()
  38. appName=file.readLine()
  39. appColor=file.readLine()
  40. file.close()
  41. l=string.len(appName)
  42.  
  43. paintutils.drawPixel(x,y,colors[appColor])
  44. term.setTextColor(colors[appColor])
  45. term.setBackgroundColor(colors[col])
  46. term.setCursorPos((x-(math.floor(l/2))),y-1)
  47. write(appName)
  48. end
  49. end
  50. end
  51.  
  52.  
  53. --Click
  54. while true do
  55. event,n,x,y=os.pullEvent("mouse_click")
  56.  
  57. if x>43 and y==1 then
  58. shell.run("maxintosh/settings")
  59. error()
  60. end
  61.  
  62. if x==51 and y==19 then
  63. term.setBackgroundColor(colors[colWind])
  64. term.setTextColor(colors[colText])
  65. paintutils.drawFilledBox(44,16,51,19,colors[colWind])
  66. term.setBackgroundColor(colors.purple)
  67. term.setTextColor(colors.orange)
  68. term.setCursorPos(51,19)
  69. term.setBackgroundColor(colors[colWind])
  70. term.setTextColor(colors[colText])
  71. write("M")
  72. term.setCursorPos(44,16)
  73. write(" logout")
  74. term.setCursorPos(44,17)
  75. write(" reboot")
  76. term.setCursorPos(44,18)
  77. write("shutdown")
  78.  
  79. while true do
  80. event,n,x,y=os.pullEvent("mouse_click")
  81.  
  82. if x>43 and y==16 then
  83. shell.run("maxintosh/login")
  84. error()
  85. end
  86.  
  87. if x>43 and y==17 then
  88. os.reboot()
  89. end
  90.  
  91. if x>43 and y==18 then
  92. os.shutdown()
  93. end
  94.  
  95. if x==51 and y==19 then
  96. shell.run("maxintosh/desktop")
  97. error()
  98. end
  99.  
  100.  
  101.  
  102. end
  103. end
  104.  
  105.  
  106.  
  107. if n==1 and not(x>43 and y==1) and x<18 then
  108. if fs.exists("maxintosh/"..currentUser.."/apps/"..x..","..y) then
  109. file=fs.open("maxintosh/"..currentUser.."/apps/"..x..","..y,"r")
  110. program=file.readLine()
  111. file.close()
  112. term.setTextColor(colors.white)
  113. term.setBackgroundColor(colors.black)
  114. term.clear()
  115. shell.run("maxintosh/"..currentUser.."/programs/"..program)
  116. shell.run("maxintosh/desktop")
  117. error()
  118. end
  119. end
  120.  
  121.  
  122. if n==2 and not(x>43 and y==1) and x<18 then
  123. if fs.exists("maxintosh/"..currentUser.."/apps/"..x..","..y) then
  124. oldX=x
  125. oldY=y
  126. appX=x
  127. appY=y
  128.  
  129. mAPI.drawWindow(2,2,colWind)
  130.  
  131. term.setTextColor(colors[colText])
  132. term.setBackgroundColor(colors[colWind])
  133. term.setCursorPos(4,5)
  134. write("change Color:")
  135. term.setCursorPos(4,8)
  136. write("change Name:")
  137. term.setCursorPos(4,11)
  138. write("new X-coord:")
  139. term.setCursorPos(4,14)
  140. write("new Y-coord:")
  141. term.setCursorPos(17,16)
  142. write("remove Application")
  143. term.setCursorPos(15,3)
  144. term.setBackgroundColor(colors[colWind])
  145. file=fs.open("maxintosh/"..currentUser.."/apps/"..oldX..","..oldY,"r")
  146. appProgram=file.readLine()
  147. file.close()
  148. write("App: ")
  149. write(appProgram)
  150.  
  151. while true do
  152. event,n,x,y=os.pullEvent("mouse_click")
  153.  
  154. if x==50 and y==2 then
  155. fs.delete("maxintosh/"..currentUser.."/apps/"..oldX..","..oldY)
  156. file=fs.open("maxintosh/"..currentUser.."/apps/"..(appX+0)..","..(appY+0),"w")
  157. file.writeLine(appProgram)
  158. file.writeLine(appName)
  159. file.writeLine(appColor)
  160. file.writeLine(appX)
  161. file.writeLine(appY)
  162. file.close()
  163. shell.run("maxintosh/desktop")
  164. error()
  165. end
  166.  
  167. if y==16 then
  168. fs.delete("maxintosh/"..currentUser.."/apps/"..oldX..","..oldY)
  169. shell.run("maxintosh/desktop")
  170. error()
  171. end
  172.  
  173.  
  174. if y==3 or y==5 or y==8 or y==11 or y==14 then
  175. file=fs.open("maxintosh/"..currentUser.."/apps/"..oldX..","..oldY,"r")
  176. appProgram=file.readLine()
  177. appName=file.readLine()
  178. appColor=file.readLine()
  179. appX=file.readLine()
  180. appY=file.readLine()
  181. file.close()
  182.  
  183. if y==3 then
  184. paintutils.drawBox(29,3,47,3,colors[colWind])
  185. term.setCursorPos(29,3)
  186. appProgram=read()
  187. end
  188. if y==5 then
  189. paintutils.drawBox(18,5,47,5,colors[colWind])
  190. term.setCursorPos(18,5)
  191. appColor=read()
  192. end
  193.  
  194. if y==8 then
  195. paintutils.drawBox(17,8,47,8,colors[colWind])
  196. term.setCursorPos(17,8)
  197. appName=read()
  198. end
  199.  
  200. if y==11 then
  201. paintutils.drawBox(17,11,47,11,colors[colWind])
  202. term.setCursorPos(17,11)
  203. appX=read()
  204. end
  205.  
  206. if y==14 then
  207. paintutils.drawBox(17,14,47,14,colors[colWind])
  208. term.setCursorPos(17,14)
  209. appY=read()
  210. end
  211.  
  212. end
  213. end
  214.  
  215.  
  216.  
  217.  
  218. else
  219.  
  220. appX=tostring(x)
  221. appY=tostring(y)
  222.  
  223. mAPI.drawWindow(2,2,colWind)
  224.  
  225. term.setTextColor(colors[colText])
  226. term.setBackgroundColor(colors[colWind])
  227. term.setCursorPos(4,4)
  228. write("App-Color: ")
  229. term.setCursorPos(4,9)
  230. write("connected Program: ")
  231. term.setCursorPos(4,14)
  232. write("App-Name:")
  233. a=false
  234. b=false
  235. c=false
  236.  
  237. while true do
  238. event,n,x,y=os.pullEvent("mouse_click")
  239.  
  240. if x==50 and y==2 then
  241. if a==true and b==true and c==true then
  242. file=fs.open("maxintosh/"..currentUser.."/apps/"..appX..","..appY,"w")
  243. file.writeLine(appProgram)
  244. file.writeLine(appName)
  245. file.writeLine(appColor)
  246. file.writeLine(tonumber(appX))
  247. file.writeLine(tonumber(appY))
  248. file.close()
  249. shell.run("maxintosh/desktop")
  250. error()
  251. else
  252. shell.run("maxintosh/desktop")
  253. error()
  254. end
  255. end
  256.  
  257. if y==4 then
  258. paintutils.drawBox(15,4,47,4,colors[colWind])
  259. term.setCursorPos(15,4)
  260. appColor=read()
  261. a=true
  262. end
  263.  
  264. if y==9 then
  265. paintutils.drawBox(25,9,47,9,colors[colWind])
  266. term.setCursorPos(25,9)
  267. appProgram=read()
  268. b=true
  269. end
  270.  
  271. if y==14 then
  272. paintutils.drawBox(31,14,47,14,colors[colWind])
  273. term.setCursorPos(16,14)
  274. appName=read()
  275. c=true
  276. end
  277. end
  278.  
  279.  
  280. end
  281. end
  282.  
  283. end
Add Comment
Please, Sign In to add comment