From 50ddb75d7cab286ea69b6c785b8d2fac1300a8ac Mon Sep 17 00:00:00 2001 From: Witnesscm Date: Sat, 10 Aug 2024 21:52:56 +0800 Subject: [PATCH] feat(misc): preload ExtVendorUI for compatibility with other addons, such as CanIMogIt --- Core/Core.lua | 6 ++++++ Modules/Misc/ExtVendorUI.lua | 2 +- Modules/Misc/Misc.lua | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Core/Core.lua b/Core/Core.lua index 7ce86ca..4f0e644 100644 --- a/Core/Core.lua +++ b/Core/Core.lua @@ -358,6 +358,12 @@ loader:SetScript("OnEvent", function(self, event, addon) end end + for _, module in next, initQueue do + if module.OnInitialize then + xpcall(module.OnInitialize, P.ThrowError, module) + end + end + for addonName, object in pairs(addonsToLoadEarly) do local isLoaded, isFinished = C_AddOns.IsAddOnLoaded(addonName) if isLoaded and isFinished then diff --git a/Modules/Misc/ExtVendorUI.lua b/Modules/Misc/ExtVendorUI.lua index 81a7b6e..362f818 100644 --- a/Modules/Misc/ExtVendorUI.lua +++ b/Modules/Misc/ExtVendorUI.lua @@ -82,4 +82,4 @@ function M:ExtVendorUI() hooksecurefunc("MerchantFrame_UpdateBuybackInfo", M.ExtVendor_UpdateBuybackPositions) end -M:RegisterMisc("ExtVendorUI", M.ExtVendorUI) \ No newline at end of file +M:RegisterPreload("ExtVendorUI", M.ExtVendorUI) \ No newline at end of file diff --git a/Modules/Misc/Misc.lua b/Modules/Misc/Misc.lua index 98cdcdb..c0f9de0 100644 --- a/Modules/Misc/Misc.lua +++ b/Modules/Misc/Misc.lua @@ -5,16 +5,25 @@ local M = P:RegisterModule("Misc") local _G = getfenv(0) local format, select = string.format, select -M.MiscList = {} +M.load = {} +M.preload = {} + +function M:RegisterPreload(name, func) + self.preload[name] = func or self[name] +end function M:RegisterMisc(name, func) - if not M.MiscList[name] then - M.MiscList[name] = func + self.load[name] = func or self[name] +end + +function M:OnInitialize() + for name, func in next, self.preload do + xpcall(func, P.ThrowError) end end function M:OnLogin() - for name, func in next, M.MiscList do + for name, func in next, self.load do xpcall(func, P.ThrowError) end end