improvement: better element data parsing
This commit is contained in:
parent
75bd09f18b
commit
da9dbb30b8
2 changed files with 26 additions and 8 deletions
|
@ -6,6 +6,9 @@ GuiScreen:implement(ElementList)
|
|||
|
||||
local TweenManager = require "birb.classes.time"
|
||||
|
||||
local elementDataStruct = require "birb.structures.elementData"
|
||||
|
||||
|
||||
function GuiScreen:new(name, controller)
|
||||
self.controller = controller or self:getGui()
|
||||
self.name = name
|
||||
|
@ -69,16 +72,30 @@ end
|
|||
|
||||
function GuiScreen:registerElements()
|
||||
local elementList = self:createElements()
|
||||
for _, element in ipairs(elementList) do
|
||||
if (element.is ~= nil) then
|
||||
self:addElement(element.name, element)
|
||||
element.screen = self
|
||||
for _, rawElement in ipairs(elementList) do
|
||||
if (rawElement.is ~= nil) then
|
||||
self:addElement(rawElement.name, rawElement)
|
||||
rawElement.screen = self
|
||||
else
|
||||
self:addElement(element[1].name, element[1])
|
||||
if (element[2] == false) then
|
||||
element[1].isVisible = false
|
||||
local elemData = utils.table.parse(rawElement, elementDataStruct, 3)
|
||||
local element = elemData.element
|
||||
self:addElement(element.name, element)
|
||||
if (elemData.delay > 0) then
|
||||
element.isVisible = false
|
||||
element:newSwitch(elemData.delay, {"isVisible"})
|
||||
print(elemData.delay)
|
||||
end
|
||||
element[1].screen = self
|
||||
if (elemData.depth ~= nil) then
|
||||
element.depth = elemData.depth
|
||||
end
|
||||
print(element, element.name, elemData.depth, elemData.focus)
|
||||
if (elemData.focus == true) then
|
||||
element:getFocus()
|
||||
end
|
||||
if (elemData.keypress ~= nil) then
|
||||
element:setKeyPressAction(elemData.keypress)
|
||||
end
|
||||
element.screen = self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
1
sonic-radiance.love/birb/structures/elementData.lua
Normal file
1
sonic-radiance.love/birb/structures/elementData.lua
Normal file
|
@ -0,0 +1 @@
|
|||
return {"element", "delay", "depth", "focus", "keypress"}
|
Loading…
Reference in a new issue