mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Update
This commit is contained in:
@@ -309,10 +309,10 @@ end
|
||||
|
||||
|
||||
---Button constructor
|
||||
---@param node_or_node_id node|string Node name or GUI Node itself.
|
||||
---@param node_or_node_id node|string Node name or GUI Node itself
|
||||
---@param callback fun()|nil Callback on button click
|
||||
---@param custom_args any|nil Custom args for any Button event
|
||||
---@param anim_node node|string|nil Node to animate instead of trigger node.
|
||||
---@param anim_node node|string|nil Node to animate instead of trigger node
|
||||
function M:init(node_or_node_id, callback, custom_args, anim_node)
|
||||
self.druid = self:get_druid()
|
||||
self.node = self:get_node(node_or_node_id)
|
||||
|
@@ -194,7 +194,7 @@ end
|
||||
|
||||
|
||||
function M.load_palette()
|
||||
local PALETTE_PATH = sys.get_config_string("fluid.palette")
|
||||
local PALETTE_PATH = sys.get_config_string("druid.palette")
|
||||
if PALETTE_PATH then
|
||||
PALETTE_DATA = M.load_json(PALETTE_PATH) --[[@as table<string, table<string, vector4>>]]
|
||||
end
|
||||
|
@@ -424,7 +424,7 @@ function M._update_nodes(lines, settings)
|
||||
gui.set_outline(node, word.outline)
|
||||
gui.set_shadow(node, word.shadow)
|
||||
gui.set_text(node, word.text)
|
||||
gui.set_color(node, word.color)
|
||||
gui.set_color(node, word.color or word.text_color)
|
||||
gui.set_font(node, word.font or settings.font)
|
||||
end
|
||||
word.node = node
|
||||
|
@@ -102,6 +102,7 @@ local rich_text = require("druid.custom.rich_text.module.rt")
|
||||
---@field relative_scale number
|
||||
---@field source_text string
|
||||
---@field color vector4
|
||||
---@field text_color vector4
|
||||
---@field position vector3
|
||||
---@field offset vector3
|
||||
---@field scale vector3
|
||||
|
@@ -89,35 +89,23 @@ end
|
||||
|
||||
--- Translate the text by locale_id
|
||||
---@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
|
||||
---@param ... string Optional params for string.format
|
||||
---@return druid.lang_text 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 }
|
||||
function M:translate(locale_id, ...)
|
||||
self.last_locale_args = { ... }
|
||||
self.last_locale = locale_id or self.last_locale
|
||||
self.text:set_text(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
|
||||
self.text:set_text(settings.get_text(self.last_locale, ...) or "")
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Format string with new text params on localized text
|
||||
---@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
|
||||
---@param ... string Optional params for string.format
|
||||
---@return druid.lang_text Current instance
|
||||
function M:format(a, b, c, d, e, f, g)
|
||||
self.last_locale_args = { a, b, c, d, e, f, g }
|
||||
self.text:set_text(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
|
||||
function M:format(...)
|
||||
self.last_locale_args = { ... }
|
||||
self.text:set_text(settings.get_text(self.last_locale, ...) or "")
|
||||
|
||||
return self
|
||||
end
|
||||
|
@@ -288,14 +288,16 @@ function M:refresh_layout()
|
||||
local new_row_width = width * (0.5 - layout_pivot_offset.x)
|
||||
|
||||
-- Compare with eps due the float loss and element flickering
|
||||
if current_x + node_width - new_row_width > 0.0001 then
|
||||
if current_x + node_width - new_row_width > 0.00001 then
|
||||
current_y = current_y - row.height - margin.y
|
||||
|
||||
if row_index < #rows then
|
||||
row_index = row_index + 1
|
||||
row = rows[row_index]
|
||||
end
|
||||
|
||||
current_x = -row.width * (0.5 + layout_pivot_offset.x)
|
||||
current_y = current_y - row.height - margin.y
|
||||
|
||||
if is_justify and row.count > 1 then
|
||||
current_x = -max_width * (0.5 + layout_pivot_offset.x)
|
||||
end
|
||||
|
@@ -1,3 +1,5 @@
|
||||
-- Hello! Wish you a good day!
|
||||
|
||||
local events = require("event.events")
|
||||
local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
|
@@ -4,7 +4,7 @@ local M = {}
|
||||
M.default_style = nil
|
||||
|
||||
---@param text_id string
|
||||
---@vararg any
|
||||
---@param ... string Optional params for string.format
|
||||
function M.get_text(text_id, ...)
|
||||
return "[Druid]: locales not inited"
|
||||
end
|
||||
|
Reference in New Issue
Block a user