readd description caching
This commit is contained in:
1 parent
6e43195c58
commit
1c76973250
1 file changed
+54
-50
@@ -391,6 +391,7 @@ local function handleScaleKey()
|
||||
-- press and hold ScaleKey
|
||||
if Input.IsButtonPressed(ScaleKey, 0) then
|
||||
if scaleHoldFrame > 60 then
|
||||
EID.MCM_OptionChanged = true
|
||||
local scaleConfigName = (EID.Config["DisplayMode"] == "local" and "LocalScale" or "Scale")
|
||||
if scaleToBigger then
|
||||
local newScale = EID.Scale + scaleSpeed
|
||||
@@ -417,6 +418,7 @@ local function handleScaleKey()
|
||||
end
|
||||
-- press ScaleKey
|
||||
if Input.IsButtonTriggered(ScaleKey, 0) then
|
||||
EID.MCM_OptionChanged = true
|
||||
scaleHoldFrame = 0
|
||||
local scale
|
||||
local scaleConfigName = (EID.Config["DisplayMode"] == "local" and "LocalScale" or "Scale")
|
||||
@@ -443,13 +445,38 @@ end
|
||||
---------------------------------------------------------------------------
|
||||
---------------------------Printing Functions------------------------------
|
||||
|
||||
local previousFormattedLines = {}
|
||||
local previousBulletpoints = {}
|
||||
local previousDesc = ""
|
||||
local previousRenderPos = Vector.Zero
|
||||
EID.CachingDescription = false
|
||||
EID.CachedIcons = {}
|
||||
EID.CachedStrings = {}
|
||||
|
||||
function EID:printDescription(desc)
|
||||
local textScale = Vector(EID.Scale, EID.Scale)
|
||||
local renderPos = EID:getTextPosition()
|
||||
|
||||
EID.CachingDescription = false
|
||||
if previousDesc == desc.Description and not EID.OptionChanged and not EID.MCM_OptionChanged then
|
||||
local localModeDiff = renderPos - previousRenderPos
|
||||
-- Drawing our currently saved description
|
||||
for _,icon in ipairs(EID.CachedIcons) do
|
||||
icon[1]:SetFrame(icon[5], icon[6])
|
||||
EID:renderIcon(icon[1], icon[2] + localModeDiff.X, icon[3] + localModeDiff.Y, icon[4])
|
||||
end
|
||||
for i,str in ipairs(EID.CachedStrings) do
|
||||
--print(str[4])
|
||||
EID.font:DrawStringScaledUTF8(str[1], str[2] + localModeDiff.X, str[3] + localModeDiff.Y, EID.Scale, EID.Scale, str[4], 0, false)
|
||||
end
|
||||
return
|
||||
else
|
||||
-- Drawing a new description
|
||||
EID.CachingDescription = true
|
||||
EID.CachedIcons = {}
|
||||
EID.CachedStrings = {}
|
||||
previousDesc = desc.Description
|
||||
previousRenderPos = Vector(renderPos.X, renderPos.Y)
|
||||
end
|
||||
|
||||
local textScale = Vector(EID.Scale, EID.Scale)
|
||||
local offsetX = 0
|
||||
EID.lineHeight = EID.Config["LineHeight"]
|
||||
if EID.Config["ShowItemIcon"] then
|
||||
@@ -486,9 +513,6 @@ function EID:printDescription(desc)
|
||||
end
|
||||
if EID.Config["ShowItemType"] and (itemType == 3 or itemType == 4) then
|
||||
local offsetY = 2
|
||||
if EID.Scale < 1 then
|
||||
offsetY = -1
|
||||
end
|
||||
EID.IconSprite:Play(EID.ItemTypeAnm2Names[itemType])
|
||||
EID:renderIcon(EID.IconSprite, renderPos.X + offsetX * EID.Scale, renderPos.Y + offsetY * EID.Scale)
|
||||
if itemType == 3 then
|
||||
@@ -504,14 +528,8 @@ function EID:printDescription(desc)
|
||||
EID.InlineIconSprite2:SetFrame("numbers", curItemConfig.MaxCharges)
|
||||
end
|
||||
EID:renderIcon(EID.InlineIconSprite2, renderPos.X + offsetX * EID.Scale, renderPos.Y + offsetY * EID.Scale)
|
||||
offsetX = offsetX + 8
|
||||
elseif itemType == 4 then
|
||||
-- familiar
|
||||
offsetX = offsetX + 8
|
||||
end
|
||||
if not EID.Config["ShowItemName"] then
|
||||
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
||||
end
|
||||
offsetX = offsetX + 8
|
||||
end
|
||||
--Display Itemname
|
||||
if EID.Config["ShowItemName"] then
|
||||
@@ -536,7 +554,7 @@ function EID:printDescription(desc)
|
||||
local quality = tonumber(EID.itemConfig:GetCollectible(tonumber(desc.ObjSubType)).Quality)
|
||||
curName = curName.." - {{Quality"..quality.."}}"
|
||||
end
|
||||
|
||||
-- Display the mod this item is from
|
||||
if desc.ModName then
|
||||
if EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Name only" then
|
||||
curName = curName .. " {{"..EID.Config["ModIndicatorTextColor"].."}}" .. EID.ModIndicator[desc.ModName].Name
|
||||
@@ -552,10 +570,10 @@ function EID:printDescription(desc)
|
||||
textScale,
|
||||
EID:getNameColor()
|
||||
)
|
||||
|
||||
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
||||
end
|
||||
|
||||
|
||||
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
||||
|
||||
--Display Transformation
|
||||
if not (desc.Transformation == "0" or desc.Transformation == "" or desc.Transformation == nil) then
|
||||
for transform in string.gmatch(desc.Transformation, "([^,]+)") do
|
||||
@@ -582,48 +600,32 @@ function EID:printDescription(desc)
|
||||
end
|
||||
end
|
||||
end
|
||||
if previousDesc ~= desc.Description then
|
||||
EID:clearDescriptionCache()
|
||||
previousDesc = desc.Description
|
||||
end
|
||||
EID:printBulletPoints(desc.Description, renderPos)
|
||||
end
|
||||
|
||||
function EID:clearDescriptionCache()
|
||||
previousFormattedLines = {}
|
||||
previousBulletpoints = {}
|
||||
end
|
||||
|
||||
function EID:printBulletPoints(description, renderPos)
|
||||
local textboxWidth = tonumber(EID.Config["TextboxWidth"])
|
||||
local textScale = Vector(EID.Scale, EID.Scale)
|
||||
description = EID:replaceShortMarkupStrings(description)
|
||||
if #previousFormattedLines == 0 then
|
||||
for line in string.gmatch(description, "([^#]+)") do
|
||||
previousBulletpoints[#previousFormattedLines+1] = true
|
||||
for _,v in ipairs(EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID.Config["Language"]])) do
|
||||
table.insert(previousFormattedLines, v)
|
||||
for line in string.gmatch(description, "([^#]+)") do
|
||||
local formatedLines = EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID.Config["Language"]])
|
||||
local textColor = EID:getTextColor()
|
||||
for i, lineToPrint in ipairs(formatedLines) do
|
||||
-- render bulletpoint
|
||||
if i == 1 then
|
||||
local bpIcon = EID:handleBulletpointIcon(lineToPrint)
|
||||
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)
|
||||
else
|
||||
textColor = EID:renderString(bpIcon, renderPos, textScale , textColor)
|
||||
end
|
||||
EID.LastRenderCallColor = EID:copyKColor(textColor) -- Save line start Color for eventual Color Reset call
|
||||
end
|
||||
textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Scale, 0), textScale, textColor)
|
||||
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
||||
end
|
||||
end
|
||||
|
||||
local textColor = EID:getTextColor()
|
||||
for i, lineToPrint in ipairs(previousFormattedLines) do
|
||||
-- render bulletpoint
|
||||
if previousBulletpoints[i] then
|
||||
textColor = EID:getTextColor()
|
||||
local bpIcon = EID:handleBulletpointIcon(lineToPrint)
|
||||
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)
|
||||
else
|
||||
textColor = EID:renderString(bpIcon, renderPos, textScale , textColor)
|
||||
end
|
||||
EID.LastRenderCallColor = EID:copyKColor(textColor) -- Save line start Color for eventual Color Reset call
|
||||
end
|
||||
textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Scale, 0), textScale, textColor)
|
||||
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
|
||||
end
|
||||
end
|
||||
---------------------------------------------------------------------------
|
||||
----------------------------Handle New Room--------------------------------
|
||||
@@ -943,13 +945,15 @@ local searchPartitions = EntityPartition.FAMILIAR + EntityPartition.ENEMY + Enti
|
||||
|
||||
EID.lastDescriptionEntity = nil
|
||||
EID.lastDist = 0
|
||||
EID.OptionChanged = false
|
||||
|
||||
local function onRender(t)
|
||||
-- Increases by 60 per second, ignores pauses
|
||||
EID.GameRenderCount = EID.GameRenderCount + 1
|
||||
EID.OptionChanged = EID.MCM_OptionChanged
|
||||
EID.MCM_OptionChanged = false
|
||||
EID:resumeCoroutines()
|
||||
|
||||
|
||||
EID.isDisplaying = false
|
||||
EID:setPlayer()
|
||||
EID.TabPreviewID = 0
|
||||
|
||||
Reference in new issue
Block a user