mirror of
https://github.com/Insality/druid
synced 2025-09-28 02:22:19 +02:00
Resolve #171 #158 Don't need to pass full template name, correct work with inner clone_tree and inner templates
This commit is contained in:
39
example/examples/system/inner_templates/inner_panel.lua
Normal file
39
example/examples/system/inner_templates/inner_panel.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
local component = require("druid.component")
|
||||
|
||||
local InnerButton = require("example.examples.system.inner_templates.inner_button")
|
||||
|
||||
---@class inner_panel : druid.base_component
|
||||
local InnerPanel = component.create("inner_panel")
|
||||
|
||||
local SCHEME = {
|
||||
ROOT = "root",
|
||||
BACKGROUND = "background",
|
||||
INNER_BUTTON_1 = "inner_button_1",
|
||||
INNER_BUTTON_2 = "inner_button_2",
|
||||
INNER_BUTTON_PREFAB = "inner_button_prefab",
|
||||
INNER_BUTTON_PREFAB_ROOT = "inner_button_prefab/root",
|
||||
}
|
||||
|
||||
|
||||
function InnerPanel:init(template, nodes)
|
||||
self:set_template(template)
|
||||
self:set_nodes(nodes)
|
||||
self.root = self:get_node(SCHEME.ROOT)
|
||||
self.druid = self:get_druid()
|
||||
|
||||
self.button1 = self.druid:new(InnerButton, SCHEME.INNER_BUTTON_1, nodes)
|
||||
self.button2 = self.druid:new(InnerButton, SCHEME.INNER_BUTTON_2, nodes)
|
||||
|
||||
local prefab = self:get_node(SCHEME.INNER_BUTTON_PREFAB_ROOT)
|
||||
local button_nodes = gui.clone_tree(prefab)
|
||||
self.button3 = self.druid:new(InnerButton, SCHEME.INNER_BUTTON_PREFAB, button_nodes)
|
||||
|
||||
gui.set_enabled(prefab, false)
|
||||
end
|
||||
|
||||
|
||||
function InnerPanel:on_remove()
|
||||
end
|
||||
|
||||
|
||||
return InnerPanel
|
Reference in New Issue
Block a user