From 6264b3a43342767edf0cb41ec376de2f149d04bf Mon Sep 17 00:00:00 2001 From: ImUnicke Date: Sun, 28 Jul 2024 16:00:20 -0600 Subject: [PATCH] Retail: Now showing 'Class' icons in place of 'Specialization' icons when no specializations show for the current ATT row (WIP - plan to add Races as well when no Classes shown) --- AllTheThings.lua | 15 +++++++++++++-- src/Classes/CharacterClass.lua | 31 +++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/AllTheThings.lua b/AllTheThings.lua index 6a3c38ee65..f568c0e1e1 100644 --- a/AllTheThings.lua +++ b/AllTheThings.lua @@ -1495,8 +1495,8 @@ app.RecreateObject = function(t) return obj; end -local GetFixedItemSpecInfo, GetSpecsString, GetGroupItemIDWithModID, GetItemIDAndModID, GroupMatchesParams - = app.GetFixedItemSpecInfo, app.GetSpecsString, app.GetGroupItemIDWithModID, app.GetItemIDAndModID, app.GroupMatchesParams +local GetFixedItemSpecInfo, GetSpecsString, GetGroupItemIDWithModID, GetItemIDAndModID, GroupMatchesParams, GetClassesString + = app.GetFixedItemSpecInfo, app.GetSpecsString, app.GetGroupItemIDWithModID, app.GetItemIDAndModID, app.GroupMatchesParams, app.GetClassesString -- Symlink Lib do @@ -3122,6 +3122,11 @@ local function GetSearchResults(method, paramA, paramB, ...) local specs = entry.specs; if specs and #specs > 0 then right = GetSpecsString(specs, false, false) .. right; + else + local c = entry.c; + if c and #c > 0 then + right = GetClassesString(c, false, false) .. right; + end end -- If this entry has customCollect requirements, list them for clarity @@ -7263,6 +7268,12 @@ local function SetRowData(self, row, data) if specs and #specs > 0 then summary = GetSpecsString(specs, false, false) .. summary; -- iconAdjust = iconAdjust - #specs; + else + local classes = data.c + if classes and #classes > 0 then + summary = GetClassesString(classes, false, false) .. summary; + -- iconAdjust = iconAdjust - #classes; + end end local rowSummary = row.Summary; local rowLabel = row.Label; diff --git a/src/Classes/CharacterClass.lua b/src/Classes/CharacterClass.lua index cae81fa2cb..e9a90d4767 100644 --- a/src/Classes/CharacterClass.lua +++ b/src/Classes/CharacterClass.lua @@ -7,8 +7,8 @@ local Colorize = app.Modules.Color.Colorize; local C_CreatureInfo = C_CreatureInfo; local RAID_CLASS_COLORS, GetPlayerInfoByGUID, UnitClass, UnitGUID, UnitIsGroupLeader, UnitRace = RAID_CLASS_COLORS, GetPlayerInfoByGUID, UnitClass, UnitGUID, UnitIsGroupLeader, UnitRace; -local math_floor, rawget, rawset, setmetatable - = math.floor, rawget, rawset, setmetatable; +local math_floor, rawget, rawset, setmetatable, ipairs + = math.floor, rawget, rawset, setmetatable, ipairs -- Class Info Helpers local ClassIcons = { @@ -54,7 +54,7 @@ if GetSpecializationInfoByID then rawset(t, key, specInfo); return specInfo; end - + local info = { icon = ClassIcons[key] or "Interface\\Icons\\INV_Misc_QuestionMark", file = "WARRIOR", @@ -124,7 +124,7 @@ local ClassInfoMetatable = { __index = function(t, key) }; ---@diagnostic disable-next-line: inject-field info.icontext = "|T" .. info.icon .. ":0|t " .. info.text; - + rawset(ClassInfoByID, classID, info); rawset(ClassInfoByClassFile, info.file, info); rawset(ClassInfoByClassName, info.name, info); @@ -139,6 +139,29 @@ setmetatable(ClassInfoByID, ClassInfoMetatable); setmetatable(ClassInfoByClassFile, ClassInfoMetatable); setmetatable(ClassInfoByClassName, ClassInfoMetatable); +-- Returns a string containing the class icons, followed by their respective names if desired +local function GetClassesString(c, includeNames, trim) + local icons = {} + local info + if includeNames then + for i,cl in ipairs(c) do + info = ClassInfoByID[cl] + icons[i] = info.icontext + end + else + for i,cl in ipairs(c) do + icons[i * 3 - 2] = "|T"; + icons[i * 3 - 1] = ClassIcons[cl]; + icons[i * 3] = ":0|t "; + end + end + if trim then + return app.TableConcat(icons):match('^%s*(.*%S)'); + end + return app.TableConcat(icons); +end +app.GetClassesString = GetClassesString + -- Implementation app.CreateCharacterClass = app.CreateClassWithInfo("CharacterClass", "classID", ClassInfoByID, { ["nmc"] = function(t)