Skip to content

Commit

Permalink
Retail: Now showing 'Class' icons in place of 'Specialization' icons …
Browse files Browse the repository at this point in the history
…when no specializations show for the current ATT row (WIP - plan to add Races as well when no Classes shown)
  • Loading branch information
ImUnicke committed Jul 28, 2024
1 parent 0a29713 commit 6264b3a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
15 changes: 13 additions & 2 deletions AllTheThings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
31 changes: 27 additions & 4 deletions src/Classes/CharacterClass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down

0 comments on commit 6264b3a

Please sign in to comment.