From 86ebf590a68b14a168fd9f4f784bcc90eb28b554 Mon Sep 17 00:00:00 2001 From: Wofsauge Date: Sat, 27 Sep 2025 22:39:07 +0200 Subject: [PATCH] Added {{Indent}} and {{IND}} to allow for bulletpoint indentations closes #910 --- features/eid_api.lua | 8 ++++++++ features/eid_data.lua | 1 + main.lua | 15 +++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/features/eid_api.lua b/features/eid_api.lua index b3bcc6dd..2bd12fe1 100644 --- a/features/eid_api.lua +++ b/features/eid_api.lua @@ -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 diff --git a/features/eid_data.lua b/features/eid_data.lua index 17dc253e..f6d7a36d 100644 --- a/features/eid_data.lua +++ b/features/eid_data.lua @@ -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}}"}, diff --git a/main.lua b/main.lua index 26b43e40..9a36ff7a 100644 --- a/main.lua +++ b/main.lua @@ -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