Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- --local expl = loadfile("expl.lua")
- local gpu = component.gpu
- local thread = require"thread"
- graphicsID = {}
- GUI = {}
- screenSizeX, screenSizeY = gpu.getResolution()
- print(screenSizeX.." ".. screenSizeY)
- GUI.button = {
- newBackend = function(x1,y1,x2,y2)
- backendId = math.random()
- buf = {id = backendId,name = "backend",backendPos = {x1 = x1, y1 = y1, x2 = x2, y2 = y2},color = 0x3c3c3c}
- table.insert(GUI.button.backend,buf)
- table.insert(graphicsID, backendId)
- end
- ,
- applyToLayer = function()
- table.insert()
- gpu.fill(x1, y1,
- x2-2, y2-1, "+")
- end
- ,
- makeButton = function()
- gpu.setBackground(0x3c3c3c)
- gpu.fill(x1,y1,x2,y2, " ")
- end
- --giveInteract = fucntion ()
- -- print("in progress")--end
- }
- GUI.currentContaier = { --пример таблицы текущего контейнера - id, x1,y1,x2,y2,color,pointerToВХОДЯЩИЕВОВНУТРЬКНОПКИ
- getByID= function(ID)
- for k , v in graphicsID do
- print(v ..'\t'..k)
- end
- end
- }
- GUI.button.size = {5,7}
- GUI.button.backend = { }
- GUI.button.position = { }
- GUI.button.buttonContainer = {buttonContainerX = x-GUI.button.size[1]/2,buttonContainerY=y-GUI.button.size[2]/2}
- GUI.button.shadowLayer = {beginX =x-GUI.button.size[1]/2,beginY = y-GUI.button.size[2]/2,
- endX = GUI.button.size[1], endY = GUI.button.size[2] }
- GUI.button.control = {}
- GUI.button.control.operation = {directionVector ={x = 0, y = 0}}
- EXPL = {}
- EXPL.mouseEvent = {x = 1, y = 1, touchX = 0, touchY = 0,
- onTouch = function(x,y)
- if x > screenSizeX or x <0 then
- x = 0
- end
- if y >screenSizeY or y<0 then
- y = 0
- end
- if
- end}
- main_thread = thread.create(function ()
- while true do
- id, _,
- EXPL.mouseEvent.x,
- EXPL.mouseEvent.y = event.pullMultiple("touch", "interrupted")
- if id == "touch" then
- EXPL.mouseEvent.touchX = EXPL.mouseEvent.x
- EXPL.mouseEvent.touchY = EXPL.mouseEvent.y
- EXPL.mouseEvent.onTouch(EXPL.mouseEvent.x,EXPL.mouseEvent.y)
- end
- end
- end
- ):detach()
- GUI.button.control.operation ={dragandmove = function()
- local _,x, y = event.pull("drag")
- if x ==
- GUI.button.shadowLayer.buttonContainerX = EXPL.mouseEvent.touchX
- GUI.button.shadowLayer.buttonContainerY = EXPL.mouseEvent.touchY
- end
- --сюда пихнуть начальный слой
- end}
- --обертка функций для взаимодействия с внешними программами
- GUI.api = {}
- GUI.api.makeButton = function()
- end
- --API:
- --
- return GUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement