mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-07 06:00:00 +00:00
nameplates: use single event listener for all plates
This commit is contained in:
+19
-13
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user