Legebatterie

Apps--disk

Feb 7th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. os.loadAPI("maxintosh/mAPI")
  2.  
  3. side="right"
  4. files={}
  5. yToF={}
  6.  
  7.  
  8. --------------UNWRAP--------------
  9. unwrap=function(cPath)
  10.  
  11. mAPI.drawWindow(5,4,colWind)
  12. term.setBackgroundColor(colors[colWind])
  13. term.setTextColor(colors[colText])
  14. content={}
  15. yToC={}
  16. content=fs.list(cPath)
  17. max=table.maxn(content)
  18.  
  19. for i=1,max do
  20. term.setCursorPos(7,4+(i))
  21. if fs.isDir(cPath.."/"..content[i]) then term.setBackgroundColor(colors[col]) end
  22. write(content[i])
  23. term.setBackgroundColor(colors[colWind])
  24. yToF[4+(i)]=content[i]
  25. end
  26. while true do
  27. e,n,x,y=os.pullEvent("mouse_click")
  28.  
  29. if x==47 and y==4 then
  30. shell.run(shell.getRunningProgram())
  31. error()
  32. end
  33.  
  34. if x<35 and n==1 then
  35. yyy=y
  36. if not(fs.isDir(cPath.."/"..yToF[yyy])) then
  37. term.setBackgroundColor(colors.black)
  38. term.setTextColor(colors.white)
  39. term.clear()
  40. shell.run(path.."/"..yToF[y])
  41. shell.run("maxintosh/desktop")
  42. error()
  43. error()
  44. else
  45. unwrap(cPath.."/"..yToF[yyy])
  46. end
  47. end
  48.  
  49. if x<35 and n==2 then
  50. yyy=y
  51. mAPI.drawWindow(10,6)
  52. term.setTextColor(colors[colText])
  53. term.setBackgroundColor(colors[colWind])
  54. term.setCursorPos(12,8)
  55. write("delete")
  56. term.setCursorPos(12,10)
  57. write("copy to PC")
  58. term.setCursorPos(12,12)
  59. write("rename")
  60. while true do
  61. e,n,x,y=os.pullEvent("mouse_click")
  62. if y==6 then
  63. shell.run(shell.getRunningProgram())
  64. error()
  65. end
  66.  
  67. if y==8 then
  68. fs.delete(cPath.."/"..yToF[yyy])
  69. shell.run(shell.getRunningProgram())
  70. error()
  71. end
  72.  
  73. if y==10 then
  74. fs.copy(cPath.."/"..yToF[yyy],"maxintosh/"..currentUser.."/programs/"..yToF[yyy])
  75. end
  76.  
  77. if y==12 then
  78. term.setCursorPos(12,13)
  79. name=read()
  80. fs.copy(cPath.."/"..yToF[yyy],cPath.."/"..name)
  81. paintutils.drawBox(12,13,30,13,colors[colWind])
  82. fs.delete(cPath.."/"..yToF[yyy])
  83. end
  84. end
  85. end
  86.  
  87. end
  88. end
  89.  
  90.  
  91.  
  92.  
  93. ------------------------------FLOPPY--------------------------------------
  94.  
  95. mAPI.drawWindow(2,2,colWind)
  96. term.setTextColor(colors[colText])
  97. term.setBackgroundColor(colors[colWind])
  98.  
  99. if disk.hasData(side) then
  100. name=disk.getLabel(side)
  101. id=disk.getID(side)
  102. if not(name==nil) then l=string.len(name) else l=5 name="-no-"
  103. end
  104. path=disk.getMountPath(side)
  105. term.setCursorPos((49-(6+l)),3)
  106. write("disk: "..name)
  107. files=fs.list(path)
  108. max=table.maxn(files)
  109.  
  110. for i=1,max do
  111. term.setCursorPos(4,2+(2*i))
  112. if fs.isDir(path.."/"..files[i]) then term.setBackgroundColor(colors[col]) end
  113. write(files[i])
  114. term.setBackgroundColor(colors[colWind])
  115. yToF[2+(2*i)]=files[i]
  116. end
  117.  
  118. term.setCursorPos(39,7)
  119. write("eject disk")
  120. term.setCursorPos(37,9)
  121. write("copy from PC")
  122. term.setCursorPos(38,11)
  123. write("change Name")
  124.  
  125.  
  126. while true do
  127. event,n,x,y=os.pullEvent("mouse_click")
  128.  
  129. if x==50 and y==2 then error() end
  130.  
  131. if y==7 then disk.eject(side) error() end
  132.  
  133. if y==9 then
  134. term.setCursorPos(38,10)
  135. p=read()
  136. if fs.exists("maxintosh/"..currentUser.."/programs/"..p) then
  137. fs.copy("maxintosh/"..currentUser.."/programs/"..p, path.."/"..p)
  138.  
  139. else
  140. paintutils.drawBox(37,10,49,10,colors[colWind])
  141. term.setBackgroundColor(colors.red)
  142. term.setTextColor(colors.black)
  143. term.setCursorPos(37,10)
  144. write("not found")
  145. sleep(3)
  146. end
  147. shell.run(shell.getRunningProgram())
  148. error()
  149. paintutils.drawBox(37,10,49,10,colors[colWind])
  150. end
  151.  
  152. if y==11 then
  153. term.setCursorPos(38,12)
  154. p=read()
  155. disk.setLabel(side,p)
  156. paintutils.drawBox(36,12,49,12,colors[colWind])
  157. end
  158.  
  159.  
  160.  
  161. if x<35 and n==1 then
  162. yyy=y
  163. if not(fs.isDir(path.."/"..yToF[y])) then
  164. term.setBackgroundColor(colors.black)
  165. term.setTextColor(colors.white)
  166. term.clear()
  167. shell.run(path.."/"..yToF[y])
  168. shell.run("maxintosh/desktop")
  169. error()
  170. error()
  171. else
  172. cPath=fs.combine(path,yToF[y])
  173. unwrap(cPath)
  174. end
  175. end
  176.  
  177. if x<35 and n==2 then
  178. mAPI.drawWindow(10,6)
  179. term.setTextColor(colors[colText])
  180. term.setBackgroundColor(colors[colWind])
  181. term.setCursorPos(12,8)
  182. write("delete")
  183. term.setCursorPos(12,10)
  184. write("copy to PC")
  185. term.setCursorPos(12,12)
  186. write("rename")
  187. while true do
  188. e,n,x,y=os.pullEvent("mouse_click")
  189. if y==6 then
  190. shell.run(shell.getRunningProgram())
  191. error()
  192. end
  193.  
  194. if y==8 then
  195. fs.delete(path.."/"..yToF[yyy])
  196. shell.run(shell.getRunningProgram())
  197. error()
  198. end
  199.  
  200. if y==10 then
  201. fs.copy(path.."/"..yToF[yyy],"maxintosh/"..currentUser.."/programs/"..yToF[yyy])
  202. end
  203.  
  204. if y==12 then
  205. term.setCursorPos(12,13)
  206. name=read()
  207. fs.copy(path.."/"..yToF[yyy],path.."/"..name)
  208. paintutils.drawBox(12,13,30,13,colors[colWind])
  209. fs.delete(path.."/"..yToF[yyy])
  210. end
  211. end
  212. end
  213. end
  214.  
  215.  
  216. ---------------------------------AUDIO-----------------------------------------------
  217. elseif disk.hasAudio(side) then
  218. title=disk.getAudioTitle(side)
  219. l=string.len(title)
  220. term.setCursorPos((41-l),4)
  221. write("title: "..title)
  222. term.setCursorPos(24,8)
  223. write("play")
  224. term.setCursorPos(24,10)
  225. write("stop")
  226. term.setCursorPos(21,13)
  227. write("eject disk")
  228.  
  229. while true do
  230. event,n,x,y=os.pullEvent("mouse_click")
  231.  
  232. if x==50 and y==2 then error() end
  233.  
  234. if y==13 then disk.eject(side) error() end
  235.  
  236. if y==8 then disk.playAudio(side) end
  237.  
  238. if y==10 then disk.stopAudio(side) end
  239.  
  240.  
  241. end
  242.  
  243. else
  244.  
  245. ------------------------NO_DISK-----------------------------------------
  246. term.setBackgroundColor(colors.red)
  247. term.setTextColor(colors.black)
  248. term.setCursorPos(22,8)
  249. write("no disk")
  250. term.setBackgroundColor(colors.green)
  251. term.setCursorPos(21,10)
  252. write(" refresh! ")
  253.  
  254. while true do
  255. event,n,x,y=os.pullEvent("mouse_click")
  256. if x==50 and y==2 then error() end
  257.  
  258. if y==10 then
  259. p=shell.getRunningProgram()
  260. shell.run(p)
  261. error()
  262. end
  263. end
  264. end
Add Comment
Please, Sign In to add comment