Advertisement
Guest User

programs

a guest
Apr 26th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. slc = 0
  2.  
  3. local w,h = term.getSize()
  4.  
  5. function printCentered(msg, height)
  6. term.setCursorPos(w/2 - #msg/2, height)
  7. term.write(msg)
  8. end
  9.  
  10. function time()
  11. local time = os.time()
  12. local fTime = textutils.formatTime(time, false)
  13. term.setCursorPos(w - 7, h)
  14. term.setBackgroundColor(tBarC)
  15. term.setTextColor(tBartC)
  16. write(fTime)
  17. end
  18.  
  19. function titleBar()
  20. term.setCursorPos(1,h)
  21. term.setBackgroundColor(tBarC)
  22. term.setTextColor(tBartC)
  23. term.clearLine()
  24. term.setTextColor(tBartC)
  25. term.setCursorPos(1, h)
  26. write(" Menu ")
  27. end
  28.  
  29. function loadPrograms()
  30. --load shell icon
  31. local shellicon = paintutils.loadImage("m-os/images/icons/shell")
  32. paintutils.drawImage(shellicon, 2, 3)
  33. term.setBackgroundColor(colors.black)
  34. term.setTextColor(colors.yellow)
  35. term.setCursorPos(2,3)
  36. print("Shl")
  37. term.setCursorPos(2,4)
  38. print(">")
  39. term.setCursorPos(1,6)
  40. term.setBackgroundColor(colors.white)
  41. term.setTextColor(colors.gray)
  42. print("Shell")
  43. --load file browser icon
  44. local fileicon = paintutils.loadImage("m-os/images/icons/file")
  45. paintutils.drawImage(fileicon, 7, 3)
  46. term.setCursorPos(7,5)
  47. term.setTextColor(colors.white)
  48. print("FILE")
  49. term.setCursorPos(7,6)
  50. term.setBackgroundColor(colors.white)
  51. term.setTextColor(colors.gray)
  52. print("File")
  53. --load paint icon
  54. local painticon = paintutils.loadImage("m-os/images/icons/paint")
  55. paintutils.drawImage(painticon, 13,3)
  56. term.setCursorPos(12,6)
  57. term.setBackgroundColor(colors.white)
  58. term.setTextColor(colors.gray)
  59. print("Paint")
  60. end
  61.  
  62. function drawWindow()
  63. local tbarC = colors.lightBlue
  64. local tBartC = colors.white
  65. term.setBackgroundColor(colors.white)
  66. term.clear()
  67. term.setCursorPos(1,1)
  68. term.setBackgroundColor(tbarC)
  69. term.setTextColor(tBartC)
  70. term.clearLine()
  71. term.setCursorPos(2,1)
  72. write("Programs")
  73. term.setCursorPos(w,1)
  74. term.setBackgroundColor(colors.red)
  75. print("X")
  76. loadPrograms()
  77. term.setBackgroundColor(colors.white)
  78. term.setTextColor(colors.gray)
  79. end
  80.  
  81. function paintArgs()
  82. slc = 1
  83. drawWindow()
  84. local y1 = h/2-3
  85. local y2 = h/2+6
  86. paintutils.drawBox(w/2-10,h/2-3,w/2+10,h/2+4,colors.lightGray)
  87. paintutils.drawFilledBox(w/2-9,h/2-2,w/2+9,h/2+3,colors.white)
  88. paintutils.drawLine(w/2-10,h/2-3,w/2+10,h/2-3,colors.lightBlue)
  89. term.setTextColor(colors.white)
  90. term.setCursorPos(w/2-10, h/2-3)
  91. print("Open File")
  92. term.setTextColor(colors.gray)
  93. term.setCursorPos(w/2-9, h/2-2)
  94. term.setBackgroundColor(colors.white)
  95. print("Enter a image path.")
  96. term.setBackgroundColor(colors.gray)
  97. printCentered(" ",h/2-1)
  98. term.setBackgroundColor(colors.white)
  99. term.setCursorPos(w/2-9,h/2)
  100. print("Press enter 2 times")
  101. term.setCursorPos(w/2-9,h/2+1)
  102. print("to open.")
  103. term.setCursorPos(w/2-9,h/2+2)
  104. print("Press Q 2 times to")
  105. term.setCursorPos(w/2-9,h/2+3)
  106. print("close")
  107. end
  108.  
  109. drawWindow()
  110. titleBar()
  111.  
  112. while true do
  113. drawWindow()
  114. titleBar()
  115. local event, button, X, Y = os.pullEvent()
  116. if event == "mouse_click" then
  117. if X == w and Y==1 and button ==1 then
  118. term.clear()
  119. shell.run("m-os/desktop")
  120. elseif X>=1 and X<=5 and Y==6 and button == 1 then
  121. term.setBackgroundColor(colors.black)
  122. term.setTextColor(colors.yellow)
  123. term.setCursorPos(1,1)
  124. term.clear()
  125. print("To go back to M-OS, type 'exit'.")
  126. shell.run("shell")
  127. elseif X>=7 and X<=11 and Y==6 and button == 1 then
  128. term.clear()
  129. shell.run("m-os/programs/file_browser")
  130. elseif X>=12 and X<=17 and Y==6 and button == 1 then
  131. paintArgs()
  132. titleBar()
  133. term.setCursorPos(w/2-8,h/2-1)
  134. term.setBackgroundColor(colors.gray)
  135. term.setTextColor(colors.white)
  136. term.setCursorBlink(true)
  137. input = read()
  138. local event, key = os.pullEvent("key")
  139. if key == keys.enter and slc == 1 then
  140. shell.run("paint","pictures/"..input)
  141. end
  142. end
  143. end
  144. end
  145.  
  146. while true do
  147. local event, key = os.pullEvent("key")
  148. if key == keys.enter and slc == 1 then
  149. shell.run("paint","pictures/"..input)
  150. end
  151. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement