Throttle nameplate class color refreshes
This commit is contained in:
@@ -15,6 +15,7 @@ module.enable = function(self)
|
|||||||
if ShaguPlates then return end
|
if ShaguPlates then return end
|
||||||
|
|
||||||
local colorsByName = {}
|
local colorsByName = {}
|
||||||
|
local colorsVersion = 0
|
||||||
local useClassicTokens = API and API.eventutils and _G.C_EventUtils
|
local useClassicTokens = API and API.eventutils and _G.C_EventUtils
|
||||||
and _G.C_EventUtils.IsEventValid("NAME_PLATE_UNIT_ADDED")
|
and _G.C_EventUtils.IsEventValid("NAME_PLATE_UNIT_ADDED")
|
||||||
and _G.C_EventUtils.IsEventValid("NAME_PLATE_UNIT_REMOVED")
|
and _G.C_EventUtils.IsEventValid("NAME_PLATE_UNIT_REMOVED")
|
||||||
@@ -40,17 +41,22 @@ module.enable = function(self)
|
|||||||
color = class and RAID_CLASS_COLORS[class] or nil
|
color = class and RAID_CLASS_COLORS[class] or nil
|
||||||
end
|
end
|
||||||
colorsByName[name] = color or false
|
colorsByName[name] = color or false
|
||||||
|
colorsVersion = colorsVersion + 1
|
||||||
elseif event == "NAME_PLATE_UNIT_REMOVED" then
|
elseif event == "NAME_PLATE_UNIT_REMOVED" then
|
||||||
colorsByName[name] = nil
|
colorsByName[name] = nil
|
||||||
|
colorsVersion = colorsVersion + 1
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(ShaguTweaks.libnameplate.OnUpdate, function()
|
table.insert(ShaguTweaks.libnameplate.OnUpdate, function()
|
||||||
if useClassicTokens then
|
if useClassicTokens then
|
||||||
-- libnameplate owns the real native frame. The token listener above only
|
-- No nameplate identity/class data changed since this plate was last
|
||||||
-- caches exact class information, so this hot path is just one name read
|
-- checked. Keep the unavoidable shared OnUpdate callback to one integer
|
||||||
-- and one table lookup with no TargetByName scan and no C frame wrapper.
|
-- comparison between ClassicAPI nameplate events.
|
||||||
|
if this.ShaguTweaksClassColorVersion == colorsVersion then return end
|
||||||
|
this.ShaguTweaksClassColorVersion = colorsVersion
|
||||||
|
|
||||||
local name = this.name and this.name:GetText()
|
local name = this.name and this.name:GetText()
|
||||||
local color = name and colorsByName[name]
|
local color = name and colorsByName[name]
|
||||||
if color then
|
if color then
|
||||||
|
|||||||
Reference in New Issue
Block a user