Advertisement
MCFunRide

Codename MissingName

Oct 30th, 2015
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.60 KB | None | 0 0
  1. -- Codename Power
  2. -- Innovation starts here.
  3. -- All code in one file
  4. -- Hybrid OS
  5.  
  6. --[ INIT ]--
  7.  
  8. function center(y,str)
  9. local w,h = term.getSize()
  10. local x = term.getCursorPos()
  11. x = math.floor(math.max((w / 2) - (#str / 2)),0)
  12. term.setCursorPos(x,y)
  13. print(str)
  14. end
  15.  
  16. function centerSP(y,str)
  17. local w,h = term.getSize()
  18. local x = term.getCursorPos()
  19. x = math.floor(math.max((w / 2) - (#str / 2)),0)
  20. term.setCursorPos(x,y)
  21. textutils.slowPrint(str)
  22. end
  23.  
  24. function centerW(y,str)
  25. local w,h = term.getSize()
  26. local x = term.getCursorPos()
  27. x = math.floor(math.max((w / 2) - (#str / 2)),0)
  28. term.setCursorPos(x,y)
  29. term.write(str)
  30. end
  31.  
  32. function clearScr()
  33. term.clear()
  34. term.setCursorPos(1,1)
  35. end
  36.  
  37. function bg(c)
  38. term.setBackgroundColor(c)
  39. clearScr()
  40. end
  41.  
  42. function fadeIn()
  43. bg(colors.black)
  44. sleep(0.1)
  45. bg(colors.gray)
  46. sleep(0.1)
  47. bg(colors.lightGray)
  48. sleep(0.1)
  49. bg(colors.white)
  50. end
  51.  
  52. a = [[
  53. 49999
  54. 99999
  55. 99999
  56. 99999
  57. ddddd
  58. ]]
  59. f = fs.open("/.img","w")
  60. f.writeLine(a)
  61. f.close()
  62. f = nil
  63. img = paintutils.loadImage("/.img")
  64. f = fs.open("/.version","r")
  65. ver = f.readAll()
  66. f.close()
  67. f = nil
  68. function wip()
  69. bg(colors.red)
  70. term.setTextColor(colors.white)
  71. centerSP(10,"Work in progress!")
  72. centerSP(12,"Either not working, buggy or")
  73. centerSP(13,"not done yet!")
  74. center(15,"You can help contribute!")
  75. center(16,"Go to github.com/MCFunRide/Codename-Hybrid")
  76. center(17,"If you wish to fix bits of code!")
  77. sleep(3)
  78. desktop()
  79. end
  80. function bios()
  81. term.setBackgroundColor(colors.white)
  82. term.clear()
  83. term.setCursorPos(1,1)
  84. term.setBackgroundColor(colors.gray)
  85. term.clearLine()
  86. term.setTextColor(colors.white)
  87. center(1,"Codename Hybrid")
  88. term.setCursorPos(1,3)
  89. term.setBackgroundColor(colors.lightGray)
  90. term.clearLine()
  91. center(3,"Shell")
  92. term.setCursorPos(1,5)
  93. term.clearLine()
  94. center(5,"Shutdown")
  95. term.setCursorPos(1,7)
  96. term.clearLine()
  97. center(7,"Reboot")
  98.  
  99. while true do
  100. e = {os.pullEvent("mouse_click")}
  101. if e[4] == 3 then
  102. term.setBackgroundColor(colors.black)
  103. term.clear()
  104. term.setTextColor(colors.yellow)
  105. term.setCursorPos(1,1)
  106. print("Codename Hybrid RECOVERY Shell")
  107. return
  108. elseif e[4] == 5 then
  109. os.shutdown()
  110. elseif e[4] == 7 then
  111. os.reboot()
  112. end
  113. end
  114. end
  115. function shellProg()
  116. term.clear()
  117. term.setCursorPos(1,1)
  118. function os.version()
  119. return "Codename Hybrid Shell 1.0"
  120. end
  121. shell.run("multishell")
  122. end
  123. function fileMan()
  124. m = 0
  125. local w,h = term.getSize()
  126. curDir = "/"
  127. function drawMenu(filename)
  128. m = 1
  129. term.setCursorPos(25,3)
  130. term.setBackgroundColor(colors.orange)
  131. print(" "..filename.." ")
  132. term.setCursorPos(25,4)
  133. print(" Delete ")
  134. term.setCursorPos(25,5)
  135. print(" Rename ")
  136. term.setCursorPos(25,6)
  137. print(" Edit ")
  138. end
  139.  
  140. function drawDir()
  141. l = fs.list(curDir)
  142. bg(colors.white)
  143. paintutils.drawLine(1,1,w,1,colors.gray)
  144. term.setCursorPos(1,1)
  145. term.setTextColor(colors.white)
  146. print("File Manager")
  147. term.setBackgroundColor(colors.white)
  148. if m == 1 then
  149. drawMenu(l[y2])
  150. end
  151. for i,v in pairs(l) do
  152. if fs.isDir(v) then
  153. term.setTextColor(colors.green)
  154. print(v)
  155. term.setTextColor(colors.black)
  156. elseif v == ".img" then
  157. elseif v == ".version" then
  158. else
  159. term.setTextColor(colors.black)
  160. print(v)
  161. end
  162. end
  163. end
  164. drawDir()
  165. m = 0
  166. function code()
  167. while true do
  168. e2,b2,x2,y2 = os.pullEvent("mouse_click")
  169. if l[y2] then
  170. term.setCursorPos(1,10)
  171. print("Event grabbed. File exists in table")
  172. if fs.exists(l[y2]) then
  173. print("File exists")
  174. print("Pos works")
  175. if fs.isDir(l[y2]) then
  176. print("Dir")
  177. curDir = "/"..l[y2]
  178. drawDir()
  179. else
  180. print("File")
  181. drawMenu(l[y2])
  182. end
  183. end
  184.  
  185. elseif x == 51 and y == 1 then
  186. desktop()
  187. elseif x >= 25 and x <= 37 and y == 4 and m == 1 then
  188. if curDir == "/" then
  189. fs.delete(l[y2])
  190. else
  191. fs.delete(curDir.."/"..l[y2])
  192. end
  193. elseif x >= 25 and x <= 37 and y == 5 and m == 1 then
  194. term.setCursorPos(25,7)
  195. write("New Name: ")
  196. new = read()
  197. if curDir == "/" then
  198. fs.rename(l[y2],new)
  199. else
  200. fs.rename(curDir.."/"..l[y2])
  201. end
  202. elseif x >= 25 and x <= 37 and y == 5 and m == 1 then
  203. if curDir == "/" then
  204. shell.run("edit "..l[y2])
  205. else
  206. shell.run("edit "..curDir.."/"..l[y2])
  207. end
  208. end
  209. end
  210. end
  211. code()
  212. end
  213.  
  214. function about()
  215. term.setBackgroundColor(colors.white)
  216. term.clear()
  217. term.setTextColor(colors.black)
  218. center(3,"Codename Hybrid - All in one OS")
  219. center(5,"All coded by CathrodeRayTube.")
  220. center(6,"Desktop UI designed by Gonow32")
  221. term.setTextColor(colors.blue)
  222. center(8,"Coded by hand. Phoenix Approved")
  223. term.setTextColor(colors.green)
  224. center(10,"Thanks for using Codename Hybrid!")
  225. center(12,"Click anywhere on-screen to go back")
  226. os.pullEvent("mouse_click")
  227. desktop()
  228. end
  229.  
  230.  
  231.  
  232. function desktop()
  233. local w,h = term.getSize()
  234. function drawDesk()
  235. bg(colors.white)
  236. local w,h = term.getSize()
  237. paintutils.drawLine(1,h,w,h,colors.gray)
  238. paintutils.drawLine(1,h,5,19,colors.green)
  239. term.setCursorPos(1,h)
  240. term.setTextColor(colors.white)
  241. write("Start")
  242. term.setCursorPos(w-8,19)
  243. term.setBackgroundColor(colors.gray)
  244. write(textutils.formatTime(os.time(),false))
  245. if menu == 1 then
  246. pList()
  247. end
  248. end
  249. function pList()
  250. term.setCursorPos(1,h-1)
  251. print(" ")
  252. term.setCursorPos(1,h-2)
  253. print(" Shutdown ")
  254. term.setCursorPos(1,h-3)
  255. print(" ")
  256. term.setCursorPos(1,h-4)
  257. print(" File Man ")
  258. term.setCursorPos(1,h-5)
  259. print(" ")
  260. term.setCursorPos(1,h-6)
  261. print(" Shell ")
  262. term.setCursorPos(1,h-7)
  263. print(" ")
  264. term.setCursorPos(1,h-8)
  265. print(" About ")
  266. term.setCursorPos(1,h-9)
  267. print(" ")
  268. end
  269. menu = 0
  270. a = false
  271. drawDesk()
  272. repeat
  273. t = os.startTimer(1)
  274. e,b,x,y = os.pullEvent()
  275. if e == "mouse_click" then
  276. if x >= 1 and x <= 11 and y == h-2 and menu == 1 then
  277. os.shutdown()
  278. elseif x >= 1 and x <= 6 and y == 19 and menu == 0 then
  279. menu = 1
  280. drawDesk()
  281. elseif x >= 1 and x <= 6 and y == 19 and menu == 1 then
  282. menu = 0
  283. drawDesk()
  284. elseif x >= 1 and x <= 11 and y == h-4 and menu == 1 then
  285. wip()
  286. a = true
  287. elseif x >= 1 and x <= 11 and y == h-6 and menu == 1 then
  288. shellProg()
  289. a = true
  290. elseif x >= 1 and x <= 11 and y == h-8 and menu == 1 then
  291. about()
  292. a = true
  293. end
  294. elseif e == "timer" and b == t then
  295. drawDesk()
  296. end
  297. until a
  298. end
  299.  
  300. --[ Beginning ]--
  301.  
  302. fadeIn()
  303. paintutils.drawImage(img,23,5)
  304. term.setBackgroundColor(colors.white)
  305. term.setTextColor(colors.gray)
  306. center(11,"Codename Hybrid")
  307. center(12,"All in one.")
  308.  
  309. term.setTextColor(colors.blue)
  310. centerW(19,"Press ALT for system setup.")
  311. local t = os.startTimer(3)
  312. b = false
  313. repeat
  314. e = {os.pullEvent()}
  315. if e[1] == "timer" and e[2] == t then
  316. b = true
  317. desktop()
  318. elseif e[1] == "key" and e[2] == 56 then
  319. b = true
  320. bios()
  321. end
  322. until b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement