Guest User

gui

a guest
Jun 23rd, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.93 KB | None | 0 0
  1. --Desktop
  2. os.loadAPI("fLib")
  3.  
  4. slc = 0
  5. tBarC = 8 --Background color
  6. tBartC = 1 --Text color
  7. backColor = 1
  8. term.setBackgroundColor(backColor)
  9. term.clear()
  10. contextX = 0
  11. contextY = 0
  12. iCon1T="Test"
  13. iCon1="icon1"
  14. iConL1="Licon1"
  15. --name
  16. --image
  17. --program
  18.  
  19. function time()
  20. term.setCursorPos(25,1)
  21. local t = os.time()
  22. print("Time: "..textutils.formatTime(t,false))
  23. sleep(1)
  24. end
  25.  
  26. function titleBar()
  27.   term.setCursorPos(1,1)
  28.   term.setBackgroundColor(tBarC)
  29.   term.setTextColor(tBartC)
  30.   term.clearLine()
  31.   term.setCursorPos(3, 1)
  32.   print("[Begin]")
  33. end
  34. function drawDesktop()
  35.   term.setBackgroundColor(backColor)
  36.   term.clear()
  37.   bground = paintutils.loadImage(".background")
  38.   paintutils.drawImage(bground,1,1) --Move to Config
  39.   icon1 = paintutils.loadImage(iCon1)
  40.   paintutils.drawImage(icon1, 2, 3)
  41.   term.setBackgroundColor(backColor)
  42.   term.setCursorPos(1,7)
  43.   term.setTextColor(colors.red)
  44.   print("+")
  45.   term.setTextColor(128)
  46.   term.setCursorPos(2,8)
  47.   print(iCon1T)
  48.   titleBar()
  49.  
  50. end
  51.  
  52. function drawMenu1()
  53. term.setTextColor(256)
  54. term.setBackgroundColor(128)
  55. term.setCursorPos(1,2)
  56. print("          ")
  57. term.setCursorPos(1,3)
  58. print(" Shutdown ")
  59. term.setCursorPos(1,4)
  60. print(" Restart  ")
  61. term.setCursorPos(1,5)
  62. print("          ")
  63. end
  64.  
  65. function drawMenu2() --
  66. term.setBackgroundColor(128)
  67. term.setTextColor(256)
  68. term.setCursorPos(contextX, contextY)
  69. print("             ")
  70. term.setCursorPos(contextX, contextY + 1)
  71. print(" edit GUI    ")
  72. term.setCursorPos(contextX, contextY+2)
  73. print(" FileManager ")
  74. term.setCursorPos(contextX, contextY+3)
  75. print("             ")
  76. end
  77.  
  78. function drawMenu3(iX, iY)
  79. term.setBackgroundColor(128)
  80. term.setTextColor(256)
  81. term.setCursorPos(iX, iY)
  82. print("          ")
  83. term.setCursorPos(iX, iY+1)
  84. print(" Rename   ")
  85. term.setCursorPos(iX, iY+2)
  86. print(" Ch-Icon  ")
  87. term.setCursorPos(iX, iY+3)
  88. print(" Re-Link  ")
  89. term.setCursorPos(iX, iY+4)
  90. print("          ")
  91. end
  92.  
  93.  
  94. drawDesktop()
  95. while true do
  96. local event, button, X, Y = os.pullEventRaw()
  97.   if slc == 0 then
  98.     if event == "mouse_click" then
  99.       if X >=2 and X <=8 and Y==1 and button == 1 then
  100.       drawMenu1()
  101.       slc = 1
  102.       elseif X >=2 and X <=5 and Y>=3 and Y<=9 and button == 1 then
  103.       shell.run(iConL1) --1st icon that can be ran
  104.        elseif X >= 1 and Y >= 2 and button == 2 then slc = 2
  105.           if X >= 38 and Y >= 14 then
  106.           contextX = 38
  107.           end
  108.           if Y >=14 then
  109.           contextY = 14
  110.           end
  111.           if X <= 38 then
  112.           contextX = X
  113.           end
  114.           if Y <= 14 then
  115.           contextY = Y
  116.           end
  117.           drawMenu2()
  118.             elseif X ==1 and Y ==7 and button ==1 then slc = 3
  119.             drawMenu3(1,9)
  120.       else
  121.       drawDesktop()
  122.      end
  123.    end
  124.   elseif slc == 1 then
  125.     if X >=1 and X <=11 and button == 1 and Y== 3 then slc = 1
  126.       os.shutdown()
  127.       elseif X>=1 and X<=11 and Y==4 and button == 1 then slc = 0
  128.       os.reboot()
  129.       else
  130.       slc = 0
  131.       drawDesktop()
  132.      end
  133.   elseif slc == 2 then
  134.         if X >= contextX and X <= contextX+13 and Y==contextY+1 and button == 1 then slc = 0
  135.         shell.run("edit","gui")
  136.         drawDesktop()
  137.           elseif X>= contextX and X <=contextX+13 and Y==contextY+2 and button == 1 then slc = 0
  138.             shell.run(iConL1)
  139.             drawDesktop()
  140.               else slc = 0
  141.               drawDesktop()
  142.         end
  143.   elseif slc == 3 then
  144.     if X >=1 and X <=10 and Y == 10 and button ==1 then
  145.     term.setTextColor(256)
  146.     term.setBackgroundColor(backColor)
  147.     term.setCursorPos(2,8)
  148.     print("        ")
  149.     term.setCursorPos(2,8)
  150.     input = read()
  151.     fLib.replaceLine("gui",12,'iCon1T="'..tostring(input)..'"')
  152.     return
  153.     shell.run("gui")
  154.       elseif X >= 1 and X <= 10 and Y == 11 and button == 1 then
  155.       term.setBackgroundColor(128)
  156.       lY = 8
  157.         for i = 1,3 do
  158.           term.setCursorPos(18, lY)
  159.           print("                    ")
  160.           lY = lY+1
  161.         end
  162.         term.setBackgroundColor(256)
  163.         term.setTextColor(1)
  164.         term.setCursorPos(19, 9)
  165.         print("                  ")
  166.         term.setCursorPos(20,9)
  167.         input = read()
  168.         fLib.replaceLine("gui",13,'iCon1="'..tostring(input)..'"')
  169.         return
  170.         shell.run("gui")
  171.        elseif X >=1 and X <= 10 and Y==12 and button == 1 then
  172.        term.setBackgroundColor(128)
  173.        lY = 8
  174.          for i =1,3 do
  175.            term.setCursorPos(18,lY)
  176.            print("                    ")
  177.            lY = lY+1
  178.          end
  179.          term.setBackgroundColor(256)
  180.          term.setCursorPos(19,9)
  181.          print("                  ")
  182.          term.setCursorPos(20,9)
  183.          term.setTextColor(1)
  184.          input = read()
  185.          fLib.replaceLine("gui",14,'iConL1="'..tostring(input)..'"')
  186.          return
  187.          shell.run("gui")
  188.        else
  189.        slc = 0
  190.        drawDesktop()
  191.      end
  192.   end
  193. end
Advertisement
Add Comment
Please, Sign In to add comment