mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 10:27:47 +02:00
Remove colors from rich text
This commit is contained in:
parent
0cf5ba30db
commit
97942965cd
@ -51,7 +51,6 @@ local rich_text = require("druid.custom.rich_text.module.rt")
|
|||||||
---@field height number
|
---@field height number
|
||||||
|
|
||||||
---@class druid.rich_text.style
|
---@class druid.rich_text.style
|
||||||
---@field COLORS table<string, vector4>
|
|
||||||
---@field ADJUST_STEPS number
|
---@field ADJUST_STEPS number
|
||||||
---@field ADJUST_SCALE_DELTA number
|
---@field ADJUST_SCALE_DELTA number
|
||||||
|
|
||||||
@ -105,7 +104,6 @@ end
|
|||||||
---@param style druid.rich_text.style
|
---@param style druid.rich_text.style
|
||||||
function M:on_style_change(style)
|
function M:on_style_change(style)
|
||||||
self.style = {
|
self.style = {
|
||||||
COLORS = style.COLORS or {},
|
|
||||||
ADJUST_STEPS = style.ADJUST_STEPS or 20,
|
ADJUST_STEPS = style.ADJUST_STEPS or 20,
|
||||||
ADJUST_SCALE_DELTA = style.ADJUST_SCALE_DELTA or 0.02,
|
ADJUST_SCALE_DELTA = style.ADJUST_SCALE_DELTA or 0.02,
|
||||||
}
|
}
|
||||||
|
@ -148,12 +148,4 @@ M["hotkey"] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
M["rich_text"] = {
|
|
||||||
COLORS = {
|
|
||||||
white = "#FFFFFF",
|
|
||||||
black = "#000000"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -205,26 +205,28 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function M:update(dt)
|
function M:update(dt)
|
||||||
if self.is_dirty then
|
if not self.is_dirty then
|
||||||
self.is_dirty = false
|
return
|
||||||
|
end
|
||||||
|
|
||||||
self:clear_created_properties()
|
self.is_dirty = false
|
||||||
|
|
||||||
local properties_count = #self.properties_constructors
|
self:clear_created_properties()
|
||||||
|
|
||||||
-- Render all current properties
|
local properties_count = #self.properties_constructors
|
||||||
local start_index = (self.current_page - 1) * self.properties_per_page + 1
|
|
||||||
local end_index = start_index + self.properties_per_page - 1
|
|
||||||
end_index = math.min(end_index, properties_count)
|
|
||||||
|
|
||||||
local is_paginator_visible = properties_count > self.properties_per_page
|
-- Render all current properties
|
||||||
gui.set_enabled(self.paginator.root, is_paginator_visible)
|
local start_index = (self.current_page - 1) * self.properties_per_page + 1
|
||||||
self.paginator:set_number_type(1, math.ceil(properties_count / self.properties_per_page), true)
|
local end_index = start_index + self.properties_per_page - 1
|
||||||
self.paginator.text_value:set_text(self.current_page .. " / " .. math.ceil(properties_count / self.properties_per_page))
|
end_index = math.min(end_index, properties_count)
|
||||||
|
|
||||||
for index = start_index, end_index do
|
local is_paginator_visible = properties_count > self.properties_per_page
|
||||||
self.properties_constructors[index]()
|
gui.set_enabled(self.paginator.root, is_paginator_visible)
|
||||||
end
|
self.paginator:set_number_type(1, math.ceil(properties_count / self.properties_per_page), true)
|
||||||
|
self.paginator.text_value:set_text(self.current_page .. " / " .. math.ceil(properties_count / self.properties_per_page))
|
||||||
|
|
||||||
|
for index = start_index, end_index do
|
||||||
|
self.properties_constructors[index]()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ return function()
|
|||||||
local rich_text = druid:new_rich_text(text_node)
|
local rich_text = druid:new_rich_text(text_node)
|
||||||
|
|
||||||
-- Test color tag with named color
|
-- 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)
|
assert(#words > 0)
|
||||||
-- Word should have a tags field with color tag
|
-- Word should have a tags field with color tag
|
||||||
@ -104,7 +104,7 @@ return function()
|
|||||||
local rich_text = druid:new_rich_text(text_node)
|
local rich_text = druid:new_rich_text(text_node)
|
||||||
|
|
||||||
-- Test shadow tag with named color
|
-- 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 > 0)
|
||||||
assert(words[1].shadow ~= nil)
|
assert(words[1].shadow ~= nil)
|
||||||
@ -129,7 +129,7 @@ return function()
|
|||||||
local rich_text = druid:new_rich_text(text_node)
|
local rich_text = druid:new_rich_text(text_node)
|
||||||
|
|
||||||
-- Test outline tag with named color
|
-- 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 > 0)
|
||||||
assert(words[1].outline ~= nil)
|
assert(words[1].outline ~= nil)
|
||||||
@ -228,7 +228,7 @@ return function()
|
|||||||
local rich_text = druid:new_rich_text(text_node)
|
local rich_text = druid:new_rich_text(text_node)
|
||||||
|
|
||||||
-- Test combined tags
|
-- 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 > 0)
|
||||||
assert(words[1].tags.color)
|
assert(words[1].tags.color)
|
||||||
@ -236,7 +236,7 @@ return function()
|
|||||||
assert(words[1].relative_scale == 2)
|
assert(words[1].relative_scale == 2)
|
||||||
|
|
||||||
-- Test nested tags
|
-- 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)
|
assert(#words >= 3)
|
||||||
-- All words should have color tag
|
-- All words should have color tag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user