diff --git a/druid/base/button.lua b/druid/base/button.lua index 840597c..120cdd6 100755 --- a/druid/base/button.lua +++ b/druid/base/button.lua @@ -92,6 +92,18 @@ function M:on_style_change(style) end +---@return druid.button self +function M:set_animations_disabled() + self.style.on_click = function() end + self.style.on_click_disabled = function() end + self.style.on_mouse_hover = function() end + self.style.on_hover = function() end + self.style.on_set_enabled = function() end + + return self +end + + function M:on_late_init() if not self.click_zone then local stencil_node = helper.get_closest_stencil_node(self.node) diff --git a/druid/base/hover.lua b/druid/base/hover.lua index 82473eb..43723b3 100644 --- a/druid/base/hover.lua +++ b/druid/base/hover.lua @@ -9,8 +9,8 @@ local component = require("druid.component") ---@class druid.hover: druid.component ---@field node node ----@field on_hover event ----@field on_mouse_hover event +---@field on_hover event fun(self: druid.hover, is_hover: boolean) +---@field on_mouse_hover event fun(self: druid.hover, is_hover: boolean) ---@field style druid.hover.style ---@field click_zone node ---@field private _is_hovered boolean|nil diff --git a/druid/druid.lua b/druid/druid.lua index 31c6e70..11adfc1 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -113,8 +113,8 @@ end ---Get a binded widget to the current game object. ---@generic T: druid.widget ---@param widget_class T The class of the widget to return ----@param gui_url_string string GUI url, if nil current gui will be used ----@return T|nil +---@param gui_url_string string? GUI url, if nil current gui will be used +---@return T function M.get_widget(widget_class, gui_url_string) local gui_url = msg.url(gui_url_string) local guis = REGISTERED_GUI_WIDGETS[gui_url.socket] @@ -135,7 +135,7 @@ end ---Register a widget to the current game object. ---@param druid druid.instance The druid instance to register -function M.register_gui_widget(druid) +function M.register_druid_as_widget(druid) local gui_url = msg.url() REGISTERED_GUI_WIDGETS[gui_url.socket] = REGISTERED_GUI_WIDGETS[gui_url.socket] or {} table.insert(REGISTERED_GUI_WIDGETS[gui_url.socket], { @@ -147,4 +147,5 @@ function M.register_gui_widget(druid) }) end + return M diff --git a/druid/druid.gui_script b/druid/druid_widget.gui_script similarity index 90% rename from druid/druid.gui_script rename to druid/druid_widget.gui_script index 43dc816..335ec6d 100644 --- a/druid/druid.gui_script +++ b/druid/druid_widget.gui_script @@ -3,7 +3,7 @@ local druid = require("druid.druid") function init(self) self.druid = druid.new(self) - druid.register_gui_widget(self.druid) + druid.register_druid_as_widget(self.druid) end diff --git a/druid/extended/input.lua b/druid/extended/input.lua index 6cdab63..46cb305 100755 --- a/druid/extended/input.lua +++ b/druid/extended/input.lua @@ -14,13 +14,13 @@ local utf8 = utf8 or utf8_lua ---@field on_input_wrong fun(self: druid.input, button_node: node) Callback on wrong user input ---@class druid.input: druid.component ----@field on_input_select event ----@field on_input_unselect event ----@field on_input_text event ----@field on_input_empty event ----@field on_input_full event ----@field on_input_wrong event ----@field on_select_cursor_change event +---@field on_input_select event fun(self: druid.input, input: druid.input) +---@field on_input_unselect event fun(self: druid.input, text: string, input: druid.input) +---@field on_input_text event fun(self: druid.input) +---@field on_input_empty event fun(self: druid.input) +---@field on_input_full event fun(self: druid.input) +---@field on_input_wrong event fun(self: druid.input) +---@field on_select_cursor_change event fun(self: druid.input, cursor_index: number, start_index: number, end_index: number) ---@field style table ---@field text druid.text local M = component.create("input") diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index 031378a..3b8295d 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -700,7 +700,7 @@ end local hotkey = require("druid.extended.hotkey") ---Create Hotkey component ---@param keys_array string|string[] Keys for trigger action. Should contains one action key and any amount of modificator keys ----@param callback function|nil The callback function +---@param callback function|event|nil The callback function ---@param callback_argument any|nil The argument to pass into the callback function ---@return druid.hotkey component Hotkey component function M:new_hotkey(keys_array, callback, callback_argument) diff --git a/druid/widget/properties_panel/properties/property_input.lua b/druid/widget/properties_panel/properties/property_input.lua index 0301ba8..9fd101a 100644 --- a/druid/widget/properties_panel/properties/property_input.lua +++ b/druid/widget/properties_panel/properties/property_input.lua @@ -30,14 +30,16 @@ function M:set_text_property(text) end ----@param text string +---@param text string|number ---@return widget.property_input function M:set_text_value(text) - self.rich_input:set_text(text) + self.rich_input:set_text(tostring(text)) return self end +---@param callback fun(self: widget.property_input, text: string) +---@param callback_context any function M:on_change(callback, callback_context) self.rich_input.input.on_input_unselect:subscribe(callback, callback_context) end diff --git a/druid/widget/properties_panel/properties/property_slider.lua b/druid/widget/properties_panel/properties/property_slider.lua index bbbb9ec..780f469 100644 --- a/druid/widget/properties_panel/properties/property_slider.lua +++ b/druid/widget/properties_panel/properties/property_slider.lua @@ -8,6 +8,7 @@ local helper = require("druid.helper") ---@field text_name druid.text ---@field text_value druid.text ---@field slider druid.slider +---@field on_change_value event fun(value:number) local M = {} diff --git a/docs_md/01-components.md b/wiki/01-components.md similarity index 100% rename from docs_md/01-components.md rename to wiki/01-components.md diff --git a/docs_md/02-creating_custom_components.md b/wiki/02-creating_custom_components.md similarity index 100% rename from docs_md/02-creating_custom_components.md rename to wiki/02-creating_custom_components.md diff --git a/docs_md/03-styles.md b/wiki/03-styles.md similarity index 100% rename from docs_md/03-styles.md rename to wiki/03-styles.md diff --git a/docs_md/FAQ.md b/wiki/FAQ.md similarity index 100% rename from docs_md/FAQ.md rename to wiki/FAQ.md diff --git a/docs_md/advanced-setup.md b/wiki/advanced-setup.md similarity index 100% rename from docs_md/advanced-setup.md rename to wiki/advanced-setup.md diff --git a/docs_md/changelog.md b/wiki/changelog.md similarity index 100% rename from docs_md/changelog.md rename to wiki/changelog.md diff --git a/docs_md/optimize_druid_size.md b/wiki/optimize_druid_size.md similarity index 100% rename from docs_md/optimize_druid_size.md rename to wiki/optimize_druid_size.md diff --git a/docs_md/widgets.md b/wiki/widgets.md similarity index 100% rename from docs_md/widgets.md rename to wiki/widgets.md