Reduce spell tooltip scanning

This commit is contained in:
OldManAlpha 2025-08-29 15:41:46 -07:00
parent aaadb265a1
commit 2247ba244f
2 changed files with 25 additions and 1 deletions

View File

@ -65,6 +65,9 @@ RegisterEventHandler("UNIT_AURA", function()
if not IsRelevantUnit(unit) then
return
end
if unit == "player" then
util.MarkSpellCostCacheDirty()
end
PTUnit.Get(unit):UpdateAuras()
for ui in UnitFrames(unit) do
ui:UpdateAuras()
@ -107,6 +110,10 @@ RegisterEventHandler("PLAYER_TARGET_CHANGED", function()
end)
RegisterEventHandler("SPELLS_CHANGED", function()
PuppeteerSettings.UpdateTrackedDebuffTypes()
util.MarkSpellCostCacheDirty()
end)
RegisterEventHandler("CHARACTER_POINTS_CHANGED", function()
util.MarkSpellCostCacheDirty()
end)
RegisterEventHandler("RAID_TARGET_UPDATE", function()
for _, ui in ipairs(AllUnitFrames) do

View File

@ -562,8 +562,23 @@ function GetSpellID(spellname)
return foundID
end
local costCache = {}
local costTypeCache = {}
local costCacheDirty = false
function MarkSpellCostCacheDirty()
costCacheDirty = true
end
-- Returns the numerical cost and the resource name; "unknown" if the spell is unknown; 0 if the spell is free
function GetResourceCost(spellName)
if costCacheDirty then
ClearTable(costCache)
ClearTable(costTypeCache)
costCacheDirty = false
end
if costCache[spellName] then
return costCache[spellName], costTypeCache[spellName]
end
ScanningTooltip:SetOwner(UIParent, "ANCHOR_NONE");
local spellID, bookType
@ -587,8 +602,10 @@ function GetResourceCost(spellName)
local leftText = _G["PTScanningTooltipTextLeft2"]
if leftText:GetText() then
return ExtractResourceCost(leftText:GetText())
costCache[spellName], costTypeCache[spellName] = ExtractResourceCost(leftText:GetText())
return costCache[spellName], costTypeCache[spellName]
end
costCache[spellName] = 0
return 0
end