Added {{Indent}} and {{IND}} to allow for bulletpoint indentations
closes #910
This commit is contained in:
1 parent
9b00e86ff4
commit
86ebf590a6
3 files changed
+20
-4
No files matched your search
@@ -1340,6 +1340,14 @@ function EID:handleBulletpointIcon(text, ignoreBPConfig)
|
|||||||
return "\007"
|
return "\007"
|
||||||
end
|
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
|
local colorFunc = nil
|
||||||
---Gets a KColor from a Markup-string (example Input: "{{ColorText}}").
|
---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
|
---Returns the KColor object and a boolean value indicating if the given string was a color markup or not
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ EID.TextReplacementPairs = {
|
|||||||
{"{{CR}}", "{{ColorReset}}"}, -- Shortcut for Color Resetting
|
{"{{CR}}", "{{ColorReset}}"}, -- Shortcut for Color Resetting
|
||||||
{"{{EthernalHeart}}", "{{EternalHeart}}"}, -- fix spelling error
|
{"{{EthernalHeart}}", "{{EternalHeart}}"}, -- fix spelling error
|
||||||
{"{{CONFIG_BoC_Toggle}}", function(_) return EID.ButtonToIconMap[EID.Config["BagOfCraftingToggleKey"]] or "{{ButtonSelect}}" end},
|
{"{{CONFIG_BoC_Toggle}}", function(_) return EID.ButtonToIconMap[EID.Config["BagOfCraftingToggleKey"]] or "{{ButtonSelect}}" end},
|
||||||
|
{"{{IND}}", "{{Indent}}"}, -- Shortcut for Indent
|
||||||
-- more common/official names
|
-- more common/official names
|
||||||
{"{{MimicChest}}", "{{TrapChest}}"},
|
{"{{MimicChest}}", "{{TrapChest}}"},
|
||||||
{"{{EternalChest}}", "{{HolyChest}}"},
|
{"{{EternalChest}}", "{{HolyChest}}"},
|
||||||
|
|||||||
@@ -767,30 +767,37 @@ end
|
|||||||
function EID:printBulletPoints(description, renderPos, ignoreBPConfig)
|
function EID:printBulletPoints(description, renderPos, ignoreBPConfig)
|
||||||
local textboxWidth = tonumber(EID.Config["TextboxWidth"])
|
local textboxWidth = tonumber(EID.Config["TextboxWidth"])
|
||||||
local textScale = Vector(EID.Scale, EID.Scale)
|
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:replaceNameMarkupStrings(description)
|
||||||
description = EID:replaceShortMarkupStrings(description)
|
description = EID:replaceShortMarkupStrings(description)
|
||||||
description = EID:replaceMarkupSize(description)
|
description = EID:replaceMarkupSize(description)
|
||||||
for line in string.gmatch(description, "([^#]+)") do
|
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 formatedLines = EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID:getLanguage()])
|
||||||
local textColor = EID:getTextColor()
|
local textColor = EID:getTextColor()
|
||||||
|
|
||||||
|
local indentOffset = numIndentations * textOffset
|
||||||
for i, lineToPrint in ipairs(formatedLines) do
|
for i, lineToPrint in ipairs(formatedLines) do
|
||||||
-- render bulletpoint
|
-- render bulletpoint
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
local bpIcon, rejectedIcon = EID:handleBulletpointIcon(lineToPrint, ignoreBPConfig)
|
local bpIcon, rejectedIcon = EID:handleBulletpointIcon(lineToPrint, ignoreBPConfig)
|
||||||
if EID:getIcon(bpIcon) ~= EID.InlineIcons["ERROR"] then
|
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)
|
textColor = EID:renderString(bpIcon, renderPos + bulletpointOffset + indentOffset, textScale , textColor, true)
|
||||||
else
|
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)
|
textColor = EID:renderString(bpIcon, renderPos + indentOffset, textScale , textColor)
|
||||||
end
|
end
|
||||||
EID.LastRenderCallColor = EID:copyKColor(textColor) -- Save line start Color for eventual Color Reset call
|
EID.LastRenderCallColor = EID:copyKColor(textColor) -- Save line start Color for eventual Color Reset call
|
||||||
end
|
end
|
||||||
-- Remove leading spaces
|
-- Remove leading spaces
|
||||||
lineToPrint = lineToPrint:match('^%s*(.*)')
|
lineToPrint = lineToPrint:match('^%s*(.*)')
|
||||||
-- render text
|
-- render text
|
||||||
textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Scale, 0), textScale, textColor)
|
textColor = EID:renderString(lineToPrint, renderPos + textOffset + indentOffset, textScale, textColor)
|
||||||
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return renderPos
|
return renderPos
|
||||||
|
|||||||
Reference in new issue
Block a user