mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 02:17:52 +02:00
New way of component registration
This commit is contained in:
parent
d5c3aae745
commit
832ebe5674
@ -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
|
@ -6,6 +6,11 @@ local lang = {
|
||||
}
|
||||
|
||||
local function setup_druid(self)
|
||||
|
||||
-- two different way of exernal component regesstration
|
||||
druid.comps["my_mega_test_comp"] = require "druid.base.text"
|
||||
druid.register("my_custom_component", {})
|
||||
|
||||
druid_settings.is_debug = true
|
||||
|
||||
druid_settings.play_sound = function(name)
|
||||
@ -33,8 +38,6 @@ function init(self)
|
||||
self.druid:new_button("button_3", function()
|
||||
print("On button 3")
|
||||
end)
|
||||
|
||||
druid.register("my_custom_component", {})
|
||||
|
||||
self.druid:new_android_back(function(self, params)
|
||||
print("On android back", params)
|
||||
|
Loading…
x
Reference in New Issue
Block a user