From 7a6f529c82b04a83e898efb008b2cb3cbecd0071 Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 8 Feb 2025 00:28:20 +0200 Subject: [PATCH] Update --- druid/base/scroll.lua | 5 +++-- druid/base/static_grid.lua | 8 +++++--- druid/component.lua | 2 +- druid/custom/rich_text/rich_text.lua | 7 +++++++ druid/extended/lang_text.lua | 2 +- druid/system/druid_instance.lua | 10 +++++----- druid/widget/properties_panel/properties_panel.lua | 7 +++++-- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 172899d..aec7977 100755 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -528,11 +528,12 @@ function M:bind_grid(grid) end self._grid_on_change = grid.on_change_items - self._grid_on_change_callback = self._grid_on_change:subscribe(function() + self._grid_on_change_callback = function() local size = grid:get_size() local offset = grid:get_offset() self:set_size(size, offset) - end) + end + self._grid_on_change:subscribe(self._grid_on_change_callback) self:set_size(grid:get_size(), grid:get_offset()) return self diff --git a/druid/base/static_grid.lua b/druid/base/static_grid.lua index 7788d99..a138fe2 100644 --- a/druid/base/static_grid.lua +++ b/druid/base/static_grid.lua @@ -201,7 +201,7 @@ end --- Return grid index by node ---@param node node The gui node in the grid ----@return number The node index +---@return number|nil index The node index function M:get_index_by_node(node) for index, grid_node in pairs(self.nodes) do if node == grid_node then @@ -356,7 +356,7 @@ end --- Return grid content borders ----@return vector3 The grid content borders +---@return vector4 The grid content borders function M:get_borders() return self.border end @@ -463,10 +463,12 @@ end --- Sort grid nodes by custom comparator function ---@param comparator function The comparator function. (a, b) -> boolean ----@return druid.grid Current grid instance +---@return druid.grid self Current grid instance function M:sort_nodes(comparator) table.sort(self.nodes, comparator) self:_update(true) + + return self end diff --git a/druid/component.lua b/druid/component.lua index 0156fad..3c82000 100644 --- a/druid/component.lua +++ b/druid/component.lua @@ -25,7 +25,7 @@ local helper = require("druid.helper") ---@field update fun(self:druid.base_component, dt:number)|nil ---@field on_remove fun(self:druid.base_component)|nil ---@field on_input fun(self:druid.base_component, action_id:number, action:table)|nil ----@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:userdata)|nil +---@field on_message fun(self:druid.base_component, message_id:hash, message:table, sender:url)|nil ---@field on_late_init fun(self:druid.base_component)|nil ---@field on_focus_lost fun(self:druid.base_component)|nil ---@field on_focus_gained fun(self:druid.base_component)|nil diff --git a/druid/custom/rich_text/rich_text.lua b/druid/custom/rich_text/rich_text.lua index 30d1c35..80deec4 100644 --- a/druid/custom/rich_text/rich_text.lua +++ b/druid/custom/rich_text/rich_text.lua @@ -121,6 +121,13 @@ local rich_text = require("druid.custom.rich_text.module.rt") ---@field width number ---@field height number +---@class druid.rich_text.style +---@field COLORS table +---@field ADJUST_STEPS number +---@field ADJUST_SCALE_DELTA number +---@field ADJUST_TYPE string +---@field ADJUST_SCALE number + ---@class druid.rich_text.lines_metrics ---@field text_width number ---@field text_height number diff --git a/druid/extended/lang_text.lua b/druid/extended/lang_text.lua index 8c8c276..d0745c9 100755 --- a/druid/extended/lang_text.lua +++ b/druid/extended/lang_text.lua @@ -71,7 +71,7 @@ end ---@param text string Text for text node ---@return druid.lang_text Current instance function M:set_to(text) - self.last_locale = false + self.last_locale = nil self.text:set_text(text) self.on_change:trigger() diff --git a/druid/system/druid_instance.lua b/druid/system/druid_instance.lua index e3ba150..f9d0de2 100755 --- a/druid/system/druid_instance.lua +++ b/druid/system/druid_instance.lua @@ -474,14 +474,14 @@ end ---@generic T: druid.base_component ---@param widget T ---@param template string|nil The template name used by widget ----@param nodes table|node|nil The nodes table from gui.clone_tree or prefab node to use for clone +---@param nodes table|node|nil The nodes table from gui.clone_tree or prefab node to use for clone ---@vararg any ---@return T function M:new_widget(widget, template, nodes, ...) local instance = create_widget(self, widget) if type(nodes) == "userdata" then - nodes = gui.clone_tree(nodes) + nodes = gui.clone_tree(nodes) --[[@as table]] end instance.druid = instance:get_druid(template, nodes) @@ -543,10 +543,10 @@ local text = require("druid.base.text") ---Create Text component ---@param node string|node The node_id or gui.get_node(node_id) ---@param value string|nil Initial text. Default value is node text from GUI scene. ----@param no_adjust boolean|nil If true, text will be not auto-adjust size +---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference ---@return druid.text Text component -function M:new_text(node, value, no_adjust) - return self:new(text, node, value, no_adjust) +function M:new_text(node, value, adjust_type) + return self:new(text, node, value, adjust_type) end diff --git a/druid/widget/properties_panel/properties_panel.lua b/druid/widget/properties_panel/properties_panel.lua index f19af12..cae5d3f 100644 --- a/druid/widget/properties_panel/properties_panel.lua +++ b/druid/widget/properties_panel/properties_panel.lua @@ -136,7 +136,10 @@ function M:on_size_changed(new_size) local width = self.layout:get_size().x - self.layout.padding.x - self.layout.padding.z for index = 1, #self.properties do - self.properties[index].container:set_size(width) + local property = self.properties[index] + if property.container then + property.container:set_size(width) + end end self.paginator.container:set_size(width) end @@ -216,7 +219,7 @@ end ---@generic T: druid.widget ---@param widget_class T ---@param template string|nil ----@param nodes table|node|nil +---@param nodes table|node|nil ---@param on_create fun(widget: T)|nil ---@return widget.properties_panel function M:add_inner_widget(widget_class, template, nodes, on_create)