Added {{Indent}} and {{IND}} to allow for bulletpoint indentations

closes #910
This commit is contained in:
Wofsauge committed 2025-09-27 22:39:07 +02:00
1 parent 9b00e86ff4
commit 86ebf590a6
3 files changed
+20 -4

No files matched your search

+8
View File
@@ -1340,6 +1340,14 @@ function EID:handleBulletpointIcon(text, ignoreBPConfig)
return "\007"
end
-- Find indentation markup, remove it and return the modified string and the number of indentations
-- position of the markup in the text is irrelevant. it only affects the indentation of the bullet point
---@param text string
---@return string, integer
function EID:handleTextIndentation(text)
return string.gsub(text, "{{Indent}}", "")
end
local colorFunc = nil
---Gets a KColor from a Markup-string (example Input: "{{ColorText}}").
---Returns the KColor object and a boolean value indicating if the given string was a color markup or not
+1
View File
@@ -133,6 +133,7 @@ EID.TextReplacementPairs = {
{"{{CR}}", "{{ColorReset}}"}, -- Shortcut for Color Resetting
{"{{EthernalHeart}}", "{{EternalHeart}}"}, -- fix spelling error
{"{{CONFIG_BoC_Toggle}}", function(_) return EID.ButtonToIconMap[EID.Config["BagOfCraftingToggleKey"]] or "{{ButtonSelect}}" end},
{"{{IND}}", "{{Indent}}"}, -- Shortcut for Indent
-- more common/official names
{"{{MimicChest}}", "{{TrapChest}}"},
{"{{EternalChest}}", "{{HolyChest}}"},
+11 -4
View File
@@ -767,30 +767,37 @@ end
function EID:printBulletPoints(description, renderPos, ignoreBPConfig)
local textboxWidth = tonumber(EID.Config["TextboxWidth"])
local textScale = Vector(EID.Scale, EID.Scale)
local textOffset = Vector(12 * EID.Scale, 0) -- offset of the text to the bullet point
local bulletpointOffset = Vector(-3 * EID.Scale, 0) -- offset of bulletpoint icons relative to the default bulletpoint
description = EID:replaceNameMarkupStrings(description)
description = EID:replaceShortMarkupStrings(description)
description = EID:replaceMarkupSize(description)
for line in string.gmatch(description, "([^#]+)") do
local numIndentations = 0
line, numIndentations = EID:handleTextIndentation(line)
local formatedLines = EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID:getLanguage()])
local textColor = EID:getTextColor()
local indentOffset = numIndentations * textOffset
for i, lineToPrint in ipairs(formatedLines) do
-- render bulletpoint
if i == 1 then
local bpIcon, rejectedIcon = EID:handleBulletpointIcon(lineToPrint, ignoreBPConfig)
if EID:getIcon(bpIcon) ~= EID.InlineIcons["ERROR"] then
lineToPrint = string.gsub(lineToPrint, bpIcon, "", 1)
textColor = EID:renderString(bpIcon, renderPos + Vector(-3 * EID.Scale, 0), textScale , textColor, true)
textColor = EID:renderString(bpIcon, renderPos + bulletpointOffset + indentOffset, textScale , textColor, true)
else
if rejectedIcon then lineToPrint = string.gsub(lineToPrint, rejectedIcon, "", 1) end
textColor = EID:renderString(bpIcon, renderPos, textScale , textColor)
textColor = EID:renderString(bpIcon, renderPos + indentOffset, 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
textColor = EID:renderString(lineToPrint, renderPos + textOffset + indentOffset, textScale, textColor)
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
end
end
return renderPos