Advertisement
Guest User

desktop

a guest
Apr 28th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. local w,h = term.getSize()
  2.  
  3. slc = 0
  4. tBarC = 8
  5. tBartC = colors.white
  6. backColor = 1
  7. isBuild = false
  8. term.setBackgroundColor(backColor)
  9. term.clear()
  10.  
  11. function time()
  12. local time = os.time()
  13. local fTime = textutils.formatTime(time, false)
  14. term.setCursorPos(w - 7, h)
  15. term.setBackgroundColor(tBarC)
  16. term.setTextColor(tBartC)
  17. write(fTime)
  18. end
  19.  
  20. function titleBar()
  21. term.setCursorPos(1,h)
  22. term.setBackgroundColor(tBarC)
  23. term.setTextColor(tBartC)
  24. term.clearLine()
  25. term.setTextColor(tBartC)
  26. term.setCursorPos(1, h)
  27. write(" Menu ")
  28. term.setCursorPos(w - 5, h)
  29. end
  30.  
  31. function titleBarMenuClick()
  32. term.setCursorPos(1,h)
  33. term.setBackgroundColor(tBarC)
  34. term.setTextColor(tBartC)
  35. term.clearLine()
  36. term.setBackgroundColor(colors.gray)
  37. term.setCursorPos(1, h)
  38. write(" Menu ")
  39. end
  40.  
  41. function drawDesktop()
  42. term.setBackgroundColor(backColor)
  43. term.clear()
  44. bground = paintutils.loadImage("m-os/images/bground")
  45. paintutils.drawImage(bground,w/2-51/2,h/2-19/2)
  46. titleBar()
  47. if isBuild == true then
  48. term.setBackgroundColor(colors.white)
  49. term.setTextColor(colors.lightGray)
  50. term.setCursorPos(w-27,h-2)
  51. print("M-OS 1.1.1 Deveolper Preview")
  52. term.setCursorPos(w-27,h-1)
  53. print("build-4, build date: 4/27/17")
  54. end
  55. end
  56.  
  57. function drawMenu1()
  58. term.setTextColor(tBartC)
  59. term.setBackgroundColor(tBarC)
  60. term.setCursorPos(1,h - 9)
  61. print(" ")
  62. term.setCursorPos(1,h - 8)
  63. print(" Settings ")
  64. term.setCursorPos(1,h - 7)
  65. print(" Programs ")
  66. term.setCursorPos(1,h - 6)
  67. print(" ")
  68. term.setCursorPos(1,h - 5)
  69. print(" Logoff ")
  70. term.setCursorPos(1,h - 4)
  71. print(" ")
  72. term.setCursorPos(1, h - 3)
  73. print(" Shutdown ")
  74. term.setCursorPos(1, h - 2)
  75. print(" Restart ")
  76. term.setCursorPos(1, h - 1)
  77. print(" ")
  78. end
  79.  
  80.  
  81.  
  82. drawDesktop()
  83.  
  84.  
  85. while true do
  86. local event, button, X, Y = os.pullEvent()
  87. if event == "mouse_click" then
  88. if X >=2 and X <=6 and Y==h and button ==1 and slc == 0 then
  89. drawMenu1()
  90. titleBarMenuClick()
  91. slc = 1
  92. sleep(0.2)
  93. canClick = true
  94. elseif X>=1 and X<=6 and Y==h and button == 1 and slc == 1 and canClick == true then
  95. drawDesktop()
  96. slc = 0
  97. elseif X>=1 and X<=11 and Y==h - 7 and slc == 1 and button == 1 then
  98. shell.run("m-os/programs/installed_programs")
  99. elseif X>=1 and X<=11 and Y==h-8 and slc == 1 and button == 1 then
  100. shell.run("m-os/settings")
  101. elseif X>=1 and X<=11 and Y==h-5 and slc == 1 and button == 1 then
  102. shell.run("m-os/logon")
  103. elseif X>=1 and X<=11 and Y==h - 2 and slc == 1 and button == 1 then
  104. os.reboot()
  105. elseif X>=1 and X<=11 and Y==h - 3 and slc == 1 and button == 1 then
  106. os.shutdown()
  107. end
  108. end
  109. end
  110.  
  111. local w,h = term.getSize()
  112.  
  113. local ok, err = pcall(main)
  114. if not ok then
  115. term.setBackgroundColor(colors.red)
  116. term.clear()
  117. term.setBackgroundColor(colors.gray)
  118. term.setCursorPos(1,1)
  119. term.clearLine()
  120. term.setTextColor(colors.white)
  121. print("Internal System Error")
  122. term.setBackgroundColor(colors.red)
  123. print("The following error has occured: " .. err)
  124. print("Please report this error to MarcoPolo0306. (=")
  125. print("(Your computer will restart in 15 seconds.)")
  126. sleep(15)
  127. os.reboot()
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement