mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 10:02:18 +02:00
Update annotations P.1
This commit is contained in:
@@ -10,11 +10,11 @@
|
||||
--
|
||||
-- Please review the following API pages:
|
||||
--
|
||||
-- @{Helper} - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc
|
||||
-- Helper - A useful set of functions for working with GUI nodes, such as centering nodes, get GUI scale ratio, etc
|
||||
--
|
||||
-- @{DruidEvent} - The core event system in Druid. Learn how to subscribe to any event in every Druid component.
|
||||
-- DruidEvent - The core event system in Druid. Learn how to subscribe to any event in every Druid component.
|
||||
--
|
||||
-- @{BaseComponent} - The parent class of all Druid components. You can find all default component methods there.
|
||||
-- BaseComponent - The parent class of all Druid components. You can find all default component methods there.
|
||||
--
|
||||
-- # Tech Info #
|
||||
--
|
||||
@@ -89,7 +89,21 @@ local back_handler = require("druid.base.back_handler")
|
||||
-- local lang_text = require("druid.extended.lang_text")
|
||||
-- local timer_component = require("druid.extended.timer")
|
||||
|
||||
local DruidInstance = {}
|
||||
---@class druid_instance
|
||||
---@field components_all druid.base_component[] All created components
|
||||
---@field components_interest table<string, druid.base_component[]> All components sorted by interest
|
||||
---@field url url
|
||||
---@field private _context table Druid context
|
||||
---@field private _style table Druid style table
|
||||
---@field private _deleted boolean
|
||||
---@field private _is_late_remove_enabled boolean
|
||||
---@field private _late_remove druid.base_component[]
|
||||
---@field private _input_blacklist druid.base_component[]|nil
|
||||
---@field private _input_whitelist druid.base_component[]|nil
|
||||
---@field private _input_inited boolean
|
||||
---@field private _late_init_timer_id number
|
||||
---@field private _input_components druid.base_component[]
|
||||
local M = {}
|
||||
|
||||
local MSG_ADD_FOCUS = hash("acquire_input_focus")
|
||||
local MSG_REMOVE_FOCUS = hash("release_input_focus")
|
||||
@@ -219,17 +233,15 @@ end
|
||||
|
||||
|
||||
--- Druid class constructor
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam table context Druid context. Usually it is self of gui script
|
||||
-- @tparam table style Druid style table
|
||||
-- @local
|
||||
function DruidInstance.initialize(self, context, style)
|
||||
function M:initialize(context, style)
|
||||
self._context = context
|
||||
self._style = style or settings.default_style
|
||||
self._deleted = false
|
||||
self._is_late_remove_enabled = false
|
||||
self._late_remove = {}
|
||||
self._is_debug = false
|
||||
self.url = msg.url()
|
||||
|
||||
self._input_blacklist = nil
|
||||
@@ -244,11 +256,10 @@ end
|
||||
|
||||
|
||||
-- Create new component.
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam BaseComponent component Component module
|
||||
-- @tparam any ... Other component params to pass it to component:init function
|
||||
-- @treturn BaseComponent Component instance
|
||||
function DruidInstance.new(self, component, ...)
|
||||
function M:new(component, ...)
|
||||
local instance = create(self, component)
|
||||
|
||||
if instance.init then
|
||||
@@ -263,8 +274,7 @@ end
|
||||
|
||||
|
||||
--- Call this in gui_script final function.
|
||||
-- @tparam DruidInstance self
|
||||
function DruidInstance.final(self)
|
||||
function M:final()
|
||||
local components = self.components_all
|
||||
|
||||
for i = #components, 1, -1 do
|
||||
@@ -282,10 +292,9 @@ end
|
||||
--- Remove created component from Druid instance.
|
||||
--
|
||||
-- Component `on_remove` function will be invoked, if exist.
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam BaseComponent component Component instance
|
||||
-- @treturn boolean True if component was removed
|
||||
function DruidInstance.remove(self, component)
|
||||
function M:remove(component)
|
||||
if self._is_late_remove_enabled then
|
||||
table.insert(self._late_remove, component)
|
||||
return false
|
||||
@@ -334,9 +343,8 @@ end
|
||||
--- Druid late update function called after initialization and before the regular update step
|
||||
-- This function is used to check the GUI state and perform actions after all components and nodes have been created.
|
||||
-- An example use case is performing an auto stencil check in the GUI hierarchy for input components.
|
||||
-- @tparam DruidInstance self
|
||||
-- @local
|
||||
function DruidInstance.late_init(self)
|
||||
function M:late_init()
|
||||
local late_init_components = self.components_interest[base_component.ON_LATE_INIT]
|
||||
while late_init_components[1] do
|
||||
late_init_components[1]:on_late_init()
|
||||
@@ -353,9 +361,8 @@ end
|
||||
--- Call this in gui_script update function.
|
||||
--
|
||||
-- Used for: scroll, progress, timer components
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam number dt Delta time
|
||||
function DruidInstance.update(self, dt)
|
||||
function M:update(dt)
|
||||
self._is_late_remove_enabled = true
|
||||
|
||||
local components = self.components_interest[base_component.ON_UPDATE]
|
||||
@@ -371,11 +378,10 @@ end
|
||||
--- Call this in gui_script on_input function.
|
||||
--
|
||||
-- Used for almost all components
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam hash action_id Action_id from on_input
|
||||
-- @tparam table action Action from on_input
|
||||
-- @treturn boolean The boolean value is input was consumed
|
||||
function DruidInstance.on_input(self, action_id, action)
|
||||
function M:on_input(action_id, action)
|
||||
self._is_late_remove_enabled = true
|
||||
|
||||
local components = self.components_interest[base_component.ON_INPUT]
|
||||
@@ -392,11 +398,10 @@ end
|
||||
--- Call this in gui_script on_message function.
|
||||
--
|
||||
-- Used for special actions. See SPECIFIC_UI_MESSAGES table
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam hash message_id Message_id from on_message
|
||||
-- @tparam table message Message from on_message
|
||||
-- @tparam url sender Sender from on_message
|
||||
function DruidInstance.on_message(self, message_id, message, sender)
|
||||
function M:on_message(message_id, message, sender)
|
||||
local specific_ui_message = base_component.SPECIFIC_UI_MESSAGES[message_id]
|
||||
|
||||
if specific_ui_message == base_component.ON_MESSAGE_INPUT then
|
||||
@@ -431,9 +436,8 @@ end
|
||||
|
||||
--- Calls the on_focus_lost function in all related components
|
||||
-- This one called by on_window_callback by global window listener
|
||||
-- @tparam DruidInstance self
|
||||
-- @local
|
||||
function DruidInstance.on_focus_lost(self)
|
||||
function M:on_focus_lost()
|
||||
local components = self.components_interest[base_component.ON_FOCUS_LOST]
|
||||
for i = 1, #components do
|
||||
components[i]:on_focus_lost()
|
||||
@@ -443,9 +447,8 @@ end
|
||||
|
||||
--- Calls the on_focus_gained function in all related components
|
||||
-- This one called by on_window_callback by global window listener
|
||||
-- @tparam DruidInstance self
|
||||
-- @local
|
||||
function DruidInstance.on_focus_gained(self)
|
||||
function M:on_focus_gained()
|
||||
local components = self.components_interest[base_component.ON_FOCUS_GAINED]
|
||||
for i = 1, #components do
|
||||
components[i]:on_focus_gained()
|
||||
@@ -456,9 +459,8 @@ end
|
||||
--- Calls the on_language_change function in all related components
|
||||
-- This one called by global druid.on_language_change, but can be
|
||||
-- call manualy to update all translations
|
||||
-- @tparam DruidInstance self
|
||||
-- @local
|
||||
function DruidInstance.on_language_change(self)
|
||||
function M:on_language_change()
|
||||
local components = self.components_interest[base_component.ON_LANGUAGE_CHANGE]
|
||||
for i = 1, #components do
|
||||
components[i]:on_language_change()
|
||||
@@ -470,10 +472,9 @@ end
|
||||
--
|
||||
-- If whitelist is not empty and component not contains in this list,
|
||||
-- component will be not processed on input step
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam table|BaseComponent|nil whitelist_components The array of component to whitelist
|
||||
-- @treturn self @{DruidInstance}
|
||||
function DruidInstance.set_whitelist(self, whitelist_components)
|
||||
-- @treturn self DruidInstance
|
||||
function M:set_whitelist(whitelist_components)
|
||||
if whitelist_components and whitelist_components._component then
|
||||
whitelist_components = { whitelist_components }
|
||||
end
|
||||
@@ -491,11 +492,10 @@ end
|
||||
--- Set blacklist components for input processing.
|
||||
--
|
||||
-- If blacklist is not empty and component contains in this list,
|
||||
-- component will be not processed on input step
|
||||
-- @tparam DruidInstance self @{DruidInstance}
|
||||
-- component will be not processed on input step DruidInstance
|
||||
-- @tparam table|BaseComponent|nil blacklist_components The array of component to blacklist
|
||||
-- @treturn self @{DruidInstance}
|
||||
function DruidInstance.set_blacklist(self, blacklist_components)
|
||||
-- @treturn self DruidInstance
|
||||
function M:set_blacklist(blacklist_components)
|
||||
if blacklist_components and blacklist_components._component then
|
||||
blacklist_components = { blacklist_components }
|
||||
end
|
||||
@@ -510,35 +510,9 @@ function DruidInstance.set_blacklist(self, blacklist_components)
|
||||
end
|
||||
|
||||
|
||||
--- Set debug mode for current Druid instance. It's enable debug log messages
|
||||
-- @tparam DruidInstance self @{DruidInstance}
|
||||
-- @tparam boolean|nil is_debug
|
||||
-- @treturn self @{DruidInstance}
|
||||
--- Remove all components on late remove step DruidInstance
|
||||
-- @local
|
||||
function DruidInstance.set_debug(self, is_debug)
|
||||
self._is_debug = is_debug
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Log message, if is_debug mode is enabled
|
||||
-- @tparam DruidInstance self @{DruidInstance}
|
||||
-- @tparam string message
|
||||
-- @tparam table|nil context
|
||||
-- @local
|
||||
function DruidInstance.log_message(self, message, context)
|
||||
if not self._is_debug then
|
||||
return
|
||||
end
|
||||
|
||||
print("[Druid]:", message, helper.table_to_string(context))
|
||||
end
|
||||
|
||||
|
||||
--- Remove all components on late remove step
|
||||
-- @tparam DruidInstance self @{DruidInstance}
|
||||
-- @local
|
||||
function DruidInstance._clear_late_remove(self)
|
||||
function M:_clear_late_remove()
|
||||
if #self._late_remove == 0 then
|
||||
return
|
||||
end
|
||||
@@ -550,229 +524,188 @@ function DruidInstance._clear_late_remove(self)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Button} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node The node_id or gui.get_node(node_id)
|
||||
-- @tparam function|nil callback Button callback
|
||||
-- @tparam any|nil params Button callback params
|
||||
-- @tparam node|string|nil anim_node Button anim node (node, if not provided)
|
||||
-- @treturn Button @{Button} component
|
||||
function DruidInstance.new_button(self, node, callback, params, anim_node)
|
||||
return DruidInstance.new(self, button, node, callback, params, anim_node)
|
||||
--- Create Button component
|
||||
---@param node string|node The node_id or gui.get_node(node_id)
|
||||
---@param callback function|nil Button callback
|
||||
---@param params any|nil Button callback params
|
||||
---@param anim_node node|string|nil Button anim node (node, if not provided)
|
||||
---@return druid.button Button component
|
||||
function M:new_button(node, callback, params, anim_node)
|
||||
return self:new(button, node, callback, params, anim_node)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Blocker} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node The node_id or gui.get_node(node_id)
|
||||
-- @treturn Blocker @{Blocker} component
|
||||
function DruidInstance.new_blocker(self, node)
|
||||
return DruidInstance.new(self, blocker, node)
|
||||
--- Create Blocker component
|
||||
---@param node string|node The node_id or gui.get_node(node_id)
|
||||
---@return druid.blocker Blocker component
|
||||
function M:new_blocker(node)
|
||||
return self:new(blocker, node)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{BackHandler} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam function|nil callback @The callback(self, custom_args) to call on back event
|
||||
-- @tparam any|nil params Callback argument
|
||||
-- @treturn BackHandler @{BackHandler} component
|
||||
function DruidInstance.new_back_handler(self, callback, params)
|
||||
return DruidInstance.new(self, back_handler, callback, params)
|
||||
--- Create BackHandler component
|
||||
---@param callback function|nil The callback(self, custom_args) to call on back event
|
||||
---@param params any|nil Callback argument
|
||||
---@return druid.back_handler BackHandler component
|
||||
function M:new_back_handler(callback, params)
|
||||
return self:new(back_handler, callback, params)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Hover} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node The node_id or gui.get_node(node_id)
|
||||
-- @tparam function|nil on_hover_callback Hover callback
|
||||
-- @tparam function|nil on_mouse_hover_callback Mouse hover callback
|
||||
-- @treturn Hover @{Hover} component
|
||||
function DruidInstance.new_hover(self, node, on_hover_callback, on_mouse_hover_callback)
|
||||
return DruidInstance.new(self, hover, node, on_hover_callback, on_mouse_hover_callback)
|
||||
--- Create Hover component
|
||||
---@param node string|node The node_id or gui.get_node(node_id)
|
||||
---@param on_hover_callback function|nil Hover callback
|
||||
---@param on_mouse_hover_callback function|nil Mouse hover callback
|
||||
---@return druid.hover Hover component
|
||||
function M:new_hover(node, on_hover_callback, on_mouse_hover_callback)
|
||||
return self:new(hover, node, on_hover_callback, on_mouse_hover_callback)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Text} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node The node_id or gui.get_node(node_id)
|
||||
-- @tparam string|nil value Initial text. Default value is node text from GUI scene.
|
||||
-- @tparam boolean|nil no_adjust If true, text will be not auto-adjust size
|
||||
-- @treturn Text @{Text} component
|
||||
function DruidInstance.new_text(self, node, value, no_adjust)
|
||||
return DruidInstance.new(self, text, node, value, no_adjust)
|
||||
--- 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
|
||||
---@return druid.text Text component
|
||||
function M:new_text(node, value, no_adjust)
|
||||
return self:new(text, node, value, no_adjust)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{StaticGrid} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node parent_node The node_id or gui.get_node(node_id). Parent of all Grid items.
|
||||
-- @tparam node item Element prefab. Required to get grid's item size. Can be adjusted separately.
|
||||
-- @tparam number|nil in_row How many nodes in row can be placed
|
||||
-- @treturn StaticGrid @{StaticGrid} component
|
||||
-- @local
|
||||
function DruidInstance.new_grid(self, parent_node, item, in_row)
|
||||
return DruidInstance.new(self, static_grid, parent_node, item, in_row)
|
||||
--- Create StaticGrid component
|
||||
---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items.
|
||||
---@param item node Element prefab. Required to get grid's item size. Can be adjusted separately.
|
||||
---@param in_row number|nil How many nodes in row can be placed
|
||||
---@return druid.grid StaticGrid component
|
||||
function M:new_grid(parent_node, item, in_row)
|
||||
return self:new(static_grid, parent_node, item, in_row)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{StaticGrid} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node parent_node The node_id or gui.get_node(node_id). Parent of all Grid items.
|
||||
-- @tparam string|node item Item prefab. Required to get grid's item size. Can be adjusted separately.
|
||||
-- @tparam number|nil in_row How many nodes in row can be placed
|
||||
-- @treturn StaticGrid @{StaticGrid} component
|
||||
function DruidInstance.new_static_grid(self, parent_node, item, in_row)
|
||||
return DruidInstance.new(self, static_grid, parent_node, item, in_row)
|
||||
--- Create StaticGrid component
|
||||
---@param parent_node string|node The node_id or gui.get_node(node_id). Parent of all Grid items.
|
||||
---@param item string|node Item prefab. Required to get grid's item size. Can be adjusted separately.
|
||||
---@param in_row number|nil How many nodes in row can be placed
|
||||
---@return druid.grid StaticGrid component
|
||||
function M:new_static_grid(parent_node, item, in_row)
|
||||
return self:new(static_grid, parent_node, item, in_row)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Scroll} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node view_node The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
-- @tparam string|node content_node The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node.
|
||||
-- @treturn Scroll @{Scroll} component
|
||||
function DruidInstance.new_scroll(self, view_node, content_node)
|
||||
return DruidInstance.new(self, scroll, view_node, content_node)
|
||||
--- Create Scroll component
|
||||
---@param view_node string|node The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
---@param content_node string|node The node_id or gui.get_node(node_id). Will used as scrollable node inside view_node.
|
||||
---@return druid.scroll Scroll component
|
||||
function M:new_scroll(view_node, content_node)
|
||||
return self:new(scroll, view_node, content_node)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Drag} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
-- @tparam function|nil on_drag_callback Callback for on_drag_event(self, dx, dy)
|
||||
-- @treturn Drag @{Drag} component
|
||||
function DruidInstance.new_drag(self, node, on_drag_callback)
|
||||
return DruidInstance.new(self, drag, node, on_drag_callback)
|
||||
--- Create Drag component
|
||||
---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
---@param on_drag_callback function|nil Callback for on_drag_event(self, dx, dy)
|
||||
---@return druid.drag Drag component
|
||||
function M:new_drag(node, on_drag_callback)
|
||||
return self:new(drag, node, on_drag_callback)
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Swipe} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
-- @tparam function|nil on_swipe_callback Swipe callback for on_swipe_end event
|
||||
-- @treturn Swipe @{Swipe} component
|
||||
function DruidInstance.new_swipe(self, node, on_swipe_callback)
|
||||
return helper.require_component_message("swipe")
|
||||
--- Create Swipe component
|
||||
---@param node string|node The node_id or gui.get_node(node_id). Will used as user input node.
|
||||
---@param on_swipe_callback function|nil Swipe callback for on_swipe_end event
|
||||
---@return druid.swipe Swipe component
|
||||
function M:new_swipe(node, on_swipe_callback)
|
||||
return helper.require_component_message("swipe") --[[@as druid.swipe]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{DynamicGrid} component
|
||||
-- Deprecated
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node parent_node The node_id or gui.get_node(node_id). Parent of all Grid items.
|
||||
-- @treturn DynamicGrid @{DynamicGrid} component
|
||||
function DruidInstance.new_dynamic_grid(self, parent_node)
|
||||
return helper.require_component_message("dynamic_grid")
|
||||
--- Create LangText component
|
||||
---@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 node. Default: const.TEXT_ADJUST.DOWNSCALE
|
||||
---@return druid.lang_text LangText component
|
||||
function M:new_lang_text(node, locale_id, adjust_type)
|
||||
return helper.require_component_message("lang_text") --[[@as druid.lang_text]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{LangText} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @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 node. Default: const.TEXT_ADJUST.DOWNSCALE
|
||||
-- @treturn LangText @{LangText} component
|
||||
function DruidInstance.new_lang_text(self, node, locale_id, adjust_type)
|
||||
return helper.require_component_message("lang_text")
|
||||
--- Create Slider component
|
||||
---@param pin_node string|node The_node id or gui.get_node(node_id).
|
||||
---@param end_pos vector3 The end position of slider
|
||||
---@param callback function|nil On slider change callback
|
||||
---@return druid.slider Slider component
|
||||
function M:new_slider(pin_node, end_pos, callback)
|
||||
return helper.require_component_message("slider") --[[@as druid.slider]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Slider} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node pin_node The_node id or gui.get_node(node_id).
|
||||
-- @tparam vector3 end_pos The end position of slider
|
||||
-- @tparam function|nil callback On slider change callback
|
||||
-- @treturn Slider @{Slider} component
|
||||
function DruidInstance.new_slider(self, pin_node, end_pos, callback)
|
||||
return helper.require_component_message("slider")
|
||||
--- Create Input component
|
||||
---@param click_node string|node Button node to enabled input component
|
||||
---@param text_node string|node|druid.text Text node what will be changed on user input
|
||||
---@param keyboard_type number|nil Gui keyboard type for input field
|
||||
---@return druid.input Input component
|
||||
function M:new_input(click_node, text_node, keyboard_type)
|
||||
return helper.require_component_message("input") --[[@as druid.input]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Input} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node click_node Button node to enabled input component
|
||||
-- @tparam string|node|druid.text text_node Text node what will be changed on user input
|
||||
-- @tparam number|nil keyboard_type Gui keyboard type for input field
|
||||
-- @treturn Input @{Input} component
|
||||
function DruidInstance.new_input(self, click_node, text_node, keyboard_type)
|
||||
return helper.require_component_message("input")
|
||||
--- Create DataList component
|
||||
---@param druid_scroll druid.scroll The Scroll instance for Data List component
|
||||
---@param druid_grid druid.grid 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])
|
||||
---@return druid.data_list DataList component
|
||||
function M:new_data_list(druid_scroll, druid_grid, create_function)
|
||||
return helper.require_component_message("data_list") --[[@as druid.data_list]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{DataList} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam Scroll druid_scroll The Scroll instance for Data List component
|
||||
-- @tparam StaticGrid druid_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])
|
||||
-- @treturn DataList @{DataList} component
|
||||
function DruidInstance.new_data_list(self, druid_scroll, druid_grid, create_function)
|
||||
return helper.require_component_message("data_list")
|
||||
--- Create Timer component
|
||||
---@param node string|node Gui text node
|
||||
---@param seconds_from number Start timer value in seconds
|
||||
---@param seconds_to number|nil End timer value in seconds
|
||||
---@param callback function|nil Function on timer end
|
||||
---@return druid.timer Timer component
|
||||
function M:new_timer(node, seconds_from, seconds_to, callback)
|
||||
return helper.require_component_message("timer") --[[@as druid.timer]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Timer} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node Gui text node
|
||||
-- @tparam number seconds_from Start timer value in seconds
|
||||
-- @tparam number|nil seconds_to End timer value in seconds
|
||||
-- @tparam function|nil callback Function on timer end
|
||||
-- @treturn Timer @{Timer} component
|
||||
function DruidInstance.new_timer(self, node, seconds_from, seconds_to, callback)
|
||||
return helper.require_component_message("timer")
|
||||
--- Create Progress component
|
||||
---@param node string|node Progress bar fill node or node name
|
||||
---@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
|
||||
---@return druid.progress Progress component
|
||||
function M:new_progress(node, key, init_value)
|
||||
return helper.require_component_message("progress") --[[@as druid.progress]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Progress} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node Progress bar fill node or node name
|
||||
-- @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
|
||||
-- @treturn Progress @{Progress} component
|
||||
function DruidInstance.new_progress(self, node, key, init_value)
|
||||
return helper.require_component_message("progress")
|
||||
--- Create Layout component
|
||||
---@param node string|node The_node id or gui.get_node(node_id).
|
||||
---@param mode string The layout mode
|
||||
---@return druid.layout Layout component
|
||||
function M:new_layout(node, mode)
|
||||
return helper.require_component_message("layout") --[[@as druid.layout]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Layout} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node node The_node id or gui.get_node(node_id).
|
||||
-- @tparam string mode The layout mode
|
||||
-- @treturn Layout @{Layout} component
|
||||
function DruidInstance.new_layout(self, node, mode)
|
||||
return helper.require_component_message("layout")
|
||||
--- 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 The callback function
|
||||
---@param callback_argument any|nil The argument to pass into the callback function
|
||||
---@return druid.hotkey Hotkey component
|
||||
function M:new_hotkey(keys_array, callback, callback_argument)
|
||||
return helper.require_component_message("hotkey") --[[@as druid.hotkey]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{Hotkey} component
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|string[] keys_array Keys for trigger action. Should contains one action key and any amount of modificator keys
|
||||
-- @tparam function callback The callback function
|
||||
-- @tparam any|nil callback_argument The argument to pass into the callback function
|
||||
-- @treturn Hotkey @{Hotkey} component
|
||||
function DruidInstance.new_hotkey(self, keys_array, callback, callback_argument)
|
||||
return helper.require_component_message("hotkey")
|
||||
--- Create RichText component.
|
||||
---@param text_node string|node The text node to make Rich Text
|
||||
---@param value string|nil The initial text value. Default will be gui.get_text(text_node)
|
||||
---@return druid.rich_text RichText component
|
||||
function M:new_rich_text(text_node, value)
|
||||
return helper.require_component_message("rich_text", "custom") --[[@as druid.rich_text]]
|
||||
end
|
||||
|
||||
|
||||
--- Create @{RichText} component.
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string|node text_node The text node to make Rich Text
|
||||
-- @tparam string|nil value The initial text value. Default will be gui.get_text(text_node)
|
||||
-- @treturn RichText @{RichText} component
|
||||
function DruidInstance.new_rich_text(self, text_node, value)
|
||||
return helper.require_component_message("rich_text", "custom")
|
||||
end
|
||||
|
||||
|
||||
--- Create @{RichInput} component.
|
||||
--- Create RichInput component.
|
||||
-- As a template please check rich_input.gui layout.
|
||||
-- @tparam DruidInstance self
|
||||
-- @tparam string template The template string name
|
||||
-- @tparam table nodes Nodes table from gui.clone_tree
|
||||
-- @treturn RichInput @{RichInput} component
|
||||
function DruidInstance.new_rich_input(self, template, nodes)
|
||||
return helper.require_component_message("rich_input", "custom")
|
||||
---@param template string The template string name
|
||||
---@param nodes table Nodes table from gui.clone_tree
|
||||
---@return druid.rich_input RichInput component
|
||||
function M:new_rich_input(template, nodes)
|
||||
return helper.require_component_message("rich_input", "custom") --[[@as druid.rich_input]]
|
||||
end
|
||||
|
||||
|
||||
return DruidInstance
|
||||
return M
|
||||
|
@@ -1,21 +1,15 @@
|
||||
-- Copyright (c) 2021 Maksim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
|
||||
|
||||
--- Druid settings file
|
||||
-- @module settings
|
||||
-- @local
|
||||
|
||||
---@class druid.system.settings
|
||||
local M = {}
|
||||
|
||||
M.default_style = nil
|
||||
|
||||
|
||||
function M.get_text(name, a, b, c, d, e, f, g)
|
||||
---@param text_id string
|
||||
---@vararg any
|
||||
function M.get_text(text_id, ...)
|
||||
return "[Druid]: locales not inited"
|
||||
end
|
||||
|
||||
|
||||
function M.play_sound(name)
|
||||
function M.play_sound(sound_id)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user