Skip to content

Commit

Permalink
feat(misc): preload ExtVendorUI
Browse files Browse the repository at this point in the history
for compatibility with other addons, such as CanIMogIt
  • Loading branch information
Witnesscm committed Aug 10, 2024
1 parent e1aa439 commit 50ddb75
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Core/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Modules/Misc/ExtVendorUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ function M:ExtVendorUI()
hooksecurefunc("MerchantFrame_UpdateBuybackInfo", M.ExtVendor_UpdateBuybackPositions)
end

M:RegisterMisc("ExtVendorUI", M.ExtVendorUI)
M:RegisterPreload("ExtVendorUI", M.ExtVendorUI)
17 changes: 13 additions & 4 deletions Modules/Misc/Misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 50ddb75

Please sign in to comment.