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

@ -131,8 +131,12 @@ Create a new lua file to create a new widget class. This widget can be created w
local M = {} local M = {}
function M:init() function M:init()
self.druid = self:get_druid()
self.root = self:get_node("root") self.root = self:get_node("root")
self.button = self.druid:new_button("button", self.on_click)
end
function M:on_click()
print("Button clicked!")
end end
return M return M

View File

@ -31,7 +31,7 @@ def main():
texture = node.get_attribute("texture") texture = node.get_attribute("texture")
font = node.get_attribute("font") font = node.get_attribute("font")
if texture: if texture and texture.value:
layer = texture.value.split("/")[0] layer = texture.value.split("/")[0]
node.set_attribute("layer", layer) node.set_attribute("layer", layer)

View File

@ -4495,6 +4495,210 @@ nodes {
parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor"
template_node_child: true template_node_child: true
} }
nodes {
type: TYPE_TEMPLATE
id: "example_properties_panel/properties_panel/property_vector3"
parent: "example_properties_panel/properties_panel/propeties"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/root"
parent: "example_properties_panel/properties_panel/property_vector3"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/text_name"
parent: "example_properties_panel/properties_panel/property_vector3/root"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/E_Anchor"
parent: "example_properties_panel/properties_panel/property_vector3/root"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/field_x"
parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/text_x"
parent: "example_properties_panel/properties_panel/property_vector3/field_x"
template_node_child: true
}
nodes {
type: TYPE_TEMPLATE
id: "example_properties_panel/properties_panel/property_vector3/rich_input_x"
parent: "example_properties_panel/properties_panel/property_vector3/field_x"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/button"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/placeholder_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/input_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_node"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_x/cursor_node"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/selected_x"
parent: "example_properties_panel/properties_panel/property_vector3/field_x"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/field_y"
parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/text_y"
parent: "example_properties_panel/properties_panel/property_vector3/field_y"
template_node_child: true
}
nodes {
type: TYPE_TEMPLATE
id: "example_properties_panel/properties_panel/property_vector3/rich_input_y"
parent: "example_properties_panel/properties_panel/property_vector3/field_y"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/button"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/placeholder_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/input_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_node"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_y/cursor_node"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/selected_y"
parent: "example_properties_panel/properties_panel/property_vector3/field_y"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/field_z"
parent: "example_properties_panel/properties_panel/property_vector3/E_Anchor"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/text_z"
parent: "example_properties_panel/properties_panel/property_vector3/field_z"
template_node_child: true
}
nodes {
type: TYPE_TEMPLATE
id: "example_properties_panel/properties_panel/property_vector3/rich_input_z"
parent: "example_properties_panel/properties_panel/property_vector3/field_z"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/button"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/placeholder_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/input_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_node"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/root"
template_node_child: true
}
nodes {
type: TYPE_TEXT
id: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_text"
parent: "example_properties_panel/properties_panel/property_vector3/rich_input_z/cursor_node"
template_node_child: true
}
nodes {
type: TYPE_BOX
id: "example_properties_panel/properties_panel/property_vector3/selected_z"
parent: "example_properties_panel/properties_panel/property_vector3/field_z"
template_node_child: true
}
nodes { nodes {
position { position {
x: -20.0 x: -20.0

View File

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

View File

@ -8,10 +8,6 @@ textures {
texture: "/example/assets/druid_example.atlas" texture: "/example/assets/druid_example.atlas"
} }
nodes { nodes {
position {
x: 960.0
y: 540.0
}
size { size {
x: 700.0 x: 700.0
y: 500.0 y: 500.0
@ -202,6 +198,18 @@ nodes {
inherit_alpha: true inherit_alpha: true
template: "/example/templates/button_text_green.gui" 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 { nodes {
position { position {
x: 160.0 x: 160.0
@ -213,6 +221,18 @@ nodes {
inherit_alpha: true inherit_alpha: true
template: "/example/templates/button_text_red.gui" 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 { layers {
name: "druid" name: "druid"
} }

View File

@ -8,10 +8,6 @@ textures {
texture: "/example/assets/druid_example.atlas" texture: "/example/assets/druid_example.atlas"
} }
nodes { nodes {
position {
x: 960.0
y: 540.0
}
size { size {
x: 700.0 x: 700.0
y: 500.0 y: 500.0
@ -201,6 +197,18 @@ nodes {
inherit_alpha: true inherit_alpha: true
template: "/example/templates/button_text_green.gui" 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 { layers {
name: "druid" name: "druid"
} }

View File

@ -8,10 +8,6 @@ textures {
texture: "/example/assets/druid_example.atlas" texture: "/example/assets/druid_example.atlas"
} }
nodes { nodes {
position {
x: 960.0
y: 540.0
}
size { size {
x: 600.0 x: 600.0
y: 580.0 y: 580.0
@ -173,6 +169,23 @@ nodes {
inherit_alpha: true inherit_alpha: true
template: "/example/templates/button_text_white.gui" 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 { layers {
name: "druid" 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 = self.druid:new_grid("content", self.prefab, 2)
self.grid.style.IS_DYNAMIC_NODE_POSES = true 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") panthera.play(self.animation, "open")
self:load_langs() self:load_langs()

View File

@ -177,6 +177,15 @@
"ui_example_widget_property_checkbox": "Property Checkbox", "ui_example_widget_property_checkbox": "Property Checkbox",
"ui_example_widget_property_checkbox_description": "Here is a widget used in Properties panel", "ui_example_widget_property_checkbox_description": "Here is a widget used in Properties panel",
"ui_example_widget_memory_panel": "Memory Panel",
"ui_example_widget_memory_panel_description": "Here is a example of memory panel usage",
"ui_example_widget_fps_panel": "FPS Panel",
"ui_example_widget_fps_panel_description": "Here is a example of FPS panel usage",
"ui_example_widget_properties_panel": "Properties Panel",
"ui_example_widget_properties_panel_description": "Here is a example of properties panel usage",
"ui_example_gamepad_tester": "Gamepad Tester", "ui_example_gamepad_tester": "Gamepad Tester",
"ui_example_gamepad_tester_description": "Test your gamepad here to bind buttons and axes", "ui_example_gamepad_tester_description": "Test your gamepad here to bind buttons and axes",