move UIBuilder creation into the layout
This commit is contained in:
parent
c7ee957c8c
commit
031da7fd0a
@ -5,13 +5,12 @@
|
||||
local builder = {}
|
||||
builder.__index = builder
|
||||
|
||||
local function new(elementTree)
|
||||
local l = {}
|
||||
l.elementTree = elementTree
|
||||
l._cache = {}
|
||||
--- @return UIBuilder
|
||||
local function new(from)
|
||||
from._cache = {}
|
||||
|
||||
setmetatable(l, builder)
|
||||
return l
|
||||
setmetatable(from, builder)
|
||||
return from
|
||||
end
|
||||
|
||||
--- @param element? UIElement
|
||||
|
||||
@ -2,23 +2,26 @@ local ScreenArea = require "lib.simple_ui.screen_area"
|
||||
local Center = require "lib.simple_ui.center"
|
||||
local Placeholder = require "lib.simple_ui.placeholder"
|
||||
local Padding = require "lib.simple_ui.padding"
|
||||
local Builder = require "lib.simple_ui.builder"
|
||||
|
||||
|
||||
return ScreenArea:new {
|
||||
build = function(self)
|
||||
return
|
||||
(love.timer.getTime() / 2) % 2 < 1 and
|
||||
Center:new {
|
||||
child = Padding:new {
|
||||
left = 8,
|
||||
right = 8,
|
||||
top = 8,
|
||||
bottom = 8,
|
||||
child = Placeholder:new {
|
||||
key = "const :)",
|
||||
return Builder {
|
||||
elementTree = ScreenArea:new {
|
||||
build = function(self)
|
||||
return
|
||||
(love.timer.getTime() / 2) % 2 < 1 and
|
||||
Center:new {
|
||||
child = Padding:new {
|
||||
left = 8,
|
||||
right = 8,
|
||||
top = 8,
|
||||
bottom = 8,
|
||||
child = Placeholder:new {
|
||||
key = "const :)",
|
||||
}
|
||||
}
|
||||
}
|
||||
or nil
|
||||
}
|
||||
end
|
||||
or nil
|
||||
}
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
3
main.lua
3
main.lua
@ -2,8 +2,7 @@
|
||||
|
||||
local character = require "lib/character/character"
|
||||
require "lib/tree"
|
||||
local UIBuilder = require("lib.simple_ui.builder")
|
||||
local testLayout = UIBuilder(require "lib.simple_ui.level.test")
|
||||
local testLayout = require("lib.simple_ui.level.test")
|
||||
|
||||
function love.conf(t)
|
||||
t.console = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user