Skip to content

Commit c7fd54f

Browse files
committed
refactor: use more robust expansion feature conditional logic
1 parent 6a05531 commit c7fd54f

File tree

32 files changed

+363
-533
lines changed

32 files changed

+363
-533
lines changed

Components/Core/Common/PlayerNames.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ function NAMES:OnInitialize()
9393
self:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
9494
end
9595

96+
local scoreHasRankReturn = type(select(7, GetBattlefieldScore(1))) == 'number'
9697
function NAMES:UPDATE_BATTLEFIELD_SCORE()
9798
for i = 1, GetNumBattlefieldScores() do
9899
local name, class, _
99-
if not TMW.isRetail then
100+
if scoreHasRankReturn then
100101
-- There's an extra "rank" return that's not there in retail.
102+
-- Its there in classic up through at least MOP.
101103
name, _, _, _, _, _, _, _, _, class = GetBattlefieldScore(i)
102104
else
103105
name, _, _, _, _, _, _, _, class = GetBattlefieldScore(i)

Components/Core/Common/SpellUsable.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ local SpellUsable = TMW.COMMON.SpellUsable
3030
local Actions = TMW.COMMON.Actions
3131

3232
-- todo: can we feature detect hasPreciseActionEvents?
33-
local hasPreciseActionEvents = select(4, GetBuildInfo()) >= 110000
33+
local hasPreciseActionEvents = ClassicExpansionAtLeast(LE_EXPANSION_WAR_WITHIN)
3434

3535
if hasPreciseActionEvents then
3636
SpellUsable:RegisterEvent("ACTION_USABLE_CHANGED")

Components/Core/Common/SwingTimerMonitor.lua

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,21 @@ TMW:RegisterCallback("TMW_GLOBAL_UPDATE", function()
5858
pGUID = UnitGUID("player")
5959
end)
6060

61-
local swingSpells =
62-
not TMW.isRetail and {
63-
[strlowerCache[GetSpellName(78)]] = 1, -- Heroic Strike
64-
[strlowerCache[GetSpellName(845)]] = 1, -- Cleave
65-
[strlowerCache[GetSpellName(6807)]] = 1, -- Maul
66-
} or {
67-
-- Retail spells:
68-
[strlowerCache[GetSpellName(404542)]] = 1, -- Crusading Strikes (ret talent)
69-
}
70-
71-
if GetSpellName(56815) then
72-
swingSpells[strlowerCache[GetSpellName(56815)]] = 1 -- Rune Strike
73-
end
74-
if GetSpellName(2973) then
75-
swingSpells[strlowerCache[GetSpellName(2973)]] = 1 -- Raptor Strike (vanilla - cata)
61+
local swingSpells = {}
62+
local function addSwingSpell(spell)
63+
local name = GetSpellName(spell)
64+
if name then
65+
swingSpells[strlowerCache[name]] = 1
66+
end
7667
end
7768

69+
addSwingSpell(78) -- Heroic Strike
70+
addSwingSpell(845) -- Cleave
71+
addSwingSpell(6807) -- Maul
72+
addSwingSpell(56815) -- Rune Strike
73+
addSwingSpell(2973) -- Raptor Strike (vanilla - cata)
74+
addSwingSpell(404542) -- Crusading Strikes (ret talent)
75+
7876
-- ---------------------------------
7977
-- Misc state update functions
8078
-- ---------------------------------

Components/Core/Conditions/Categories/BuffsDebuffs.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ for i = 1, 3 do -- BUFFTOOLTIPSCAN
448448
check = function(check)
449449
check:SetTexts(L["ONLYCHECKMINE"], L["ONLYCHECKMINE_DESC"])
450450
end,
451-
icon = not TMW.isRetail and "Interface\\Icons\\spell_ice_lament" or "Interface\\Icons\\ability_priest_clarityofwill",
451+
icon = ClassicExpansionAtLeast(LE_EXPANSION_WARLORDS_OF_DRAENOR) and "Interface\\Icons\\ability_priest_clarityofwill" or "Interface\\Icons\\spell_ice_lament",
452452
tcoords = CNDT.COMMON.standardtcoords,
453453
funcstr = function(c)
454454
if CanUsePackedAuras(c) then
@@ -591,7 +591,7 @@ ConditionCategory:RegisterCondition(12.5,"DEBUFFPERC", {
591591
check:SetTexts(L["ONLYCHECKMINE"], L["ONLYCHECKMINE_DESC"])
592592
end,
593593
formatter = TMW.C.Formatter.PERCENT,
594-
icon = not TMW.isRetail and "Interface\\Icons\\ability_rogue_dualweild" or "Interface\\Icons\\spell_priest_voidshift",
594+
icon = ClassicExpansionAtLeast(LE_EXPANSION_MISTS_OF_PANDARIA) and "Interface\\Icons\\spell_priest_voidshift" or "Interface\\Icons\\ability_rogue_dualweild",
595595
tcoords = CNDT.COMMON.standardtcoords,
596596
funcstr = function(c)
597597
if CanUsePackedAuras(c) then

Components/Core/Conditions/Categories/Location.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ConditionCategory:RegisterCondition(1, "INSTANCE2", {
6161

6262
unit = false,
6363
bitFlagTitle = L["CONDITIONPANEL_BITFLAGS_CHOOSEMENU_TYPES"],
64-
bitFlags = not TMW.isRetail and {
64+
bitFlags = ClassicExpansionAtMost(LE_EXPANSION_WRATH_OF_THE_LICH_KING) and {
6565
[01] = {order=01, text=L["CONDITIONPANEL_INSTANCETYPE_NONE"], space=true, }, -- None (Outside)
6666
[02] = {order=02, text=BATTLEGROUND, }, -- Battleground
6767
[03] = {order=03, text=ARENA, space=true, }, -- Arena

Components/Core/Conditions/Categories/Misc.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ ConditionCategory:RegisterCondition(12, "TIMEOFDAY", {
222222
--return CNDT.COMMON.formatSeconds(k*60)
223223
end,
224224
unit = false,
225-
icon = not TMW.isRetail and "Interface\\Icons\\inv_misc_pocketwatch_02" or "Interface\\Icons\\Ability_Racial_TimeIsMoney",
225+
icon = ClassicExpansionAtLeast(LE_EXPANSION_MISTS_OF_PANDARIA) and "Interface\\Icons\\Ability_Racial_TimeIsMoney" or "Interface\\Icons\\inv_misc_pocketwatch_02",
226226
tcoords = CNDT.COMMON.standardtcoords,
227227
Env = {
228228
GetDaysElapsedMinutes = function()

Components/Core/Conditions/Categories/PlayerAttributes.lua

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ if C_PvP.IsWarModeDesired then
141141
funcstr = [[BOOLCHECK( IsWarModeDesired() )]],
142142
events = function(ConditionObject, c)
143143
return
144-
ConditionObject:GenerateNormalEventString("PLAYER_FLAGS_CHANGED")
144+
ConditionObject:GenerateNormalEventString("PLAYER_FLAGS_CHANGED")
145145
end,
146146
})
147147
end
@@ -155,22 +155,9 @@ end)
155155

156156
ConditionCategory:RegisterSpacer(5.5)
157157

158-
local FirstStances = not TMW.isRetail and {
159-
DRUID = 5487, -- Bear Form
160-
PRIEST = 15473, -- Shadowform
161-
ROGUE = 1784, -- Stealth
162-
WARRIOR = 2457, -- Battle Stance
163-
PALADIN = 19746, -- Concentration Aura
164-
DEATHKNIGHT = 48266,-- Blood Presence
165-
} or {
166-
DRUID = 5487, -- Bear Form
167-
ROGUE = 1784, -- Stealth
168-
WARRIOR = 386208, -- Defensive Stance
169-
}
170158
ConditionCategory:RegisterCondition(6, "STANCE", {
171-
text = pclass == "DRUID" and L["SHAPESHIFT"] or
172-
L["STANCE"],
173-
159+
text = L["STANCE"],
160+
174161
bool = true,
175162

176163
name = function(editbox)
@@ -180,9 +167,7 @@ ConditionCategory:RegisterCondition(6, "STANCE", {
180167
useSUG = "stances",
181168
allowMultipleSUGEntires = true,
182169
unit = PLAYER,
183-
icon = function()
184-
return GetSpellTexture(FirstStances[pclass] or FirstStances.WARRIOR) or GetSpellTexture(FirstStances.WARRIOR)
185-
end,
170+
icon = "Interface\\Icons\\Ability_warrior_offensivestance",
186171
tcoords = CNDT.COMMON.standardtcoords,
187172
Env = {
188173
StanceHelper = function(spellSet)
@@ -223,7 +208,6 @@ ConditionCategory:RegisterCondition(6, "STANCE", {
223208
return
224209
ConditionObject:GenerateNormalEventString("UPDATE_SHAPESHIFT_FORM")
225210
end,
226-
hidden = not FirstStances[pclass],
227211
})
228212

229213
ConditionCategory:RegisterSpacer(6.5)
@@ -280,13 +264,13 @@ ConditionCategory:RegisterCondition(13.1, "PETMODE2", {
280264
bitFlagTitle = L["CONDITIONPANEL_BITFLAGS_CHOOSEMENU_TYPES"],
281265
bitFlags = {
282266
[0] = L["CONDITIONPANEL_PETMODE_NONE"],
283-
[1] = not TMW.isRetail and PET_MODE_AGRESSIVE or PET_MODE_ASSIST,
267+
[1] = ClassicExpansionAtMost(LE_EXPANSION_WRATH_OF_THE_LICH_KING) and PET_MODE_AGRESSIVE or PET_MODE_ASSIST,
284268
[2] = PET_MODE_DEFENSIVE,
285269
[3] = PET_MODE_PASSIVE
286270
},
287271

288272
unit = false,
289-
icon = not TMW.isRetail and PET_PASSIVE_TEXTURE or PET_ASSIST_TEXTURE,
273+
icon = ClassicExpansionAtMost(LE_EXPANSION_WRATH_OF_THE_LICH_KING) and PET_PASSIVE_TEXTURE or PET_ASSIST_TEXTURE,
290274
tcoords = CNDT.COMMON.standardtcoords,
291275

292276
Env = {

Components/Core/Conditions/Categories/PlayerAttributes_config.lua

Lines changed: 54 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -31,134 +31,63 @@ Module.noMin = true
3131
Module.showColorHelp = false
3232
Module.helpText = L["SUG_TOOLTIPTITLE_GENERIC"]
3333

34-
Module.stances = TMW.isMop and {
35-
WARRIOR = {
36-
[2457] = GetSpellName(2457), -- Battle Stance
37-
[71] = GetSpellName(71), -- Defensive Stance
38-
[2458] = GetSpellName(2458), -- Berserker Stance
39-
},
40-
DRUID = {
41-
[5487] = GetSpellName(5487), -- Bear Form
42-
[768] = GetSpellName(768), -- Cat Form
43-
[1066] = GetSpellName(1066), -- Aquatic Form
44-
[783] = GetSpellName(783), -- Travel Form
45-
[24858] = GetSpellName(24858), -- Moonkin Form
46-
[33891] = GetSpellName(33891), -- Tree of Life
47-
[33943] = GetSpellName(33943), -- Flight Form
48-
[40120] = GetSpellName(40120), -- Swift Flight Form
49-
},
50-
PRIEST = {
51-
[15473] = GetSpellName(15473), -- Shadowform
52-
},
53-
ROGUE = {
54-
[1784] = GetSpellName(1784), -- Stealth
55-
},
56-
HUNTER = {
57-
[13165] = GetSpellName(13165), -- Aspect of the Hawk
58-
[109260] = GetSpellName(109260), -- Aspect of the Iron Hawk
59-
[5118] = GetSpellName(5118), -- Aspect of the Cheetah
60-
[13159] = GetSpellName(13159), -- Aspect of the Pack
61-
},
62-
DEATHKNIGHT = {
63-
[48263] = GetSpellName(48263), -- Blood Presence
64-
[48266] = GetSpellName(48266), -- Frost Presence
65-
[48265] = GetSpellName(48265), -- Unholy Presence
66-
},
67-
PALADIN = {
68-
[105361] = GetSpellName(105361), -- Seal of Command
69-
[20165] = GetSpellName(20165), -- Seal of Insight
70-
[20164] = GetSpellName(20164), -- Seal of Justice
71-
[20154] = GetSpellName(20154), -- Seal of Righteousness
72-
[31801] = GetSpellName(31801), -- Seal of Truth
73-
},
74-
WARLOCK = {
75-
[103958] = GetSpellName(103958), -- Metamorphosis
76-
[114168] = GetSpellName(114168), -- Dark Apotheosis
77-
},
78-
MONK = {
79-
[115069] = GetSpellName(115069), -- Sturdy Ox
80-
[115070] = GetSpellName(115070), -- Wise Serpent
81-
[103985] = GetSpellName(103985), -- Fierce Tiger
82-
},
83-
} or (TMW.isWrath or TMW.isCata) and {
84-
WARRIOR = {
85-
[2457] = GetSpellName(2457), -- Battle Stance
86-
[71] = GetSpellName(71), -- Defensive Stance
87-
[2458] = GetSpellName(2458), -- Berserker Stance
88-
},
89-
DRUID = {
90-
[5487] = GetSpellName(5487), -- Bear Form
91-
[9634] = GetSpellName(9634), -- Dire Bear Form
92-
[768] = GetSpellName(768), -- Cat Form
93-
[783] = GetSpellName(783), -- Travel Form
94-
[1066] = GetSpellName(1066), -- Aquatic Form
95-
[24858] = GetSpellName(24858), -- Moonkin Form
96-
[33891] = GetSpellName(33891), -- Tree of Life
97-
[33943] = GetSpellName(33943), -- Flight Form
98-
[40120] = GetSpellName(40120), -- Swift Flight Form
99-
},
100-
PRIEST = {
101-
[15473] = GetSpellName(15473), -- Shadowform
102-
},
103-
ROGUE = {
104-
[1784] = GetSpellName(1784), -- Stealth
105-
},
106-
PALADIN = {
107-
[19746] = GetSpellName(19746), -- Concentration Aura
108-
[32223] = GetSpellName(32223), -- Crusader Aura
109-
[465] = GetSpellName(465), -- Devotion Aura
110-
[19900] = GetSpellName(19891), -- Fire Resistance Aura
111-
[19898] = GetSpellName(19891), -- Frost Resistance Aura
112-
[19896] = GetSpellName(19891), -- Shadow Resistance Aura
113-
[7294] = GetSpellName(7294), -- Retribution Aura
114-
},
115-
DEATHKNIGHT = {
116-
[48266] = GetSpellName(48266), -- Blood
117-
[48263] = GetSpellName(48263), -- Frost
118-
[48265] = GetSpellName(48265), -- Unholy
119-
},
120-
} or TMW.isClassic and {
121-
WARRIOR = {
122-
[2457] = GetSpellName(2457), -- Battle Stance
123-
[71] = GetSpellName(71), -- Defensive Stance
124-
[2458] = GetSpellName(2458), -- Berserker Stance
125-
},
126-
DRUID = {
127-
[5487] = GetSpellName(5487), -- Bear Form
128-
[768] = GetSpellName(768), -- Cat Form
129-
[783] = GetSpellName(783), -- Travel Form
130-
[24858] = GetSpellName(24858), -- Moonkin Form
131-
},
132-
PRIEST = {
133-
[15473] = GetSpellName(15473), -- Shadowform
134-
},
135-
ROGUE = {
136-
[1784] = GetSpellName(1784), -- Stealth
137-
},
138-
} or {
139-
DRUID = {
140-
[5487] = GetSpellName(5487), -- Bear Form
141-
[768] = GetSpellName(768), -- Cat Form
142-
[783] = GetSpellName(783), -- Travel Form
143-
[24858] = GetSpellName(24858), -- Moonkin Form
144-
[33891] = GetSpellName(33891), -- Incarnation: Tree of Life
145-
[171745] = GetSpellName(171745), -- Claws of Shirvallah
146-
},
147-
ROGUE = {
148-
[1784] = GetSpellName(1784), -- Stealth
149-
},
150-
WARRIOR = {
151-
[386164] = GetSpellName(386164), -- Battle Stance
152-
[386208] = GetSpellName(386208), -- Defensive Stance
153-
[386196] = GetSpellName(386196), -- Berserker Stance
154-
},
34+
Module.stances = {
35+
[2457] = GetSpellName(2457), -- Battle Stance
36+
[71] = GetSpellName(71), -- Defensive Stance
37+
[2458] = GetSpellName(2458), -- Berserker Stance
38+
[386164] = GetSpellName(386164), -- Battle Stance (dragonflight)
39+
[386208] = GetSpellName(386208), -- Defensive Stance (dragonflight)
40+
[386196] = GetSpellName(386196), -- Berserker Stance (dragonflight)
41+
42+
[5487] = GetSpellName(5487), -- Bear Form
43+
[768] = GetSpellName(768), -- Cat Form
44+
[1066] = GetSpellName(1066), -- Aquatic Form
45+
[783] = GetSpellName(783), -- Travel Form
46+
[24858] = GetSpellName(24858), -- Moonkin Form
47+
[33891] = GetSpellName(33891), -- Tree of Life
48+
[33943] = GetSpellName(33943), -- Flight Form
49+
[40120] = GetSpellName(40120), -- Swift Flight Form
50+
[9634] = GetSpellName(9634), -- Dire Bear Form
51+
[171745] = GetSpellName(171745), -- Claws of Shirvallah
52+
53+
[1784] = GetSpellName(1784), -- Stealth
54+
55+
[13165] = GetSpellName(13165), -- Aspect of the Hawk
56+
[109260] = GetSpellName(109260), -- Aspect of the Iron Hawk
57+
[5118] = GetSpellName(5118), -- Aspect of the Cheetah
58+
[13159] = GetSpellName(13159), -- Aspect of the Pack
59+
60+
[48263] = GetSpellName(48263), -- Blood Presence
61+
[48266] = GetSpellName(48266), -- Frost Presence
62+
[48265] = GetSpellName(48265), -- Unholy Presence
63+
64+
[103958] = GetSpellName(103958), -- Metamorphosis
65+
[114168] = GetSpellName(114168), -- Dark Apotheosis
66+
67+
[15473] = GetSpellName(15473), -- Shadowform
68+
69+
[115069] = GetSpellName(115069), -- Sturdy Ox
70+
[115070] = GetSpellName(115070), -- Wise Serpent
71+
[103985] = GetSpellName(103985), -- Fierce Tiger
72+
73+
[105361] = GetSpellName(105361), -- Seal of Command
74+
[20165] = GetSpellName(20165), -- Seal of Insight
75+
[20164] = GetSpellName(20164), -- Seal of Justice
76+
[20154] = GetSpellName(20154), -- Seal of Righteousness
77+
[31801] = GetSpellName(31801), -- Seal of Truth
78+
[19746] = GetSpellName(19746), -- Concentration Aura
79+
[32223] = GetSpellName(32223), -- Crusader Aura
80+
[465] = GetSpellName(465), -- Devotion Aura
81+
[19900] = GetSpellName(19891), -- Fire Resistance Aura
82+
[19898] = GetSpellName(19891), -- Frost Resistance Aura
83+
[19896] = GetSpellName(19891), -- Shadow Resistance Aura
84+
[7294] = GetSpellName(7294), -- Retribution Aura
15585
}
86+
15687
function Module:Table_Get()
15788
local allStances = {}
158-
for class, stances in pairs(self.stances) do
159-
for spellID, name in pairs(stances) do
160-
allStances[spellID] = name
161-
end
89+
for spellID, name in pairs(Module.stances) do
90+
allStances[spellID] = name
16291
end
16392
return allStances
16493
end

Components/Core/Conditions/Categories/PlayerCombatStats-Wrath.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ if GetExpertise and CR_EXPERTISE then
186186
})
187187
end
188188

189-
if select(4, GetBuildInfo()) < 60000 and UnitRangedAttackPower and GetRangedCritChance and GetRangedHaste then
189+
if ClassicExpansionAtMost(LE_EXPANSION_MISTS_OF_PANDARIA) and UnitRangedAttackPower and GetRangedCritChance and GetRangedHaste then
190190
-- Mop and below
191191
ConditionCategory:RegisterSpacer(20)
192192

0 commit comments

Comments
 (0)