Skip to content

Commit

Permalink
Disable the addon for WOTLK Classic and make sure the options panel i…
Browse files Browse the repository at this point in the history
…s not rendered.
  • Loading branch information
smp4903 committed Aug 29, 2022
1 parent 786082f commit c4fd63e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
33 changes: 30 additions & 3 deletions FiveSecondRule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,33 @@ do -- Private Scope
FiveSecondRule:SetScript("OnUpdate", function(self, sinceLastUpdate) onUpdate(sinceLastUpdate); end);

-- INITIALIZATION
function Init()
function Init()
if (not IsGameVersionValid()) then
PrintNotSupported()
DisableAddon()
return
end

LoadOptions()

TickBar:LoadSpells() -- LOCALIZATION
FiveSecondRule:Refresh()

PrintHelp()

end

function IsGameVersionValid()
local _, _, _, tocversion = GetBuildInfo()
return tocversion < 30400 -- Before WOTLK Classic
end

function DisableAddon()
FiveSecondRule:SetScript("OnUpdate", nil)
DisableAddOn(ADDON_NAME)
end


function LoadOptions()
FiveSecondRule_Options = FiveSecondRule_Options or AddonUtils:deepcopy(defaults)

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

if event == "ADDON_LOADED" then
if arg1 == ADDON_NAME then
Init()
PrintHelp()
end
end

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

function PrintNotSupported()
local colorHex = "ed2d2d"
print("|cff"..colorHex.."FiveSecondRule is not supported in this game version.")
print("|cff"..colorHex.."The addon has been automatically disable with effect from your next UI reload.")
end


-- Expose Field Variables and Functions
FiveSecondRule.Unlock = Unlock
FiveSecondRule.Lock = Lock
Expand All @@ -198,6 +224,7 @@ do -- Private Scope
FiveSecondRule.GetPower = GetPower
FiveSecondRule.GetPowerMax = GetPowerMax
FiveSecondRule.GetPowerType = GetPowerType
FiveSecondRule.IsGameVersionValid = IsGameVersionValid

end

Expand Down
2 changes: 1 addition & 1 deletion FiveSecondRule.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 11403
## Title: Five Second Rule
## 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.
## Version: 1.32
## Version: 1.33
## DefaultState: enabled
## Author: CassiniEU @ Twitch.com
## SavedVariablesPerCharacter: FiveSecondRule_Options
Expand Down
2 changes: 1 addition & 1 deletion FiveSecondRule_TBC.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 20504
## Title: Five Second Rule
## 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.
## Version: 1.32
## Version: 1.33
## DefaultState: enabled
## Author: CassiniEU @ Twitch.com
## SavedVariablesPerCharacter: FiveSecondRule_Options
Expand Down
2 changes: 1 addition & 1 deletion FiveSecondRule_Vanilla.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 11403
## Title: Five Second Rule
## 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.
## Version: 1.32
## Version: 1.33
## DefaultState: enabled
## Author: CassiniEU @ Twitch.com
## SavedVariablesPerCharacter: FiveSecondRule_Options
Expand Down
2 changes: 1 addition & 1 deletion Modules/OptionsPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NAMESPACE.OptionsPanelFrame = OptionsPanelFrame
OptionsPanelFrame:RegisterEvent("PLAYER_LOGIN")
OptionsPanelFrame:SetScript("OnEvent",
function(self, event, arg1, ...)
if event == "PLAYER_LOGIN" then
if event == "PLAYER_LOGIN" and FiveSecondRule.IsGameVersionValid() then
local loader = CreateFrame('Frame', nil, InterfaceOptionsFrame)
loader:SetScript('OnShow', function(self)
self:SetScript('OnShow', nil)
Expand Down

0 comments on commit c4fd63e

Please sign in to comment.