mirror of
https://github.com/Insality/druid
synced 2025-09-28 02:22:19 +02:00
Update annotations: dynamic_grid, input, lang_text, progress, radio_roup, slider, timer
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
--- Component to handle all GUI texts
|
||||
-- Good working with localization system
|
||||
-- @module druid.lang_text
|
||||
-- @module LangText
|
||||
-- @within BaseComponent
|
||||
-- @alias druid.lang_text
|
||||
|
||||
--- Component events
|
||||
-- @table Events
|
||||
-- @tfield druid_event on_change On change text callback
|
||||
--- On change text callback
|
||||
-- @tfield druid_event on_change
|
||||
|
||||
--- The text component
|
||||
-- @tfield Text text
|
||||
|
||||
--- Component fields
|
||||
-- @table Fields
|
||||
-- @tfield druid.text text The text component
|
||||
|
||||
local Event = require("druid.event")
|
||||
local const = require("druid.const")
|
||||
@@ -21,11 +20,11 @@ local LangText = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
|
||||
|
||||
|
||||
--- Component init function
|
||||
-- @function lang_text:init
|
||||
-- @tparam LangText self
|
||||
-- @tparam node node The text node
|
||||
-- @tparam string locale_id Default locale id
|
||||
-- @tparam bool no_adjust If true, will not correct text size
|
||||
function LangText:init(node, locale_id, no_adjust)
|
||||
function LangText.init(self, node, locale_id, no_adjust)
|
||||
self.druid = self:get_druid()
|
||||
self.text = self.druid:new_text(node, locale_id, no_adjust)
|
||||
self.last_locale_args = {}
|
||||
@@ -38,7 +37,7 @@ function LangText:init(node, locale_id, no_adjust)
|
||||
end
|
||||
|
||||
|
||||
function LangText:on_language_change()
|
||||
function LangText.on_language_change(self)
|
||||
if self.last_locale then
|
||||
self:translate(self.last_locale, unpack(self.last_locale_args))
|
||||
end
|
||||
@@ -46,9 +45,9 @@ end
|
||||
|
||||
|
||||
--- Setup raw text to lang_text component
|
||||
-- @function lang_text:set_to
|
||||
-- @tparam LangText self
|
||||
-- @tparam string text Text for text node
|
||||
function LangText:set_to(text)
|
||||
function LangText.set_to(self, text)
|
||||
self.last_locale = false
|
||||
self.text:set_to(text)
|
||||
self.on_change:trigger()
|
||||
@@ -56,9 +55,9 @@ end
|
||||
|
||||
|
||||
--- Translate the text by locale_id
|
||||
-- @function lang_text:translate
|
||||
-- @tparam LangText self
|
||||
-- @tparam string locale_id Locale id
|
||||
function LangText:translate(locale_id, ...)
|
||||
function LangText.translate(self, locale_id, ...)
|
||||
self.last_locale_args = {...}
|
||||
self.last_locale = locale_id or self.last_locale
|
||||
self.text:set_to(settings.get_text(self.last_locale, ...))
|
||||
|
Reference in New Issue
Block a user