Skip to content

Commit c4fd63e

Browse files
committed
Disable the addon for WOTLK Classic and make sure the options panel is not rendered.
1 parent 786082f commit c4fd63e

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

FiveSecondRule.lua

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,33 @@ do -- Private Scope
4343
FiveSecondRule:SetScript("OnUpdate", function(self, sinceLastUpdate) onUpdate(sinceLastUpdate); end);
4444

4545
-- INITIALIZATION
46-
function Init()
46+
function Init()
47+
if (not IsGameVersionValid()) then
48+
PrintNotSupported()
49+
DisableAddon()
50+
return
51+
end
52+
4753
LoadOptions()
4854

4955
TickBar:LoadSpells() -- LOCALIZATION
5056
FiveSecondRule:Refresh()
57+
58+
PrintHelp()
59+
60+
end
61+
62+
function IsGameVersionValid()
63+
local _, _, _, tocversion = GetBuildInfo()
64+
return tocversion < 30400 -- Before WOTLK Classic
5165
end
5266

67+
function DisableAddon()
68+
FiveSecondRule:SetScript("OnUpdate", nil)
69+
DisableAddOn(ADDON_NAME)
70+
end
71+
72+
5373
function LoadOptions()
5474
FiveSecondRule_Options = FiveSecondRule_Options or AddonUtils:deepcopy(defaults)
5575

@@ -65,14 +85,13 @@ do -- Private Scope
6585
function onEvent(self, event, arg1, ...)
6686
if (select(2, UnitClass("player")) == "WARRIOR") then
6787
-- Disable the addon for warriors, since there is no reliable power or life to track in order to show power ticks.
68-
FiveSecondRule:SetScript("OnUpdate", nil)
88+
DisableAddon()
6989
return
7090
end
7191

7292
if event == "ADDON_LOADED" then
7393
if arg1 == ADDON_NAME then
7494
Init()
75-
PrintHelp()
7695
end
7796
end
7897

@@ -189,6 +208,13 @@ do -- Private Scope
189208
print("|cff"..colorHex.."FiveSecondRule loaded - /fsr")
190209
end
191210

211+
function PrintNotSupported()
212+
local colorHex = "ed2d2d"
213+
print("|cff"..colorHex.."FiveSecondRule is not supported in this game version.")
214+
print("|cff"..colorHex.."The addon has been automatically disable with effect from your next UI reload.")
215+
end
216+
217+
192218
-- Expose Field Variables and Functions
193219
FiveSecondRule.Unlock = Unlock
194220
FiveSecondRule.Lock = Lock
@@ -198,6 +224,7 @@ do -- Private Scope
198224
FiveSecondRule.GetPower = GetPower
199225
FiveSecondRule.GetPowerMax = GetPowerMax
200226
FiveSecondRule.GetPowerType = GetPowerType
227+
FiveSecondRule.IsGameVersionValid = IsGameVersionValid
201228

202229
end
203230

FiveSecondRule.toc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Interface: 11403
22
## Title: Five Second Rule
33
## Notes: Track the so-called "5-second-rule" (5SR or FSR), which refers to the time needed to elapse after spending mana, for mana regen to resume. Notable, this rule excludes "mp5"-gear.
4-
## Version: 1.32
4+
## Version: 1.33
55
## DefaultState: enabled
66
## Author: CassiniEU @ Twitch.com
77
## SavedVariablesPerCharacter: FiveSecondRule_Options

FiveSecondRule_TBC.toc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Interface: 20504
22
## Title: Five Second Rule
33
## Notes: Track the so-called "5-second-rule" (5SR or FSR), which refers to the time needed to elapse after spending mana, for mana regen to resume. Notable, this rule excludes "mp5"-gear.
4-
## Version: 1.32
4+
## Version: 1.33
55
## DefaultState: enabled
66
## Author: CassiniEU @ Twitch.com
77
## SavedVariablesPerCharacter: FiveSecondRule_Options

FiveSecondRule_Vanilla.toc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Interface: 11403
22
## Title: Five Second Rule
33
## Notes: Track the so-called "5-second-rule" (5SR or FSR), which refers to the time needed to elapse after spending mana, for mana regen to resume. Notable, this rule excludes "mp5"-gear.
4-
## Version: 1.32
4+
## Version: 1.33
55
## DefaultState: enabled
66
## Author: CassiniEU @ Twitch.com
77
## SavedVariablesPerCharacter: FiveSecondRule_Options

Modules/OptionsPanel.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ NAMESPACE.OptionsPanelFrame = OptionsPanelFrame
1515
OptionsPanelFrame:RegisterEvent("PLAYER_LOGIN")
1616
OptionsPanelFrame:SetScript("OnEvent",
1717
function(self, event, arg1, ...)
18-
if event == "PLAYER_LOGIN" then
18+
if event == "PLAYER_LOGIN" and FiveSecondRule.IsGameVersionValid() then
1919
local loader = CreateFrame('Frame', nil, InterfaceOptionsFrame)
2020
loader:SetScript('OnShow', function(self)
2121
self:SetScript('OnShow', nil)

0 commit comments

Comments
 (0)