mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
Blocker by default is enabled, update color palette, add rich text split by characters option, able to pass a data to GO widgets
This commit is contained in:
@@ -181,6 +181,7 @@ function M.create(text, settings, style)
|
||||
shadow = settings.shadow,
|
||||
outline = settings.outline,
|
||||
font = gui.get_font(settings.text_prefab),
|
||||
split_to_characters = settings.split_to_characters,
|
||||
-- Image params
|
||||
---@type druid.rich_text.word.image
|
||||
image = nil,
|
||||
|
@@ -29,6 +29,7 @@ local function add_word(text, settings, words)
|
||||
end
|
||||
|
||||
words[#words + 1] = data
|
||||
return data
|
||||
end
|
||||
|
||||
|
||||
@@ -44,7 +45,16 @@ local function split_line(line, settings, words)
|
||||
else
|
||||
local wi = #words
|
||||
for word in trimmed_text:gmatch("%S+") do
|
||||
add_word(word .. " ", settings, words)
|
||||
if settings.split_to_characters then
|
||||
for i = 1, #word do
|
||||
local symbol = utf8.sub(word, i, i)
|
||||
local w = add_word(symbol, settings, words)
|
||||
w.nobr = true
|
||||
end
|
||||
add_word(" ", settings, words)
|
||||
else
|
||||
add_word(word .. " ", settings, words)
|
||||
end
|
||||
end
|
||||
local first = words[wi + 1]
|
||||
first.text = ws_start .. first.text
|
||||
|
@@ -2,7 +2,8 @@
|
||||
-- Author: Britzl
|
||||
-- Modified by: Insality
|
||||
|
||||
local color = require("druid.custom.rich_text.module.rt_color")
|
||||
--local color = require("druid.custom.rich_text.module.rt_color")
|
||||
local color = require("druid.color")
|
||||
|
||||
local M = {}
|
||||
local tags = {}
|
||||
@@ -44,19 +45,19 @@ end
|
||||
-- Example: <color=FF0000>Rich Text</color>
|
||||
M.register("color", function(params, settings, style)
|
||||
params = style.COLORS[params] or params
|
||||
settings.color = color.parse(params)
|
||||
settings.color = color.get_color(params)
|
||||
end)
|
||||
|
||||
|
||||
M.register("shadow", function(params, settings, style)
|
||||
params = style.COLORS[params] or params
|
||||
settings.shadow = color.parse(params)
|
||||
settings.shadow = color.get_color(params)
|
||||
end)
|
||||
|
||||
|
||||
M.register("outline", function(params, settings, style)
|
||||
params = style.COLORS[params] or params
|
||||
settings.outline = color.parse(params)
|
||||
settings.outline = color.get_color(params)
|
||||
end)
|
||||
|
||||
|
||||
|
@@ -13,6 +13,7 @@ local rich_text = require("druid.custom.rich_text.module.rt")
|
||||
---@field image_pixel_grid_snap boolean
|
||||
---@field combine_words boolean
|
||||
---@field default_animation string
|
||||
---@field split_by_character boolean
|
||||
---@field text_prefab node
|
||||
---@field adjust_scale number
|
||||
---@field default_texture string
|
||||
@@ -194,6 +195,15 @@ function M:tagged(tag)
|
||||
end
|
||||
|
||||
|
||||
---Set if the rich text should split to characters, not words
|
||||
---@param value boolean
|
||||
---@return druid.rich_text self
|
||||
function M:set_split_to_characters(value)
|
||||
self._settings.split_to_characters = value
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
---Get all current created words, each word is a table that contains the information about the word
|
||||
---@return druid.rich_text.word[]
|
||||
function M:get_words()
|
||||
@@ -239,6 +249,7 @@ function M:_create_settings()
|
||||
outline = gui.get_outline(self.root),
|
||||
text_leading = gui.get_leading(self.root),
|
||||
is_multiline = gui.get_line_break(self.root),
|
||||
split_to_characters = false,
|
||||
|
||||
-- Image settings
|
||||
image_pixel_grid_snap = false, -- disabled now
|
||||
|
Reference in New Issue
Block a user