Fix for examples

This commit is contained in:
Insality
2025-01-29 23:13:09 +02:00
parent db0c4c8ee5
commit da5c6b9a54
9 changed files with 319 additions and 32 deletions

View File

@@ -7,31 +7,60 @@ local M = {}
function M:init()
self.properties_panel = self.druid:new_widget(properties_panel, "properties_panel")
self.properties_panel:add_button("Button", function()
print("Button clicked")
self.properties_panel:add_button(function(button)
button:set_text_button("Button")
button.button.on_click:subscribe(function()
print("Button clicked")
end)
end)
self.properties_panel:add_checkbox("Checkbox", false, function(value)
print("Checkbox clicked", value)
self.properties_panel:add_checkbox(function(checkbox)
--print("Checkbox clicked", value)
checkbox:set_text_property("Checkbox")
checkbox.on_change_value:subscribe(function(value)
print("Checkbox clicked", value)
end)
checkbox:set_value(false)
end)
self.properties_panel:add_input("Input", "Initial", function(value)
print("Input value", value)
self.properties_panel:add_input(function(input)
input:set_text_property("Input")
input:set_text_value("Initial")
input:on_change(function(text)
print("Input changed", text)
end)
end)
self.properties_panel:add_left_right_selector("Arrows Number", 0, function(value)
print("Left Right Number value", value)
end):set_number_type(0, 42, true, 1)
self.properties_panel:add_left_right_selector("Arrows Array", "Zero", function(value)
print("Left Right Array value", value)
end):set_array_type({"Zero", "One", "Two", "Three", "Four", "Five"}, false, 1)
self.properties_panel:add_slider("Slider", 0.5, function(value)
print("Slider value", value)
self.properties_panel:add_left_right_selector(function(selector)
selector:set_template("Arrows Number")
selector.on_change_value:subscribe(function(value)
print("Left Right Selector changed", value)
end)
selector:set_number_type(0, 42, true, 1)
selector:set_value(0)
end)
self.properties_panel:add_text("Text", "Some text")
self.properties_panel:add_left_right_selector(function(selector)
selector:set_template("Arrows Array")
selector.on_change_value:subscribe(function(value)
print("Left Right Array value", value)
end)
selector:set_array_type({"Zero", "One", "Two", "Three", "Four", "Five"}, false, 1)
selector:set_value("Zero")
end)
self.properties_panel:add_slider(function(slider)
slider:set_text_property("Slider")
slider:set_value(0.5)
slider:on_change(function(value)
print("Slider changed", value)
end)
end)
self.properties_panel:add_text(function(text)
text:set_text_property("Text")
text:set_text_value("Hello, World!")
end)
end

View File

@@ -8,10 +8,6 @@ textures {
texture: "/example/assets/druid_example.atlas"
}
nodes {
position {
x: 960.0
y: 540.0
}
size {
x: 700.0
y: 500.0
@@ -202,6 +198,18 @@ nodes {
inherit_alpha: true
template: "/example/templates/button_text_green.gui"
}
nodes {
type: TYPE_BOX
id: "button_accept/root"
parent: "button_accept"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "button_accept/text"
parent: "button_accept/root"
template_node_child: true
}
nodes {
position {
x: 160.0
@@ -213,6 +221,18 @@ nodes {
inherit_alpha: true
template: "/example/templates/button_text_red.gui"
}
nodes {
type: TYPE_BOX
id: "button_decline/root"
parent: "button_decline"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "button_decline/text"
parent: "button_decline/root"
template_node_child: true
}
layers {
name: "druid"
}

View File

@@ -8,10 +8,6 @@ textures {
texture: "/example/assets/druid_example.atlas"
}
nodes {
position {
x: 960.0
y: 540.0
}
size {
x: 700.0
y: 500.0
@@ -201,6 +197,18 @@ nodes {
inherit_alpha: true
template: "/example/templates/button_text_green.gui"
}
nodes {
type: TYPE_BOX
id: "button_accept/root"
parent: "button_accept"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "button_accept/text"
parent: "button_accept/root"
template_node_child: true
}
layers {
name: "druid"
}

View File

@@ -8,10 +8,6 @@ textures {
texture: "/example/assets/druid_example.atlas"
}
nodes {
position {
x: 960.0
y: 540.0
}
size {
x: 600.0
y: 580.0
@@ -173,6 +169,23 @@ nodes {
inherit_alpha: true
template: "/example/templates/button_text_white.gui"
}
nodes {
size {
x: 245.0
y: 75.0
}
type: TYPE_BOX
id: "button/root"
parent: "button"
overridden_fields: 4
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "button/text"
parent: "button/root"
template_node_child: true
}
layers {
name: "druid"
}

View File

@@ -38,7 +38,7 @@ function M:init(template, nodes)
self.grid = self.druid:new_grid("content", self.prefab, 2)
self.grid.style.IS_DYNAMIC_NODE_POSES = true
self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), nodes)
self.animation = panthera.create_gui(window_animation_panthera, self:get_template(), self:get_nodes())
panthera.play(self.animation, "open")
self:load_langs()