Advertisement
ndfjay

GUI part 1

Jan 1st, 2013
9,449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. --Desktop
  2.  
  3. slc = 0
  4. tBarC = 8
  5. tBartC = 1
  6. backColor = 1
  7. term.setBackgroundColor(backColor)
  8. term.clear()
  9. function titleBar()
  10.   term.setCursorPos(1,1)
  11.   term.setBackgroundColor(tBarC)
  12.   term.setTextColor(tBartC)
  13.   term.clearLine()
  14.   term.setCursorPos(3, 1)
  15.   print("[Begin]")
  16. end
  17. function drawDesktop()
  18.   term.setBackgroundColor(backColor)
  19.   term.clear()
  20.   bground = paintutils.loadImage(".background")
  21.   paintutils.drawImage(bground,1,1)
  22.   titleBar()
  23.  
  24. end
  25.  
  26. function drawMenu1()
  27. term.setTextColor(256)
  28. term.setBackgroundColor(128)
  29. term.setCursorPos(1,2)
  30. print("          ")
  31. term.setCursorPos(1,3)
  32. print(" Shutdown ")
  33. term.setCursorPos(1,4)
  34. print(" Restart  ")
  35. term.setCursorPos(1,5)
  36. print("          ")
  37.  
  38. end
  39.  
  40. drawDesktop()
  41. while true do
  42. local event, button, X, Y = os.pullEventRaw()
  43.   if slc == 0 then
  44.     if event == "mouse_click" then
  45.       if X >=2 and X <=8 and Y==1 and button ==1 then
  46.       drawMenu1()
  47.       slc = 1
  48.         else
  49.         drawDesktop()
  50.       end
  51.     end
  52.    elseif slc == 1 then
  53.      if X >=1 and X <=11 and button == 1 and Y== 3 then slc = 0
  54.        os.shutdown()
  55.        elseif X>=1 and X<=11 and Y==4 and button ==1 then slc = 0
  56.        os.reboot()
  57.        else
  58.        slc = 0
  59.        drawDesktop()
  60.      
  61.      end
  62.   end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement