1+ -- Used to store a backup of the original "Show" method to restore it later if needed.
2+ local originalShowFunction = nil
3+
14local frame = CreateFrame (" FRAME" , " HideExpansionButtonFrame" )
25frame :RegisterEvent (" ADDON_LOADED" )
3- frame :RegisterEvent (" COVENANT_CALLINGS_UPDATED" )
4- frame :RegisterEvent (" PLAYER_ENTERING_WORLD" )
6+ frame :RegisterEvent (" PLAYER_LOGIN" )
57
68frame :SetScript (" OnEvent" , function (self , event , ...)
79 if event == " ADDON_LOADED" then
810 local addonName = ...
911 if addonName == " HideExpansionButton" and ExpansionButtonVisible == nil then
1012 ExpansionButtonVisible = false
11- SetButtonState ()
1213 frame :UnregisterEvent (" ADDON_LOADED" )
1314 end
14- elseif event == " COVENANT_CALLINGS_UPDATED" then
15- -- Something fires this event and then turns the button back on after.
16- -- Since it doesn't seem to fire another event when it's done we just
17- -- have to wait an arbitrary amount of time.
18- C_Timer .After (5 , SetButtonState )
1915 else
2016 SetButtonState ()
2117 end
@@ -28,9 +24,19 @@ function SlashCmdList.HIDEEXPANSIONBUTTON(msg, editbox)
2824end
2925
3026function SetButtonState ()
27+ -- Before we hide the button we save its `Show` method and then override it.
28+ -- Otherwise everytime you zone to a new expansion WoW will just turn it back on.
29+ -- When we need to show it again we just restore the method before calling it.
3130 if ExpansionButtonVisible then
31+ if originalShowFunction ~= nil then
32+ ExpansionLandingPageMinimapButton .Show = originalShowFunction
33+ end
3234 ExpansionLandingPageMinimapButton :Show ()
3335 else
3436 ExpansionLandingPageMinimapButton :Hide ()
37+ if originalShowFunction == nil then
38+ originalShowFunction = ExpansionLandingPageMinimapButton .Show
39+ end
40+ ExpansionLandingPageMinimapButton .Show = function () end
3541 end
3642end
0 commit comments