Replace HookAddonOrVariable with an EventUtil-based HookAddon

The polling lurker frame is gone. HookAddon gates on
C_AddOns.DoesAddOnExist, waits for PLAYER_LOGIN with
EventUtil.ContinueOnPlayerLogin, then runs on
EventUtil.ContinueOnAddOnLoaded. Addons loaded at startup still hook
only after every pfUI module and skin exists and after the addon's
own VARIABLES_LOADED setup. Load-on-demand addons still hook on their
ADDON_LOADED.

The "or variable" form is gone. Callers that passed a global now pass
the addon that defines it: TheoryCraft, SuperMacro, DPSMate and
Turtle_GroupUI. DPSMate names its windows from its settings, so its
hook now checks for DPSMate_DPSMate itself, as the variable lookup
used to. eqcompare's Guda check uses HookAddon too.
This commit is contained in:
Brues
2026-10-31 00:28:30 -05:00
parent b9c260b8e1
commit b64ae7dd53
22 changed files with 69 additions and 90 deletions
+14 -38
View File
@@ -651,45 +651,21 @@ function hooksecurefunc(tbl, name, func)
return _G.hooksecurefunc(tbl, name, func)
end
-- [ HookAddonOrVariable ]
-- Sets a function to be called automatically once an addon gets loaded
-- 'addon' [string] addon or variable name
-- [ HookAddon ]
-- Runs a function once an addon has loaded, but never before PLAYER_LOGIN.
-- Module and skin bodies run inside pfUI's own ADDON_LOADED, so an addon that
-- is already loaded there would otherwise run its hook before later pfUI
-- modules exist and before the addon's own VARIABLES_LOADED setup. A
-- load-on-demand addon runs its hook on its ADDON_LOADED. Hooks for addons
-- that are not installed are dropped. Hooks on the same addon run in no
-- particular order.
-- 'addon' [string] addon name
-- 'func' [function] function that should run
do
local lurker
local pending = {}
local function ProcessPending()
if not lurker.foundConfig then return end
for i = table.getn(pending), 1, -1 do
local hook = pending[i]
if IsAddOnLoaded(hook.addon) or _G[hook.addon] then
hook.func()
table.remove(pending, i)
end
end
if table.getn(pending) == 0 then
lurker:UnregisterAllEvents()
end
end
function pfUI.api.HookAddonOrVariable(addon, func)
if not lurker then
lurker = CreateFrame("Frame", nil)
lurker:SetScript("OnEvent", function()
if event == "VARIABLES_LOADED" or event == "PLAYER_ENTERING_WORLD" then
this.foundConfig = true
end
ProcessPending()
end)
end
table.insert(pending, { addon = addon, func = func })
lurker:RegisterEvent("ADDON_LOADED")
lurker:RegisterEvent("VARIABLES_LOADED")
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
ProcessPending()
end
function pfUI.api.HookAddon(addon, func)
if not C_AddOns.DoesAddOnExist(addon) then return end
EventUtil.ContinueOnPlayerLogin(function()
EventUtil.ContinueOnAddOnLoaded(addon, func)
end)
end
-- [ QueueFunction ]