@@ -3,6 +3,9 @@ local name, ns = ...
33--- @class TransmogUpgradeMaster
44local TUM = {}
55TransmogUpgradeMaster = TUM
6+ -- @debug@
7+ _G .TUM = TUM
8+ -- @end-debug@
69
710--- @type TransmogUpgradeMasterData
811TUM .data = ns .data
@@ -68,9 +71,9 @@ local catalystSlots = {
6871
6972local playerClassID = select (3 , UnitClass (" player" ))
7073
71- TUM .currentSeason = 14 ; -- TWW S2
7274
7375do
76+ TUM .currentSeason = TUM .data .currentSeason ;
7477 TUM .sets = TUM .data .sets ;
7578 TUM .setSourceIDs = TUM .data .setSourceIDs ;
7679 TUM .catalystItems = TUM .data .catalystItems ;
8083EventUtil .ContinueOnAddOnLoaded (name , function ()
8184 TUM .db = TUM .Config :Init ()
8285 local currentSeason = C_MythicPlus .GetCurrentSeason ()
83- TUM .currentSeason = (currentSeason and currentSeason > 0 ) and currentSeason or 14
86+ TUM .currentSeason = (currentSeason and currentSeason > 0 ) and currentSeason or TUM . data . currentSeason
8487
8588 RunNextFrame (function ()
8689 TUM :InitItemSourceMap ()
@@ -95,9 +98,10 @@ EventUtil.ContinueOnAddOnLoaded(name, function()
9598end )
9699
97100--- @param classID number
101+ --- @param seasonID number ?
98102--- @return nil | { [1] : number , [2] : number , [3] : number , [4] : number } # lfrSetID, normalSetID, heroicSetID, mythicSetID
99- function TUM :GetSetsForClass (classID )
100- return self .sets [self .currentSeason ] and self .sets [self .currentSeason ][classID ] or nil ;
103+ function TUM :GetSetsForClass (classID , seasonID )
104+ return self .sets [seasonID or self .currentSeason ] and self .sets [seasonID or self .currentSeason ][classID ] or nil ;
101105end
102106
103107--- @param classMask number
@@ -161,6 +165,21 @@ function TUM:InitItemSourceMap()
161165 end )
162166end
163167
168+ local BONUS_ID_OFFSET = 13 ;
169+ function TUM :GetItemSeason (itemLink )
170+ local _ , data = LinkUtil .ExtractLink (itemLink );
171+ local parts = strsplittable (' :' , data );
172+ local numBonusIDs = tonumber (parts [BONUS_ID_OFFSET ]) or 0 ;
173+ for index = (BONUS_ID_OFFSET + 1 ), (BONUS_ID_OFFSET + numBonusIDs ) do
174+ local bonusID = tonumber (parts [index ]);
175+ if self .data .catalystBonusIDMap [bonusID ] then
176+ return self .data .catalystBonusIDMap [bonusID ];
177+ end
178+ end
179+
180+ return nil ;
181+ end
182+
164183--- previous season items are not (yet?) supported
165184--- @param itemLink string
166185--- @return boolean
@@ -225,10 +244,13 @@ function TUM:HandleTooltip(tooltip)
225244 self :AddDebugLine (tooltip , ' itemID: ' .. tostring (itemID ))
226245
227246 local upgradeInfo = C_Item .GetItemUpgradeInfo (itemLink )
228- if not upgradeInfo or not self :IsCurrentSeasonItem (itemLink ) then
229- self :AddDebugLine (tooltip , ' not upgradable current season item' )
247+ local canUpgrade = upgradeInfo and self :IsCurrentSeasonItem (itemLink )
248+ local seasonID = self :GetItemSeason (itemLink )
249+ if not upgradeInfo or not seasonID then
250+ self :AddDebugLine (tooltip , ' not upgradable or no seasonID' )
230251 return
231252 end
253+ self :AddDebugLine (tooltip , ' seasonID: ' .. tostring (seasonID ))
232254
233255 local canUpgradeToNextBreakpoint = false
234256 local currentTier = 0 ;
@@ -237,11 +259,22 @@ function TUM:HandleTooltip(tooltip)
237259 if currentTier and upgradeInfo .currentLevel >= 5 and currentTier < 4 then
238260 currentTier = currentTier + 1
239261 end
240- if upgradeInfo .currentLevel < 5 and currentTier < 4 then
262+ if canUpgrade and upgradeInfo .currentLevel < 5 and currentTier < 4 then
241263 canUpgradeToNextBreakpoint = true
242264 end
243265 end
244- if currentTier == 0 then return end
266+ if currentTier == 0 then
267+ local _ , sourceID = C_TransmogCollection .GetItemInfo (itemLink )
268+ local sourceIDs = self :GetSourceIDsForItemID (itemID )
269+ local index = tIndexOf (sourceIDs or {}, sourceID )
270+ currentTier = index
271+
272+ if currentTier == 0 then
273+ self :AddDebugLine (tooltip , ' no tier info found' )
274+
275+ return
276+ end
277+ end
245278 self :AddDebugLine (tooltip , ' currentTier: ' .. tostring (currentTier ))
246279
247280 local itemSlot = C_Item .GetItemInventoryTypeByID (itemLink )
@@ -262,7 +295,7 @@ function TUM:HandleTooltip(tooltip)
262295
263296 local classIDList = self :ConvertClassMaskToClassList (setInfo .classMask )
264297
265- local classSets = self :GetSetsForClass (classIDList [1 ])
298+ local classSets = self :GetSetsForClass (classIDList [1 ], seasonID )
266299 if classSets and tIndexOf (classSets , setID ) then
267300 relatedSets = classSets
268301 end
@@ -273,7 +306,7 @@ function TUM:HandleTooltip(tooltip)
273306 self :AddDebugLine (tooltip , ' isCatalysed: ' .. tostring (isCatalysed ))
274307 local canCatalyse = not isCatalysed and self :IsCatalystSlot (itemSlot ) and self :IsValidArmorTypeForPlayer (itemLink )
275308 if canCatalyse then
276- local playerSets = self :GetSetsForClass (playerClassID )
309+ local playerSets = self :GetSetsForClass (playerClassID , seasonID )
277310 if playerSets then
278311 local currentIsCollected = self :IsSetItemCollected (playerSets [currentTier ], itemSlot )
279312 self :AddTooltipLine (tooltip , CATALYST_MARKUP .. " Catalyst appearance" , currentIsCollected )
@@ -283,10 +316,16 @@ function TUM:HandleTooltip(tooltip)
283316 nextIsCollected )
284317 end
285318 else
286- -- todo: add a 1-time error message that set info for current season+class couldn't be found
319+ local collected = self :IsCatalystItemCollected (seasonID , playerClassID , itemSlot , currentTier )
320+ if collected == nil then
321+ TUM :ShowLoadingTooltipIfLoading (tooltip )
322+ -- todo: add a 1-time error message that set info for current season+class couldn't be found
323+ else
324+ self :AddTooltipLine (tooltip , CATALYST_MARKUP .. " Catalyst appearance" , collected )
325+ end
287326 end
288327 else
289- self :AddDebugLine (tooltip , ' not catalysable or already catalysed' )
328+ self :AddDebugLine (tooltip , ' can \' t catalyse or already catalysed' )
290329 end
291330 if isCatalysed and relatedSets and canUpgradeToNextBreakpoint then
292331 local nextSetID = relatedSets [currentTier + 1 ]
@@ -300,14 +339,19 @@ function TUM:HandleTooltip(tooltip)
300339 local nextSourceInfo = C_TransmogCollection .GetSourceInfo (sourceIDs [currentTier + 1 ])
301340 local isCollected = nextSourceInfo and nextSourceInfo .isCollected
302341 self :AddTooltipLine (tooltip , UPGRADE_MARKUP .. " Upgrade appearance" , isCollected )
303- elseif not self .itemSourceMapInitialized then
304- local progress = self .itemSourceMapProgress / self .itemSourceMapTotal * 100
305- local text = string.format (" TransmogUpgradeMaster is loading (%.0f%%)" , progress )
306- tooltip :AddLine (text , nil , nil , nil , true )
342+ else
343+ TUM :ShowLoadingTooltipIfLoading (tooltip )
307344 end
308345 end
309346end
310347
348+ function TUM :ShowLoadingTooltipIfLoading (tooltip )
349+ if self .itemSourceMapInitialized then return end
350+ local progress = self .itemSourceMapProgress / self .itemSourceMapTotal * 100
351+ local text = string.format (" TransmogUpgradeMaster is loading (%.0f%%)" , progress )
352+ tooltip :AddLine (text , nil , nil , nil , true )
353+ end
354+
311355function TUM :GetSourceIDsForItemID (itemID )
312356 return self .itemSourceIDs [itemID ]
313357end
@@ -329,6 +373,26 @@ function TUM:IsItemCatalysed(itemID)
329373 return not not self .catalystItemByID [itemID ]
330374end
331375
376+ --- @param seasonID number
377+ --- @param slot number # Enum.InventoryType
378+ --- @param tier number # one of TIER_x constants
379+ function TUM :IsCatalystItemCollected (seasonID , classID , slot , tier )
380+ if not self .catalystItems [seasonID ] or not self .catalystItems [seasonID ][classID ] then
381+ return nil
382+ end
383+ local itemID = self .catalystItems [seasonID ][classID ][slot ]
384+ if not itemID then return nil end
385+
386+ local sourceIDs = self :GetSourceIDsForItemID (itemID )
387+ if not sourceIDs or not sourceIDs [tier ] then
388+ return nil
389+ end
390+
391+ local sourceInfo = C_TransmogCollection .GetSourceInfo (sourceIDs [tier ])
392+
393+ return sourceInfo and sourceInfo .isCollected or false
394+ end
395+
332396function TUM :IsSetItemCollected (transmogSetID , slot )
333397 if self .setSourceIDs [transmogSetID ] then
334398 local sourceID = self .setSourceIDs [transmogSetID ][slot ]
0 commit comments