Refonte pour utiliser le systeme de GUI #112
2 changed files with 26 additions and 8 deletions
|
@ -6,6 +6,9 @@ GuiScreen:implement(ElementList)
|
||||||
|
|
||||||
local TweenManager = require "birb.classes.time"
|
local TweenManager = require "birb.classes.time"
|
||||||
|
|
||||||
|
local elementDataStruct = require "birb.structures.elementData"
|
||||||
|
|
||||||
|
|
||||||
function GuiScreen:new(name, controller)
|
function GuiScreen:new(name, controller)
|
||||||
self.controller = controller or self:getGui()
|
self.controller = controller or self:getGui()
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -69,16 +72,30 @@ end
|
||||||
|
|
||||||
function GuiScreen:registerElements()
|
function GuiScreen:registerElements()
|
||||||
local elementList = self:createElements()
|
local elementList = self:createElements()
|
||||||
for _, element in ipairs(elementList) do
|
for _, rawElement in ipairs(elementList) do
|
||||||
if (element.is ~= nil) then
|
if (rawElement.is ~= nil) then
|
||||||
self:addElement(element.name, element)
|
self:addElement(rawElement.name, rawElement)
|
||||||
element.screen = self
|
rawElement.screen = self
|
||||||
else
|
else
|
||||||
self:addElement(element[1].name, element[1])
|
local elemData = utils.table.parse(rawElement, elementDataStruct, 3)
|
||||||
if (element[2] == false) then
|
local element = elemData.element
|
||||||
element[1].isVisible = false
|
self:addElement(element.name, element)
|
||||||
|
if (elemData.delay > 0) then
|
||||||
|
element.isVisible = false
|
||||||
|
element:newSwitch(elemData.delay, {"isVisible"})
|
||||||
|
print(elemData.delay)
|
||||||
end
|
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
|
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