
Refactor Icon and Variable Bar Text Definitions
Twintop opened this issue ยท 0 comments
Bar Text variables and icons are currently defined within the FillSpellData_{SPEC NAME}
functions in individual class modules. This is clunky and adds more locations that have to be updated to add new variables or icons. Now that spell data is split into separate {CLASS}Classes.lua
files, we can also make the filling of specCache.SPEC.barTextVariables
more data-driven by moving these variables into each spell. Examples below:
Current
local function FillSpellData_Shadow()
Setup_Shadow()
specCache.shadow.spellsData:FillSpellData()
local spells = specCache.shadow.spellsData.spells --[[@as TRB.Classes.Priest.ShadowSpells]]
-- This is done here so that we can get icons for the options menu!
specCache.shadow.barTextVariables.icons = {
{ variable = "#casting", icon = "", description = L["BarTextIconCasting"], printInSettings = true },
{ variable = "#item_ITEMID_", icon = "", description = L["BarTextIconCustomItem"], printInSettings = true },
{ variable = "#spell_SPELLID_", icon = "", description = L["BarTextIconCustomSpell"], printInSettings = true },
...
{ variable = "#mm", icon = spells.mindMelt.icon, description = spells.mindMelt.name, printInSettings = true },
{ variable = "#mindMelt", icon = spells.mindMelt.icon, description = spells.mindMelt.name, printInSettings = false },
...
}
specCache.shadow.barTextVariables.values = {
--Almost of the variables that are shared globally are here, such as $haste, $int, $inCombat
...
{ variable = "$mmTime", description = L["PriestShadowBarTextVariable_mmTime"], printInSettings = true, color = false },
{ variable = "$mmStacks", description = L["PriestShadowBarTextVariable_mmStacks"], printInSettings = true, color = false },
...
}
end
Definitions moved to spells
function TRB.Classes.Priest.ShadowSpells:New()
---@type TRB.Classes.SpecializationSpellsBase
local base = TRB.Classes.SpecializationSpellsBase
self = setmetatable(base:New(), TRB.Classes.Priest.ShadowSpells) --[[@as TRB.Classes.Priest.ShadowSpells]]
...
self.mindMelt = TRB.Classes.SpellBase:New({
id = 391092,
isTalent = true,
barTextVariables = {
icons = {
{
variable = "#mm",
printInSettings = true,
description = L["LocalizationString"] -- Typically omitted as the name will be filled in once the spell info is loaded
icon = function()
--Custom method to determine the icon here, if needed. Usually icon will be omitted and just filled in once the spell info is loaded
end
},
{
variable = "#mindMelt",
printInSettings = false
},
},
barText = {
{
variable = "$mmTime",
description = L["PriestShadowBarTextVariable_mmTime"],
printInSettings = true,
color = false -- Typically omitted because this only applies ever (currently) to Shadow Priests for haste coloring.
},
{
variable = "$mmStacks",
description = L["PriestShadowBarTextVariable_mmStacks"],
printInSettings = true
}
}
}
})
...
return self
end
Once these values are relocated, inside TRB.Classes.SpellBase:New() we'll need to fill in the gaps and store them off. Then, when FillSpellData_{SPEC}
is called, we will need to set the specCache values to pull from the spells list (or cache it somewhere first? it should never change).