Working on the new version
This commit is contained in:
parent
ba0ae5059f
commit
50c8ff250f
100
gui/init.lua
100
gui/init.lua
@ -1,20 +1,57 @@
|
|||||||
local multi,thread = require("multi"):init()
|
local multi,thread = require("multi"):init()
|
||||||
local GLOBAL, THREAD = require("multi.integration.loveManager"):init()
|
local GLOBAL, THREAD = require("multi.integration.loveManager"):init()
|
||||||
local gui = {}
|
local gui = {}
|
||||||
gui.updater = multi:newProcessor("UpdateManager",true)
|
local updater = multi:newProcessor("UpdateManager",true)
|
||||||
gui.drawer = multi:newProcessor("DrawManager",true)
|
local drawer = multi:newProcessor("DrawManager",true)
|
||||||
|
local bit = require("bit")
|
||||||
|
local band, bor = bit.band, bit.bor
|
||||||
gui.__index = gui
|
gui.__index = gui
|
||||||
gui.MOUSE_PRIMARY = 1
|
gui.MOUSE_PRIMARY = 1
|
||||||
gui.MOUSE_SECONDARY = 2
|
gui.MOUSE_SECONDARY = 2
|
||||||
gui.MOUSE_MIDDLE = 3
|
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
|
-- Base Library
|
||||||
function gui:newBase(typ,dualDim)
|
function gui:newBase(typ,x, y, w, h, sx, sy, sw, sh)
|
||||||
local c = {}
|
local c = {}
|
||||||
c.parent = self
|
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)
|
setmetatable(c, gui)
|
||||||
end
|
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 = {}
|
local dd = {}
|
||||||
dd.offset={}
|
dd.offset={}
|
||||||
dd.scale={}
|
dd.scale={}
|
||||||
@ -38,37 +75,46 @@ function gui:newDualDim(x,y,w,h,sx,sy,sw,sh)
|
|||||||
end
|
end
|
||||||
-- Objects
|
-- Objects
|
||||||
-- Frames
|
-- 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
|
end
|
||||||
-- Texts
|
-- 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
|
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
|
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
|
end
|
||||||
function gui:newTextLabel()
|
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
|
|
||||||
function gui:newTextBox()
|
|
||||||
--
|
|
||||||
end
|
end
|
||||||
-- Images
|
-- 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
|
-- Root gui
|
||||||
gui.Type = "root"
|
gui.Type = "root"
|
||||||
|
gui.Children = {}
|
||||||
gui.dualDim = gui:newDualDim()
|
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
|
return gui
|
||||||
Loading…
x
Reference in New Issue
Block a user