Remove colors from rich text

This commit is contained in:
Insality 2025-05-28 22:13:44 +03:00
parent 0cf5ba30db
commit 97942965cd
4 changed files with 22 additions and 30 deletions

View File

@ -51,7 +51,6 @@ local rich_text = require("druid.custom.rich_text.module.rt")
---@field height number
---@class druid.rich_text.style
---@field COLORS table<string, vector4>
---@field ADJUST_STEPS number
---@field ADJUST_SCALE_DELTA number
@ -105,7 +104,6 @@ end
---@param style druid.rich_text.style
function M:on_style_change(style)
self.style = {
COLORS = style.COLORS or {},
ADJUST_STEPS = style.ADJUST_STEPS or 20,
ADJUST_SCALE_DELTA = style.ADJUST_SCALE_DELTA or 0.02,
}

View File

@ -148,12 +148,4 @@ M["hotkey"] = {
}
M["rich_text"] = {
COLORS = {
white = "#FFFFFF",
black = "#000000"
}
}
return M

View File

@ -205,7 +205,10 @@ end
function M:update(dt)
if self.is_dirty then
if not self.is_dirty then
return
end
self.is_dirty = false
self:clear_created_properties()
@ -225,7 +228,6 @@ function M:update(dt)
for index = start_index, end_index do
self.properties_constructors[index]()
end
end
end

View File

@ -81,7 +81,7 @@ return function()
local rich_text = druid:new_rich_text(text_node)
-- Test color tag with named color
local words = rich_text:set_text("<color=red>Colored Text</color>")
local words = rich_text:set_text("<color=#FF0000>Colored Text</color>")
assert(#words > 0)
-- Word should have a tags field with color tag
@ -104,7 +104,7 @@ return function()
local rich_text = druid:new_rich_text(text_node)
-- Test shadow tag with named color
local words = rich_text:set_text("<shadow=black>Shadowed Text</shadow>")
local words = rich_text:set_text("<shadow=#000000>Shadowed Text</shadow>")
assert(#words > 0)
assert(words[1].shadow ~= nil)
@ -129,7 +129,7 @@ return function()
local rich_text = druid:new_rich_text(text_node)
-- Test outline tag with named color
local words = rich_text:set_text("<outline=black>Outlined Text</outline>")
local words = rich_text:set_text("<outline=#000000>Outlined Text</outline>")
assert(#words > 0)
assert(words[1].outline ~= nil)
@ -228,7 +228,7 @@ return function()
local rich_text = druid:new_rich_text(text_node)
-- Test combined tags
local words = rich_text:set_text("<color=red><size=2>Big Red Text</size></color>")
local words = rich_text:set_text("<color=#FF0000><size=2>Big Red Text</size></color>")
assert(#words > 0)
assert(words[1].tags.color)
@ -236,7 +236,7 @@ return function()
assert(words[1].relative_scale == 2)
-- Test nested tags
words = rich_text:set_text("<color=red>Red <size=2>Big Red</size> Red</color>")
words = rich_text:set_text("<color=#FF0000>Red <size=2>Big Red</size> Red</color>")
assert(#words >= 3)
-- All words should have color tag