Preserve class portrait refresh while throttling ToT

This commit is contained in:
Dusk-92
2026-08-23 21:49:24 +02:00
parent 84c58e3a14
commit 0d443bd163
+4 -16
View File
@@ -41,11 +41,8 @@ local function UpdatePortraits(frame)
local _, class = UnitClass(frame.unit) local _, class = UnitClass(frame.unit)
class = UnitIsPlayer(frame.unit) and class or nil class = UnitIsPlayer(frame.unit) and class or nil
-- Don't reapply the exact same class texture on every UnitFrame_Update. -- Reapply after Blizzard's UnitFrame_Update: that function can replace the
local state = class or false -- portrait texture even when the new target has the same class.
if frame.ShaguTweaksPortraitClass == state then return end
frame.ShaguTweaksPortraitClass = state
if class then if class then
local iconCoords = CLASS_ICON_TCOORDS[class] local iconCoords = CLASS_ICON_TCOORDS[class]
if iconCoords then if iconCoords then
@@ -70,14 +67,6 @@ module.enable = function(self)
events:RegisterEvent("PLAYER_ENTERING_WORLD") events:RegisterEvent("PLAYER_ENTERING_WORLD")
events:RegisterEvent("UNIT_PORTRAIT_UPDATE") events:RegisterEvent("UNIT_PORTRAIT_UPDATE")
events:SetScript("OnEvent", function() events:SetScript("OnEvent", function()
-- force a state refresh because Blizzard may have replaced the texture
PlayerFrame.ShaguTweaksPortraitClass = nil
TargetFrame.ShaguTweaksPortraitClass = nil
PartyMemberFrame1.ShaguTweaksPortraitClass = nil
PartyMemberFrame2.ShaguTweaksPortraitClass = nil
PartyMemberFrame3.ShaguTweaksPortraitClass = nil
PartyMemberFrame4.ShaguTweaksPortraitClass = nil
UpdatePortraits(PlayerFrame) UpdatePortraits(PlayerFrame)
UpdatePortraits(TargetFrame) UpdatePortraits(TargetFrame)
UpdatePortraits(PartyMemberFrame1) UpdatePortraits(PartyMemberFrame1)
@@ -87,8 +76,8 @@ module.enable = function(self)
end) end)
-- Target-of-target has no reliable vanilla portrait event. The old module -- Target-of-target has no reliable vanilla portrait event. The old module
-- refreshed it every rendered frame. With ClassicAPI we can cheaply watch -- refreshed it every rendered frame. ClassicAPI gives us UnitGUID, so poll
-- its GUID and only touch the portrait when the unit actually changes. -- cheaply at 5 Hz and only redraw when the actual unit changes.
local tot = CreateFrame("Frame", nil, TargetFrame) local tot = CreateFrame("Frame", nil, TargetFrame)
tot.elapsed = 0 tot.elapsed = 0
tot.lastguid = nil tot.lastguid = nil
@@ -100,7 +89,6 @@ module.enable = function(self)
local guid = API.UnitGUID and API.UnitGUID("targettarget") or UnitName("targettarget") local guid = API.UnitGUID and API.UnitGUID("targettarget") or UnitName("targettarget")
if guid ~= this.lastguid then if guid ~= this.lastguid then
this.lastguid = guid this.lastguid = guid
TargetofTargetFrame.ShaguTweaksPortraitClass = nil
UpdatePortraits(TargetofTargetFrame) UpdatePortraits(TargetofTargetFrame)
end end
end) end)