Skip to content

Commit af34f92

Browse files
committed
Prioritize items based on how far an item needs to travel
The intention of this change is to make it easier to verify at a glance whether an item is available for catalysing later. A warband item sitting on another character might be committed to that specific character, and so should be considered a lower priority for other characters. With this commit, items in the TUM Collections UI tooltip are first ordered according to this priority: 1. Catalyse 2. Upgrade 3. Upgrade & Catalyse which matches the priority of how the Catalyse and Upgrade icons are aggregated into Collections table. Within the tooltips, items are then ordered according to "distance", which tracks how far the item has to travel to be catalysed: 1. (Zero distance) Item is on a character of the same class as the tier appearance under consideration. 2. Item is in the warband bank. 3. (Maximum distance) Item is on a character of a different class from the tier appearance under consideration. A warband icon has been added to indicate whether the item needs to travel. This icon is also shown in the Collections table.
1 parent 557b0b6 commit af34f92

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

collectionUi.lua

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ local SEASON_NAMES = {
1717
};
1818
local CATALYST_MARKUP = CreateAtlasMarkup('CreationCatalyst-32x32', 18, 18)
1919
local UPGRADE_MARKUP = CreateAtlasMarkup('CovenantSanctum-Upgrade-Icon-Available', 18, 18)
20+
local WARBAND_MARKUP = CreateAtlasMarkup('warbands-icon', 18, 18)
2021
local OK_MARKUP = "|TInterface\\RaidFrame\\ReadyCheck-Ready:0|t"
2122
local NOK_MARKUP = "|TInterface\\RaidFrame\\ReadyCheck-NotReady:0|t"
2223
local OTHER_MARKUP = CreateAtlasMarkup('QuestRepeatableTurnin', 14, 16)
@@ -408,6 +409,9 @@ function UI:BuildUI()
408409
if result.requiresCatalyse then
409410
text = CATALYST_MARKUP .. ' ' .. text;
410411
end
412+
if result.distance > 0 then
413+
text = WARBAND_MARKUP .. ' ' .. text;
414+
end
411415
GameTooltip:AddDoubleLine(text, result.location, 1, 1, 1, 1, 1, 1);
412416
end
413417
else
@@ -602,32 +606,31 @@ function UI:OnUpdate()
602606
end
603607
if results and next(results) then
604608
table.sort(results, function(a, b)
605-
if a.sortPriority ~= b.sortPriority then
606-
return a.sortPriority > b.sortPriority;
609+
-- Order as Catalyse, then Upgrade, then CatalyseUpgrade.
610+
if a.requiresUpgrade ~= b.requiresUpgrade then
611+
return not a.requiresUpgrade and b.requiresUpgrade;
612+
end
613+
if a.requiresCatalyse ~= b.requiresCatalyse then
614+
return not a.requiresCatalyse and b.requiresCatalyse;
615+
end
616+
if a.distance ~= b.distance then
617+
return a.distance < b.distance;
607618
end
608619
if a.location ~= b.location then
609620
return a.location > b.location;
610621
end
611622
return a.itemLink > b.itemLink;
612623
end);
613-
local catalystRequired = true;
614-
local upgradeRequired = true;
615-
for _, result in pairs(results) do
616-
if not result.requiresUpgrade and not result.requiresCatalyseUpgrade then
617-
upgradeRequired = false;
618-
catalystRequired = true;
619-
break;
620-
end
621-
if not result.requiresCatalyse and not result.requiresCatalyseUpgrade then
622-
catalystRequired = false;
623-
end
624-
end
625-
if upgradeRequired then
624+
local firstResult = results[1];
625+
if firstResult.requiresUpgrade then
626626
text = ' ' .. UPGRADE_MARKUP .. text;
627627
end
628-
if catalystRequired then
628+
if firstResult.requiresCatalyse then
629629
text = ' ' .. CATALYST_MARKUP .. text;
630630
end
631+
if firstResult.distance > 0 then
632+
text = ' ' .. WARBAND_MARKUP .. text;
633+
end
631634
end
632635
if text == other then
633636
column.Text:AdjustPointsOffset(-3, 0);
@@ -735,18 +738,19 @@ local function checkResult(scanResult, classID, seasonID)
735738
local tumResult = TUM:IsAppearanceMissing(scanResult.itemLink, classID);
736739

737740
local location;
738-
local sortPriority = 0;
741+
local distance = 0;
739742
if scanResult.source.character then
740743
local classColor = C_ClassColor.GetClassColor(scanClassFile)
744+
local classFile = C_CreatureInfo.GetClassInfo(classID).classFile
741745
location = string.format(
742746
'%s: %s',
743747
classColor:WrapTextInColorCode(scanResult.source.character),
744748
scanResult.source.container
745749
);
746-
sortPriority = scanResult.source.character == playerFullName and 1000 or 10;
750+
distance = scanClassFile ~= classFile and 1000 or 0;
747751
elseif scanResult.source.warband then
748752
location = CreateAtlasMarkup('warbands-icon', 17, 13) .. ' Warband bank';
749-
sortPriority = 100 + scanResult.source.warband;
753+
distance = 100 + scanResult.source.warband;
750754
end
751755

752756
local info, upgradeInfo;
@@ -758,10 +762,9 @@ local function checkResult(scanResult, classID, seasonID)
758762
knownFromOtherItem = tumResult.catalystAppearanceLearnedFromOtherItem,
759763
requiresCatalyse = true,
760764
requiresUpgrade = false,
761-
requiresCatalyseUpgrade = false,
762765
itemLink = scanResult.itemLink,
763766
location = location,
764-
sortPriority = sortPriority,
767+
distance = distance,
765768
};
766769
end
767770

@@ -773,10 +776,9 @@ local function checkResult(scanResult, classID, seasonID)
773776
knownFromOtherItem = (isItemCatalysed and tumResult.upgradeAppearanceLearnedFromOtherItem) or tumResult.catalystUpgradeAppearanceLearnedFromOtherItem,
774777
requiresCatalyse = not isItemCatalysed,
775778
requiresUpgrade = true,
776-
requiresCatalyseUpgrade = not isItemCatalysed,
777779
itemLink = scanResult.itemLink,
778780
location = location,
779-
sortPriority = sortPriority,
781+
distance = distance,
780782
};
781783
end
782784

types.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
--- @field knownFromOtherItem boolean
1616
--- @field requiresUpgrade boolean
1717
--- @field requiresCatalyse boolean
18-
--- @field requiresCatalyseUpgrade boolean
1918
--- @field itemLink string
2019
--- @field location string
21-
--- @field sortPriority number # higher numbers should be sorted first
20+
--- @field distance number # 0 = same character, 100+ = warband bank, 1000 = different character.
2221

2322
--- @class TUM_AppearanceMissingResult
2423
--- @field canCatalyse boolean? # whether the item can be catalysed; if false, the catalystAppearanceMissing values will be nil

0 commit comments

Comments
 (0)