Fixed Stat+color markup bullet point icon handling causing visual glitches

This commit is contained in:
Wofsauge committed 2025-03-25 22:07:51 +01:00
1 parent 21be5a3d2d
commit f87f26758a
2 files changed
+19 -7

No files matched your search

+14 -5
View File
@@ -1321,12 +1321,21 @@ end
---@param text string
---@return string, string?
function EID:handleBulletpointIcon(text)
local firstWord = EID:removeColorMarkup(string.match(text, "([^%s]+)"))
if EID:getIcon(firstWord) ~= EID.InlineIcons["ERROR"] and string.find(firstWord, "{{.-}}")~=nil then
if not EID.Config["StatAndPickupBulletpoints"] and EID.StatPickupBulletpointBlacklist[firstWord] then
return "\007", firstWord
-- Find the position where '}}' is followed by a space or letter
local firstMarkupPos, _ = string.find(text, "{{.-}}")
local startPos, endPos = string.find(text, "}}%s")
-- check if string starts with markup and has
if firstMarkupPos and startPos and firstMarkupPos == 1 then
-- The split should be right after '}}', so adjust the position
local firstWord = string.sub(text, 1, endPos - 1)
firstWord = EID:removeColorMarkup(firstWord)
if EID:getIcon(firstWord) ~= EID.InlineIcons["ERROR"] and string.find(firstWord, "{{.-}}")~=nil then
if not EID.Config["StatAndPickupBulletpoints"] and EID.StatPickupBulletpointBlacklist[firstWord] then
return "\007", firstWord
end
return firstWord
end
return firstWord
end
return "\007"
end
+5 -2
View File
@@ -753,14 +753,17 @@ function EID:printBulletPoints(description, renderPos)
if i == 1 then
local bpIcon, rejectedIcon = EID:handleBulletpointIcon(lineToPrint)
if EID:getIcon(bpIcon) ~= EID.InlineIcons["ERROR"] then
lineToPrint = string.gsub(lineToPrint, bpIcon .. " ", "", 1)
lineToPrint = string.gsub(lineToPrint, bpIcon, "", 1)
textColor = EID:renderString(bpIcon, renderPos + Vector(-3 * EID.Scale, 0), textScale , textColor, true)
else
if rejectedIcon then lineToPrint = string.gsub(lineToPrint, rejectedIcon .. " ", "", 1) end
if rejectedIcon then lineToPrint = string.gsub(lineToPrint, rejectedIcon, "", 1) end
textColor = EID:renderString(bpIcon, renderPos, textScale , textColor)
end
EID.LastRenderCallColor = EID:copyKColor(textColor) -- Save line start Color for eventual Color Reset call
end
-- Remove leading spaces
lineToPrint = lineToPrint:match('^%s*(.*)')
-- render text
textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Scale, 0), textScale, textColor)
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
end