Remove html api, update docs

This commit is contained in:
Insality
2025-03-20 00:26:29 +02:00
parent f786b20951
commit 10556ba31a
69 changed files with 294 additions and 17870 deletions

View File

@@ -2,7 +2,16 @@ local event = require("event.event")
local component = require("druid.component")
local settings = require("druid.system.settings")
---The component used for displaying localized text, can automatically update text when locale is changed
---The component used for displaying localized text, can automatically update text when locale is changed.
---It wraps the Text component to handle localization using druid's get_text_function to set text by its id.
---
---### Setup
---Create lang text component with druid: `text = druid:new_lang_text(node_name, locale_id)`
---
---### Notes
---- Component automatically updates text when locale is changed
---- Uses druid's get_text_function to get localized text by id
---- Supports string formatting with additional parameters
---@class druid.lang_text: druid.component
---@field text druid.text The text component
---@field node node The node of the text component
@@ -13,7 +22,7 @@ local M = component.create("lang_text")
---@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 locale_id string|nil Default locale id or text from node as default. If not provided, will use text from the node
---@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()
@@ -38,7 +47,7 @@ function M:on_language_change()
end
---Setup raw text to lang_text component
---Setup raw text to lang_text component. This will clear any locale settings.
---@param text string Text for text node
---@return druid.lang_text self Current instance
function M:set_to(text)
@@ -50,7 +59,7 @@ function M:set_to(text)
end
---Setup raw text to lang_text component
---Setup raw text to lang_text component. This will clear any locale settings.
---@param text string Text for text node
---@return druid.lang_text self Current instance
function M:set_text(text)
@@ -58,8 +67,8 @@ function M:set_text(text)
end
---Translate the text by locale_id
---@param locale_id string Locale id
---Translate the text by locale_id. The text will be automatically updated when locale changes.
---@param locale_id string Locale id to get text from
---@param ... string Optional params for string.format
---@return druid.lang_text self Current instance
function M:translate(locale_id, ...)
@@ -71,7 +80,7 @@ function M:translate(locale_id, ...)
end
---Format string with new text params on localized text
---Format string with new text params on localized text. Keeps the current locale but updates the format parameters.
---@param ... string Optional params for string.format
---@return druid.lang_text self Current instance
function M:format(...)