Advertisement
Axeer

minecraft_graphic_library

Aug 12th, 2020
2,510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. local component = require("component")
  2. --local expl = loadfile("expl.lua")
  3. local gpu = component.gpu
  4. local thread  = require"thread"
  5. graphicsID = {}
  6. GUI = {}
  7.     screenSizeX, screenSizeY = gpu.getResolution()
  8. print(screenSizeX.." ".. screenSizeY)
  9. GUI.button = {
  10.        newBackend = function(x1,y1,x2,y2)
  11.        backendId = math.random()
  12.        buf = {id = backendId,name = "backend",backendPos = {x1 = x1, y1 = y1, x2 = x2, y2 = y2},color = 0x3c3c3c}
  13.         table.insert(GUI.button.backend,buf)
  14.         table.insert(graphicsID, backendId)
  15.     end
  16. ,
  17. applyToLayer = function()
  18. table.insert()
  19.  gpu.fill(x1, y1,
  20.     x2-2, y2-1, "+")
  21. end
  22. ,
  23. makeButton = function()
  24. gpu.setBackground(0x3c3c3c)
  25.     gpu.fill(x1,y1,x2,y2,  " ")
  26. end
  27. --giveInteract = fucntion ()
  28. --  print("in progress")--end
  29. }
  30. GUI.currentContaier = { --пример таблицы текущего контейнера - id, x1,y1,x2,y2,color,pointerToВХОДЯЩИЕВОВНУТРЬКНОПКИ
  31. getByID= function(ID)
  32. for k , v in graphicsID do
  33.     print(v ..'\t'..k)
  34. end
  35. end
  36. }
  37. GUI.button.size = {5,7}
  38. GUI.button.backend = { }
  39. GUI.button.position = { }
  40. GUI.button.buttonContainer = {buttonContainerX = x-GUI.button.size[1]/2,buttonContainerY=y-GUI.button.size[2]/2}
  41. GUI.button.shadowLayer = {beginX =x-GUI.button.size[1]/2,beginY = y-GUI.button.size[2]/2,
  42. endX = GUI.button.size[1], endY = GUI.button.size[2] }
  43. GUI.button.control = {}
  44. GUI.button.control.operation = {directionVector ={x = 0, y = 0}}
  45.  
  46. EXPL = {}
  47. EXPL.mouseEvent = {x = 1, y = 1, touchX = 0, touchY = 0,
  48. onTouch = function(x,y)
  49. if x > screenSizeX or x <0 then
  50.     x = 0
  51. end
  52. if y >screenSizeY or y<0 then
  53.     y = 0
  54. end
  55.  
  56. if
  57. end}
  58.  
  59.  
  60.  main_thread = thread.create(function ()
  61.     while true do
  62.    id, _,
  63.   EXPL.mouseEvent.x,
  64.   EXPL.mouseEvent.y = event.pullMultiple("touch", "interrupted")
  65.    
  66.      if id == "touch" then
  67.  
  68.         EXPL.mouseEvent.touchX = EXPL.mouseEvent.x
  69.         EXPL.mouseEvent.touchY = EXPL.mouseEvent.y
  70.         EXPL.mouseEvent.onTouch(EXPL.mouseEvent.x,EXPL.mouseEvent.y)
  71.          
  72.   end
  73.  
  74. end
  75. end
  76.     ):detach()
  77.  GUI.button.control.operation ={dragandmove = function()
  78. local _,x, y = event.pull("drag")
  79.     if x ==
  80.         GUI.button.shadowLayer.buttonContainerX = EXPL.mouseEvent.touchX
  81.         GUI.button.shadowLayer.buttonContainerY = EXPL.mouseEvent.touchY
  82.     end
  83.         --сюда пихнуть начальный слой
  84. end}
  85. --обертка функций для взаимодействия с внешними программами
  86. GUI.api = {}
  87. GUI.api.makeButton = function()
  88.  
  89.    
  90.  
  91. end
  92. --API:
  93. --
  94.  
  95. return GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement