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

@@ -56,10 +56,10 @@ local M = component.create("data_list")
--- The DataList constructor
-- @tparam DataList self DataList
-- @tparam Scroll scroll The Scroll instance for Data List component
-- @tparam StaticGrid grid The StaticGrid} or @{DynamicGrid instance for Data List component
-- @tparam function create_function The create function callback(self, data, index, data_list). Function should return (node, [component])
---@param self DataList DataList
---@param scroll Scroll The Scroll instance for Data List component
---@param grid StaticGrid The StaticGrid} or @{DynamicGrid instance for Data List component
---@param create_function function The create function callback(self, data, index, data_list). Function should return (node, [component])
function M:init(scroll, grid, create_function)
self.scroll = scroll
self.grid = grid
@@ -87,7 +87,7 @@ end
--- Druid System on_remove function
-- @tparam DataList self DataList
---@param self DataList DataList
function M:on_remove()
self:clear()
self.scroll.on_scroll:unsubscribe(self._refresh, self)
@@ -95,8 +95,8 @@ end
--- Set refresh function for DataList component
-- @tparam DataList self DataList
-- @tparam boolean is_use_cache Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
---@param self DataList DataList
---@param is_use_cache boolean Use cache version of DataList. Requires make setup of components in on_element_add callback and clean in on_element_remove
-- @treturn druid.data_list Current DataList instance
function M:set_use_cache(is_use_cache)
self._is_use_cache = is_use_cache
@@ -105,8 +105,8 @@ end
--- Set new data set for DataList component
-- @tparam DataList self DataList
-- @tparam table data The new data array
---@param self DataList DataList
---@param data table The new data array
-- @treturn druid.data_list Current DataList instance
function M:set_data(data)
self._data = data or {}
@@ -117,7 +117,7 @@ end
--- Return current data from DataList component
-- @tparam DataList self DataList
---@param self DataList DataList
-- @treturn table The current data array
function M:get_data()
return self._data
@@ -125,10 +125,10 @@ end
--- Add element to DataList. Currenly untested
-- @tparam DataList self DataList
-- @tparam table data
-- @tparam number|nil index
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
---@param self DataList DataList
---@param data table
---@param index number|nil
---@param shift_policy number|nil The constant from const.SHIFT.*
function M:add(data, index, shift_policy)
index = index or #self._data + 1
shift_policy = shift_policy or const.SHIFT.RIGHT
@@ -139,9 +139,9 @@ end
--- Remove element from DataList. Currenly untested
-- @tparam DataList self DataList
-- @tparam number|nil index
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
---@param self DataList DataList
---@param index number|nil
---@param shift_policy number|nil The constant from const.SHIFT.*
function M:remove(index, shift_policy)
helper.remove_with_shift(self._data, index, shift_policy)
self:_refresh()
@@ -149,9 +149,9 @@ end
--- Remove element from DataList by data value. Currenly untested
-- @tparam DataList self DataList
-- @tparam table data
-- @tparam number|nil shift_policy The constant from const.SHIFT.*
---@param self DataList DataList
---@param data table
---@param shift_policy number|nil The constant from const.SHIFT.*
function M:remove_by_data(data, shift_policy)
local index = helper.contains(self._data, data)
if index then
@@ -162,7 +162,7 @@ end
--- Clear the DataList and refresh visuals
-- @tparam DataList self DataList
---@param self DataList DataList
function M:clear()
self._data = {}
self:_refresh()
@@ -170,8 +170,8 @@ end
--- Return index for data value
-- @tparam DataList self DataList
-- @tparam table data
---@param self DataList DataList
---@param data table
function M:get_index(data)
for index, value in pairs(self._data) do
if value == data then
@@ -184,7 +184,7 @@ end
--- Return all currenly created nodes in DataList
-- @tparam DataList self DataList
---@param self DataList DataList
-- @treturn node[] List of created nodes
function M:get_created_nodes()
local nodes = {}
@@ -198,7 +198,7 @@ end
--- Return all currenly created components in DataList
-- @tparam DataList self DataList
---@param self DataList DataList
-- @treturn druid.base_component[] List of created nodes
function M:get_created_components()
local components = {}
@@ -212,8 +212,8 @@ end
--- Instant scroll to element with passed index
-- @tparam DataList self DataList
-- @tparam number index
---@param self DataList DataList
---@param index number
function M:scroll_to_index(index)
local pos = self.grid:get_pos(index)
self.scroll:scroll_to(pos)
@@ -221,8 +221,8 @@ end
--- Add element at passed index using cache or create new
-- @tparam DataList self DataList
-- @tparam number index
---@param self DataList DataList
---@param index number
---@private
function M:_add_at(index)
if self._data_visual[index] then
@@ -255,8 +255,8 @@ end
--- Remove element from passed index and add it to cache if applicable
-- @tparam DataList self DataList
-- @tparam number index
---@param self DataList DataList
---@param index number
---@private
function M:_remove_at(index)
self.grid:remove(index, const.SHIFT.NO_SHIFT)
@@ -286,7 +286,7 @@ end
--- Refresh all elements in DataList
-- @tparam DataList self DataList
---@param self DataList DataList
---@private
function M:_refresh()
self.scroll:set_size(self.grid:get_size_for(#self._data))

View File

@@ -38,10 +38,10 @@ local M = component.create("hotkey")
--- The Hotkey constructor
-- @tparam Hotkey self Hotkey
-- @tparam string[]|string keys The keys to be pressed for trigger callback. Should contains one key and any modificator keys
-- @tparam function callback The callback function
-- @tparam any|nil callback_argument The argument to pass into the callback function
---@param self Hotkey Hotkey
---@param keys string[]|string The keys to be pressed for trigger callback. Should contains one key and any modificator keys
---@param callback function The callback function
---@param callback_argument any|nil The argument to pass into the callback function
function M:init(keys, callback, callback_argument)
self.druid = self:get_druid()
@@ -73,9 +73,9 @@ end
--- Add hotkey for component callback
-- @tparam Hotkey self Hotkey
-- @tparam string[]|hash[]|string|hash keys that have to be pressed before key pressed to activate
-- @tparam any|nil callback_argument The argument to pass into the callback function
---@param self Hotkey Hotkey
---@param keys string[]|hash[]|string|hash that have to be pressed before key pressed to activate
---@param callback_argument any|nil The argument to pass into the callback function
-- @treturn Hotkey Current instance
function M:add_hotkey(keys, callback_argument)
keys = keys or {}
@@ -174,8 +174,8 @@ end
--- If true, the callback will be triggered on action.repeated
-- @tparam Hotkey self Hotkey
-- @tparam bool is_enabled_repeated The flag value
---@param self Hotkey Hotkey
---@param is_enabled_repeated bool The flag value
-- @treturn Hotkey
function M:set_repeat(is_enabled_repeated)
self._is_process_repeated = is_enabled_repeated

View File

@@ -109,8 +109,8 @@ M.ALLOWED_ACTIONS = {
}
--- Mask text by replacing every character with a mask character
-- @tparam string text
-- @tparam string mask
---@param text string
---@param mask string
-- @treturn string Masked text
local function mask_text(text, mask)
mask = mask or "*"
@@ -156,10 +156,10 @@ end
--- The Input constructor
-- @tparam Input self Input
-- @tparam node click_node Node to enabled input component
-- @tparam node|Text text_node Text node what will be changed on user input. You can pass text component instead of text node name Text
-- @tparam number|nil keyboard_type Gui keyboard type for input field
---@param self Input Input
---@param click_node node Node to enabled input component
---@param text_node node|Text Text node what will be changed on user input. You can pass text component instead of text node name Text
---@param keyboard_type number|nil Gui keyboard type for input field
function M:init(click_node, text_node, keyboard_type)
self.druid = self:get_druid()
@@ -328,8 +328,8 @@ function M:get_text_selected()
end
--- Replace selected text with new text
-- @tparam Input self Input
-- @tparam string text The text to replace selected text
---@param self Input Input
---@param text string The text to replace selected text
-- @treturn string New input text
function M:get_text_selected_replaced(text)
local left_part = utf8.sub(self.value, 1, self.start_index)
@@ -346,8 +346,8 @@ end
--- Set text for input field
-- @tparam Input self Input
-- @tparam string input_text The string to apply for input field
---@param self Input Input
---@param input_text string The string to apply for input field
function M:set_text(input_text)
input_text = tostring(input_text or "")
@@ -395,7 +395,7 @@ end
--- Select input field. It will show the keyboard and trigger on_select events
-- @tparam Input self Input
---@param self Input Input
function M:select()
gui.reset_keyboard()
self.marked_value = ""
@@ -420,7 +420,7 @@ end
--- Remove selection from input. It will hide the keyboard and trigger on_unselect events
-- @tparam Input self Input
---@param self Input Input
function M:unselect()
gui.reset_keyboard()
self.marked_value = ""
@@ -439,7 +439,7 @@ end
--- Return current input field text
-- @tparam Input self Input
---@param self Input Input
-- @treturn string The current input field text
function M:get_text()
if self.marked_value ~= "" then
@@ -452,8 +452,8 @@ end
--- Set maximum length for input field.
-- Pass nil to make input field unliminted (by default)
-- @tparam Input self Input
-- @tparam number max_length Maximum length for input text field
---@param self Input Input
---@param max_length number Maximum length for input text field
-- @treturn druid.input Current input instance
function M:set_max_length(max_length)
self.max_length = max_length
@@ -464,8 +464,8 @@ end
--- Set allowed charaters for input field.
-- See: https://defold.com/ref/stable/string/
-- ex: [%a%d] for alpha and numeric
-- @tparam Input self Input
-- @tparam string characters Regulax exp. for validate user input
---@param self Input Input
---@param characters string Regulax exp. for validate user input
-- @treturn druid.input Current input instance
function M:set_allowed_characters(characters)
self.allowed_characters = characters
@@ -474,7 +474,7 @@ end
--- Reset current input selection and return previous value
-- @tparam Input self Input
---@param self Input Input
-- @treturn druid.input Current input instance
function M:reset_changes()
self:set_text(self.previous_value)
@@ -484,10 +484,10 @@ end
--- Set cursor position in input field
-- @tparam Input self Input
-- @tparam number|nil cursor_index Cursor index for cursor position, if nil - will be set to the end of the text
-- @tparam number|nil start_index Start index for cursor position, if nil - will be set to the end of the text
-- @tparam number|nil end_index End index for cursor position, if nil - will be set to the start_index
---@param self Input Input
---@param cursor_index number|nil Cursor index for cursor position, if nil - will be set to the end of the text
---@param start_index number|nil Start index for cursor position, if nil - will be set to the end of the text
---@param end_index number|nil End index for cursor position, if nil - will be set to the start_index
-- @treturn druid.input Current input instance
function M:select_cursor(cursor_index, start_index, end_index)
local len = utf8.len(self.value)
@@ -507,10 +507,10 @@ end
--- Change cursor position by delta
-- @tparam Input self Input
-- @tparam number delta side for cursor position, -1 for left, 1 for right
-- @tparam boolean is_add_to_selection (Shift key)
-- @tparam boolean is_move_to_end (Ctrl key)
---@param self Input Input
---@param delta number side for cursor position, -1 for left, 1 for right
---@param is_add_to_selection boolean (Shift key)
---@param is_move_to_end boolean (Ctrl key)
function M:move_selection(delta, is_add_to_selection, is_move_to_end)
local len = utf8.len(self.value)
local cursor_index = self.cursor_index

View File

@@ -42,10 +42,10 @@ local M = component.create("lang_text")
--- The LangText constructor
-- @tparam LangText self LangText
-- @tparam string|node node The node_id or gui.get_node(node_id)
-- @tparam string|nil locale_id Default locale id or text from node as default
-- @tparam string|nil adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
---@param self LangText LangText
---@param node string|node The node_id or gui.get_node(node_id)
---@param locale_id string|nil Default locale id or text from node as default
---@param adjust_type string|nil Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
function M:init(node, locale_id, adjust_type)
self.druid = self:get_druid()
self.text = self.druid:new_text(node, locale_id, adjust_type)
@@ -69,8 +69,8 @@ end
--- Setup raw text to lang_text component
-- @tparam LangText self LangText
-- @tparam string text Text for text node
---@param self LangText LangText
---@param text string Text for text node
-- @treturn LangText Current instance
function M:set_to(text)
self.last_locale = false
@@ -82,15 +82,15 @@ end
--- Translate the text by locale_id
-- @tparam LangText self LangText
-- @tparam string locale_id Locale id
-- @tparam string|nil a Optional param to string.format
-- @tparam string|nil b Optional param to string.format
-- @tparam string|nil c Optional param to string.format
-- @tparam string|nil d Optional param to string.format
-- @tparam string|nil e Optional param to string.format
-- @tparam string|nil f Optional param to string.format
-- @tparam string|nil g Optional param to string.format
---@param self LangText LangText
---@param locale_id string Locale id
---@param a string|nil Optional param to string.format
---@param b string|nil Optional param to string.format
---@param c string|nil Optional param to string.format
---@param d string|nil Optional param to string.format
---@param e string|nil Optional param to string.format
---@param f string|nil Optional param to string.format
---@param g string|nil Optional param to string.format
-- @treturn LangText Current instance
function M:translate(locale_id, a, b, c, d, e, f, g)
self.last_locale_args = { a, b, c, d, e, f, g }
@@ -102,14 +102,14 @@ end
--- Format string with new text params on localized text
-- @tparam LangText self LangText
-- @tparam string|nil a Optional param to string.format
-- @tparam string|nil b Optional param to string.format
-- @tparam string|nil c Optional param to string.format
-- @tparam string|nil d Optional param to string.format
-- @tparam string|nil e Optional param to string.format
-- @tparam string|nil f Optional param to string.format
-- @tparam string|nil g Optional param to string.format
---@param self LangText LangText
---@param a string|nil Optional param to string.format
---@param b string|nil Optional param to string.format
---@param c string|nil Optional param to string.format
---@param d string|nil Optional param to string.format
---@param e string|nil Optional param to string.format
---@param f string|nil Optional param to string.format
---@param g string|nil Optional param to string.format
-- @treturn LangText Current instance
function M:format(a, b, c, d, e, f, g)
self.last_locale_args = { a, b, c, d, e, f, g }

View File

@@ -131,10 +131,10 @@ end
--- The Progress constructor
-- @tparam Progress self Progress
-- @tparam string|node node Node name or GUI Node itself.
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y
-- @tparam number|nil init_value Initial value of progress bar. Default: 1
---@param self Progress Progress
---@param node string|node Node name or GUI Node itself.
---@param key string Progress bar direction: const.SIDE.X or const.SIDE.Y
---@param init_value number|nil Initial value of progress bar. Default: 1
function M:init(node, key, init_value)
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
@@ -193,22 +193,22 @@ end
--- Fill a progress bar and stop progress animation
-- @tparam Progress self Progress
---@param self Progress Progress
function M:fill()
set_bar_to(self, 1, true)
end
--- Empty a progress bar
-- @tparam Progress self Progress
---@param self Progress Progress
function M:empty()
set_bar_to(self, 0, true)
end
--- Instant fill progress bar to value
-- @tparam Progress self Progress
-- @tparam number to Progress bar value, from 0 to 1
---@param self Progress Progress
---@param to number Progress bar value, from 0 to 1
function M:set_to(to)
to = helper.clamp(to, 0, 1)
set_bar_to(self, to)
@@ -216,16 +216,16 @@ end
--- Return current progress bar value
-- @tparam Progress self Progress
---@param self Progress Progress
function M:get()
return self.last_value
end
--- Set points on progress bar to fire the callback
-- @tparam Progress self Progress
-- @tparam number[] steps Array of progress bar values
-- @tparam function callback Callback on intersect step value
---@param self Progress Progress
---@param steps number[] Array of progress bar values
---@param callback function Callback on intersect step value
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
function M:set_steps(steps, callback)
self.steps = steps
@@ -234,9 +234,9 @@ end
--- Start animation of a progress bar
-- @tparam Progress self Progress
-- @tparam number to value between 0..1
-- @tparam function|nil callback Callback on animation ends
---@param self Progress Progress
---@param to number value between 0..1
---@param callback function|nil Callback on animation ends
function M:to(to, callback)
to = helper.clamp(to, 0, 1)
-- cause of float error
@@ -253,8 +253,8 @@ end
--- Set progress bar max node size
-- @tparam Progress self Progress
-- @tparam vector3 max_size The new node maximum (full) size
---@param self Progress Progress
---@param max_size vector3 The new node maximum (full) size
-- @treturn Progress Progress
function M:set_max_size(max_size)
self.max_size[self.key] = max_size[self.key]

View File

@@ -69,10 +69,10 @@ end
--- The Slider constructor
-- @tparam Slider self Slider
-- @tparam node node Gui pin node
-- @tparam vector3 end_pos The end position of slider
-- @tparam function|nil callback On slider change callback
---@param self Slider Slider
---@param node node Gui pin node
---@param end_pos vector3 The end position of slider
---@param callback function|nil On slider change callback
function M:init(node, end_pos, callback)
self.node = self:get_node(node)
@@ -197,9 +197,9 @@ end
--- Set value for slider
-- @tparam Slider self Slider
-- @tparam number value Value from 0 to 1
-- @tparam boolean|nil is_silent Don't trigger event if true
---@param self Slider Slider
---@param value number Value from 0 to 1
---@param is_silent boolean|nil Don't trigger event if true
function M:set(value, is_silent)
value = helper.clamp(value, 0, 1)
set_position(self, value)
@@ -212,8 +212,8 @@ end
--- Set slider steps. Pin node will
-- apply closest step position
-- @tparam Slider self Slider
-- @tparam number[] steps Array of steps
---@param self Slider Slider
---@param steps number[] Array of steps
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
-- @treturn Slider Slider
function M:set_steps(steps)
@@ -226,8 +226,8 @@ end
-- User can touch any place of node, pin instantly will
-- move at this position and node drag will start.
-- This function require the Defold version 1.3.0+
-- @tparam Slider self Slider
-- @tparam node|string|nil input_node
---@param self Slider Slider
---@param input_node node|string|nil
-- @treturn Slider Slider
function M:set_input_node(input_node)
self._input_node = self:get_node(input_node)
@@ -236,15 +236,15 @@ end
--- Set Slider input enabled or disabled
-- @tparam Slider self Slider
-- @tparam boolean is_enabled
---@param self Slider Slider
---@param is_enabled boolean
function M:set_enabled(is_enabled)
self._is_enabled = is_enabled
end
--- Check if Slider component is enabled
-- @tparam Slider self Slider
---@param self Slider Slider
-- @treturn boolean
function M:is_enabled()
return self._is_enabled

View File

@@ -10,10 +10,10 @@
-- @alias druid.swipe
--- Swipe node
-- @tparam node node
---@param node node
--- Restriction zone
-- @tparam node|nil click_zone
---@param click_zone node|nil
--- Trigger on swipe event(self, swipe_side, dist, delta_time)
-- @tfield druid.event on_swipe) druid.event
@@ -160,8 +160,8 @@ end
--- Strict swipe click area. Useful for
-- restrict events outside stencil node
-- @tparam Swipe self Swipe
-- @tparam node|string|nil zone Gui node
---@param self Swipe Swipe
---@param zone node|string|nil Gui node
function M:set_click_zone(zone)
self.click_zone = self:get_node(zone)
end