Advertisement
Good_Pudge

Drawer

Feb 12th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1. local gg = require("gpgui")
  2. --local gp = require("gpic")
  3. local gpu = require("component").gpu
  4. local bgold,fgold = gpu.getBackground(),gpu.getForeground()
  5. local w,h = gpu.getResolution()
  6.  
  7. require("term").clear()
  8. gpu.fill(1,h-3,w,1,"━")
  9.  
  10. local form = gg.newForm()
  11.  
  12. local tbg = gg.newTextbox()
  13. tbg:setSize(6,3)
  14. tbg:setPos(1,h-2)
  15.  
  16. local tfg = gg.newTextbox()
  17. tfg:setSize(6,3)
  18. tfg:setPos(8,h-2)
  19.  
  20. local resetColors = gg.newButton()
  21. resetColors:setPos(16,h-2)
  22. resetColors:setSize(9,3)
  23. resetColors:setValue("СБРОС")
  24. resetColors:setFunc(function()
  25.   gpu.setBackground(bgold)
  26.   gpu.setForeground(fgold)
  27. end)
  28.  
  29. local symb
  30. local own = gg.newOwn()
  31. own:addListener("drag")
  32. own:addListener("touch")
  33. own:setFunc(function(type,_,x,y,button,_)
  34.   if type == "drag" or type == "touch" then
  35.     if y < h-3 then
  36.       if button == 0 then
  37.         if tbg:getValue() ~= "" then
  38.           gpu.setBackground(tonumber("0x"..tbg:getValue()));
  39.         end
  40.         if tfg:getValue() ~= "" then
  41.           gpu.setForeground(tonumber("0x"..tfg:getValue()));
  42.         end
  43.         gpu.set(x,y,symb);
  44.       elseif button == 1 then
  45.         gpu.setBackground(bgold)
  46.         gpu.setForeground(fgold)
  47.         gpu.set(x,y," ");
  48.       end
  49.     end
  50.   end
  51. end)
  52.  
  53. local buttons = {}
  54. local chars = {"▓","▒","░","X","┏","┓","━","┗","┛","┃","┣","┫","┳","┻","╋"}
  55.  
  56. for i=1,#chars do
  57.   buttons["b"..i] = gg.newButton()
  58.   buttons["b"..i]:setPos(30+i*2,h-1)
  59.   buttons["b"..i]:setValue(chars[i])
  60.   buttons["b"..i]:setSize(1,1)
  61.   buttons["b"..i]:setFunc(function() symb = chars[i] end)
  62.   form:add(buttons["b"..i])
  63. end
  64.  
  65. local exit = gg.newButton()
  66. exit:setPos(w-5,h-2)
  67. exit:setSize(5,3)
  68. exit:setValue("ВЫЙТИ")
  69. exit:setFunc(function()
  70.   form:ignore()
  71.   own:ignore()
  72.   gpu.setBackground(bgold)
  73.   gpu.setForeground(fgold)
  74.   require("term").clear()
  75.   os.exit()
  76. end)
  77.  
  78. --[[local save = gg.newButton()
  79. save:setPos(w-12,h-2)
  80. save:setSize(4,3)
  81. save:setValue("SAVE")
  82. save:setFunc(function()
  83.   local pic = gp.new(1,1,w,h-4)
  84.   gp.
  85. end)]]
  86.  
  87. form:add(tbg)
  88. form:add(tfg)
  89. form:add(resetColors)
  90. form:add(exit)
  91. form:add(own)
  92. form:draw()
  93. form:listen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement