replace all tparam

This commit is contained in:
Insality
2024-11-07 18:34:27 +01:00
parent 999c6222a0
commit 620facbe1f
15 changed files with 281 additions and 281 deletions

View File

@@ -471,7 +471,7 @@ end
--- Set button enabled state.
-- The style.on_set_enabled will be triggered.
-- Disabled button is not clickable.
-- @tparam boolean|nil state Enabled state
---@param state boolean|nil Enabled state
---@return druid.button self
function M:set_enabled(state)
self.disabled = not state
@@ -495,7 +495,7 @@ end
-- Useful to restrict click outside out stencil node or scrollable content.
--
-- This functions calls automatically if you don't disable it in game.project: druid.no_stencil_check
-- @tparam node|string|nil zone Gui node
---@param zone node|string|nil Gui node
---@return druid.button self
function M:set_click_zone(zone)
self.click_zone = self:get_node(zone)
@@ -523,8 +523,8 @@ end
--- Set function for additional check for button click availability
-- @tparam function|nil check_function Should return true or false. If true - button can be pressed.
-- @tparam function|nil failure_callback Function will be called on button click, if check function return false
---@param check_function function|nil Should return true or false. If true - button can be pressed.
---@param failure_callback function|nil Function will be called on button click, if check function return false
---@return druid.button self
function M:set_check_function(check_function, failure_callback)
self._check_function = check_function
@@ -538,7 +538,7 @@ end
-- The HTML5 button's doesn't call any events except on_click event.
--
-- If the game is not HTML, html mode will be not enabled
-- @tparam boolean|nil is_web_mode If true - button will be called inside html5 callback
---@param is_web_mode boolean|nil If true - button will be called inside html5 callback
---@return druid.button self
function M:set_web_user_interaction(is_web_mode)
self._is_html5_mode = not not (is_web_mode and html5)

View File

@@ -35,10 +35,10 @@ local M = component.create("hover")
--- The Hover constructor
-- @tparam Hover self Hover
-- @tparam node node Gui node
-- @tparam function on_hover_callback Hover callback
-- @tparam function on_mouse_hover On mouse hover callback
---@param self Hover Hover
---@param node node Gui node
---@param on_hover_callback function Hover callback
---@param on_mouse_hover function On mouse hover callback
function M:init(node, on_hover_callback, on_mouse_hover)
self.node = self:get_node(node)
@@ -115,8 +115,8 @@ end
--- Set hover state
-- @tparam Hover self Hover
-- @tparam boolean|nil state The hover state
---@param self Hover Hover
---@param state boolean|nil The hover state
function M:set_hover(state)
if self._is_hovered == state then
return
@@ -132,7 +132,7 @@ end
--- Return current hover state. True if touch action was on the node at current time
-- @tparam Hover self Hover
---@param self Hover Hover
-- @treturn boolean The current hovered state
function M:is_hovered()
return self._is_hovered
@@ -140,8 +140,8 @@ end
--- Set mouse hover state
-- @tparam Hover self Hover
-- @tparam boolean|nil state The mouse hover state
---@param self Hover Hover
---@param state boolean|nil The mouse hover state
function M:set_mouse_hover(state)
if self._is_mouse_hovered == state then
return
@@ -157,7 +157,7 @@ end
--- Return current hover state. True if nil action_id (usually desktop mouse) was on the node at current time
-- @tparam Hover self Hover
---@param self Hover Hover
-- @treturn boolean The current hovered state
function M:is_mouse_hovered()
return self._is_mouse_hovered
@@ -166,8 +166,8 @@ end
--- Strict hover click area. Useful for
-- no click events outside stencil node
-- @tparam Hover self Hover
-- @tparam node|string|nil zone Gui node
---@param self Hover Hover
---@param zone node|string|nil Gui node
function M:set_click_zone(zone)
self.click_zone = self:get_node(zone)
end
@@ -176,8 +176,8 @@ end
--- Set enable state of hover component.
-- If hover is not enabled, it will not generate
-- any hover events
-- @tparam Hover self Hover
-- @tparam boolean|nil state The hover enabled state
---@param self Hover Hover
---@param state boolean|nil The hover enabled state
function M:set_enabled(state)
self._is_enabled = state
@@ -193,7 +193,7 @@ end
--- Return current hover enabled state
-- @tparam Hover self Hover
---@param self Hover Hover
-- @treturn boolean The hover enabled state
function M:is_enabled()
return self._is_enabled

View File

@@ -171,9 +171,9 @@ end
--- The Scroll constructor
-- @tparam Scroll self Scroll
-- @tparam string|node view_node GUI view scroll node
-- @tparam string|node content_node GUI content scroll node
---@param self Scroll Scroll
---@param view_node string|node GUI view scroll node
---@param content_node string|node GUI content scroll node
function M:init(view_node, content_node)
self.druid = self:get_druid()
@@ -253,9 +253,9 @@ end
--- Start scroll to target point.
-- @tparam Scroll self Scroll
-- @tparam vector3 point Target point
-- @tparam boolean|nil is_instant Instant scroll flag
---@param self Scroll Scroll
---@param point vector3 Target point
---@param is_instant boolean|nil Instant scroll flag
-- @usage scroll:scroll_to(vmath.vector3(0, 50, 0))
-- @usage scroll:scroll_to(vmath.vector3(0), true)
function M:scroll_to(point, is_instant)
@@ -287,9 +287,9 @@ end
--- Scroll to item in scroll by point index.
-- @tparam Scroll self Scroll
-- @tparam number index Point index
-- @tparam boolean|nil skip_cb If true, skip the point callback
---@param self Scroll Scroll
---@param index number Point index
---@param skip_cb boolean|nil If true, skip the point callback
function M:scroll_to_index(index, skip_cb)
if not self.points then
return
@@ -310,9 +310,9 @@ end
--- Start scroll to target scroll percent
-- @tparam Scroll self Scroll
-- @tparam vector3 percent target percent
-- @tparam boolean|nil is_instant instant scroll flag
---@param self Scroll Scroll
---@param percent vector3 target percent
---@param is_instant boolean|nil instant scroll flag
-- @usage scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))
function M:scroll_to_percent(percent, is_instant)
local border = self.available_pos
@@ -336,7 +336,7 @@ end
--- Return current scroll progress status.
-- Values will be in [0..1] interval
-- @tparam Scroll self Scroll
---@param self Scroll Scroll
-- @treturn vector3 New vector with scroll progress values
function M:get_percent()
local x_perc = 1 - inverse_lerp(self.available_pos.x, self.available_pos.z, self.position.x)
@@ -348,9 +348,9 @@ end
--- Set scroll content size.
-- It will change content gui node size
-- @tparam Scroll self Scroll
-- @tparam vector3 size The new size for content node
-- @tparam vector3|nil offset Offset value to set, where content is starts
---@param self Scroll Scroll
---@param size vector3 The new size for content node
---@param offset vector3|nil Offset value to set, where content is starts
-- @treturn druid.scroll Current scroll instance
function M:set_size(size, offset)
if offset then
@@ -364,8 +364,8 @@ end
--- Set new scroll view size in case the node size was changed.
-- @tparam Scroll self Scroll
-- @tparam vector3 size The new size for view node
---@param self Scroll Scroll
---@param size vector3 The new size for view node
-- @treturn druid.scroll Current scroll instance
function M:set_view_size(size)
gui.set_size(self.view_node, size)
@@ -378,7 +378,7 @@ end
--- Refresh scroll view size
-- @tparam Scroll self Scroll
---@param self Scroll Scroll
function M:update_view_size()
self.view_size = helper.get_scaled_size(self.view_node)
self.view_border = helper.get_border(self.view_node)
@@ -391,8 +391,8 @@ end
--- Enable or disable scroll inert.
-- If disabled, scroll through points (if exist)
-- If no points, just simple drag without inertion
-- @tparam Scroll self Scroll
-- @tparam boolean|nil state Inert scroll state
---@param self Scroll Scroll
---@param state boolean|nil Inert scroll state
-- @treturn druid.scroll Current scroll instance
function M:set_inert(state)
self._is_inert = state
@@ -402,7 +402,7 @@ end
--- Return if scroll have inertion.
-- @tparam Scroll self Scroll
---@param self Scroll Scroll
-- @treturn boolean @If scroll have inertion
function M:is_inert()
return self._is_inert
@@ -411,8 +411,8 @@ end
--- Set extra size for scroll stretching.
-- Set 0 to disable stretching effect
-- @tparam Scroll self Scroll
-- @tparam number|nil stretch_size Size in pixels of additional scroll area
---@param self Scroll Scroll
---@param stretch_size number|nil Size in pixels of additional scroll area
-- @treturn druid.scroll Current scroll instance
function M:set_extra_stretch_size(stretch_size)
self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
@@ -423,7 +423,7 @@ end
--- Return vector of scroll size with width and height.
-- @tparam Scroll self Scroll
---@param self Scroll Scroll
-- @treturn vector3 Available scroll size
function M:get_scroll_size()
return self.available_size
@@ -432,8 +432,8 @@ end
--- Set points of interest.
-- Scroll will always centered on closer points
-- @tparam Scroll self Scroll
-- @tparam table points Array of vector3 points
---@param self Scroll Scroll
---@param points table Array of vector3 points
-- @treturn druid.scroll Current scroll instance
function M:set_points(points)
self.points = points
@@ -449,8 +449,8 @@ end
--- Lock or unlock horizontal scroll
-- @tparam Scroll self Scroll
-- @tparam boolean|nil state True, if horizontal scroll is enabled
---@param self Scroll Scroll
---@param state boolean|nil True, if horizontal scroll is enabled
-- @treturn druid.scroll Current scroll instance
function M:set_horizontal_scroll(state)
self._is_horizontal_scroll = state
@@ -460,8 +460,8 @@ end
--- Lock or unlock vertical scroll
-- @tparam Scroll self Scroll
-- @tparam boolean|nil state True, if vertical scroll is enabled
---@param self Scroll Scroll
---@param state boolean|nil True, if vertical scroll is enabled
-- @treturn druid.scroll Current scroll instance
function M:set_vertical_scroll(state)
self._is_vertical_scroll = state
@@ -472,8 +472,8 @@ end
--- Check node if it visible now on scroll.
-- Extra border is not affected. Return true for elements in extra scroll zone
-- @tparam Scroll self Scroll
-- @tparam node node The node to check
---@param self Scroll Scroll
---@param node node The node to check
-- @treturn boolean True if node in visible scroll area
function M:is_node_in_view(node)
local node_offset_for_view = gui.get_position(node)
@@ -513,8 +513,8 @@ end
--- Bind the grid component (Static or Dynamic) to recalculate
-- scroll size on grid changes
-- @tparam Scroll self Scroll
-- @tparam StaticGrid grid Druid grid component
---@param self Scroll Scroll
---@param grid StaticGrid Druid grid component
-- @treturn druid.scroll Current scroll instance
function M:bind_grid(grid)
if self._grid_on_change then
@@ -542,8 +542,8 @@ end
--- Strict drag scroll area. Useful for
-- restrict events outside stencil node
-- @tparam Drag self
-- @tparam node|string node Gui node
---@param self Drag
---@param node node|string Gui node
function M:set_click_zone(node)
self.drag:set_click_zone(node)
end

View File

@@ -128,10 +128,10 @@ end
--- The StaticGrid constructor
-- @tparam StaticGrid self StaticGrid
-- @tparam string|node parent The GUI Node container, where grid's items will be placed
-- @tparam node element Element prefab. Need to get it size
-- @tparam number|nil in_row How many nodes in row can be placed. By default 1
---@param self StaticGrid StaticGrid
---@param parent string|node The GUI Node container, where grid's items will be placed
---@param element node Element prefab. Need to get it size
---@param in_row number|nil How many nodes in row can be placed. By default 1
function M:init(parent, element, in_row)
self.parent = self:get_node(parent)
self.nodes = {}
@@ -165,8 +165,8 @@ end
local _temp_pos = vmath.vector3(0)
--- Return pos for grid node index
-- @tparam StaticGrid self StaticGrid
-- @tparam number index The grid element index
---@param self StaticGrid StaticGrid
---@param index number The grid element index
-- @treturn vector3 @Node position
function M:get_pos(index)
local row = math.ceil(index / self.in_row) - 1
@@ -183,8 +183,8 @@ end
--- Return index for grid pos
-- @tparam StaticGrid self StaticGrid
-- @tparam vector3 pos The node position in the grid
---@param self StaticGrid StaticGrid
---@param pos vector3 The node position in the grid
-- @treturn number The node index
function M:get_index(pos)
-- Offset to left-top corner from node pivot
@@ -203,8 +203,8 @@ end
--- Return grid index by node
-- @tparam StaticGrid self StaticGrid
-- @tparam node node The gui node in the grid
---@param self StaticGrid StaticGrid
---@param node node The gui node in the grid
-- @treturn number The node index
function M:get_index_by_node(node)
for index, grid_node in pairs(self.nodes) do
@@ -223,8 +223,8 @@ end
--- Set grid anchor. Default anchor is equal to anchor of grid parent node
-- @tparam StaticGrid self StaticGrid
-- @tparam vector3 anchor Anchor
---@param self StaticGrid StaticGrid
---@param anchor vector3 Anchor
function M:set_anchor(anchor)
self.anchor = anchor
self:_update()
@@ -232,7 +232,7 @@ end
--- Update grid content
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
function M:refresh()
self:_update(true)
end
@@ -270,11 +270,11 @@ end
--- Add new item to the grid
-- @tparam StaticGrid self StaticGrid
-- @tparam node item GUI node
-- @tparam number|nil index The item position. By default add as last item
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
-- @tparam boolean|nil is_instant If true, update node positions instantly
---@param self StaticGrid StaticGrid
---@param item node GUI node
---@param index number|nil The item position. By default add as last item
---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT
---@param is_instant boolean|nil If true, update node positions instantly
function M:add(item, index, shift_policy, is_instant)
index = index or ((self.last_index or 0) + 1)
@@ -295,8 +295,8 @@ end
--- Set new items to the grid. All previous items will be removed
-- @tparam StaticGrid self StaticGrid
-- @tparam node[] nodes The new grid nodes
---@param self StaticGrid StaticGrid
---@param nodes node[] The new grid nodes
-- @tparam[opt=false] boolean is_instant If true, update node positions instantly
function M:set_items(nodes, is_instant)
self.nodes = nodes
@@ -312,10 +312,10 @@ end
--- Remove the item from the grid. Note that gui node will be not deleted
-- @tparam StaticGrid self StaticGrid
-- @tparam number index The grid node index to remove
-- @tparam number|nil shift_policy How shift nodes, if required. Default: const.SHIFT.RIGHT
-- @tparam boolean|nil is_instant If true, update node positions instantly
---@param self StaticGrid StaticGrid
---@param index number The grid node index to remove
---@param shift_policy number|nil How shift nodes, if required. Default: const.SHIFT.RIGHT
---@param is_instant boolean|nil If true, update node positions instantly
-- @treturn node The deleted gui node from grid
function M:remove(index, shift_policy, is_instant)
assert(self.nodes[index], "No grid item at given index " .. index)
@@ -333,7 +333,7 @@ end
--- Return grid content size
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @treturn vector3 The grid content size
function M:get_size()
return vmath.vector3(
@@ -366,7 +366,7 @@ end
--- Return grid content borders
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @treturn vector3 The grid content borders
function M:get_borders()
return self.border
@@ -374,7 +374,7 @@ end
--- Return array of all node positions
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @treturn vector3[] All grid node positions
function M:get_all_pos()
local result = {}
@@ -388,8 +388,8 @@ end
--- Change set position function for grid nodes. It will call on
-- update poses on grid elements. Default: gui.set_position
-- @tparam StaticGrid self StaticGrid
-- @tparam function callback Function on node set position
---@param self StaticGrid StaticGrid
---@param callback function Function on node set position
-- @treturn druid.static_grid Current grid instance
function M:set_position_function(callback)
self._set_position_function = callback or gui.set_position
@@ -400,7 +400,7 @@ end
--- Clear grid nodes array. GUI nodes will be not deleted!
-- If you want to delete GUI nodes, use static_grid.nodes array before grid:clear
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @treturn druid.static_grid Current grid instance
function M:clear()
self.border.x = 0
@@ -419,7 +419,7 @@ end
--- Return StaticGrid offset, where StaticGrid content starts.
-- @tparam StaticGrid self StaticGrid The StaticGrid instance
---@param self StaticGrid StaticGrid The StaticGrid instance
-- @treturn vector3 The StaticGrid offset
function M:get_offset()
local borders = self:get_borders()
@@ -435,8 +435,8 @@ end
--- Set new in_row elements for grid
-- @tparam StaticGrid self StaticGrid
-- @tparam number in_row The new in_row value
---@param self StaticGrid StaticGrid
---@param in_row number The new in_row value
-- @treturn druid.static_grid Current grid instance
function M:set_in_row(in_row)
self.in_row = in_row
@@ -454,7 +454,7 @@ end
--- Set new node size for grid
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
-- @tparam[opt] number width The new node width
-- @tparam[opt] number height The new node height
-- @treturn druid.static_grid Current grid instance
@@ -479,8 +479,8 @@ end
--- Sort grid nodes by custom comparator function
-- @tparam StaticGrid self StaticGrid
-- @tparam function comparator The comparator function. (a, b) -> boolean
---@param self StaticGrid StaticGrid
---@param comparator function The comparator function. (a, b) -> boolean
-- @treturn druid.static_grid Current grid instance
function M:sort_nodes(comparator)
table.sort(self.nodes, comparator)
@@ -489,8 +489,8 @@ end
--- Update grid inner state
-- @tparam StaticGrid self StaticGrid
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
---@param self StaticGrid StaticGrid
---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback
---@private
function M:_update(is_instant)
self:_update_indexes()
@@ -500,7 +500,7 @@ end
--- Update first and last indexes of grid nodes
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
---@private
function M:_update_indexes()
self.first_index = nil
@@ -516,7 +516,7 @@ end
--- Update grid content borders, recalculate min and max values
-- @tparam StaticGrid self StaticGrid
---@param self StaticGrid StaticGrid
---@private
function M:_update_borders()
if not self.first_index then
@@ -535,8 +535,8 @@ end
--- Update grid nodes position
-- @tparam StaticGrid self StaticGrid
-- @tparam boolean|nil is_instant If true, node position update instantly, otherwise with set_position_function callback
---@param self StaticGrid StaticGrid
---@param is_instant boolean|nil If true, node position update instantly, otherwise with set_position_function callback
---@private
function M:_update_pos(is_instant)
local zero_offset = self:_get_zero_offset()

View File

@@ -288,10 +288,10 @@ end
--- The Text constructor
-- @tparam Text self Text
-- @tparam string|node node Node name or GUI Text Node itself
-- @tparam string|nil value Initial text. Default value is node text from GUI scene. Default: nil
-- @tparam string|nil adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE
---@param self Text Text
---@param node string|node Node name or GUI Text Node itself
---@param value string|nil Initial text. Default value is node text from GUI scene. Default: nil
---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference. Default: DOWNSCALE
function M:init(node, value, adjust_type)
self.node = self:get_node(node)
self.pos = gui.get_position(self.node)
@@ -335,8 +335,8 @@ end
--- Calculate text width with font with respect to trailing space
-- @tparam Text self Text
-- @tparam string text|nil
---@param self Text Text
---@param text|nil string
-- @treturn number Width
-- @treturn number Height
function M:get_text_size(text)
@@ -360,8 +360,8 @@ end
--- Get chars count by width
-- @tparam Text self Text
-- @tparam number width
---@param self Text Text
---@param width number
-- @treturn number Chars count
function M:get_text_index_by_width(width)
local text = self.last_value
@@ -394,8 +394,8 @@ end
--- Set text to text field
-- @tparam Text self Text
-- @tparam string set_to Text for node
---@param self Text Text
---@param set_to string Text for node
-- @treturn Text Current text instance
function M:set_to(set_to)
set_to = set_to or ""
@@ -412,8 +412,8 @@ end
--- Set text area size
-- @tparam Text self Text
-- @tparam vector3 size The new text area size
---@param self Text Text
---@param size vector3 The new text area size
-- @treturn Text Current text instance
function M:set_size(size)
self.start_size = size
@@ -425,8 +425,8 @@ end
--- Set color
-- @tparam Text self Text
-- @tparam vector4 color Color for node
---@param self Text Text
---@param color vector4 Color for node
-- @treturn Text Current text instance
function M:set_color(color)
self.color = color
@@ -437,8 +437,8 @@ end
--- Set alpha
-- @tparam Text self Text
-- @tparam number alpha Alpha for node
---@param self Text Text
---@param alpha number Alpha for node
-- @treturn Text Current text instance
function M:set_alpha(alpha)
self.color.w = alpha
@@ -449,8 +449,8 @@ end
--- Set scale
-- @tparam Text self Text
-- @tparam vector3 scale Scale for node
---@param self Text Text
---@param scale vector3 Scale for node
-- @treturn Text Current text instance
function M:set_scale(scale)
self.last_scale = scale
@@ -461,8 +461,8 @@ end
--- Set text pivot. Text will re-anchor inside text area
-- @tparam Text self Text
-- @tparam number pivot The gui.PIVOT_* constant
---@param self Text Text
---@param pivot number The gui.PIVOT_* constant
-- @treturn Text Current text instance
function M:set_pivot(pivot)
local prev_pivot = gui.get_pivot(self.node)
@@ -487,7 +487,7 @@ end
--- Return true, if text with line break
-- @tparam Text self Text
---@param self Text Text
-- @treturn boolean Is text node with line break
function M:is_multiline()
return gui.get_line_break(self.node)
@@ -495,9 +495,9 @@ end
--- Set text adjust, refresh the current text visuals, if needed
-- @tparam Text self Text
-- @tparam string|nil adjust_type See const.TEXT_ADJUST. If pass nil - use current adjust type
-- @tparam number|nil minimal_scale If pass nil - not use minimal scale
---@param self Text Text
---@param adjust_type string|nil See const.TEXT_ADJUST. If pass nil - use current adjust type
---@param minimal_scale number|nil If pass nil - not use minimal scale
-- @treturn Text Current text instance
function M:set_text_adjust(adjust_type, minimal_scale)
self.adjust_type = adjust_type
@@ -509,8 +509,8 @@ end
--- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
-- @tparam Text self Text
-- @tparam number minimal_scale If pass nil - not use minimal scale
---@param self Text Text
---@param minimal_scale number If pass nil - not use minimal scale
-- @treturn Text Current text instance
function M:set_minimal_scale(minimal_scale)
self._minimal_scale = minimal_scale