Cache our formatted lines to avoid calling fitTextToWidth
This commit is contained in:
1 parent
34ea5395eb
commit
2381835798
1 file changed
+20
-4
@@ -441,6 +441,10 @@ end
|
|||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
---------------------------Printing Functions------------------------------
|
---------------------------Printing Functions------------------------------
|
||||||
|
|
||||||
|
local previousFormattedLines = {}
|
||||||
|
local previousBulletpoints = {}
|
||||||
|
local previousDesc = ""
|
||||||
|
|
||||||
function EID:printDescription(desc)
|
function EID:printDescription(desc)
|
||||||
local textScale = Vector(EID.Scale, EID.Scale)
|
local textScale = Vector(EID.Scale, EID.Scale)
|
||||||
local renderPos = EID:getTextPosition()
|
local renderPos = EID:getTextPosition()
|
||||||
@@ -576,6 +580,11 @@ function EID:printDescription(desc)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if previousDesc ~= desc.Description then
|
||||||
|
previousFormattedLines = {}
|
||||||
|
previousBulletpoints = {}
|
||||||
|
previousDesc = desc.Description
|
||||||
|
end
|
||||||
EID:printBulletPoints(desc.Description, renderPos)
|
EID:printBulletPoints(desc.Description, renderPos)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -583,12 +592,20 @@ function EID:printBulletPoints(description, renderPos)
|
|||||||
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)
|
||||||
description = EID:replaceShortMarkupStrings(description)
|
description = EID:replaceShortMarkupStrings(description)
|
||||||
|
if #previousFormattedLines == 0 then
|
||||||
for line in string.gmatch(description, "([^#]+)") do
|
for line in string.gmatch(description, "([^#]+)") do
|
||||||
local formatedLines = EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID.Config["Language"]])
|
previousBulletpoints[#previousFormattedLines+1] = true
|
||||||
|
for _,v in ipairs(EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID.Config["Language"]])) do
|
||||||
|
table.insert(previousFormattedLines, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local textColor = EID:getTextColor()
|
local textColor = EID:getTextColor()
|
||||||
for i, lineToPrint in ipairs(formatedLines) do
|
for i, lineToPrint in ipairs(previousFormattedLines) do
|
||||||
-- render bulletpoint
|
-- render bulletpoint
|
||||||
if i == 1 then
|
if previousBulletpoints[i] then
|
||||||
|
textColor = EID:getTextColor()
|
||||||
local bpIcon = EID:handleBulletpointIcon(lineToPrint)
|
local bpIcon = EID:handleBulletpointIcon(lineToPrint)
|
||||||
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)
|
||||||
@@ -602,7 +619,6 @@ function EID:printBulletPoints(description, renderPos)
|
|||||||
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
----------------------------Handle New Room--------------------------------
|
----------------------------Handle New Room--------------------------------
|
||||||
local isMirrorRoom = false
|
local isMirrorRoom = false
|
||||||
|
|||||||
Reference in new issue
Block a user