Merge pull request #356 from Buurazu/master

Full caching of most recent description
This commit is contained in:
wofsauge authored and GitHub committed 2022-01-30 15:33:34 +01:00
commit 16a1d74fd4
5 files changed
+140 -241

No files matched your search

+18 -5
View File
@@ -323,13 +323,13 @@ function EID:getDescriptionObj(Type, Variant, SubType, entity)
description.ModName = tableEntry and tableEntry[4] description.ModName = tableEntry and tableEntry[4]
for _,modifier in pairs(EID.DescModifiers) do for _,modifier in ipairs(EID.DescModifiers) do
local result = modifier.condition(description) local result = modifier.condition(description)
if type(result) == "table" then if type(result) == "table" then
for _,callback in ipairs(result) do for _,callback in ipairs(result) do
description = callback(description)
-- If the modifier loads a different description obj (which also goes through the modifier checks), we should stop our checks so text doesn't get printed twice -- If the modifier loads a different description obj (which also goes through the modifier checks), we should stop our checks so text doesn't get printed twice
if description.ObjSubType ~= SubType then break end if description.ObjSubType ~= SubType then break end
description = callback(description)
end end
elseif result then elseif result then
description = modifier.callback(description) description = modifier.callback(description)
@@ -666,6 +666,10 @@ function EID:renderIcon(spriteObj, posX, posY, callback)
end end
spriteObj:Render(Vector(posX, posY), nullVector, nullVector) spriteObj:Render(Vector(posX, posY), nullVector, nullVector)
if EID.CachingDescription then
table.insert(EID.CachedIcons, {spriteObj, posX, posY, callback, spriteObj:GetAnimation(), spriteObj:GetFrame()})
end
end end
-- Returns the icon used for the bulletpoint. It will look at the first word in the given string. -- Returns the icon used for the bulletpoint. It will look at the first word in the given string.
@@ -834,6 +838,9 @@ function EID:renderString(str, position, scale, kcolor)
local strFiltered, spriteTable = EID:filterIconMarkup(textPart[1], position.X, position.Y) local strFiltered, spriteTable = EID:filterIconMarkup(textPart[1], position.X, position.Y)
EID:renderInlineIcons(spriteTable, position.X + offsetX, position.Y) EID:renderInlineIcons(spriteTable, position.X + offsetX, position.Y)
EID.font:DrawStringScaledUTF8(strFiltered, position.X + offsetX, position.Y, scale.X, scale.Y, textPart[2], 0, false) EID.font:DrawStringScaledUTF8(strFiltered, position.X + offsetX, position.Y, scale.X, scale.Y, textPart[2], 0, false)
if EID.CachingDescription then
table.insert(EID.CachedStrings, {strFiltered, position.X + offsetX, position.Y, textPart[2]})
end
offsetX = offsetX + EID:getStrWidth(strFiltered) * scale.X offsetX = offsetX + EID:getStrWidth(strFiltered) * scale.X
end end
return textPartsTable[#textPartsTable][2] return textPartsTable[#textPartsTable][2]
@@ -842,16 +849,22 @@ end
-- Adds Description object modifiers. -- Adds Description object modifiers.
-- Used for altering descriptions. Example: Spindown dice, Tarot Cloth, ... -- Used for altering descriptions. Example: Spindown dice, Tarot Cloth, ...
function EID:addDescriptionModifier(modifierName, condition, callback) function EID:addDescriptionModifier(modifierName, condition, callback)
EID.DescModifiers[modifierName] = { table.insert(EID.DescModifiers, {
name = modifierName,
condition = condition, condition = condition,
callback = callback callback = callback
} })
end end
-- Removes a Description object modifier -- Removes a Description object modifier
-- Used for altering descriptions. Example: Spindown dice, Tarot Cloth, ... -- Used for altering descriptions. Example: Spindown dice, Tarot Cloth, ...
function EID:removeDescriptionModifier(modifierName) function EID:removeDescriptionModifier(modifierName)
EID.DescModifiers[modifierName] = nil for i,v in ipairs(EID.DescModifiers) do
if v[name] == modifierName then
table.remove(EID.DescModifiers,i)
return
end
end
end end
-- Interpolates between 2 KColors with a given fraction. -- Interpolates between 2 KColors with a given fraction.
+31 -34
View File
@@ -688,9 +688,8 @@ local resetBagCounter = 0
local craftingIsHidden = false local craftingIsHidden = false
local showCraftingResult = false local showCraftingResult = false
local prevSimplifiedDesc = "" local prevDesc = ""
local prevListDesc = "" EID.RefreshBagTextbox = false
local refreshTextbox = false
--this combination algorithm was adopted from this Java code: https://stackoverflow.com/a/16256122 --this combination algorithm was adopted from this Java code: https://stackoverflow.com/a/16256122
--note that it will run into duplicates, for example if you have eight pennies and a key, it can't tell the difference between --note that it will run into duplicates, for example if you have eight pennies and a key, it can't tell the difference between
@@ -881,7 +880,7 @@ local function RecipeCrunchCoroutine()
bagOfCraftingRefreshes = 0 bagOfCraftingRefreshes = 0
end end
isRefresh = false isRefresh = false
refreshTextbox = true EID.RefreshBagTextbox = true
end end
function EID:handleBagOfCraftingRendering() function EID:handleBagOfCraftingRendering()
@@ -973,7 +972,7 @@ function EID:handleBagOfCraftingRendering()
EID.bagOfCraftingCurPickupCount = #pickups EID.bagOfCraftingCurPickupCount = #pickups
calcHeldItems() calcHeldItems()
calcFloorItems() calcFloorItems()
refreshTextbox = true EID.RefreshBagTextbox = true
else else
roomItems = EID.bagOfCraftingRoomQueries[curRoomIndex..""] or {} roomItems = EID.bagOfCraftingRoomQueries[curRoomIndex..""] or {}
end end
@@ -1014,18 +1013,17 @@ function EID:handleBagOfCraftingRendering()
EID:printDescription(customDescObj) EID:printDescription(customDescObj)
return true return true
elseif EID.Config["BagOfCraftingDisplayMode"] == "No Recipes" then elseif EID.Config["BagOfCraftingDisplayMode"] == "No Recipes" then
prevListDesc = "" if not EID.RefreshBagTextbox and prevDesc ~= "" and not EID.OptionChanged then
if not refreshTextbox and prevSimplifiedDesc ~= "" then EID:appendToDescription(customDescObj, prevDesc)
EID:appendToDescription(customDescObj, prevSimplifiedDesc)
EID:printDescription(customDescObj) EID:printDescription(customDescObj)
return true return true
end end
prevSimplifiedDesc = "" prevDesc = ""
refreshTextbox = false EID.RefreshBagTextbox = false
prevSimplifiedDesc = prevSimplifiedDesc .. getHotkeyString() prevDesc = prevDesc .. getHotkeyString()
prevSimplifiedDesc = prevSimplifiedDesc .. getFloorItemsString(false, roomItems) prevDesc = prevDesc .. getFloorItemsString(false, roomItems)
local mostValuableBag = {} local mostValuableBag = {}
for i=1,8 do for i=1,8 do
@@ -1036,10 +1034,10 @@ function EID:handleBagOfCraftingRendering()
local bagQualityDesc = EID:getDescriptionEntry("CraftingBagQuality") local bagQualityDesc = EID:getDescriptionEntry("CraftingBagQuality")
local bestQualityDesc = EID:getDescriptionEntry("CraftingBestQuality") local bestQualityDesc = EID:getDescriptionEntry("CraftingBestQuality")
if (#EID.BagItems > 0) then prevSimplifiedDesc = prevSimplifiedDesc .. bagQualityDesc .. " " .. bagQuality .. "#" .. bagResult .. "#" end if (#EID.BagItems > 0) then prevDesc = prevDesc .. bagQualityDesc .. " " .. bagQuality .. "#" .. bagResult .. "#" end
if (bestQuality > bagQuality) then prevSimplifiedDesc = prevSimplifiedDesc .. bestQualityDesc .. " " .. bestQuality .. "#{{Blank}} " .. tableToCraftingIconsFunc(self,mostValuableBag, true) .. "#" .. bestResult .. "#" end if (bestQuality > bagQuality) then prevDesc = prevDesc .. bestQualityDesc .. " " .. bestQuality .. "#{{Blank}} " .. tableToCraftingIconsFunc(self,mostValuableBag, true) .. "#" .. bestResult .. "#" end
EID:appendToDescription(customDescObj, prevSimplifiedDesc) EID:appendToDescription(customDescObj, prevDesc)
EID:printDescription(customDescObj) EID:printDescription(customDescObj)
return true return true
end end
@@ -1101,7 +1099,7 @@ function EID:handleBagOfCraftingRendering()
upHeld = Isaac.GetTime() upHeld = Isaac.GetTime()
--lock the current results so you can actually do a recipe that you've scrolled down to without losing it --lock the current results so you can actually do a recipe that you've scrolled down to without losing it
elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTLEFT, EID.player.ControllerIndex) then elseif Input.IsActionTriggered(ButtonAction.ACTION_SHOOTLEFT, EID.player.ControllerIndex) then
refreshTextbox = true EID.RefreshBagTextbox = true
if (lockedResults == nil) then lockedResults = queryString if (lockedResults == nil) then lockedResults = queryString
else lockedResults = nil end else lockedResults = nil end
--refresh the recipes --refresh the recipes
@@ -1133,20 +1131,19 @@ function EID:handleBagOfCraftingRendering()
--fix bug with being allowed to go to an empty page if recipe count = multiple of page size (or if we refresh on last page) --fix bug with being allowed to go to an empty page if recipe count = multiple of page size (or if we refresh on last page)
if (bagOfCraftingOffset >= numResults) then bagOfCraftingOffset = bagOfCraftingOffset - EID.Config["BagOfCraftingResults"] end if (bagOfCraftingOffset >= numResults) then bagOfCraftingOffset = bagOfCraftingOffset - EID.Config["BagOfCraftingResults"] end
prevSimplifiedDesc = "" if not EID.RefreshBagTextbox and prevDesc ~= "" and bagOfCraftingOffset == prevOffset and not EID.OptionChanged then
if not refreshTextbox and prevListDesc ~= "" and bagOfCraftingOffset == prevOffset then EID:appendToDescription(customDescObj, prevDesc)
EID:appendToDescription(customDescObj, prevListDesc)
EID:printDescription(customDescObj) EID:printDescription(customDescObj)
return true return true
end end
prevListDesc = "" prevDesc = ""
refreshTextbox = false EID.RefreshBagTextbox = false
prevListDesc = prevListDesc .. getHotkeyString() prevDesc = prevDesc .. getHotkeyString()
prevListDesc = prevListDesc .. getFloorItemsString(true, roomItems) prevDesc = prevDesc .. getFloorItemsString(true, roomItems)
local resultDesc = EID:getDescriptionEntry("CraftingResults") local resultDesc = EID:getDescriptionEntry("CraftingResults")
prevListDesc = prevListDesc .. resultDesc prevDesc = prevDesc .. resultDesc
local prevItem = 0 local prevItem = 0
@@ -1158,7 +1155,7 @@ function EID:handleBagOfCraftingRendering()
--currentRecipesList is now a table of tables for each item, so we have to iterate over the table using sortedIDs --currentRecipesList is now a table of tables for each item, so we have to iterate over the table using sortedIDs
if (bagOfCraftingOffset > 0) then if (bagOfCraftingOffset > 0) then
prevListDesc = prevListDesc .. prefix .. "...+"..bagOfCraftingOffset.." more" prevDesc = prevDesc .. prefix .. "...+"..bagOfCraftingOffset.." more"
end end
local curOffset = 0 local curOffset = 0
refreshPosition = -1 refreshPosition = -1
@@ -1172,35 +1169,35 @@ function EID:handleBagOfCraftingRendering()
if not v then break end if not v then break end
if (curOffset > bagOfCraftingOffset) then if (curOffset > bagOfCraftingOffset) then
if not EID.Config["BagOfCraftingDisplayNames"] then if not EID.Config["BagOfCraftingDisplayNames"] then
prevListDesc = prevListDesc .."#{{Collectible"..v[2].."}} " prevDesc = prevDesc .."#{{Collectible"..v[2].."}} "
--tack on the secondary recipe image to achievement-locked recipes --tack on the secondary recipe image to achievement-locked recipes
if v[3] then prevListDesc = prevListDesc .."({{Collectible" .. v[3] .. "}})" end if v[3] then prevDesc = prevDesc .."({{Collectible" .. v[3] .. "}})" end
--color the equals sign with the item quality, so the order of the list can make sense --color the equals sign with the item quality, so the order of the list can make sense
prevListDesc = prevListDesc .. qualities[CraftingItemQualities[v[2]]] .. "={{CR}}" prevDesc = prevDesc .. qualities[CraftingItemQualities[v[2]]] .. "={{CR}}"
--only display the item name if it's the first occurrence --only display the item name if it's the first occurrence
else else
if prevItem ~= v[2] then if prevItem ~= v[2] then
--substring the first 18 characters of the item name so it fits on one line; is there a way to get around desc line length limits? --substring the first 18 characters of the item name so it fits on one line; is there a way to get around desc line length limits?
prevListDesc = prevListDesc .."#{{Collectible"..v[2].."}} ".. qualities[CraftingItemQualities[v[2]]] .. prevDesc = prevDesc .."#{{Collectible"..v[2].."}} ".. qualities[CraftingItemQualities[v[2]]] ..
string.sub(EID:getObjectName(5, 100, v[2]),1,18).."#" string.sub(EID:getObjectName(5, 100, v[2]),1,18).."#"
else else
prevListDesc = prevListDesc .."#" prevDesc = prevDesc .."#"
end end
--replace recipe bulletpoint with the secondary recipe on achievement-locked recipes --replace recipe bulletpoint with the secondary recipe on achievement-locked recipes
if v[3] then prevListDesc = prevListDesc .."{{Collectible" .. v[3] .. "}} " end if v[3] then prevDesc = prevDesc .."{{Collectible" .. v[3] .. "}} " end
end end
prevListDesc = prevListDesc .. tableToCraftingIconsFunc(self, v[1], true) prevDesc = prevDesc .. tableToCraftingIconsFunc(self, v[1], true)
prevItem = v[2] prevItem = v[2]
end end
end end
end end
end end
if (bagOfCraftingOffset + EID.Config["BagOfCraftingResults"] < numResults) then if (bagOfCraftingOffset + EID.Config["BagOfCraftingResults"] < numResults) then
prevListDesc = prevListDesc .. prefix .. "...+"..(numResults-EID.Config["BagOfCraftingResults"]-bagOfCraftingOffset).." more" prevDesc = prevDesc .. prefix .. "...+"..(numResults-EID.Config["BagOfCraftingResults"]-bagOfCraftingOffset).." more"
end end
EID:appendToDescription(customDescObj, prevListDesc) EID:appendToDescription(customDescObj, prevDesc)
EID:printDescription(customDescObj) EID:printDescription(customDescObj)
return true return true
end end
+8 -3
View File
@@ -101,7 +101,7 @@ local function VoidCallback(descObj, isRune)
if REPENTANCE then voidNames[2] = EID:getDescriptionEntry("GlitchedItemText", 1) end if REPENTANCE then voidNames[2] = EID:getDescriptionEntry("GlitchedItemText", 1) end
local eidTable = (isRune and EID.BlackRuneStatIncreases) or EID.VoidStatIncreases local eidTable = (isRune and EID.BlackRuneStatIncreases) or EID.VoidStatIncreases
local increases = ((inPreview or isAltOption) and eidTable[3]) or (shopItem and eidTable[2]) or eidTable[1] local increases = ((isAltOption or not descObj.Entity) and eidTable[3]) or (shopItem and eidTable[2]) or eidTable[1]
EID:appendToDescription(descObj, "#" .. prefix .. voidIntro .. "#") EID:appendToDescription(descObj, "#" .. prefix .. voidIntro .. "#")
for i,v in ipairs(increases) do for i,v in ipairs(increases) do
@@ -418,8 +418,6 @@ if REPENTANCE then
if collectiblesOwned[711] and EID:getEntityData(descObj.Entity, "EID_FlipItemID") then table.insert(callbacks, FlipCallback) end if collectiblesOwned[711] and EID:getEntityData(descObj.Entity, "EID_FlipItemID") then table.insert(callbacks, FlipCallback) end
if collectiblesOwned[723] or (EID.absorbedItems[723] and collectiblesOwned[477]) then table.insert(callbacks, SpindownDiceCallback) end if collectiblesOwned[723] or (EID.absorbedItems[723] and collectiblesOwned[477]) then table.insert(callbacks, SpindownDiceCallback) end
-- currently, only Repentance collectible modifiers have Tab previews so put it here
if EID.player and Input.IsActionPressed(ButtonAction.ACTION_MAP, EID.player.ControllerIndex) and not inPreview then table.insert(callbacks, TabCallback) end
-- Card / Rune Callbacks -- Card / Rune Callbacks
elseif descObj.ObjVariant == PickupVariant.PICKUP_TAROTCARD then elseif descObj.ObjVariant == PickupVariant.PICKUP_TAROTCARD then
@@ -465,3 +463,10 @@ local function EIDConditionsAB(descObj)
return callbacks return callbacks
end end
EID:addDescriptionModifier("EID Afterbirth+", EIDConditionsAB, nil) EID:addDescriptionModifier("EID Afterbirth+", EIDConditionsAB, nil)
local function TabConditions(descObj)
if EID.player and Input.IsActionPressed(ButtonAction.ACTION_MAP, EID.player.ControllerIndex) and not inPreview then return true end
return false
end
EID:addDescriptionModifier("EID Tab Previews", TabConditions, TabCallback)
+52 -48
View File
@@ -389,6 +389,7 @@ local function handleScaleKey()
-- press and hold ScaleKey -- press and hold ScaleKey
if Input.IsButtonPressed(ScaleKey, 0) then if Input.IsButtonPressed(ScaleKey, 0) then
if scaleHoldFrame > 60 then if scaleHoldFrame > 60 then
EID.MCM_OptionChanged = true
local scaleConfigName = (EID.Config["DisplayMode"] == "local" and "LocalScale" or "Scale") local scaleConfigName = (EID.Config["DisplayMode"] == "local" and "LocalScale" or "Scale")
if scaleToBigger then if scaleToBigger then
local newScale = EID.Scale + scaleSpeed local newScale = EID.Scale + scaleSpeed
@@ -415,6 +416,7 @@ local function handleScaleKey()
end end
-- press ScaleKey -- press ScaleKey
if Input.IsButtonTriggered(ScaleKey, 0) then if Input.IsButtonTriggered(ScaleKey, 0) then
EID.MCM_OptionChanged = true
scaleHoldFrame = 0 scaleHoldFrame = 0
local scale local scale
local scaleConfigName = (EID.Config["DisplayMode"] == "local" and "LocalScale" or "Scale") local scaleConfigName = (EID.Config["DisplayMode"] == "local" and "LocalScale" or "Scale")
@@ -441,13 +443,37 @@ end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
---------------------------Printing Functions------------------------------ ---------------------------Printing Functions------------------------------
local previousFormattedLines = {}
local previousBulletpoints = {}
local previousDesc = "" local previousDesc = ""
local previousRenderPos = Vector.Zero
EID.CachingDescription = false
EID.CachedIcons = {}
EID.CachedStrings = {}
function EID:printDescription(desc) function EID:printDescription(desc)
local textScale = Vector(EID.Scale, EID.Scale)
local renderPos = EID:getTextPosition() 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
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 local offsetX = 0
EID.lineHeight = EID.Config["LineHeight"] EID.lineHeight = EID.Config["LineHeight"]
if EID.Config["ShowItemIcon"] then if EID.Config["ShowItemIcon"] then
@@ -484,9 +510,6 @@ function EID:printDescription(desc)
end end
if EID.Config["ShowItemType"] and (itemType == 3 or itemType == 4) then if EID.Config["ShowItemType"] and (itemType == 3 or itemType == 4) then
local offsetY = 2 local offsetY = 2
if EID.Scale < 1 then
offsetY = -1
end
EID.IconSprite:Play(EID.ItemTypeAnm2Names[itemType]) EID.IconSprite:Play(EID.ItemTypeAnm2Names[itemType])
EID:renderIcon(EID.IconSprite, renderPos.X + offsetX * EID.Scale, renderPos.Y + offsetY * EID.Scale) EID:renderIcon(EID.IconSprite, renderPos.X + offsetX * EID.Scale, renderPos.Y + offsetY * EID.Scale)
if itemType == 3 then if itemType == 3 then
@@ -502,14 +525,8 @@ function EID:printDescription(desc)
EID.InlineIconSprite2:SetFrame("numbers", curItemConfig.MaxCharges) EID.InlineIconSprite2:SetFrame("numbers", curItemConfig.MaxCharges)
end end
EID:renderIcon(EID.InlineIconSprite2, renderPos.X + offsetX * EID.Scale, renderPos.Y + offsetY * EID.Scale) 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 end
offsetX = offsetX + 8
end end
--Display Itemname --Display Itemname
if EID.Config["ShowItemName"] then if EID.Config["ShowItemName"] then
@@ -534,7 +551,7 @@ function EID:printDescription(desc)
local quality = tonumber(EID.itemConfig:GetCollectible(tonumber(desc.ObjSubType)).Quality) local quality = tonumber(EID.itemConfig:GetCollectible(tonumber(desc.ObjSubType)).Quality)
curName = curName.." - {{Quality"..quality.."}}" curName = curName.." - {{Quality"..quality.."}}"
end end
-- Display the mod this item is from
if desc.ModName then if desc.ModName then
if EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Name only" then if EID.Config["ModIndicatorDisplay"] == "Both" or EID.Config["ModIndicatorDisplay"] == "Name only" then
curName = curName .. " {{"..EID.Config["ModIndicatorTextColor"].."}}" .. EID.ModIndicator[desc.ModName].Name curName = curName .. " {{"..EID.Config["ModIndicatorTextColor"].."}}" .. EID.ModIndicator[desc.ModName].Name
@@ -550,10 +567,10 @@ function EID:printDescription(desc)
textScale, textScale,
EID:getNameColor() EID:getNameColor()
) )
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
end end
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
--Display Transformation --Display Transformation
if not (desc.Transformation == "0" or desc.Transformation == "" or desc.Transformation == nil) then if not (desc.Transformation == "0" or desc.Transformation == "" or desc.Transformation == nil) then
for transform in string.gmatch(desc.Transformation, "([^,]+)") do for transform in string.gmatch(desc.Transformation, "([^,]+)") do
@@ -580,48 +597,32 @@ function EID:printDescription(desc)
end end
end end
end end
if previousDesc ~= desc.Description then
EID:clearDescriptionCache()
previousDesc = desc.Description
end
EID:printBulletPoints(desc.Description, renderPos) EID:printBulletPoints(desc.Description, renderPos)
end end
function EID:clearDescriptionCache()
previousFormattedLines = {}
previousBulletpoints = {}
end
function EID:printBulletPoints(description, renderPos) 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 local textColor = EID:getTextColor()
for _,v in ipairs(EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID.Config["Language"]])) do for i, lineToPrint in ipairs(formatedLines) do
table.insert(previousFormattedLines, v) -- 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 end
textColor = EID:renderString(lineToPrint, renderPos + Vector(12 * EID.Scale, 0), textScale, textColor)
renderPos.Y = renderPos.Y + EID.lineHeight * EID.Scale
end end
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 end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
----------------------------Handle New Room-------------------------------- ----------------------------Handle New Room--------------------------------
@@ -940,10 +941,13 @@ local searchPartitions = EntityPartition.FAMILIAR + EntityPartition.ENEMY + Enti
EID.lastDescriptionEntity = nil EID.lastDescriptionEntity = nil
EID.lastDist = 0 EID.lastDist = 0
EID.OptionChanged = false
local function onRender(t) local function onRender(t)
-- Increases by 60 per second, ignores pauses -- Increases by 60 per second, ignores pauses
EID.GameRenderCount = EID.GameRenderCount + 1 EID.GameRenderCount = EID.GameRenderCount + 1
EID.OptionChanged = EID.MCM_OptionChanged
EID.MCM_OptionChanged = false
EID:resumeCoroutines() EID:resumeCoroutines()
EID.isDisplaying = false EID.isDisplaying = false
+31 -151
View File
@@ -23,6 +23,7 @@ local MCMCompat_isDisplayingDummyMCMObj = false
local MCMCompat_oldPermanentObj = false local MCMCompat_oldPermanentObj = false
EID.MCMLoaded = MCMLoaded EID.MCMLoaded = MCMLoaded
local colorNameArray = {} local colorNameArray = {}
EID.MCM_OptionChanged = false
local function renderDummyDesc(reload) local function renderDummyDesc(reload)
if reload then if reload then
@@ -135,6 +136,7 @@ function EID:AddBooleanSetting(category, optionName, displayText, params)
end, end,
OnChange = params.onChangeFunc or function(currentBool) OnChange = params.onChangeFunc or function(currentBool)
EID.Config[optionName] = currentBool EID.Config[optionName] = currentBool
EID.MCM_OptionChanged = true
end, end,
Info = params.infoText or {} Info = params.infoText or {}
} }
@@ -168,6 +170,7 @@ function EID:AddHotkeySetting(category, optionName, displayText, infoText, isCon
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.Config[optionName] = currentNum or -1 EID.Config[optionName] = currentNum or -1
EID.MCM_OptionChanged = true
end, end,
PopupGfx = ModConfigMenu.PopupGfx.WIDE_SMALL, PopupGfx = ModConfigMenu.PopupGfx.WIDE_SMALL,
PopupWidth = 280, PopupWidth = 280,
@@ -228,6 +231,8 @@ if MCMLoaded then
return "Language: " .. displayLanguage[AnIndexOf(EID.Languages, EID.Config["Language"])] return "Language: " .. displayLanguage[AnIndexOf(EID.Languages, EID.Config["Language"])]
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
EID.RefreshBagTextbox = true -- Crafting isn't open so it won't notice MCM_OptionChanged, but definitely needs to refresh
EID.Config["Language"] = EID.Languages[currentNum] EID.Config["Language"] = EID.Languages[currentNum]
local isFixed = EID:fixDefinedFont() local isFixed = EID:fixDefinedFont()
if isFixed then if isFixed then
@@ -330,6 +335,7 @@ if MCMLoaded then
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.Config["LineHeight"] = currentNum EID.Config["LineHeight"] = currentNum
EID.MCM_OptionChanged = true
end, end,
Info = {"Default = 11","Line height will automatically change when changing a font/language"} Info = {"Default = 11","Line height will automatically change when changing a font/language"}
} }
@@ -351,7 +357,7 @@ if MCMLoaded then
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.Config["TextboxWidth"] = currentNum EID.Config["TextboxWidth"] = currentNum
EID:clearDescriptionCache() EID.MCM_OptionChanged = true
end, end,
Info = {"Default = 130, varies per language","Width of the EID textbox, in pixels"} Info = {"Default = 130, varies per language","Width of the EID textbox, in pixels"}
} }
@@ -857,6 +863,7 @@ if MCMLoaded then
) )
-- Display Mode -- Display Mode
-- Note: MCM's dummy desc doesn't play well with changing this at the moment!
local displayModes = {"default", "local"} local displayModes = {"default", "local"}
local displayModeTips = {"default: text will be displayed in the top-left of the screen.", "local: text will be displayed under the described object."} local displayModeTips = {"default: text will be displayed in the top-left of the screen.", "local: text will be displayed under the described object."}
MCM.AddSetting( MCM.AddSetting(
@@ -905,6 +912,7 @@ if MCMLoaded then
end end
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
if EID.Config["DisplayMode"] == "local" then if EID.Config["DisplayMode"] == "local" then
EID.Config["LocalScale"] = textScales[currentNum] EID.Config["LocalScale"] = textScales[currentNum]
else else
@@ -920,7 +928,7 @@ if MCMLoaded then
"ScaleKey", "Toggle Scale (Keyboard)", "ScaleKey", "Toggle Scale (Keyboard)",
"Press or hold this key to toggle the scale.", false) "Press or hold this key to toggle the scale.", false)
-- Transparency -- Local Mode Centered or not
MCM.AddSetting( MCM.AddSetting(
"EID", "EID",
"Visuals", "Visuals",
@@ -937,6 +945,7 @@ if MCMLoaded then
return "Local mode centered: " .. onOff return "Local mode centered: " .. onOff
end, end,
OnChange = function(currentBool) OnChange = function(currentBool)
EID.MCM_OptionChanged = true
EID.Config["LocalModeCentered"] = currentBool EID.Config["LocalModeCentered"] = currentBool
end end
} }
@@ -957,6 +966,7 @@ if MCMLoaded then
AnIndexOf(transparencies, EID.Config["Transparency"]) - 1 .. " " .. EID.Config["Transparency"] AnIndexOf(transparencies, EID.Config["Transparency"]) - 1 .. " " .. EID.Config["Transparency"]
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
EID.Config["Transparency"] = transparencies[currentNum + 1] EID.Config["Transparency"] = transparencies[currentNum + 1]
end end
} }
@@ -964,135 +974,15 @@ if MCMLoaded then
MCM.AddSpace("EID", "Visuals") MCM.AddSpace("EID", "Visuals")
--------ShowItemName--------- -- Simple toggles of what is shown in the title and transformation lines of a description
MCM.AddSetting( EID:AddBooleanSetting("Visuals", "ShowItemName", "Display Item Name")
"EID", EID:AddBooleanSetting("Visuals", "ShowItemType", "Display Item Type")
"Visuals", EID:AddBooleanSetting("Visuals", "ShowItemIcon", "Display Item Icon")
{ EID:AddBooleanSetting("Visuals", "TransformationText", "Display Transformation Name")
Type = ModConfigMenu.OptionType.BOOLEAN, EID:AddBooleanSetting("Visuals", "TransformationIcons", "Display Transformation Icon")
CurrentSetting = function() EID:AddBooleanSetting("Visuals", "ShowQuality", "Display Quality Info", {repOnly = true})
return EID.Config["ShowItemName"] EID:AddBooleanSetting("Visuals", "ShowObjectID", "Display Object ID")
end,
Display = function()
local onOff = "False"
if EID.Config["ShowItemName"] then
onOff = "True"
end
return "Display Item Name: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["ShowItemName"] = currentBool
end
}
)
--------ShowItemType---------
MCM.AddSetting(
"EID",
"Visuals",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["ShowItemType"]
end,
Display = function()
local onOff = "False"
if EID.Config["ShowItemType"] then
onOff = "True"
end
return "Display Item Type: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["ShowItemType"] = currentBool
end
}
)
MCM.AddSetting(
"EID",
"Visuals",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["ShowItemIcon"]
end,
Display = function()
local onOff = "False"
if EID.Config["ShowItemIcon"] then
onOff = "True"
end
return "Display Item Icon: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["ShowItemIcon"] = currentBool
end
}
)
-------TRANSFORMATIONS---------
MCM.AddSetting(
"EID",
"Visuals",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["TransformationText"]
end,
Display = function()
local onOff = "False"
if EID.Config["TransformationText"] then
onOff = "True"
end
return "Display Transformation Name: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["TransformationText"] = currentBool
end
}
)
-------TRANSFORMATION ICON---------
MCM.AddSetting(
"EID",
"Visuals",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["TransformationIcons"]
end,
Display = function()
local onOff = "False"
if EID.Config["TransformationIcons"] then
onOff = "True"
end
return "Display Transformation Icon: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["TransformationIcons"] = currentBool
end
}
)
if REPENTANCE then
-------Quality ICON---------
MCM.AddSetting(
"EID",
"Visuals",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["ShowQuality"]
end,
Display = function()
local onOff = "False"
if EID.Config["ShowQuality"] then
onOff = "True"
end
return "Display Quality Info: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["ShowQuality"] = currentBool
end
}
)
end
-------Mod indicator for modded items--------- -------Mod indicator for modded items---------
local modIndicatorDisplays = {"Both","Name only","Icon only", "None"} local modIndicatorDisplays = {"Both","Name only","Icon only", "None"}
MCM.AddSetting( MCM.AddSetting(
@@ -1109,31 +999,12 @@ if MCMLoaded then
return "Mod indicator displayed for: " .. EID.Config["ModIndicatorDisplay"] return "Mod indicator displayed for: " .. EID.Config["ModIndicatorDisplay"]
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
EID.Config["ModIndicatorDisplay"] = modIndicatorDisplays[currentNum] EID.Config["ModIndicatorDisplay"] = modIndicatorDisplays[currentNum]
end end
} }
) )
-------Object ID---------
MCM.AddSetting(
"EID",
"Visuals",
{
Type = ModConfigMenu.OptionType.BOOLEAN,
CurrentSetting = function()
return EID.Config["ShowObjectID"]
end,
Display = function()
local onOff = "False"
if EID.Config["ShowObjectID"] then
onOff = "True"
end
return "Display Object ID: " .. onOff
end,
OnChange = function(currentBool)
EID.Config["ShowObjectID"] = currentBool
end
}
)
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-----------------------------BAG OF CRAFTING------------------------------- -----------------------------BAG OF CRAFTING-------------------------------
@@ -1155,6 +1026,7 @@ if MCMLoaded then
return "Show Display: " .. EID.Config["DisplayBagOfCrafting"] return "Show Display: " .. EID.Config["DisplayBagOfCrafting"]
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
EID.Config["DisplayBagOfCrafting"] = bagDisplays[currentNum] EID.Config["DisplayBagOfCrafting"] = bagDisplays[currentNum]
end, end,
Info = {"Always = Always show Results, Hold = Show when holding up bag, Never = Never show results"} Info = {"Always = Always show Results, Hold = Show when holding up bag, Never = Never show results"}
@@ -1176,6 +1048,7 @@ if MCMLoaded then
return "Display Mode: " .. EID.Config["BagOfCraftingDisplayMode"] return "Display Mode: " .. EID.Config["BagOfCraftingDisplayMode"]
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
EID.Config["BagOfCraftingDisplayMode"] = bagDisplayModes[currentNum] EID.Config["BagOfCraftingDisplayMode"] = bagDisplayModes[currentNum]
end, end,
Info = {"Toggle showing a list of recipes, an item preview when bag is full, what item pool/quality you might get, or only the floor pickups"} Info = {"Toggle showing a list of recipes, an item preview when bag is full, what item pool/quality you might get, or only the floor pickups"}
@@ -1207,6 +1080,7 @@ if MCMLoaded then
AnIndexOf(diceSteps, EID.Config["BagOfCraftingResults"]) - 1 .. " " .. EID.Config["BagOfCraftingResults"] AnIndexOf(diceSteps, EID.Config["BagOfCraftingResults"]) - 1 .. " " .. EID.Config["BagOfCraftingResults"]
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
EID.Config["BagOfCraftingResults"] = diceSteps[currentNum + 1] EID.Config["BagOfCraftingResults"] = diceSteps[currentNum + 1]
end, end,
Info = {"Page size for the preview of items currently craftable with Bag of Crafting"} Info = {"Page size for the preview of items currently craftable with Bag of Crafting"}
@@ -1269,6 +1143,7 @@ if MCMLoaded then
return "Show Item Names: " .. onOff return "Show Item Names: " .. onOff
end, end,
OnChange = function(currentBool) OnChange = function(currentBool)
EID.MCM_OptionChanged = true
EID.Config["BagOfCraftingDisplayNames"] = currentBool EID.Config["BagOfCraftingDisplayNames"] = currentBool
end, end,
Info = {"If on, each result takes two lines; lower your displayed results accordingly"} Info = {"If on, each result takes two lines; lower your displayed results accordingly"}
@@ -1394,6 +1269,7 @@ if MCMLoaded then
return "Descriptions: " .. string.gsub(EID.Config["TextColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["TextColor"]).."/"..#colorNameArray..")" return "Descriptions: " .. string.gsub(EID.Config["TextColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["TextColor"]).."/"..#colorNameArray..")"
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
if currentNum == 0 then currentNum = #colorNameArray end if currentNum == 0 then currentNum = #colorNameArray end
if currentNum > #colorNameArray then currentNum = 1 end if currentNum > #colorNameArray then currentNum = 1 end
EID.Config["TextColor"] = colorNameArray[currentNum] EID.Config["TextColor"] = colorNameArray[currentNum]
@@ -1417,6 +1293,7 @@ if MCMLoaded then
return "Names: " .. string.gsub(EID.Config["ItemNameColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["ItemNameColor"]).."/"..#colorNameArray..")" return "Names: " .. string.gsub(EID.Config["ItemNameColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["ItemNameColor"]).."/"..#colorNameArray..")"
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
if currentNum == 0 then currentNum = #colorNameArray end if currentNum == 0 then currentNum = #colorNameArray end
if currentNum > #colorNameArray then currentNum = 1 end if currentNum > #colorNameArray then currentNum = 1 end
EID.Config["ItemNameColor"] = colorNameArray[currentNum] EID.Config["ItemNameColor"] = colorNameArray[currentNum]
@@ -1440,6 +1317,7 @@ if MCMLoaded then
return "Transformations: " .. string.gsub(EID.Config["TransformationColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["TransformationColor"]).."/"..#colorNameArray..")" return "Transformations: " .. string.gsub(EID.Config["TransformationColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["TransformationColor"]).."/"..#colorNameArray..")"
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
if currentNum == 0 then currentNum = #colorNameArray end if currentNum == 0 then currentNum = #colorNameArray end
if currentNum > #colorNameArray then currentNum = 1 end if currentNum > #colorNameArray then currentNum = 1 end
EID.Config["TransformationColor"] = colorNameArray[currentNum] EID.Config["TransformationColor"] = colorNameArray[currentNum]
@@ -1463,6 +1341,7 @@ if MCMLoaded then
return "Errors: " .. string.gsub(EID.Config["ErrorColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["ErrorColor"]).."/"..#colorNameArray..")" return "Errors: " .. string.gsub(EID.Config["ErrorColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["ErrorColor"]).."/"..#colorNameArray..")"
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
if currentNum == 0 then currentNum = #colorNameArray end if currentNum == 0 then currentNum = #colorNameArray end
if currentNum > #colorNameArray then currentNum = 1 end if currentNum > #colorNameArray then currentNum = 1 end
EID.Config["ErrorColor"] = colorNameArray[currentNum] EID.Config["ErrorColor"] = colorNameArray[currentNum]
@@ -1486,6 +1365,7 @@ if MCMLoaded then
return "Mod Indicator: " .. string.gsub(EID.Config["ModIndicatorTextColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["ModIndicatorTextColor"]).."/"..#colorNameArray..")" return "Mod Indicator: " .. string.gsub(EID.Config["ModIndicatorTextColor"], "Color", "").. " ("..AnIndexOf(colorNameArray, EID.Config["ModIndicatorTextColor"]).."/"..#colorNameArray..")"
end, end,
OnChange = function(currentNum) OnChange = function(currentNum)
EID.MCM_OptionChanged = true
if currentNum == 0 then currentNum = #colorNameArray end if currentNum == 0 then currentNum = #colorNameArray end
if currentNum > #colorNameArray then currentNum = 1 end if currentNum > #colorNameArray then currentNum = 1 end
EID.Config["ModIndicatorTextColor"] = colorNameArray[currentNum] EID.Config["ModIndicatorTextColor"] = colorNameArray[currentNum]