mirror of
https://github.com/Insality/druid.git
synced 2025-09-28 02:22:18 +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)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user