diff --git a/example/examples/basic/blocker/basic_blocker.lua b/example/examples/basic/blocker/basic_blocker.lua index 4a2f784..e930bcd 100644 --- a/example/examples/basic/blocker/basic_blocker.lua +++ b/example/examples/basic/blocker/basic_blocker.lua @@ -3,6 +3,7 @@ ---@field blocker druid.blocker local M = {} + function M:init() self.root = self:get_node("root") @@ -12,12 +13,26 @@ function M:init() self.button = self.druid:new_button("button/root", self.on_button_click) end + function M:on_root_click() print("Root click") end + function M:on_button_click() print("Button click") end + +---@param output_log output_list +function M:on_example_created(output_log) + self.button_root.on_click:subscribe(function() + output_log:add_log_text("Root Clicked") + end) + self.button.on_click:subscribe(function() + output_log:add_log_text("Button Clicked") + end) +end + + return M diff --git a/example/examples/basic/checkbox/checkbox.lua b/example/examples/basic/checkbox/checkbox.lua index 30786ad..d8dee22 100644 --- a/example/examples/basic/checkbox/checkbox.lua +++ b/example/examples/basic/checkbox/checkbox.lua @@ -42,4 +42,12 @@ function M:get_state() end +---@param output_log output_list +function M:on_example_created(output_log) + self.button.on_click:subscribe(function() + output_log:add_log_text("Checkbox Clicked: " .. tostring(self.is_enabled)) + end) +end + + return M diff --git a/example/examples/basic/checkbox_group/checkbox_group.lua b/example/examples/basic/checkbox_group/checkbox_group.lua index b58b137..81138d3 100644 --- a/example/examples/basic/checkbox_group/checkbox_group.lua +++ b/example/examples/basic/checkbox_group/checkbox_group.lua @@ -32,4 +32,12 @@ function M:on_checkbox_click() end +---@param output_log output_list +function M:on_example_created(output_log) + self.on_state_changed:subscribe(function(state1, state2, state3) + output_log:add_log_text("State: " .. tostring(state1) .. " " .. tostring(state2) .. " " .. tostring(state3)) + end) +end + + return M diff --git a/example/examples/basic/examples_list.lua b/example/examples/basic/examples_list.lua index 5e69b5d..ebf5071 100644 --- a/example/examples/basic/examples_list.lua +++ b/example/examples/basic/examples_list.lua @@ -1,5 +1,3 @@ -local const = require("druid.const") -local helper = require("druid.helper") local M = {} function M.get_examples() @@ -44,55 +42,6 @@ function M.get_examples() root = "multiline_text/root", code_url = "example/examples/basic/text/multiline_text.lua", widget_class = require("example.examples.basic.text.multiline_text"), - properties_control = function(instance, properties_panel) - ---@cast instance examples.multiline_text - - local adjust_index = 1 - local adjust_types = { - "downscale", - "downscale_limited", - --"scale_then_scroll", -- works bad with container for some reason - --"scroll", -- works bad with container for some reason - "trim", - } - properties_panel:add_button("ui_adjust_next", function() - adjust_index = adjust_index + 1 - if adjust_index > #adjust_types then - adjust_index = 1 - end - instance.text:set_text_adjust(adjust_types[adjust_index], 0.8) - end) - - local pivot_index = 1 - local pivot_list = { - gui.PIVOT_CENTER, - gui.PIVOT_W, - gui.PIVOT_SW, - gui.PIVOT_S, - gui.PIVOT_SE, - gui.PIVOT_E, - gui.PIVOT_NE, - gui.PIVOT_N, - gui.PIVOT_NW, - } - - properties_panel:add_button("ui_pivot_next", function() - pivot_index = pivot_index + 1 - if pivot_index > #pivot_list then - pivot_index = 1 - end - instance:set_pivot(pivot_list[pivot_index]) - end) - end, - get_debug_info = function(instance) - ---@cast instance examples.multiline_text - local info = "" - - info = info .. "Text Adjust: " .. instance.text.adjust_type .. "\n" - info = info .. "Pivot: " .. gui.get_pivot(instance.text.node) .. "\n" - - return info - end }, { name_id = "ui_example_basic_hover", @@ -125,13 +74,6 @@ function M.get_examples() root = "basic_slider/root", code_url = "example/examples/basic/slider/basic_slider.lua", widget_class = require("example.examples.basic.slider.basic_slider"), - on_create = function(instance, output_log) - ---@cast instance examples.basic_slider - instance.slider.on_change_value:subscribe(function(_, value) - local value = helper.round(value, 2) - output_log:add_log_text("Slider Value: " .. value) - end) - end, }, { name_id = "ui_example_basic_slider_vertical", @@ -140,13 +82,6 @@ function M.get_examples() root = "basic_slider_vertical/root", code_url = "example/examples/basic/slider/basic_slider_vertical.lua", widget_class = require("example.examples.basic.slider.basic_slider_vertical"), - on_create = function(instance, output_log) - ---@cast instance examples.basic_slider_vertical - instance.slider.on_change_value:subscribe(function(_, value) - local value = helper.round(value, 2) - output_log:add_log_text("Slider Value: " .. value) - end) - end, }, { name_id = "ui_example_basic_slider_stepped", @@ -155,13 +90,6 @@ function M.get_examples() root = "basic_slider_stepped/root", code_url = "example/examples/basic/slider/basic_slider_stepped.lua", widget_class = require("example.examples.basic.slider.basic_slider_stepped"), - on_create = function(instance, output_log) - ---@cast instance examples.basic_slider_stepped - instance.slider.on_change_value:subscribe(function(_, value) - local value = helper.round(value, 2) - output_log:add_log_text("Slider Value: " .. value) - end) - end, }, { name_id = "ui_example_basic_progress_bar", @@ -170,12 +98,6 @@ function M.get_examples() root = "basic_progress_bar/root", code_url = "example/examples/basic/progress_bar/basic_progress_bar.lua", widget_class = require("example.examples.basic.progress_bar.basic_progress_bar"), - properties_control = function(instance, properties_panel) - ---@cast instance examples.basic_progress_bar - properties_panel:add_slider("ui_value", 1, function(value) - instance:set_value(value) - end) - end, }, { name_id = "ui_example_basic_progress_bar_slice9", @@ -184,12 +106,6 @@ function M.get_examples() root = "basic_progress_bar_slice9/root", code_url = "example/examples/basic/progress_bar/basic_progress_bar_slice9.lua", widget_class = require("example.examples.basic.progress_bar.basic_progress_bar_slice9"), - properties_control = function(instance, properties_panel) - ---@cast instance examples.basic_progress_bar_slice9 - properties_panel:add_slider("ui_value", 1, function(value) - instance:set_value(value) - end) - end, }, { name_id = "ui_example_basic_blocker", @@ -198,15 +114,6 @@ function M.get_examples() root = "basic_blocker/root", code_url = "example/examples/basic/blocker/basic_blocker.lua", widget_class = require("example.examples.basic.blocker.basic_blocker"), - on_create = function(instance, output_log) - ---@cast instance examples.basic_blocker - instance.button_root.on_click:subscribe(function() - output_log:add_log_text("Root Clicked") - end) - instance.button.on_click:subscribe(function() - output_log:add_log_text("Button Clicked") - end) - end, }, { name_id = "ui_example_basic_back_handler", @@ -223,12 +130,6 @@ function M.get_examples() root = "basic_timer/root", code_url = "example/examples/basic/timer/basic_timer.lua", widget_class = require("example.examples.basic.timer.basic_timer"), - on_create = function(instance, output_log) - ---@cast instance examples.basic_timer - instance.on_cycle_end:subscribe(function() - output_log:add_log_text("Timer Cycle End") - end) - end, }, { name_id = "ui_example_basic_hotkey", @@ -237,12 +138,6 @@ function M.get_examples() root = "basic_hotkey/root", code_url = "example/examples/basic/hotkey/basic_hotkey.lua", widget_class = require("example.examples.basic.hotkey.basic_hotkey"), - on_create = function(instance, output_log) - ---@cast instance examples.basic_hotkey - instance.hotkey.on_hotkey_released:subscribe(function() - output_log:add_log_text("Hotkey Released") - end) - end, }, { name_id = "ui_example_basic_scroll", @@ -251,70 +146,6 @@ function M.get_examples() root = "scroll/root", code_url = "example/examples/basic/scroll/scroll.lua", widget_class = require("example.examples.basic.scroll.scroll"), - on_create = function(instance, output_log) - ---@cast instance examples.scroll - instance.button_tutorial.on_click:subscribe(function() - output_log:add_log_text("Button Tutorial Clicked") - end) - instance.button_stencil.on_click:subscribe(function() - output_log:add_log_text("Button Stencil Clicked") - end) - end, - properties_control = function(instance, properties_panel) - ---@cast instance examples.scroll - local scroll = instance.scroll - local is_stretch = instance.scroll.style.EXTRA_STRETCH_SIZE > 0 - properties_panel:add_checkbox("ui_elastic_scroll", is_stretch, function(value) - instance.scroll:set_extra_stretch_size(value and 100 or 0) - end) - - local view_node = instance.scroll.view_node - local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL - properties_panel:add_checkbox("ui_clipping", is_stencil, function(value) - gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE) - end) - - local slider_frict = properties_panel:add_slider("ui_slider_friction", 0, function(value) - scroll.style.FRICT = 1 - ((1 - value) * 0.1) - end) - slider_frict:set_text_function(function(value) - return string.format("%.2f", 1 - ((1 - value) * 0.1)) - end) - slider_frict:set_value(1 - (1 - scroll.style.FRICT) / 0.1) - - local slider_speed = properties_panel:add_slider("ui_slider_speed", 0, function(value) - scroll.style.INERT_SPEED = value * 50 - end) - slider_speed:set_value(scroll.style.INERT_SPEED / 50) - slider_speed:set_text_function(function(value) - return string.format("%.1f", value * 50) - end) - - local slider_wheel_speed = properties_panel:add_slider("ui_slider_wheel_speed", 0, function(value) - scroll.style.WHEEL_SCROLL_SPEED = value * 30 - end) - slider_wheel_speed:set_value(scroll.style.WHEEL_SCROLL_SPEED / 30) - slider_wheel_speed:set_text_function(function(value) - return string.format("%.1f", value * 30) - end) - - local wheel_by_inertion = properties_panel:add_checkbox("ui_wheel_by_inertion", scroll.style.WHEEL_SCROLL_BY_INERTION, function(value) - scroll.style.WHEEL_SCROLL_BY_INERTION = value - end) - wheel_by_inertion:set_value(scroll.style.WHEEL_SCROLL_BY_INERTION) - end, - get_debug_info = function(instance) - ---@cast instance examples.scroll - local info = "" - - local s = instance.scroll - info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n" - info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n" - info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n" - info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n" - - return info - end }, { name_id = "ui_example_basic_scroll_slider", @@ -323,18 +154,6 @@ function M.get_examples() root = "scroll_slider/root", code_url = "example/examples/basic/scroll_slider/scroll_slider.lua", widget_class = require("example.examples.basic.scroll_slider.scroll_slider"), - get_debug_info = function(instance) - ---@cast instance examples.scroll_slider - local info = "" - - local s = instance.scroll - info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n" - info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n" - info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n" - info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n" - - return info - end }, { name_id = "ui_example_basic_grid", @@ -343,86 +162,6 @@ function M.get_examples() root = "grid/root", code_url = "example/examples/basic/grid/grid.lua", widget_class = require("example.examples.basic.grid.grid"), - properties_control = function(instance, properties_panel) - ---@cast instance examples.grid - - local grid = instance.grid - - local slider = properties_panel:add_slider("ui_grid_in_row", 0.3, function(value) - local in_row_amount = math.ceil(value * 10) - in_row_amount = math.max(1, in_row_amount) - grid:set_in_row(in_row_amount) - end) - slider:set_text_function(function(value) - return tostring(math.ceil(value * 10)) - end) - - properties_panel:add_button("ui_add_element", function() - if #instance.created_nodes >= 36 then - return - end - instance:add_element() - end) - - properties_panel:add_button("ui_remove_element", function() - instance:remove_element() - end) - - properties_panel:add_button("ui_clear_elements", function() - instance:clear() - end) - - properties_panel:add_checkbox("ui_dynamic_pos", grid.style.IS_DYNAMIC_NODE_POSES, function() - grid.style.IS_DYNAMIC_NODE_POSES = not grid.style.IS_DYNAMIC_NODE_POSES - grid:refresh() - end) - - properties_panel:add_checkbox("ui_align_last_row", grid.style.IS_ALIGN_LAST_ROW, function() - grid.style.IS_ALIGN_LAST_ROW = not grid.style.IS_ALIGN_LAST_ROW - grid:refresh() - end) - - local pivot_index = 1 - local pivot_list = { - gui.PIVOT_CENTER, - gui.PIVOT_W, - gui.PIVOT_SW, - gui.PIVOT_S, - gui.PIVOT_SE, - gui.PIVOT_E, - gui.PIVOT_NE, - gui.PIVOT_N, - gui.PIVOT_NW, - } - - properties_panel:add_button("ui_pivot_next", function() - pivot_index = pivot_index + 1 - if pivot_index > #pivot_list then - pivot_index = 1 - end - grid:set_pivot(pivot_list[pivot_index]) - end) - - local slider_size = properties_panel:add_slider("ui_item_size", 0.5, function(value) - local size = 50 + value * 100 - grid:set_item_size(size, size) - end) - slider_size:set_text_function(function(value) - return tostring(50 + math.ceil(value * 100)) - end) - slider_size:set_value(0.5) - end, - get_debug_info = function(instance) - ---@cast instance examples.grid - local info = "" - - local grid = instance.grid - info = info .. "Grid Items: " .. #grid.nodes .. "\n" - info = info .. "Grid Item Size: " .. grid.node_size.x .. " x " .. grid.node_size.y .. "\n" - info = info .. "Pivot: " .. tostring(grid.pivot) - - return info - end }, { name_id = "ui_example_basic_scroll_bind_grid", @@ -431,51 +170,6 @@ function M.get_examples() root = "scroll_bind_grid/root", code_url = "example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua", widget_class = require("example.examples.basic.scroll_bind_grid.scroll_bind_grid"), - properties_control = function(instance, properties_panel) - ---@cast instance examples.scroll_bind_grid - - local view_node = instance.scroll.view_node - local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL - properties_panel:add_checkbox("ui_clipping", is_stencil, function(value) - gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE) - end) - - properties_panel:add_button("ui_add_element", function() - if #instance.created_nodes >= 100 then - return - end - instance:add_element() - end) - - properties_panel:add_button("ui_remove_element", function() - instance:remove_element() - end) - - properties_panel:add_button("ui_clear_elements", function() - instance:clear() - end) - end, - get_debug_info = function(instance) - ---@cast instance examples.scroll_bind_grid - local info = "" - - local s = instance.scroll - local view_node_size = gui.get(s.view_node, "size.y") - local scroll_position = -s.position - local scroll_bottom_position = vmath.vector3(scroll_position.x, scroll_position.y - view_node_size, scroll_position.z) - - info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n" - info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n" - info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n" - info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n" - info = info .. "Grid Items: " .. #instance.grid.nodes .. "\n" - info = info .. "Grid Item Size: " .. instance.grid.node_size.x .. " x " .. instance.grid.node_size.y .. "\n" - info = info .. "Top Scroll Pos Grid Index: " .. instance.grid:get_index(scroll_position) .. "\n" - info = info .. "Bottm Scroll Pos Grid Index: " .. instance.grid:get_index(scroll_bottom_position) .. "\n" - - - return info - end }, { name_id = "ui_example_basic_scroll_bind_grid_horizontal", @@ -484,52 +178,6 @@ function M.get_examples() root = "scroll_bind_grid_horizontal/root", code_url = "example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua", widget_class = require("example.examples.basic.scroll_bind_grid.scroll_bind_grid_horizontal"), - properties_control = function(instance, properties_panel) - ---@cast instance examples.scroll_bind_grid_horizontal - - local view_node = instance.scroll.view_node - local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL - - properties_panel:add_checkbox("ui_clipping", is_stencil, function(value) - gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE) - end) - - - properties_panel:add_button("ui_add_element", function() - if #instance.created_nodes >= 100 then - return - end - instance:add_element() - end) - - properties_panel:add_button("ui_remove_element", function() - instance:remove_element() - end) - - properties_panel:add_button("ui_clear_elements", function() - instance:clear() - end) - end, - get_debug_info = function(instance) - ---@cast instance examples.scroll_bind_grid_horizontal - local info = "" - - local s = instance.scroll - local view_node_size = gui.get(s.view_node, "size.x") - local scroll_position = -s.position - local scroll_bottom_position = vmath.vector3(scroll_position.x + view_node_size, scroll_position.y, scroll_position.z) - - info = info .. "View Size X: " .. gui.get(s.view_node, "size.x") .. "\n" - info = info .. "Content Size X: " .. gui.get(s.content_node, "size.x") .. "\n" - info = info .. "Content position X: " .. math.ceil(s.position.x) .. "\n" - info = info .. "Content Range X: " .. s.available_pos.x .. " - " .. s.available_pos.z .. "\n" - info = info .. "Grid Items: " .. #instance.grid.nodes .. "\n" - info = info .. "Grid Item Size: " .. instance.grid.node_size.x .. " x " .. instance.grid.node_size.y .. "\n" - info = info .. "Left Scroll Pos Grid Index: " .. instance.grid:get_index(scroll_position) .. "\n" - info = info .. "Right Scroll Pos Grid Index: " .. instance.grid:get_index(scroll_bottom_position) .. "\n" - - return info - end }, { name_id = "ui_example_basic_scroll_bind_grid_points", @@ -538,51 +186,6 @@ function M.get_examples() root = "scroll_bind_grid_points/root", code_url = "example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua", widget_class = require("example.examples.basic.scroll_bind_grid.scroll_bind_grid_points"), - properties_control = function(instance, properties_panel) - ---@cast instance examples.scroll_bind_grid_points - - local view_node = instance.scroll.view_node - local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL - properties_panel:add_checkbox("ui_clipping", is_stencil, function(value) - gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE) - end) - - properties_panel:add_button("ui_add_element", function() - if #instance.created_nodes >= 100 then - return - end - instance:add_element() - end) - - properties_panel:add_button("ui_remove_element", function() - instance:remove_element() - end) - - properties_panel:add_button("ui_clear_elements", function() - instance:clear() - end) - end, - get_debug_info = function(instance) - ---@cast instance examples.scroll_bind_grid_points - local info = "" - - local s = instance.scroll - local view_node_size = gui.get(s.view_node, "size.y") - local scroll_position = -s.position - local scroll_bottom_position = vmath.vector3(scroll_position.x, scroll_position.y - view_node_size, scroll_position.z) - - info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n" - info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n" - info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n" - info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n" - info = info .. "Grid Items: " .. #instance.grid.nodes .. "\n" - info = info .. "Grid Item Size: " .. instance.grid.node_size.x .. " x " .. instance.grid.node_size.y .. "\n" - info = info .. "Top Scroll Pos Grid Index: " .. instance.grid:get_index(scroll_position) .. "\n" - info = info .. "Bottm Scroll Pos Grid Index: " .. instance.grid:get_index(scroll_bottom_position) .. "\n" - - - return info - end }, { name_id = "ui_example_basic_input", @@ -591,21 +194,6 @@ function M.get_examples() root = "basic_input/root", code_url = "example/examples/basic/input/basic_input.lua", widget_class = require("example.examples.basic.input.basic_input"), - on_create = function(instance, output_log) - ---@cast instance examples.basic_input - instance.input.on_input_select:subscribe(function() - output_log:add_log_text("Input Selected") - end) - instance.input_2.on_input_select:subscribe(function() - output_log:add_log_text("Input 2 Selected") - end) - instance.input.on_input_unselect:subscribe(function(_, text) - output_log:add_log_text("Input Deselected. Text: " .. text) - end) - instance.input_2.on_input_unselect:subscribe(function(_, text) - output_log:add_log_text("Input Deselected. Text: " .. text) - end) - end, }, { name_id = "ui_example_input_password", @@ -614,12 +202,6 @@ function M.get_examples() root = "input_password/root", code_url = "example/examples/basic/input/input_password.lua", widget_class = require("example.examples.basic.input.input_password"), - on_create = function(instance, output_log) - ---@cast instance examples.input_password - instance.input.on_input_unselect:subscribe(function(_, text) - output_log:add_log_text("Input: " .. text) - end) - end, }, { name_id = "ui_example_basic_rich_input", @@ -628,15 +210,6 @@ function M.get_examples() root = "basic_rich_input/root", code_url = "example/examples/basic/input/rich_input.lua", widget_class = require("example.examples.basic.input.rich_input"), - on_create = function(instance, output_log) - ---@cast instance examples.rich_input - instance.rich_input.input.on_input_unselect:subscribe(function(_, text) - output_log:add_log_text("Input: " .. text) - end) - instance.rich_input_2.input.on_input_unselect:subscribe(function(_, text) - output_log:add_log_text("Input 2: " .. text) - end) - end, }, { name_id = "ui_example_basic_rich_text", @@ -653,29 +226,6 @@ function M.get_examples() root = "rich_text_tags/root", code_url = "example/examples/basic/rich_text/rich_text_tags.lua", widget_class = require("example.examples.basic.rich_text.rich_text_tags"), - properties_control = function(instance, properties_panel) - local pivot_index = 1 - local pivot_list = { - gui.PIVOT_CENTER, - gui.PIVOT_W, - gui.PIVOT_SW, - gui.PIVOT_S, - gui.PIVOT_SE, - gui.PIVOT_E, - gui.PIVOT_NE, - gui.PIVOT_N, - gui.PIVOT_NW, - } - - ---@cast instance examples.rich_text_tags - properties_panel:add_button("ui_pivot_next", function() - pivot_index = pivot_index + 1 - if pivot_index > #pivot_list then - pivot_index = 1 - end - instance:set_pivot(pivot_list[pivot_index]) - end) - end }, --{ -- name_id = "ui_example_rich_text_tags_custom", @@ -722,12 +272,6 @@ function M.get_examples() root = "basic_swipe/root", code_url = "example/examples/basic/swipe/basic_swipe.lua", widget_class = require("example.examples.basic.swipe.basic_swipe"), - on_create = function(instance, output_log) - ---@cast instance examples.basic_swipe - instance.swipe.on_swipe:subscribe(function(_, side, dist, delta_time) - output_log:add_log_text("Swipe Side: " .. side) - end) - end, }, { name_id = "ui_example_checkbox", @@ -736,12 +280,6 @@ function M.get_examples() root = "checkbox/root", code_url = "example/examples/basic/checkbox/checkbox.lua", widget_class = require("example.examples.basic.checkbox.checkbox"), - on_create = function(instance, output_log) - ---@cast instance examples.checkbox - instance.button.on_click:subscribe(function() - output_log:add_log_text("Checkbox Clicked: " .. tostring(instance.is_enabled)) - end) - end, }, { name_id = "ui_example_checkbox_group", @@ -750,12 +288,6 @@ function M.get_examples() root = "checkbox_group/root", code_url = "example/examples/basic/checkbox_group/checkbox_group.lua", widget_class = require("example.examples.basic.checkbox_group.checkbox_group"), - on_create = function(instance, output_log) - ---@cast instance examples.checkbox_group - instance.on_state_changed:subscribe(function(state1, state2, state3) - output_log:add_log_text("State: " .. tostring(state1) .. " " .. tostring(state2) .. " " .. tostring(state3)) - end) - end, }, { name_id = "ui_example_radio_group", @@ -764,12 +296,6 @@ function M.get_examples() root = "radio_group/root", code_url = "example/examples/basic/radio_group/radio_group.lua", widget_class = require("example.examples.basic.radio_group.radio_group"), - on_create = function(instance, output_log) - ---@cast instance examples.radio_group - instance.on_state_changed:subscribe(function(selected) - output_log:add_log_text("Selected: " .. selected) - end) - end, }, } end diff --git a/example/examples/basic/grid/grid.lua b/example/examples/basic/grid/grid.lua index cf8d8ac..874896d 100644 --- a/example/examples/basic/grid/grid.lua +++ b/example/examples/basic/grid/grid.lua @@ -55,4 +55,86 @@ function M:clear() end +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + local grid = self.grid + + local slider = properties_panel:add_slider("ui_grid_in_row", 0.3, function(value) + local in_row_amount = math.ceil(value * 10) + in_row_amount = math.max(1, in_row_amount) + grid:set_in_row(in_row_amount) + end) + slider:set_text_function(function(value) + return tostring(math.ceil(value * 10)) + end) + + properties_panel:add_button("ui_add_element", function() + if #self.created_nodes >= 36 then + return + end + self:add_element() + end) + + properties_panel:add_button("ui_remove_element", function() + self:remove_element() + end) + + properties_panel:add_button("ui_clear_elements", function() + self:clear() + end) + + properties_panel:add_checkbox("ui_dynamic_pos", grid.style.IS_DYNAMIC_NODE_POSES, function() + grid.style.IS_DYNAMIC_NODE_POSES = not grid.style.IS_DYNAMIC_NODE_POSES + grid:refresh() + end) + + properties_panel:add_checkbox("ui_align_last_row", grid.style.IS_ALIGN_LAST_ROW, function() + grid.style.IS_ALIGN_LAST_ROW = not grid.style.IS_ALIGN_LAST_ROW + grid:refresh() + end) + + local pivot_index = 1 + local pivot_list = { + gui.PIVOT_CENTER, + gui.PIVOT_W, + gui.PIVOT_SW, + gui.PIVOT_S, + gui.PIVOT_SE, + gui.PIVOT_E, + gui.PIVOT_NE, + gui.PIVOT_N, + gui.PIVOT_NW, + } + + properties_panel:add_button("ui_pivot_next", function() + pivot_index = pivot_index + 1 + if pivot_index > #pivot_list then + pivot_index = 1 + end + grid:set_pivot(pivot_list[pivot_index]) + end) + + local slider_size = properties_panel:add_slider("ui_item_size", 0.5, function(value) + local size = 50 + value * 100 + grid:set_item_size(size, size) + end) + slider_size:set_text_function(function(value) + return tostring(50 + math.ceil(value * 100)) + end) + slider_size:set_value(0.5) +end + + +---@return string +function M:get_debug_info() + local info = "" + + info = info .. "Grid Items: " .. #self.grid.nodes .. "\n" + info = info .. "Grid Item Size: " .. self.grid.node_size.x .. " x " .. self.grid.node_size.y .. "\n" + info = info .. "Pivot: " .. tostring(self.grid.pivot) + + return info +end + + return M diff --git a/example/examples/basic/hotkey/basic_hotkey.lua b/example/examples/basic/hotkey/basic_hotkey.lua index a43ffa8..829d456 100644 --- a/example/examples/basic/hotkey/basic_hotkey.lua +++ b/example/examples/basic/hotkey/basic_hotkey.lua @@ -16,4 +16,12 @@ function M:on_hotkey() end +---@param output_log output_list +function M:on_example_created(output_log) + self.hotkey.on_hotkey_released:subscribe(function() + output_log:add_log_text("Hotkey Released") + end) +end + + return M diff --git a/example/examples/basic/input/basic_input.lua b/example/examples/basic/input/basic_input.lua index a59d593..c169756 100644 --- a/example/examples/basic/input/basic_input.lua +++ b/example/examples/basic/input/basic_input.lua @@ -14,4 +14,21 @@ function M:init() end +---@param output_log output_list +function M:on_example_created(output_log) + self.input.on_input_select:subscribe(function() + output_log:add_log_text("Input Selected") + end) + self.input_2.on_input_select:subscribe(function() + output_log:add_log_text("Input 2 Selected") + end) + self.input.on_input_unselect:subscribe(function(_, text) + output_log:add_log_text("Input Deselected. Text: " .. text) + end) + self.input_2.on_input_unselect:subscribe(function(_, text) + output_log:add_log_text("Input Deselected. Text: " .. text) + end) +end + + return M diff --git a/example/examples/basic/input/input_password.lua b/example/examples/basic/input/input_password.lua index 5b1701e..d9af327 100644 --- a/example/examples/basic/input/input_password.lua +++ b/example/examples/basic/input/input_password.lua @@ -15,4 +15,12 @@ function M:init() end +---@param output_log output_list +function M:on_example_created(output_log) + self.input.on_input_unselect:subscribe(function(_, text) + output_log:add_log_text("Input: " .. text) + end) +end + + return M diff --git a/example/examples/basic/input/rich_input.lua b/example/examples/basic/input/rich_input.lua index 56bc6e3..606ffbc 100644 --- a/example/examples/basic/input/rich_input.lua +++ b/example/examples/basic/input/rich_input.lua @@ -13,4 +13,15 @@ function M:init() end +---@param output_log output_list +function M:on_example_created(output_log) + self.rich_input.input.on_input_unselect:subscribe(function(_, text) + output_log:add_log_text("Input: " .. text) + end) + self.rich_input_2.input.on_input_unselect:subscribe(function(_, text) + output_log:add_log_text("Input 2: " .. text) + end) +end + + return M diff --git a/example/examples/basic/progress_bar/basic_progress_bar.lua b/example/examples/basic/progress_bar/basic_progress_bar.lua index 4929507..c742668 100644 --- a/example/examples/basic/progress_bar/basic_progress_bar.lua +++ b/example/examples/basic/progress_bar/basic_progress_bar.lua @@ -16,4 +16,12 @@ function M:set_value(value) end +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + properties_panel:add_slider("ui_value", 1, function(value) + self:set_value(value) + end) +end + + return M diff --git a/example/examples/basic/progress_bar/basic_progress_bar_slice9.lua b/example/examples/basic/progress_bar/basic_progress_bar_slice9.lua index 24629d0..1708779 100644 --- a/example/examples/basic/progress_bar/basic_progress_bar_slice9.lua +++ b/example/examples/basic/progress_bar/basic_progress_bar_slice9.lua @@ -16,4 +16,12 @@ function M:set_value(value) end +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + properties_panel:add_slider("ui_value", 1, function(value) + self:set_value(value) + end) +end + + return M diff --git a/example/examples/basic/radio_group/radio_group.lua b/example/examples/basic/radio_group/radio_group.lua index 098db97..25a453f 100644 --- a/example/examples/basic/radio_group/radio_group.lua +++ b/example/examples/basic/radio_group/radio_group.lua @@ -47,4 +47,12 @@ function M:on_checkbox_click() end +---@param output_log output_list +function M:on_example_created(output_log) + self.on_state_changed:subscribe(function(selected) + output_log:add_log_text("Selected: " .. selected) + end) +end + + return M diff --git a/example/examples/basic/rich_text/rich_text_tags.lua b/example/examples/basic/rich_text/rich_text_tags.lua index dcf2d7f..a1c803d 100644 --- a/example/examples/basic/rich_text/rich_text_tags.lua +++ b/example/examples/basic/rich_text/rich_text_tags.lua @@ -71,4 +71,29 @@ function M:set_pivot(pivot) end +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + local pivot_index = 1 + local pivot_list = { + gui.PIVOT_CENTER, + gui.PIVOT_W, + gui.PIVOT_SW, + gui.PIVOT_S, + gui.PIVOT_SE, + gui.PIVOT_E, + gui.PIVOT_NE, + gui.PIVOT_N, + gui.PIVOT_NW, + } + + properties_panel:add_button("ui_pivot_next", function() + pivot_index = pivot_index + 1 + if pivot_index > #pivot_list then + pivot_index = 1 + end + self:set_pivot(pivot_list[pivot_index]) + end) +end + + return M diff --git a/example/examples/basic/scroll/scroll.lua b/example/examples/basic/scroll/scroll.lua index 20bca57..6e695d3 100644 --- a/example/examples/basic/scroll/scroll.lua +++ b/example/examples/basic/scroll/scroll.lua @@ -13,4 +13,74 @@ function M:init() end +---@param output_log output_list +function M:on_example_created(output_log) + self.button_tutorial.on_click:subscribe(function() + output_log:add_log_text("Button Tutorial Clicked") + end) + self.button_stencil.on_click:subscribe(function() + output_log:add_log_text("Button Stencil Clicked") + end) +end + + +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + local scroll = self.scroll + local is_stretch = self.scroll.style.EXTRA_STRETCH_SIZE > 0 + properties_panel:add_checkbox("ui_elastic_scroll", is_stretch, function(value) + self.scroll:set_extra_stretch_size(value and 100 or 0) + end) + + local view_node = self.scroll.view_node + local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL + properties_panel:add_checkbox("ui_clipping", is_stencil, function(value) + gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE) + end) + + local slider_frict = properties_panel:add_slider("ui_slider_friction", 0, function(value) + scroll.style.FRICT = 1 - ((1 - value) * 0.1) + end) + slider_frict:set_text_function(function(value) + return string.format("%.2f", 1 - ((1 - value) * 0.1)) + end) + slider_frict:set_value(1 - (1 - scroll.style.FRICT) / 0.1) + + local slider_speed = properties_panel:add_slider("ui_slider_speed", 0, function(value) + scroll.style.INERT_SPEED = value * 50 + end) + slider_speed:set_value(scroll.style.INERT_SPEED / 50) + slider_speed:set_text_function(function(value) + return string.format("%.1f", value * 50) + end) + + local slider_wheel_speed = properties_panel:add_slider("ui_slider_wheel_speed", 0, function(value) + scroll.style.WHEEL_SCROLL_SPEED = value * 30 + end) + slider_wheel_speed:set_value(scroll.style.WHEEL_SCROLL_SPEED / 30) + slider_wheel_speed:set_text_function(function(value) + return string.format("%.1f", value * 30) + end) + + local wheel_by_inertion = properties_panel:add_checkbox("ui_wheel_by_inertion", scroll.style.WHEEL_SCROLL_BY_INERTION, function(value) + scroll.style.WHEEL_SCROLL_BY_INERTION = value + end) + wheel_by_inertion:set_value(scroll.style.WHEEL_SCROLL_BY_INERTION) +end + + +---@return string +function M:get_debug_info() + local info = "" + + local s = self.scroll + info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n" + info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n" + info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n" + info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n" + + return info +end + + return M diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua b/example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua index db4d0f9..af15637 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid.lua @@ -58,4 +58,51 @@ function M:clear() end +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + local view_node = self.scroll.view_node + local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL + properties_panel:add_checkbox("ui_clipping", is_stencil, function(value) + gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE) + end) + + properties_panel:add_button("ui_add_element", function() + if #self.created_nodes >= 100 then + return + end + self:add_element() + end) + + properties_panel:add_button("ui_remove_element", function() + self:remove_element() + end) + + properties_panel:add_button("ui_clear_elements", function() + self:clear() + end) +end + + +---@return string +function M:get_debug_info() + local info = "" + + local s = self.scroll + local view_node_size = gui.get(s.view_node, "size.y") + local scroll_position = -s.position + local scroll_bottom_position = vmath.vector3(scroll_position.x, scroll_position.y - view_node_size, scroll_position.z) + + info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n" + info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n" + info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n" + info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n" + info = info .. "Grid Items: " .. #self.grid.nodes .. "\n" + info = info .. "Grid Item Size: " .. self.grid.node_size.x .. " x " .. self.grid.node_size.y .. "\n" + info = info .. "Top Scroll Pos Grid Index: " .. self.grid:get_index(scroll_position) .. "\n" + info = info .. "Bottm Scroll Pos Grid Index: " .. self.grid:get_index(scroll_bottom_position) .. "\n" + + return info +end + + return M diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua index 416e01f..69f65e7 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_horizontal.lua @@ -58,4 +58,53 @@ function M:clear() end +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + local view_node = self.scroll.view_node + local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL + + properties_panel:add_checkbox("ui_clipping", is_stencil, function(value) + gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE) + end) + + + properties_panel:add_button("ui_add_element", function() + if #self.created_nodes >= 100 then + return + end + self:add_element() + end) + + properties_panel:add_button("ui_remove_element", function() + self:remove_element() + end) + + properties_panel:add_button("ui_clear_elements", function() + self:clear() + end) +end + + +---@return string +function M:get_debug_info() + local info = "" + + local s = self.scroll + local view_node_size = gui.get(s.view_node, "size.x") + local scroll_position = -s.position + local scroll_bottom_position = vmath.vector3(scroll_position.x + view_node_size, scroll_position.y, scroll_position.z) + + info = info .. "View Size X: " .. gui.get(s.view_node, "size.x") .. "\n" + info = info .. "Content Size X: " .. gui.get(s.content_node, "size.x") .. "\n" + info = info .. "Content position X: " .. math.ceil(s.position.x) .. "\n" + info = info .. "Content Range X: " .. s.available_pos.x .. " - " .. s.available_pos.z .. "\n" + info = info .. "Grid Items: " .. #self.grid.nodes .. "\n" + info = info .. "Grid Item Size: " .. self.grid.node_size.x .. " x " .. self.grid.node_size.y .. "\n" + info = info .. "Left Scroll Pos Grid Index: " .. self.grid:get_index(scroll_position) .. "\n" + info = info .. "Right Scroll Pos Grid Index: " .. self.grid:get_index(scroll_bottom_position) .. "\n" + + return info +end + + return M diff --git a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua index 01990c9..7618dde 100644 --- a/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua +++ b/example/examples/basic/scroll_bind_grid/scroll_bind_grid_points.lua @@ -64,4 +64,51 @@ function M:clear() end +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + local view_node = self.scroll.view_node + local is_stencil = gui.get_clipping_mode(view_node) == gui.CLIPPING_MODE_STENCIL + properties_panel:add_checkbox("ui_clipping", is_stencil, function(value) + gui.set_clipping_mode(view_node, value and gui.CLIPPING_MODE_STENCIL or gui.CLIPPING_MODE_NONE) + end) + + properties_panel:add_button("ui_add_element", function() + if #self.created_nodes >= 100 then + return + end + self:add_element() + end) + + properties_panel:add_button("ui_remove_element", function() + self:remove_element() + end) + + properties_panel:add_button("ui_clear_elements", function() + self:clear() + end) +end + + +---@return string +function M:get_debug_info() + local info = "" + + local s = self.scroll + local view_node_size = gui.get(s.view_node, "size.y") + local scroll_position = -s.position + local scroll_bottom_position = vmath.vector3(scroll_position.x, scroll_position.y - view_node_size, scroll_position.z) + + info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n" + info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n" + info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n" + info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n" + info = info .. "Grid Items: " .. #self.grid.nodes .. "\n" + info = info .. "Grid Item Size: " .. self.grid.node_size.x .. " x " .. self.grid.node_size.y .. "\n" + info = info .. "Top Scroll Pos Grid Index: " .. self.grid:get_index(scroll_position) .. "\n" + info = info .. "Bottm Scroll Pos Grid Index: " .. self.grid:get_index(scroll_bottom_position) .. "\n" + + return info +end + + return M diff --git a/example/examples/basic/scroll_slider/scroll_slider.lua b/example/examples/basic/scroll_slider/scroll_slider.lua index a5d8df2..6304089 100644 --- a/example/examples/basic/scroll_slider/scroll_slider.lua +++ b/example/examples/basic/scroll_slider/scroll_slider.lua @@ -43,4 +43,18 @@ function M:on_slider_back_hover(is_hover) end +---@return string +function M:get_debug_info() + local info = "" + + local s = self.scroll + info = info .. "View Size Y: " .. gui.get(s.view_node, "size.y") .. "\n" + info = info .. "Content Size Y: " .. gui.get(s.content_node, "size.y") .. "\n" + info = info .. "Content position Y: " .. math.ceil(s.position.y) .. "\n" + info = info .. "Content Range Y: " .. s.available_pos.y .. " - " .. s.available_pos.w .. "\n" + + return info +end + + return M diff --git a/example/examples/basic/slider/basic_slider.lua b/example/examples/basic/slider/basic_slider.lua index 0063c30..85d74f4 100644 --- a/example/examples/basic/slider/basic_slider.lua +++ b/example/examples/basic/slider/basic_slider.lua @@ -1,3 +1,5 @@ +local helper = require("druid.helper") + ---@class examples.basic_slider: druid.widget ---@field root node ---@field slider druid.slider @@ -18,4 +20,13 @@ function M:on_slider_change(value) end +---@param output_log output_list +function M:on_example_created(output_log) + self.slider.on_change_value:subscribe(function(_, value) + value = helper.round(value, 2) + output_log:add_log_text("Slider Value: " .. value) + end) +end + + return M diff --git a/example/examples/basic/slider/basic_slider_stepped.lua b/example/examples/basic/slider/basic_slider_stepped.lua index bd08ce4..06a14bd 100644 --- a/example/examples/basic/slider/basic_slider_stepped.lua +++ b/example/examples/basic/slider/basic_slider_stepped.lua @@ -1,3 +1,5 @@ +local helper = require("druid.helper") + ---@class examples.basic_slider_stepped: druid.widget ---@field root node ---@field slider druid.slider @@ -20,4 +22,13 @@ function M:on_slider_change(value) end +---@param output_log output_list +function M:on_example_created(output_log) + self.slider.on_change_value:subscribe(function(_, value) + value = helper.round(value, 2) + output_log:add_log_text("Slider Value: " .. value) + end) +end + + return M diff --git a/example/examples/basic/slider/basic_slider_vertical.lua b/example/examples/basic/slider/basic_slider_vertical.lua index 46bed0d..c340bd8 100644 --- a/example/examples/basic/slider/basic_slider_vertical.lua +++ b/example/examples/basic/slider/basic_slider_vertical.lua @@ -1,3 +1,5 @@ +local helper = require("druid.helper") + ---@class examples.basic_slider_vertical: druid.widget ---@field root node ---@field slider druid.slider @@ -18,4 +20,14 @@ function M:on_slider_change(value) end +---@param output_log output_list +function M:on_example_created(output_log) + self.slider.on_change_value:subscribe(function(_, value) + value = helper.round(value, 2) + output_log:add_log_text("Slider Value: " .. value) + end) +end + + + return M diff --git a/example/examples/basic/swipe/basic_swipe.lua b/example/examples/basic/swipe/basic_swipe.lua index 8070365..5ef7d6a 100644 --- a/example/examples/basic/swipe/basic_swipe.lua +++ b/example/examples/basic/swipe/basic_swipe.lua @@ -25,4 +25,12 @@ function M:on_swipe(swipe_side, dist, delta_time) end +---@param output_log output_list +function M:on_example_created(output_log) + self.swipe.on_swipe:subscribe(function(_, side, dist, delta_time) + output_log:add_log_text("Swipe Side: " .. side) + end) +end + + return M diff --git a/example/examples/basic/text/multiline_text.lua b/example/examples/basic/text/multiline_text.lua index 415c511..a28be61 100644 --- a/example/examples/basic/text/multiline_text.lua +++ b/example/examples/basic/text/multiline_text.lua @@ -32,4 +32,56 @@ function M:refresh_text_position() end +---@param properties_panel properties_panel +function M:properties_control(properties_panel) + local adjust_index = 1 + local adjust_types = { + "downscale", + "downscale_limited", + --"scale_then_scroll", -- works bad with container for some reason + --"scroll", -- works bad with container for some reason + "trim", + } + properties_panel:add_button("ui_adjust_next", function() + adjust_index = adjust_index + 1 + if adjust_index > #adjust_types then + adjust_index = 1 + end + self.text:set_text_adjust(adjust_types[adjust_index], 0.8) + end) + + local pivot_index = 1 + local pivot_list = { + gui.PIVOT_CENTER, + gui.PIVOT_W, + gui.PIVOT_SW, + gui.PIVOT_S, + gui.PIVOT_SE, + gui.PIVOT_E, + gui.PIVOT_NE, + gui.PIVOT_N, + gui.PIVOT_NW, + } + + properties_panel:add_button("ui_pivot_next", function() + pivot_index = pivot_index + 1 + if pivot_index > #pivot_list then + pivot_index = 1 + end + self:set_pivot(pivot_list[pivot_index]) + end) +end + + +---@return string +function M:get_debug_info() + local info = "" + + info = info .. "Text Adjust: " .. self.text.adjust_type .. "\n" + info = info .. "Pivot: " .. gui.get_pivot(self.text.node) .. "\n" + + return info +end + + return M diff --git a/example/examples/basic/timer/basic_timer.lua b/example/examples/basic/timer/basic_timer.lua index 89d7ecc..19e9efa 100644 --- a/example/examples/basic/timer/basic_timer.lua +++ b/example/examples/basic/timer/basic_timer.lua @@ -21,4 +21,12 @@ function M:init() end +---@param output_log output_list +function M:on_example_created(output_log) + self.on_cycle_end:subscribe(function() + output_log:add_log_text("Timer Cycle End") + end) +end + + return M diff --git a/game.project b/game.project index a00b8f5..03b90d8 100644 --- a/game.project +++ b/game.project @@ -107,3 +107,5 @@ path = /example/locales langs = en,ru,es,de,fr,ja,pt,it,kr,zh default = es +[event] +use_xpcall = 1