nameplates: use single event listener for all plates

This commit is contained in:
shagu
2024-11-03 11:54:06 +01:00
parent 8832e42fef
commit c7008abf05
+19 -13
View File
@@ -245,11 +245,29 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
-- create nameplate core
local nameplates = CreateFrame("Frame", "pfNameplates", UIParent)
nameplates:RegisterEvent("PLAYER_ENTERING_WORLD")
nameplates:RegisterEvent("PLAYER_TARGET_CHANGED")
nameplates:RegisterEvent("UNIT_COMBO_POINTS")
nameplates:RegisterEvent("PLAYER_COMBO_POINTS")
nameplates:RegisterEvent("UNIT_AURA")
nameplates:SetScript("OnEvent", function()
this:SetGameVariables()
if event == "PLAYER_ENTERING_WORLD" then
this:SetGameVariables()
else
this.eventcache = true
end
end)
nameplates:SetScript("OnUpdate", function()
-- propagate events to all nameplates
if this.eventcache then
this.eventcache = nil
for plate in pairs(registry) do
plate.eventcache = true
end
end
-- detect new nameplates
parentcount = WorldFrame:GetNumChildren()
if initialized < parentcount then
childs = { WorldFrame:GetChildren() }
@@ -410,13 +428,6 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
HookScript(parent, "OnShow", nameplates.OnShow)
HookScript(parent, "OnUpdate", nameplates.OnUpdate)
nameplate:RegisterEvent("PLAYER_TARGET_CHANGED")
nameplate:RegisterEvent("UNIT_AURA")
nameplate:RegisterEvent("UNIT_COMBO_POINTS")
nameplate:RegisterEvent("PLAYER_COMBO_POINTS")
nameplate:SetScript("OnEvent", nameplates.OnEvent)
nameplates.OnConfigChange(parent)
nameplates.OnShow(parent)
end
@@ -502,11 +513,6 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
nameplates:OnDataChanged(this:GetParent().nameplate)
end
nameplates.OnEvent = function(frame)
local frame = frame or this
frame.eventcache = true
end
nameplates.OnDataChanged = function(self, plate)
local visible = plate:IsVisible()
local hp = plate.original.healthbar:GetValue()