diff --git a/SharedUtil.lua b/SharedUtil.lua index f2aef79..1c1f068 100644 --- a/SharedUtil.lua +++ b/SharedUtil.lua @@ -31,6 +31,7 @@ do end Util.configIDLookup = {}; +Util.addonLoadedRegistry = {}; function Util:DebugPrint(...) if not self.debug then return; end @@ -76,6 +77,12 @@ function Util:OnInitialize() eventFrame:UnregisterEvent('ADDON_LOADED'); self:RunOnLoadCallbacks(); end + if self.addonLoadedRegistry[addonName] then + for _, callback in ipairs(self.addonLoadedRegistry[addonName]) do + securecallfunction(callback); + end + self.addonLoadedRegistry[addonName] = nil; + end end if event == 'TRAIT_CONFIG_LIST_UPDATED' then self:RefreshConfigIDLookup(); @@ -107,6 +114,16 @@ function Util:GetterSetterIncrementFactory(db, postSetCallback) return getter, setter, increment; end +function Util:ContinueOnAddonLoaded(addonName, callback) + if C_AddOns.IsAddOnLoaded(addonName) then + callback(); + return; + end + + self.addonLoadedRegistry[addonName] = self.addonLoadedRegistry[addonName] or {}; + table.insert(self.addonLoadedRegistry[addonName], callback); +end + function Util:ResetRegistry() self.classTalentUILoadCallbacks = { minPriority = 1, diff --git a/modules/changeBackground.lua b/modules/changeBackground.lua index 3fef66e..2637d4e 100644 --- a/modules/changeBackground.lua +++ b/modules/changeBackground.lua @@ -13,7 +13,7 @@ function Module:OnEnable() Util:OnTalentUILoad(function() self:SetupDefaultUI(); end); - EventUtil.ContinueOnAddOnLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function() + Util:ContinueOnAddonLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function() self:SetupTTVUI(); end); end diff --git a/modules/copyTalentButtonInfo.lua b/modules/copyTalentButtonInfo.lua index 9d8edca..e25e551 100644 --- a/modules/copyTalentButtonInfo.lua +++ b/modules/copyTalentButtonInfo.lua @@ -21,14 +21,14 @@ function Module:OnEnable() Util:OnTalentUILoad(function() self:SetupHook(Util:GetTalentFrame()); end); - EventUtil.ContinueOnAddOnLoaded('Blizzard_GenericTraitUI', function() + Util:ContinueOnAddonLoaded('Blizzard_GenericTraitUI', function() self:SetupHook(GenericTraitFrame); end); - EventUtil.ContinueOnAddOnLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function() + Util:ContinueOnAddonLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function() local talentsTab = TalentViewer and TalentViewer.GetTalentFrame and TalentViewer:GetTalentFrame(); if not talentsTab then return; end self:SetupHook(talentsTab); - end) + end); self:RegisterEvent('PLAYER_REGEN_DISABLED'); self:RegisterEvent('PLAYER_REGEN_ENABLED'); EventRegistry:RegisterCallback("TalentDisplay.TooltipCreated", self.OnTalentTooltipCreated, self) @@ -127,7 +127,7 @@ function Module:OnSpellbookButtonEnter(button) if not spellID then return; end self.textToCopy = spellID; self:EnableBinding(); - self:OnTalentTooltipCreated(nil, GameTooltip); + self:OnTalentTooltipCreated(nil, ElvUI_SpellBookTooltip or GameTooltip); end function Module:OnSpellbookButtonLeave() diff --git a/modules/inspectDiff.lua b/modules/inspectDiff.lua index 37f6145..1379a65 100644 --- a/modules/inspectDiff.lua +++ b/modules/inspectDiff.lua @@ -14,7 +14,7 @@ function Module:OnEnable() end); self.viewerButtonTextures = self.viewerButtonTextures or {}; - EventUtil.ContinueOnAddOnLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function() + Util:ContinueOnAddonLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function() self:SetupViewerHook(); end); end diff --git a/modules/miniTreeInTooltip.lua b/modules/miniTreeInTooltip.lua index 474e7ad..3d68ebe 100644 --- a/modules/miniTreeInTooltip.lua +++ b/modules/miniTreeInTooltip.lua @@ -80,9 +80,9 @@ function Module:OnEnable() end) self:SecureHook(GameTooltip, "Show", "OnTooltipShow"); - EventUtil.ContinueOnAddOnLoaded("Blizzard_InspectUI", function() + Util:ContinueOnAddonLoaded("Blizzard_InspectUI", function() self:HookInspectTalentsButton(); - end) + end); end function Module:OnDisable() diff --git a/modules/scaleTalentFrame.lua b/modules/scaleTalentFrame.lua index 58a2b35..be1df97 100644 --- a/modules/scaleTalentFrame.lua +++ b/modules/scaleTalentFrame.lua @@ -16,9 +16,9 @@ function Module:OnEnable() Util:OnTalentUILoad(function() self:SetupHook(BLIZZARD_TALENT_UI); end); - EventUtil.ContinueOnAddOnLoaded(TALENT_TREE_VIEWER, function() + Util:ContinueOnAddonLoaded(TALENT_TREE_VIEWER, function() self:SetupHook(TALENT_TREE_VIEWER); - end) + end); end function Module:OnDisable() diff --git a/modules/searchForIds.lua b/modules/searchForIds.lua index a2de52e..0659898 100644 --- a/modules/searchForIds.lua +++ b/modules/searchForIds.lua @@ -17,9 +17,9 @@ function Module:OnEnable() Util:OnTalentUILoad(function() self:SetupHook(BLIZZARD_TALENT_UI); end); - EventUtil.ContinueOnAddOnLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function() + Util:ContinueOnAddonLoaded(TalentViewerLoader and TalentViewerLoader:GetLodAddonName() or 'TalentTreeViewer', function() self:SetupHook(TALENT_TREE_VIEWER); - end) + end); end function Module:OnDisable()