Skip to content

Commit bc3b04b

Browse files
Core: Selectively disabled expansion features to support Classic
This seems to be the standard way of guarding expansion-specific API calls. The original approach using WOW_PROJECT_ID is more difficult to maintain as new classic versions might be launched in the future. Co-Authored-By: aSnejbjerg <[email protected]>
1 parent be96d83 commit bc3b04b

File tree

6 files changed

+70
-32
lines changed

6 files changed

+70
-32
lines changed

.luacheckrc

+12
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ globals = {
6060
"C_Container",
6161
"C_Item",
6262
"Settings",
63+
"LE_EXPANSION_LEVEL_CURRENT",
64+
"LE_EXPANSION_CLASSIC",
65+
"LE_EXPANSION_BURNING_CRUSADE",
66+
"LE_EXPANSION_WRATH_OF_THE_LICH_KING",
67+
"LE_EXPANSION_CATACLYSM",
68+
"LE_EXPANSION_MISTS_OF_PANDARIA",
69+
"LE_EXPANSION_WARLORDS_OF_DRAENOR",
70+
"LE_EXPANSION_LEGION",
71+
"LE_EXPANSION_BATTLE_FOR_AZEROTH",
72+
"LE_EXPANSION_SHADOWLANDS",
73+
"LE_EXPANSION_DRAGONFLIGHT",
74+
"LE_EXPANSION_WAR_WITHIN",
6375

6476
"AuraUtil",
6577
"BackdropTemplateMixin",

Core.lua

+21-20
Original file line numberDiff line numberDiff line change
@@ -679,35 +679,36 @@ function R:IsAttemptAllowed(item)
679679
Rarity:Debug(format("Attempts for item %s are disallowed (not a required dungeon: %d)", item.name, dungeonID))
680680
return false
681681
end
682+
if LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_SHADOWLANDS then
683+
local activeCovenantID = C_Covenants.GetActiveCovenantID()
684+
if item.requiresCovenant and item.requiredCovenantID and activeCovenantID ~= item.requiredCovenantID then
685+
local activeCovenantData = C_Covenants.GetCovenantData(activeCovenantID)
686+
local requiredCovenantData = C_Covenants.GetCovenantData(item.requiredCovenantID)
687+
688+
if not activeCovenantData then
689+
Rarity:Debug(
690+
format(
691+
"Attempts for item %s are disallowed (Covenant %d/%s is required, but none is currently active)",
692+
item.name,
693+
item.requiredCovenantID,
694+
requiredCovenantData.name
695+
)
696+
)
697+
return false
698+
end
682699

683-
local activeCovenantID = C_Covenants.GetActiveCovenantID()
684-
if item.requiresCovenant and item.requiredCovenantID and activeCovenantID ~= item.requiredCovenantID then
685-
local activeCovenantData = C_Covenants.GetCovenantData(activeCovenantID)
686-
local requiredCovenantData = C_Covenants.GetCovenantData(item.requiredCovenantID)
687-
688-
if not activeCovenantData then
689700
Rarity:Debug(
690701
format(
691-
"Attempts for item %s are disallowed (Covenant %d/%s is required, but none is currently active)",
702+
"Attempts for item %s are disallowed (Covenant %d/%s is required, but active covenant is %d/%s)",
692703
item.name,
693704
item.requiredCovenantID,
694-
requiredCovenantData.name
705+
requiredCovenantData.name,
706+
activeCovenantID,
707+
activeCovenantData.name
695708
)
696709
)
697710
return false
698711
end
699-
700-
Rarity:Debug(
701-
format(
702-
"Attempts for item %s are disallowed (Covenant %d/%s is required, but active covenant is %d/%s)",
703-
item.name,
704-
item.requiredCovenantID,
705-
requiredCovenantData.name,
706-
activeCovenantID,
707-
activeCovenantData.name
708-
)
709-
)
710-
return false
711712
end
712713

713714
-- If any prerequisite quests exist, check if they are all completed

Core/EventHandlers.lua

+9-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ local GetStatistic = _G.GetStatistic
5050
local GetLootSourceInfo = _G.GetLootSourceInfo
5151
local C_Timer = _G.C_Timer
5252
local IsSpellKnown = _G.IsSpellKnown
53-
local GetCurrentRenownLevel = C_MajorFactions.GetCurrentRenownLevel
53+
local GetCurrentRenownLevel = C_MajorFactions and C_MajorFactions.GetCurrentRenownLevel
5454

5555
-- Addon APIs
5656
local DebugCache = Rarity.Utils.DebugCache
@@ -83,7 +83,11 @@ function EventHandlers:Register()
8383
self:RegisterEvent("ISLAND_COMPLETED", "OnIslandCompleted")
8484
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", "OnSpellcastSucceeded")
8585
self:RegisterEvent("QUEST_TURNED_IN", "OnQuestTurnedIn")
86-
self:RegisterEvent("SHOW_LOOT_TOAST", "OnShowLootToast")
86+
87+
if LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_MISTS_OF_PANDARIA then
88+
self:RegisterEvent("SHOW_LOOT_TOAST", "OnShowLootToast")
89+
end
90+
8791
self:RegisterBucketEvent("UPDATE_INSTANCE_INFO", 1, "OnEvent")
8892
self:RegisterBucketEvent("LFG_UPDATE_RANDOM_INFO", 1, "OnEvent")
8993
self:RegisterBucketEvent("CALENDAR_UPDATE_EVENT_LIST", 1, "OnEvent")
@@ -238,6 +242,9 @@ function R:OnCurrencyUpdate(event)
238242
-- Check if any coins were used
239243
for k, v in pairs(self.coins) do
240244
local currency = GetCurrencyInfo(k)
245+
if currency == nil then
246+
return
247+
end
241248
local name, currencyAmount = currency.name, currency.quantity
242249
local diff = currencyAmount - (coinamounts[k] or 0)
243250
coinamounts[k] = currencyAmount

Core/GUI/FauxAchievementPopup.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,15 @@ local function RarityAchievementAlertFrame_SetUp(frame, itemId, attempts)
100100
return true
101101
end
102102

103+
local FUNCTION_NEVER = function()
104+
return false
105+
end
106+
local IsInPetBattle = C_PetBattles and C_PetBattles.IsInBattle or FUNCTION_NEVER
107+
103108
local RarityAchievementAlertSystem =
104109
AlertFrame:AddQueuedAlertFrameSubSystem("AchievementAlertFrameTemplate", RarityAchievementAlertFrame_SetUp, 2, 6)
105110
RarityAchievementAlertSystem:SetCanShowMoreConditionFunc(function()
106-
return not C_PetBattles.IsInBattle()
111+
return not IsInPetBattle()
107112
end)
108113

109114
local Output = Rarity.Output

Core/GUI/MainWindow.lua

+6-5
Original file line numberDiff line numberDiff line change
@@ -1093,11 +1093,12 @@ local function addGroup(group, requiresGroup)
10931093
status = colorize(L["Unavailable"], gray)
10941094
end
10951095
end
1096-
1097-
if v.requiresCovenant and v.requiredCovenantID ~= nil then
1098-
local activeCovenantID = C_Covenants.GetActiveCovenantID()
1099-
if activeCovenantID ~= v.requiredCovenantID then
1100-
status = colorize(L["Unavailable"], gray)
1096+
if LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_SHADOWLANDS then
1097+
if v.requiresCovenant and v.requiredCovenantID ~= nil then
1098+
local activeCovenantID = C_Covenants.GetActiveCovenantID()
1099+
if activeCovenantID ~= v.requiredCovenantID then
1100+
status = colorize(L["Unavailable"], gray)
1101+
end
11011102
end
11021103
end
11031104

Modules/Options/Options.lua

+16-4
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,33 @@ local TIP_HIDDEN = "TIP_HIDDEN"
6060

6161
-- Classes
6262
local classes = {
63-
["DEATHKNIGHT"] = "|c" .. RAID_CLASS_COLORS["DEATHKNIGHT"]["colorStr"] .. L["Death Knight"] .. "|r",
64-
["DEMONHUNTER"] = "|c" .. RAID_CLASS_COLORS["DEMONHUNTER"]["colorStr"] .. L["Demon Hunter"] .. "|r",
6563
["DRUID"] = "|c" .. RAID_CLASS_COLORS["DRUID"]["colorStr"] .. L["Druid"] .. "|r",
6664
["HUNTER"] = "|c" .. RAID_CLASS_COLORS["HUNTER"]["colorStr"] .. L["Hunter"] .. "|r",
6765
["MAGE"] = "|c" .. RAID_CLASS_COLORS["MAGE"]["colorStr"] .. L["Mage"] .. "|r",
68-
["MONK"] = "|c" .. RAID_CLASS_COLORS["MONK"]["colorStr"] .. L["Monk"] .. "|r",
6966
["PALADIN"] = "|c" .. RAID_CLASS_COLORS["PALADIN"]["colorStr"] .. L["Paladin"] .. "|r",
7067
["PRIEST"] = "|c" .. RAID_CLASS_COLORS["PRIEST"]["colorStr"] .. L["Priest"] .. "|r",
7168
["ROGUE"] = "|c" .. RAID_CLASS_COLORS["ROGUE"]["colorStr"] .. L["Rogue"] .. "|r",
7269
["SHAMAN"] = "|c" .. RAID_CLASS_COLORS["SHAMAN"]["colorStr"] .. L["Shaman"] .. "|r",
7370
["WARLOCK"] = "|c" .. RAID_CLASS_COLORS["WARLOCK"]["colorStr"] .. L["Warlock"] .. "|r",
7471
["WARRIOR"] = "|c" .. RAID_CLASS_COLORS["WARRIOR"]["colorStr"] .. L["Warrior"] .. "|r",
75-
["EVOKER"] = "|c" .. RAID_CLASS_COLORS["EVOKER"]["colorStr"] .. L["Evoker"] .. "|r",
7672
}
7773

74+
if LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_WRATH_OF_THE_LICH_KING then
75+
classes["DEATHKNIGHT"] = "|c" .. RAID_CLASS_COLORS["DEATHKNIGHT"]["colorStr"] .. L["Death Knight"] .. "|r"
76+
end
77+
78+
if LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_DRAGONFLIGHT then
79+
classes["EVOKER"] = "|c" .. RAID_CLASS_COLORS["EVOKER"]["colorStr"] .. L["Evoker"] .. "|r"
80+
end
81+
82+
if LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_LEGION then
83+
classes["DEMONHUNTER"] = "|c" .. RAID_CLASS_COLORS["DEMONHUNTER"]["colorStr"] .. L["Demon Hunter"] .. "|r"
84+
end
85+
86+
if LE_EXPANSION_LEVEL_CURRENT >= LE_EXPANSION_MISTS_OF_PANDARIA then
87+
classes["MONK"] = "|c" .. RAID_CLASS_COLORS["MONK"]["colorStr"] .. L["Monk"] .. "|r"
88+
end
89+
7890
local red = Rarity.Enum.Colors.Red
7991
local blue = Rarity.Enum.Colors.Blue
8092
local green = Rarity.Enum.Colors.Green

0 commit comments

Comments
 (0)