From 50c8ff250fd8c7f2ad99ec8939856c39aa6dbff0 Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Wed, 9 Feb 2022 22:18:36 -0500 Subject: [PATCH] Working on the new version --- gui/init.lua | 100 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 27 deletions(-) diff --git a/gui/init.lua b/gui/init.lua index 242278d..b6af3e2 100644 --- a/gui/init.lua +++ b/gui/init.lua @@ -1,20 +1,57 @@ local multi,thread = require("multi"):init() local GLOBAL, THREAD = require("multi.integration.loveManager"):init() local gui = {} -gui.updater = multi:newProcessor("UpdateManager",true) -gui.drawer = multi:newProcessor("DrawManager",true) +local updater = multi:newProcessor("UpdateManager",true) +local drawer = multi:newProcessor("DrawManager",true) +local bit = require("bit") +local band, bor = bit.band, bit.bor gui.__index = gui gui.MOUSE_PRIMARY = 1 gui.MOUSE_SECONDARY = 2 gui.MOUSE_MIDDLE = 3 +local frame, label ,button, image, text, box = 0, 1, 2, 4, 8, 16 +local children = {} +function gui:getChildren() + return self.Children +end +function gui:getAllChildren() + for i=0, #children do children[i]=nil end + function Seek(Items) + for i=1,#Items do + if Items[i].Visible==true then + table.insert(Stuff,Items[i]) + local NItems = Items[i]:getChildren() + if NItems ~= nil then + Seek(NItems) + end + end + end + end + local Objs = self:getChildren() + for i=1,#Objs do + if Objs[i].Visible==true then + table.insert(Stuff,Objs[i]) + local Items = Objs[i]:getChildren() + if Items ~= nil then + Seek(Items) + end + end + end + return Stuff +end + -- Base Library -function gui:newBase(typ,dualDim) +function gui:newBase(typ,x, y, w, h, sx, sy, sw, sh) local c = {} c.parent = self - c.dualDim = dualDim + c.Type = typ + c.dualDim = self:newDualDim(x, y, w, h, sx, sy, sw, sh) + c.Children = {} + c.Visible = true + c.Visibility = 1 setmetatable(c, gui) end -function gui:newDualDim(x,y,w,h,sx,sy,sw,sh) +function gui:newDualDim(x, y, w, h, sx, sy, sw, sh) local dd = {} dd.offset={} dd.scale={} @@ -38,37 +75,46 @@ function gui:newDualDim(x,y,w,h,sx,sy,sw,sh) end -- Objects -- Frames -function gui:newFrame() - -- +function gui:newFrame(x, y, w, h, sx, sy, sw, sh) + local c = self:newBase(frame, x, y, w, h, sx, sy, sw, sh) end -- Texts -function gui:newTextBase(x,y,w,h,sx,sy,sw,sh) - -- +function gui:newTextBase(typ, txt, x, y, w, h, sx, sy, sw, sh) + local c = self:newBase(text + typ,x, y, w, h, sx, sy, sw, sh) + c.text = txt end -function gui:newTextLabel() - -- +function gui:newTextButton(txt, x, y, w, h, sx, sy, sw, sh) + local c = self:newTextBase(button, txt, x, y, w, h, sx, sy, sw, sh) end -function gui:newTextButton() - -- +function gui:newTextLabel(txt, x, y, w, h, sx, sy, sw, sh) + local c = self:newTextBase(label, txt, x, y, w, h, sx, sy, sw, sh) end -function gui:newTextLabel() - -- -end -function gui:newTextBox() - -- +function gui:newTextBox(txt, x, y, w, h, sx, sy, sw, sh) + local c = self:newTextBase(box, txt, x, y, w, h, sx, sy, sw, sh) end -- Images +function gui:newImageBase(typ,x, y, w, h, sx, sy, sw, sh) + local c = self:newBase(image + typ,x, y, w, h, sx, sy, sw, sh) +end +function gui:newImageLabel(x, y, w, h, sx, sy, sw, sh) + local c = self:newImageBase(label, x, y, w, h, sx, sy, sw, sh) +end +function gui:newImageButton(x, y, w, h, sx, sy, sw, sh) + local c = self:newImageBase(button, x, y, w, h, sx, sy, sw, sh) +end +-- Draw Function + +drawer:newLoop(function() + +end) + +-- Drawing and Updating +gui.draw = drawer.run +gui.update = updater.run --- Drawing -function gui:draw() - gui.drawer.run() -end --- Updating -function gui:update() - gui.updater.run() -end -- Root gui gui.Type = "root" +gui.Children = {} gui.dualDim = gui:newDualDim() -gui.updater:newLoop(function() gui.dualDim.offset.width,gui.dualDim.offset.height = love.graphics.getDimensions() end) +updater:newLoop(function() gui.dualDim.offset.width, gui.dualDim.offset.height = love.graphics.getDimensions() end) return gui \ No newline at end of file