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:
Insality
2025-05-27 23:10:32 +03:00
parent fe955b6e64
commit 2e1f280944
8 changed files with 58 additions and 27 deletions

View File

@@ -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,

View File

@@ -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

View File

@@ -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)