Skip to content

Commit 68f72c5

Browse files
committed
Added separate info for appearances that are learned from other items
1 parent 09ce65e commit 68f72c5

File tree

3 files changed

+120
-41
lines changed

3 files changed

+120
-41
lines changed

TransmogUpgradeMaster.lua

Lines changed: 99 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ TUM.data = ns.data
1414
TUM.Config = ns.Config
1515
local settingKeys = TUM.Config.settingKeys
1616

17+
--- @alias TUM_LearnedFromOtherItem "learnedFromOtherItem"
18+
local LEARNED_FROM_OTHER_ITEM = 'learnedFromOtherItem'
19+
1720
local TIER_LFR = 1
1821
local TIER_NORMAL = 2
1922
local TIER_HEROIC = 3
@@ -58,6 +61,7 @@ local CATALYST_MARKUP = CreateAtlasMarkup('CreationCatalyst-32x32', 18, 18)
5861
local UPGRADE_MARKUP = CreateAtlasMarkup('CovenantSanctum-Upgrade-Icon-Available', 18, 18)
5962
local OK_MARKUP = "|TInterface\\RaidFrame\\ReadyCheck-Ready:0|t"
6063
local NOK_MARKUP = "|TInterface\\RaidFrame\\ReadyCheck-NotReady:0|t"
64+
local OTHER_MARKUP = CreateAtlasMarkup('QuestRepeatableTurnin', 16, 16)
6165

6266
local catalystSlots = {
6367
[Enum.InventoryType.IndexHeadType] = true,
@@ -268,18 +272,20 @@ local modifierFunctions = {
268272
--- @param tooltip GameTooltip
269273
--- @param text string
270274
--- @param isCollected boolean
271-
function TUM:AddTooltipLine(tooltip, text, isCollected)
272-
local modifierSetting = isCollected
273-
and self.db[settingKeys.showCollectedModifierKey]
274-
or self.db[settingKeys.showUncollectedModifierKey]
275+
function TUM:AddTooltipLine(tooltip, text, isCollected, fromOtherItem)
276+
local modifierSetting =
277+
(isCollected and self.db[settingKeys.showCollectedModifierKey])
278+
or (fromOtherItem and self.db[settingKeys.showCollectedFromOtherItemModifierKey])
279+
or (self.db[settingKeys.showUncollectedModifierKey])
275280
local modifierFunction = modifierFunctions[modifierSetting]
276281
if not modifierFunction or not modifierFunction() then
277282
return
278283
end
279284

280285
local ok = OK_MARKUP .. GREEN_FONT_COLOR:WrapTextInColorCode(' Collected ') .. OK_MARKUP
281286
local nok = NOK_MARKUP .. RED_FONT_COLOR:WrapTextInColorCode(' Not Collected ') .. NOK_MARKUP
282-
tooltip:AddDoubleLine(text, isCollected and ok or nok)
287+
local other = OTHER_MARKUP .. BLUE_FONT_COLOR:WrapTextInColorCode(' From Another Item ') .. OTHER_MARKUP
288+
tooltip:AddDoubleLine(text, (isCollected and ok) or (fromOtherItem and other) or nok)
283289
end
284290

285291
--- @param tooltip GameTooltip
@@ -306,30 +312,38 @@ end
306312
--- @return boolean? catalystAppearanceMissing # true if the item will teach a new appearance when catalysed
307313
--- @return boolean? catalystUpgradeAppearanceMissing # true if the item will teach a new appearance when catalysed AND upgraded to the next tier
308314
--- @return boolean? upgradeAppearanceMissing # true if the item will teach a new appearance when upgraded to the next tier
315+
--- @return boolean upgradeAppearanceLearnedFromOtherItem # true if the appearance is learned from another item
316+
--- @return boolean catalystUpgradeAppearanceLearnedFromOtherItem # true if the appearance is learned from another item
317+
--- @return boolean upgradeAppearanceLearnedFromOtherItem # true if the appearance is learned from another item
309318
function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
310319
if not C_Item.IsItemDataCachedByID(itemLink) then
311320
tryInsert(debugLines, 'item data not cached')
312321

313-
return nil, nil, nil, nil, nil
322+
return nil, nil, nil, nil, nil, false, false, false
314323
end
315324
classID = classID or playerClassID
316325
local canCatalyse, canUpgradeToNextBreakpoint = false, false
317326
local catalystMissing, catalystUpgradeMissing, upgradeMissing = nil, nil, nil
327+
local catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem = false, false, false
318328

319329
local itemID = tonumber(itemLink:match("item:(%d+)"))
320330
if not itemID or not C_Item.IsDressableItemByID(itemID) then
321-
return canCatalyse, canUpgradeToNextBreakpoint, catalystMissing, catalystUpgradeMissing, upgradeMissing
331+
return canCatalyse, canUpgradeToNextBreakpoint,
332+
catalystMissing, catalystUpgradeMissing, upgradeMissing,
333+
catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem
322334
end
323335
tryInsert(debugLines, 'itemID: ' .. tostring(itemID))
324336

325337
local upgradeInfo = C_Item.GetItemUpgradeInfo(itemLink)
326338
local canUpgrade = upgradeInfo and self:IsCurrentSeasonItem(itemLink)
327339
local seasonID = self:GetItemSeason(itemLink)
328340
tryInsert(debugLines, 'seasonID: ' .. tostring(seasonID))
329-
if not upgradeInfo or not seasonID then
330-
tryInsert(debugLines, 'not upgradable or no seasonID')
341+
if not upgradeInfo and not seasonID then
342+
tryInsert(debugLines, 'not upgradable and no seasonID')
331343

332-
return canCatalyse, canUpgradeToNextBreakpoint, catalystMissing, catalystUpgradeMissing, upgradeMissing
344+
return canCatalyse, canUpgradeToNextBreakpoint,
345+
catalystMissing, catalystUpgradeMissing, upgradeMissing,
346+
catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem
333347
end
334348

335349
local currentTier = 0;
@@ -342,16 +356,20 @@ function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
342356
canUpgradeToNextBreakpoint = true
343357
end
344358
end
359+
local _, sourceID = C_TransmogCollection.GetItemInfo(itemLink)
360+
tryInsert(debugLines, 'sourceID: ' .. tostring(sourceID))
361+
345362
if currentTier == 0 then
346-
local _, sourceID = C_TransmogCollection.GetItemInfo(itemLink)
347363
local sourceIDs = self:GetSourceIDsForItemID(itemID)
348364
local index = tIndexOf(sourceIDs or {}, sourceID)
349365
currentTier = index or 0
350366

351367
if currentTier == 0 then
352368
tryInsert(debugLines, 'no tier info found')
353369

354-
return canCatalyse, canUpgradeToNextBreakpoint, catalystMissing, catalystUpgradeMissing, upgradeMissing
370+
return canCatalyse, canUpgradeToNextBreakpoint,
371+
catalystMissing, catalystUpgradeMissing, upgradeMissing,
372+
catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem
355373
end
356374
end
357375
tryInsert(debugLines, 'currentTier: ' .. tostring(currentTier))
@@ -362,9 +380,6 @@ function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
362380
itemSlot = Enum.InventoryType.IndexChestType
363381
end
364382

365-
local _, sourceID = C_TransmogCollection.GetItemInfo(itemID)
366-
tryInsert(debugLines, 'sourceID: ' .. tostring(sourceID))
367-
368383
local setIDs = sourceID and C_TransmogSets.GetSetsContainingSourceID(sourceID)
369384
local relatedSets
370385
if setIDs and #setIDs > 0 then
@@ -385,31 +400,50 @@ function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
385400
tryInsert(debugLines, 'isCatalysed: ' .. tostring(isCatalysed))
386401
canCatalyse = not isCatalysed and self:IsCatalystSlot(itemSlot) and self:IsValidArmorTypeForClass(itemLink, classID)
387402
if canCatalyse then
403+
local catalystCollected, catalystUpgradeCollected
388404
local playerSets = self:GetSetsForClass(classID, seasonID)
389405
if playerSets then
390-
catalystMissing = not self:IsSetItemCollected(playerSets[currentTier], itemSlot)
406+
catalystCollected = self:IsSetItemCollected(playerSets[currentTier], itemSlot)
391407
if canUpgradeToNextBreakpoint then
392-
catalystUpgradeMissing = not self:IsSetItemCollected(playerSets[currentTier + 1], itemSlot)
408+
catalystUpgradeCollected = self:IsSetItemCollected(playerSets[currentTier + 1], itemSlot)
393409
end
394410
else
395-
catalystMissing = not self:IsCatalystItemCollected(seasonID, classID, itemSlot, currentTier)
411+
catalystCollected = self:IsCatalystItemCollected(seasonID, classID, itemSlot, currentTier)
396412
if canUpgradeToNextBreakpoint then
397-
catalystUpgradeMissing = not self:IsCatalystItemCollected(seasonID, classID, itemSlot, currentTier + 1)
413+
catalystUpgradeCollected = self:IsCatalystItemCollected(seasonID, classID, itemSlot, currentTier + 1)
414+
end
415+
end
416+
if catalystCollected ~= nil then
417+
catalystMissing = catalystCollected ~= true
418+
if catalystCollected == LEARNED_FROM_OTHER_ITEM then
419+
catalystFromOtherItem = true
420+
end
421+
end
422+
if catalystUpgradeCollected ~= nil then
423+
catalystUpgradeMissing = catalystUpgradeCollected ~= true
424+
if catalystUpgradeCollected == LEARNED_FROM_OTHER_ITEM then
425+
catalystUpgradeFromOtherItem = true
398426
end
399427
end
400428
else
401429
tryInsert(debugLines, 'can\'t catalyse or already catalysed')
402430
end
431+
local upgradeCollected
403432
if isCatalysed and relatedSets and canUpgradeToNextBreakpoint then
404433
local nextSetID = relatedSets[currentTier + 1]
405434
if nextSetID then
406-
upgradeMissing = not self:IsSetItemCollected(nextSetID, itemSlot)
435+
upgradeCollected = self:IsSetItemCollected(nextSetID, itemSlot)
407436
end
408437
elseif canUpgradeToNextBreakpoint then
409438
local sourceIDs = self:GetSourceIDsForItemID(itemID)
410439
if sourceIDs and sourceIDs[currentTier + 1] then
411-
local nextSourceInfo = C_TransmogCollection.GetSourceInfo(sourceIDs[currentTier + 1])
412-
upgradeMissing = not nextSourceInfo or not nextSourceInfo.isCollected
440+
upgradeCollected = self:IsSourceIDCollected(sourceIDs[currentTier + 1])
441+
end
442+
end
443+
if upgradeCollected ~= nil then
444+
upgradeMissing = upgradeCollected ~= true
445+
if upgradeCollected == LEARNED_FROM_OTHER_ITEM then
446+
upgradeFromOtherItem = true
413447
end
414448
end
415449

@@ -425,7 +459,9 @@ function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
425459
end
426460
end
427461

428-
return canCatalyse, canUpgradeToNextBreakpoint, catalystMissing, catalystUpgradeMissing, upgradeMissing
462+
return canCatalyse, canUpgradeToNextBreakpoint,
463+
catalystMissing, catalystUpgradeMissing, upgradeMissing,
464+
catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem
429465
end
430466

431467
--- @param tooltip GameTooltip
@@ -435,7 +471,9 @@ function TUM:HandleTooltip(tooltip)
435471

436472
local debugLines = {}
437473
local canCatalyse, canUpgrade,
438-
catalystMissing, catalystUpgradeMissing, upgradeMissing = self:IsAppearanceMissing(itemLink, nil, debugLines)
474+
catalystMissing, catalystUpgradeMissing, upgradeMissing,
475+
catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem
476+
= self:IsAppearanceMissing(itemLink, nil, debugLines)
439477

440478
for _, line in ipairs(debugLines) do
441479
self:AddDebugLine(tooltip, line)
@@ -446,7 +484,7 @@ function TUM:HandleTooltip(tooltip)
446484
if catalystMissing == nil then
447485
if not loadingTooltipShown then loadingTooltipShown = self:ShowLoadingTooltipIfLoading(tooltip) end
448486
else
449-
self:AddTooltipLine(tooltip, CATALYST_MARKUP .. ' Catalyst appearance', not catalystMissing)
487+
self:AddTooltipLine(tooltip, CATALYST_MARKUP .. ' Catalyst appearance', not catalystMissing, catalystFromOtherItem)
450488
end
451489
if canUpgrade then
452490
if catalystUpgradeMissing == nil then
@@ -455,7 +493,8 @@ function TUM:HandleTooltip(tooltip)
455493
self:AddTooltipLine(
456494
tooltip,
457495
CATALYST_MARKUP .. ' Catalyst & ' .. UPGRADE_MARKUP .. ' Upgrade appearance',
458-
not catalystUpgradeMissing
496+
not catalystUpgradeMissing,
497+
catalystUpgradeFromOtherItem
459498
)
460499
end
461500
end
@@ -464,7 +503,7 @@ function TUM:HandleTooltip(tooltip)
464503
if upgradeMissing == nil then
465504
if not loadingTooltipShown then loadingTooltipShown = self:ShowLoadingTooltipIfLoading(tooltip) end
466505
else
467-
self:AddTooltipLine(tooltip, UPGRADE_MARKUP .. ' Upgrade appearance', not upgradeMissing)
506+
self:AddTooltipLine(tooltip, UPGRADE_MARKUP .. ' Upgrade appearance', not upgradeMissing, upgradeFromOtherItem)
468507
end
469508
end
470509

@@ -544,9 +583,33 @@ function TUM:IsItemCatalysed(itemID)
544583
return not not self.catalystItemByID[itemID]
545584
end
546585

586+
--- @param sourceID number
587+
--- @return boolean|TUM_LearnedFromOtherItem
588+
function TUM:IsSourceIDCollected(sourceID)
589+
local sourceInfo = C_TransmogCollection.GetSourceInfo(sourceID)
590+
if not sourceInfo then
591+
return false
592+
end
593+
if sourceInfo.isCollected then
594+
return true
595+
end
596+
local sourceIDs = C_TransmogCollection.GetAllAppearanceSources(sourceInfo.visualID);
597+
if sourceIDs and #sourceIDs > 0 then
598+
for _, id in ipairs(sourceIDs) do
599+
local info = C_TransmogCollection.GetSourceInfo(id)
600+
if info and info.isCollected then
601+
return LEARNED_FROM_OTHER_ITEM
602+
end
603+
end
604+
end
605+
606+
return false
607+
end
608+
547609
--- @param seasonID number
548610
--- @param slot number # Enum.InventoryType
549611
--- @param tier number # one of TIER_x constants
612+
--- @return boolean|nil|TUM_LearnedFromOtherItem
550613
function TUM:IsCatalystItemCollected(seasonID, classID, slot, tier)
551614
if not self.catalystItems[seasonID] or not self.catalystItems[seasonID][classID] then
552615
return nil
@@ -559,30 +622,28 @@ function TUM:IsCatalystItemCollected(seasonID, classID, slot, tier)
559622
return nil
560623
end
561624

562-
local sourceInfo = C_TransmogCollection.GetSourceInfo(sourceIDs[tier])
563-
564-
return sourceInfo and sourceInfo.isCollected or false
625+
return self:IsSourceIDCollected(sourceIDs[tier])
565626
end
566627

628+
--- @param transmogSetID number
629+
--- @param slot number # Enum.InventoryType
630+
--- @return boolean|nil|TUM_LearnedFromOtherItem
567631
function TUM:IsSetItemCollected(transmogSetID, slot)
568632
if self.setSourceIDs[transmogSetID] then
569633
local sourceID = self.setSourceIDs[transmogSetID][slot]
570-
if sourceID then
571-
local sourceInfo = C_TransmogCollection.GetSourceInfo(sourceID)
572-
if sourceInfo and sourceInfo.isCollected then
573-
return true
574-
end
575-
end
576634

577-
return false
635+
return sourceID and self:IsSourceIDCollected(sourceID) or false
578636
end
579637

580638
local sources = C_TransmogSets.GetSourcesForSlot(transmogSetID, slot)
639+
local fromOtherItem = false
581640
for _, slotSourceInfo in ipairs(sources) do
582641
if slotSourceInfo.isCollected then
583642
return true
643+
elseif self:IsSourceIDCollected(slotSourceInfo.sourceID) == LEARNED_FROM_OTHER_ITEM then
644+
fromOtherItem = true
584645
end
585646
end
586647

587-
return false
648+
return fromOtherItem and LEARNED_FROM_OTHER_ITEM or false
588649
end

api.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ end
3333
--- @return boolean? catalystAppearanceMissing # true if the item will teach a new appearance when catalysed
3434
--- @return boolean? catalystUpgradeAppearanceMissing # true if the item will teach a new appearance when catalysed AND upgraded to the next tier
3535
--- @return boolean? upgradeAppearanceMissing # true if the item will teach a new appearance when upgraded to the next tier
36+
--- @return boolean upgradeAppearanceLearnedFromOtherItem # true if the appearance is learned from another item
37+
--- @return boolean catalystUpgradeAppearanceLearnedFromOtherItem # true if the appearance is learned from another item
38+
--- @return boolean upgradeAppearanceLearnedFromOtherItem # true if the appearance is learned from another item
3639
function api.IsAppearanceMissing(itemLink, classID)
3740
return TUM:IsAppearanceMissing(itemLink, classID)
3841
end

config.lua

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Config.modifierKeyOptions = {
1515
Config.settingKeys = {
1616
hideWhenCollected = "hideWhenCollected",
1717
showCollectedModifierKey = "showCollectedModifierKey",
18+
showCollectedFromOtherItemModifierKey = "showCollectedFromOtherItemModifierKey",
1819
showUncollectedModifierKey = "showUncollectedModifierKey",
1920
showWarbandCatalystInfoModifierKey = "showWarbandCatalystInfoModifierKey",
2021
warbandCatalystClassList = "warbandCatalystClassList",
@@ -28,13 +29,18 @@ function Config:Init()
2829
[self.settingKeys.hideWhenCollected] = false,
2930
[self.settingKeys.debug] = false,
3031
[self.settingKeys.showCollectedModifierKey] = self.modifierKeyOptions.always,
32+
[self.settingKeys.showCollectedFromOtherItemModifierKey] = self.modifierKeyOptions.always,
3133
[self.settingKeys.showUncollectedModifierKey] = self.modifierKeyOptions.always,
3234
[self.settingKeys.showWarbandCatalystInfoModifierKey] = self.modifierKeyOptions.shift,
3335
[self.settingKeys.warbandCatalystClassList] = {},
3436
};
3537
for k, v in pairs(defaults) do
3638
if self.db[k] == nil then
37-
self.db[k] = v;
39+
if k == self.settingKeys.showCollectedFromOtherItemModifierKey then
40+
self.db[k] = (self.db[self.settingKeys.showUncollectedModifierKey] or v);
41+
else
42+
self.db[k] = v;
43+
end
3844
end
3945
end
4046
for classID = 1, GetNumClasses() do
@@ -60,7 +66,7 @@ function Config:Init()
6066
));
6167
self:MakeDropdown(
6268
category,
63-
"Show Collected TMog in Tooltip",
69+
"Collected",
6470
self.settingKeys.showCollectedModifierKey,
6571
defaults.showCollectedModifierKey,
6672
"When to display the Upgrade and Catalyst information for collected appearances.",
@@ -69,7 +75,16 @@ function Config:Init()
6975
);
7076
self:MakeDropdown(
7177
category,
72-
"Show Uncollected TMog in Tooltip",
78+
"Collected From Other Item",
79+
self.settingKeys.showCollectedFromOtherItemModifierKey,
80+
defaults.showCollectedFromOtherItemModifierKey,
81+
"When to display the Upgrade and Catalyst information for collected appearances that are learned from other items.",
82+
showModifierOptions,
83+
Settings.VarType.String
84+
);
85+
self:MakeDropdown(
86+
category,
87+
"Uncollected",
7388
self.settingKeys.showUncollectedModifierKey,
7489
defaults.showUncollectedModifierKey,
7590
"When to display the Upgrade and Catalyst information for uncollected appearances.",

0 commit comments

Comments
 (0)