From ffdf376ac4079349521ea2534101354dab040392 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed, 1 Jul 2026 10:20:34 -0500 Subject: [PATCH] add pfUI.events callback registry, replace addoncompat OnUpdate poll Introduce a central pfUI.events registry (ClassicAPI's CallbackRegistryMixin, undefined events allowed) initialized in pfUI.lua before any module body runs, so publishers/subscribers don't depend on module load order. firstrun sets `pfUI.firstrun.completed` and fires `firstrun:complete` at the point NextStep detects no pending steps. PLAYER_ENTERING_WORLD re- enters this path on every zone, so the flag is a one-shot guard. addoncompat drops its 0.1s OnUpdate poll and either RunQueues immediately (returning user, all steps already done) or subscribes to the event. --- modules/addoncompat.lua | 18 ++++-------------- modules/firstrun.lua | 5 +++++ pfUI.lua | 4 ++++ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/modules/addoncompat.lua b/modules/addoncompat.lua index 8068f0a3..6acca64a 100644 --- a/modules/addoncompat.lua +++ b/modules/addoncompat.lua @@ -134,19 +134,9 @@ pfUI:RegisterModule("addoncompat", function () end -- run the addonconflict queue when firstrun is ready - local delay = CreateFrame("Frame") - delay:SetScript("OnUpdate", function() - -- throttle to to one query per .1 second - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + .1 end - - -- make sure the firstrun dialog has finished - if pfUI.firstrun and pfUI.firstrun.steps then - for _, step in pairs(pfUI.firstrun.steps) do - if not pfUI_init[step.name] then return end - end - end - + if pfUI.firstrun and pfUI.firstrun.completed then RunQueue() - this:SetScript("OnUpdate", nil) - end) + else + pfUI.events:RegisterCallback("firstrun:complete", RunQueue, "addoncompat") + end end) diff --git a/modules/firstrun.lua b/modules/firstrun.lua index 31fdb659..5e55c12d 100644 --- a/modules/firstrun.lua +++ b/modules/firstrun.lua @@ -46,6 +46,11 @@ pfUI:RegisterModule("firstrun", function () return end end + + if not self.completed then + self.completed = true + pfUI.events:TriggerEvent("firstrun:complete") + end end -- main function to create wizard windows diff --git a/pfUI.lua b/pfUI.lua index c0a2e9b9..fb03d647 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -102,6 +102,10 @@ pfUI.version = {} pfUI.hooks = {} pfUI.env = {} +pfUI.events = Mixin({}, CallbackRegistryMixin) +pfUI.events:OnLoad() +pfUI.events:SetUndefinedEventsAllowed(true) + -- check if macro addons are loaded (disables macrotweak/macroscan) function pfUI:MacroAddonsLoaded() return IsAddOnLoaded("Supermacro") or IsAddOnLoaded("SuperCleveRoidMacros") or IsAddOnLoaded("UltimaMacros")