From 23b813ef8a9721f4d52c2c49d3a5b41bafd66411 Mon Sep 17 00:00:00 2001 From: andrew6180 <16847730+andrew6180@users.noreply.github.com> Date: Mon, 16 Feb 2026 12:11:44 -0700 Subject: [PATCH] use C_ClassInfo for spec ids/info --- WeakAuras/Types.lua | 252 ++++++++++---------------------------------- 1 file changed, 56 insertions(+), 196 deletions(-) diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index aa40943..68573c7 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -3781,211 +3781,71 @@ do end do - local classData = { - DEATHKNIGHT = { - icon = "Interface\\Icons\\Spell_Deathknight_ClassIcon", - specs = { - [250] = { name = L["Blood"], icon = "Interface\\Icons\\Spell_Deathknight_BloodPresence" }, - [251] = { name = L["Frost"], icon = "Interface\\Icons\\Spell_Deathknight_FrostPresence" }, - [252] = { name = L["Unholy"], icon = "Interface\\Icons\\Spell_Deathknight_UnholyPresence" }, - } - }, - DRUID = { - icon = "Interface\\Icons\\Ability_Druid_Maul", - specs = { - [102] = { name = L["Balance"], icon = "Interface\\Icons\\Spell_Nature_StarFall" }, - [103] = { name = L["Feral Combat"], icon = "Interface\\Icons\\Ability_Racial_BearForm" }, - [104] = { name = L["Guardian"], icon = "Interface\\Icons\\Ability_Racial_BearForm" }, - [105] = { name = L["Restoration"], icon = "Interface\\Icons\\Spell_Nature_HealingTouch" }, - } - }, - HUNTER = { - icon = "Interface\\Icons\\INV_Weapon_Bow_07", - specs = { - [253] = { name = L["Beast Mastery"], icon = "Interface\\Icons\\Ability_Hunter_BeastTaming" }, - [254] = { name = L["Marksmanship"], icon = "Interface\\Icons\\Ability_Marksmanship" }, - [255] = { name = L["Survival"], icon = "Interface\\Icons\\Ability_Hunter_SwiftStrike" }, - } - }, - MAGE = { - icon = "Interface\\Icons\\INV_Staff_13", - specs = { - [62] = { name = L["Arcane"], icon = "Interface\\Icons\\Spell_Holy_MagicalSentry" }, - [63] = { name = L["Fire"], icon = "Interface\\Icons\\Spell_Fire_FireBolt02" }, - [64] = { name = L["Frost"], icon = "Interface\\Icons\\Spell_Frost_FrostBolt02" }, - } - }, - PALADIN = { - icon = "Interface\\Icons\\INV_Hammer_01", - specs = { - [65] = { name = L["Holy"], icon = "Interface\\Icons\\Spell_Holy_HolyBolt" }, - [66] = { name = L["Protection"], icon = "Interface\\Icons\\Spell_Holy_DevotionAura" }, - [70] = { name = L["Retribution"], icon = "Interface\\Icons\\Spell_Holy_AuraOfLight" }, - } - }, - PRIEST = { - icon = "Interface\\Icons\\INV_Staff_30", - specs = { - [256] = { name = L["Discipline"], icon = "Interface\\Icons\\Spell_Holy_WordFortitude" }, - [257] = { name = L["Holy"], icon = "Interface\\Icons\\Spell_Holy_GuardianSpirit" }, - [258] = { name = L["Shadow"], icon = "Interface\\Icons\\Spell_Shadow_ShadowWordPain" }, - } - }, - ROGUE = { - icon = "Interface\\Icons\\INV_ThrowingKnife_04", - specs = { - [259] = { name = L["Assassination"], icon = "Interface\\Icons\\Ability_Rogue_Eviscerate" }, - [260] = { name = L["Combat"], icon = "Interface\\Icons\\Ability_BackStab" }, - [261] = { name = L["Subtlety"], icon = "Interface\\Icons\\Ability_Stealth" }, - } - }, - SHAMAN = { - icon = "Interface\\Icons\\Spell_Nature_BloodLust", - specs = { - [262] = { name = L["ElementalShaman"], icon = "Interface\\Icons\\Spell_Nature_Lightning" }, - [263] = { name = L["Enhancement"], icon = "Interface\\Icons\\Spell_Nature_LightningShield" }, - [264] = { name = L["Restoration"], icon = "Interface\\Icons\\Spell_Nature_MagicImmunity" }, - } - }, - WARLOCK = { - icon = "Interface\\Icons\\Spell_Nature_FaerieFire", - specs = { - [265] = { name = L["Affliction"], icon = "Interface\\Icons\\Spell_Shadow_DeathCoil" }, - [266] = { name = L["Demonology"], icon = "Interface\\Icons\\Spell_Shadow_Metamorphosis" }, - [267] = { name = L["Destruction"], icon = "Interface\\Icons\\Spell_Shadow_RainOfFire" }, - } - }, - WARRIOR = { - icon = "Interface\\Icons\\INV_Sword_27", - specs = { - [71] = { name = L["Arms"], icon = "Interface\\Icons\\Ability_Rogue_Eviscerate" }, - [72] = { name = L["Fury"], icon = "Interface\\Icons\\Ability_Warrior_InnerRage" }, - [73] = { name = L["Protection"], icon = "Interface\\Icons\\INV_Shield_06" }, - } - }, - } - -- Creates the options layout. Due to CUSTOM_CLASS_COLORS, it needs to be created dynamically. - local function createSpecString(class, specID) - local data = classData[class] - if not data then return "" end - local classIcon = data.icon or "Interface\\Icons\\INV_Misc_QuestionMark" - local specData = data.specs[specID] or { icon = "Interface\\Icons\\INV_Misc_QuestionMark", name = "Unknown" } + local function getClassIcon(class) + if not class or class == "" then + return "Interface\\Icons\\INV_Misc_QuestionMark" + end + return "Interface\\Icons\\classicon_" .. class:lower() + end + + local function getSpecIcon(specInfo) + if specInfo and specInfo.SpecFilename then + return "Interface\\Icons\\" .. specInfo.SpecFilename + end + return "Interface\\Icons\\INV_Misc_QuestionMark" + end + + local function createSpecString(class, specInfo) + local classIcon = getClassIcon(class) + local specIcon = getSpecIcon(specInfo) + local specName = specInfo and specInfo.Name or "Unknown" local color = WA_GetClassColor(class) - return ("|T%s:0|t |T%s:0|t |c%s%s|r"):format(classIcon, specData.icon, color, specData.name) + return ("|T%s:0|t |T%s:0|t |c%s%s|r"):format(classIcon, specIcon, color, specName) + end + + local function addSpec(classFile, specInfo) + if not specInfo or not specInfo.ID then + return + end + local class = specInfo.Class or classFile or "" + local specID = specInfo.ID + Private.spec_types_all[specID] = createSpecString(class, specInfo) + Private.specid_to_icon[specID] = getSpecIcon(specInfo) + local specName = specInfo.Name or "" + local key = class .. specName + Private.specname_to_id[key] = specID + Private.specid_to_name[specID] = key end Private.spec_types_all = {} Private.spec = {} - for class, data in pairs(classData) do - for specID in pairs(data.specs) do - Private.spec_types_all[specID] = createSpecString(class, specID) + Private.specid_to_icon = {} + Private.specname_to_id = {} + Private.specid_to_name = {} + + local classOrder = CLASS_SORT_ORDER + if type(classOrder) ~= "table" or #classOrder == 0 then + classOrder = {} + if LOCALIZED_CLASS_NAMES_MALE then + for class in pairs(LOCALIZED_CLASS_NAMES_MALE) do + table.insert(classOrder, class) + end + table.sort(classOrder) + end + end + + if C_ClassInfo and C_ClassInfo.GetAllSpecs and C_ClassInfo.GetSpecInfo then + for _, class in ipairs(classOrder) do + local specs = C_ClassInfo.GetAllSpecs(class) + if specs then + for _, spec in ipairs(specs) do + addSpec(class, C_ClassInfo.GetSpecInfo(class, spec)) + end + end end end - wipe(classData) end -Private.specid_to_icon = { - [250] = "Interface\\Icons\\Spell_Deathknight_BloodPresence", - [251] = "Interface\\Icons\\Spell_Deathknight_FrostPresence", - [252] = "Interface\\Icons\\Spell_Deathknight_UnholyPresence", - [102] = "Interface\\Icons\\Spell_Nature_StarFall", - [103] = "Interface\\Icons\\Ability_Racial_BearForm", - [104] = "Interface\\Icons\\Ability_Racial_BearForm", - [105] = "Interface\\Icons\\Spell_Nature_HealingTouch", - [253] = "Interface\\Icons\\Ability_Hunter_BeastTaming", - [254] = "Interface\\Icons\\Ability_Marksmanship", - [255] = "Interface\\Icons\\Ability_Hunter_SwiftStrike", - [62] = "Interface\\Icons\\Spell_Holy_MagicalSentry", - [63] = "Interface\\Icons\\Spell_Fire_FireBolt02", - [64] = "Interface\\Icons\\Spell_Frost_FrostBolt02", - [65] = "Interface\\Icons\\Spell_Holy_HolyBolt", - [66] = "Interface\\Icons\\Spell_Holy_DevotionAura", - [70] = "Interface\\Icons\\Spell_Holy_AuraOfLight", - [256] = "Interface\\Icons\\Spell_Holy_WordFortitude", - [257] = "Interface\\Icons\\Spell_Holy_GuardianSpirit", - [258] = "Interface\\Icons\\Spell_Shadow_ShadowWordPain", - [259] = "Interface\\Icons\\Ability_Rogue_Eviscerate", - [260] = "Interface\\Icons\\Ability_BackStab", - [261] = "Interface\\Icons\\Ability_Stealth", - [262] = "Interface\\Icons\\Spell_Nature_Lightning", - [263] = "Interface\\Icons\\Spell_Nature_LightningShield", - [264] = "Interface\\Icons\\Spell_Nature_MagicImmunity", - [265] = "Interface\\Icons\\Spell_Shadow_DeathCoil", - [266] = "Interface\\Icons\\Spell_Shadow_Metamorphosis", - [267] = "Interface\\Icons\\Spell_Shadow_RainOfFire", - [71] = "Interface\\Icons\\Ability_Rogue_Eviscerate", - [72] = "Interface\\Icons\\Ability_Warrior_InnerRage", - [73] = "Interface\\Icons\\INV_Shield_06", -} - -Private.specname_to_id = { - ["DEATHKNIGHT" .. L["Blood"]] = 250, - ["DEATHKNIGHT" .. L["Frost"]] = 251, - ["DEATHKNIGHT" .. L["Unholy"]] = 252, - ["DRUID" .. L["Balance"]] = 102, - ["DRUID" .. L["Feral Combat"]] = 103, - ["DRUID" .. L["Guardian"]] = 104, - ["DRUID" .. L["Restoration"]] = 105, - ["HUNTER" .. L["Beast Mastery"]] = 253, - ["HUNTER" .. L["Marksmanship"]] = 254, - ["HUNTER" .. L["Survival"]] = 255, - ["MAGE" .. L["Arcane"]] = 62, - ["MAGE" .. L["Fire"]] = 63, - ["MAGE" .. L["Frost"]] = 64, - ["PALADIN" .. L["Holy"]] = 65, - ["PALADIN" .. L["Protection"]] = 66, - ["PALADIN" .. L["Retribution"]] = 70, - ["PRIEST" .. L["Discipline"]] = 256, - ["PRIEST" .. L["Holy"]] = 257, - ["PRIEST" .. L["Shadow"]] = 258, - ["ROGUE" .. L["Assassination"]] = 259, - ["ROGUE" .. L["Combat"]] = 260, - ["ROGUE" .. L["Subtlety"]] = 261, - ["SHAMAN" .. L["ElementalShaman"]] = 262, - ["SHAMAN" .. L["Enhancement"]] = 263, - ["SHAMAN" .. L["Restoration"]] = 264, - ["WARLOCK" .. L["Affliction"]] = 265, - ["WARLOCK" .. L["Demonology"]] = 266, - ["WARLOCK" .. L["Destruction"]] = 267, - ["WARRIOR" .. L["Arms"]] = 71, - ["WARRIOR" .. L["Fury"]] = 72, - ["WARRIOR" .. L["Protection"]] = 73, -} - -Private.specid_to_name = { - [250] = "DEATHKNIGHT" .. L["Blood"], - [251] = "DEATHKNIGHT" .. L["Frost"], - [252] = "DEATHKNIGHT" .. L["Unholy"], - [102] = "DRUID" .. L["Balance"], - [103] = "DRUID" .. L["Feral Combat"], - [104] = "DRUID" .. L["Guardian"], - [105] = "DRUID" .. L["Restoration"], - [253] = "HUNTER" .. L["Beast Mastery"], - [254] = "HUNTER" .. L["Marksmanship"], - [255] = "HUNTER" .. L["Survival"], - [62] = "MAGE" .. L["Arcane"], - [63] = "MAGE" .. L["Fire"], - [64] = "MAGE" .. L["Frost"], - [65] = "PALADIN" .. L["Holy"], - [66] = "PALADIN" .. L["Protection"], - [70] = "PALADIN" .. L["Retribution"], - [256] = "PRIEST" .. L["Discipline"], - [257] = "PRIEST" .. L["Holy"], - [258] = "PRIEST" .. L["Shadow"], - [259] = "ROGUE" .. L["Assassination"], - [260] = "ROGUE" .. L["Combat"], - [261] = "ROGUE" .. L["Subtlety"], - [262] = "SHAMAN" .. L["ElementalShaman"], - [263] = "SHAMAN" .. L["Enhancement"], - [264] = "SHAMAN" .. L["Restoration"], - [265] = "WARLOCK" .. L["Affliction"], - [266] = "WARLOCK" .. L["Demonology"], - [267] = "WARLOCK" .. L["Destruction"], - [71] = "WARRIOR" .. L["Arms"], - [72] = "WARRIOR" .. L["Fury"], - [73] = "WARRIOR" .. L["Protection"], -} - --[=[[ Old unused Talent List Private.talents_ids = { DEATHKNIGHT = {{48979,48997,49182,48978,49004,55107,48982,48987,49467,48985,49145,49015,48977,49006,49005,48988,53137,49027,49016,50365,62905,49018,55233,49189,55050,49023,61154,49028}, {49175,49455,49042,55061,49140,49226,50880,49039,51468,51123,49149,49137,49186,49471,49796,55610,49024,49188,50040,49203,50384,65661,54639,51271,49200,49143,50187,49202,49184}, {51745,48962,55129,49036,48963,49588,48965,49013,51459,49158,49146,49219,55620,49194,49220,49223,55666,49224,49208,52143,66799,51052,50391,63560,49032,49222,49217,51099,55090,50117,49206}},