diff --git a/modules/nameplates.lua b/modules/nameplates.lua index b90f9e2c..67abaf90 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -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()