diff --git a/README.md b/README.md index a3c100a..c79373d 100644 --- a/README.md +++ b/README.md @@ -131,8 +131,12 @@ Create a new lua file to create a new widget class. This widget can be created w local M = {} function M:init() - self.druid = self:get_druid() 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 return M diff --git a/druid/editor_scripts/setup_layers.py b/druid/editor_scripts/setup_layers.py index dd0d580..4af9cff 100644 --- a/druid/editor_scripts/setup_layers.py +++ b/druid/editor_scripts/setup_layers.py @@ -31,7 +31,7 @@ def main(): texture = node.get_attribute("texture") font = node.get_attribute("font") - if texture: + if texture and texture.value: layer = texture.value.split("/")[0] node.set_attribute("layer", layer) diff --git a/example/druid.gui b/example/druid.gui index 8e1b2ea..3f325af 100644 --- a/example/druid.gui +++ b/example/druid.gui @@ -4495,6 +4495,210 @@ nodes { parent: "example_properties_panel/properties_panel/property_left_right_selector/E_Anchor" 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 { position { x: -20.0 diff --git a/example/examples/widgets/properties_panel/example_properties_panel.lua b/example/examples/widgets/properties_panel/example_properties_panel.lua index f892909..887950d 100644 --- a/example/examples/widgets/properties_panel/example_properties_panel.lua +++ b/example/examples/widgets/properties_panel/example_properties_panel.lua @@ -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 diff --git a/example/examples/windows/window_confirmation/window_confirmation.gui b/example/examples/windows/window_confirmation/window_confirmation.gui index 2c11af3..2c60a9e 100644 --- a/example/examples/windows/window_confirmation/window_confirmation.gui +++ b/example/examples/windows/window_confirmation/window_confirmation.gui @@ -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" } diff --git a/example/examples/windows/window_info/window_info.gui b/example/examples/windows/window_info/window_info.gui index d216457..869dd30 100644 --- a/example/examples/windows/window_info/window_info.gui +++ b/example/examples/windows/window_info/window_info.gui @@ -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" } diff --git a/example/examples/windows/window_language/window_language.gui b/example/examples/windows/window_language/window_language.gui index c3ba2cd..29c6763 100644 --- a/example/examples/windows/window_language/window_language.gui +++ b/example/examples/windows/window_language/window_language.gui @@ -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" } diff --git a/example/examples/windows/window_language/window_language.lua b/example/examples/windows/window_language/window_language.lua index f572d64..25c9bf4 100644 --- a/example/examples/windows/window_language/window_language.lua +++ b/example/examples/windows/window_language/window_language.lua @@ -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() diff --git a/example/locales/en.json b/example/locales/en.json index c05a651..dcf64ea 100644 --- a/example/locales/en.json +++ b/example/locales/en.json @@ -177,6 +177,15 @@ "ui_example_widget_property_checkbox": "Property Checkbox", "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_description": "Test your gamepad here to bind buttons and axes",