New way of component registration

This commit is contained in:
Alexey Gulev
2019-03-27 22:07:28 +01:00
parent d5c3aae745
commit 832ebe5674
2 changed files with 10 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ M.comps = {
}
local function register_basic_components()
local register_basic_components = function ()
for k, v in pairs(M.comps) do
M.register(k, v)
end
@@ -37,6 +37,10 @@ end
--- Create UI instance for ui elements
-- @return instance with all ui components
function M.new(self)
if register_basic_components then
register_basic_components()
register_basic_components = false
end
local factory = setmetatable({}, {__index = _factory})
factory.parent = self
return factory
@@ -149,6 +153,4 @@ function _factory.update(factory, dt)
end
end
register_basic_components()
return M