@@ -28,24 +28,32 @@ local playerFullName;
2828local UI = CreateFrame (' Frame' , ' TransmogUpgradeMaster_CollectionUI' , UIParent , ' ButtonFrameTemplate' );
2929ns .UI = UI ;
3030
31- EventUtil . ContinueOnAddOnLoaded ( addonName , function ()
31+ function UI : Init ()
3232 playerFullName = UnitNameUnmodified (' player' ) .. ' -' .. GetRealmName ();
3333
34- UI .currentSeason = TUM .currentSeason
34+ self .selectedClass = playerClassID ;
35+ self .selectedSeason = TUM .currentSeason ;
36+ self .currentCurrencyID = 0 ; -- will be set later when the season is initialized
37+
38+ --- @type nil | table<Enum.InventoryType , table<TUM_Tier , TUM_UI_ResultData[]>>
39+ self .results = nil ;
40+ self :BuildUI ();
41+ self :RegisterIntoBlizzMove ();
42+ end
43+
44+ function UI :InitSeason (currentSeasonID )
45+ self .selectedSeason = currentSeasonID ;
3546 for seasonID , _ in pairs (SEASON_NAMES ) do
36- if seasonID > UI .currentSeason then
47+ if seasonID > UI .selectedSeason then
3748 SEASON_NAMES [seasonID ] = nil ;
3849 end
3950 end
40- UI .currentClass = playerClassID ;
4151
42- --- @type nil | table<Enum.InventoryType , table<TUM_Tier , TUM_UI_ResultData[]>>
43- UI .results = nil ;
44- UI :Init ();
45- UI :RegisterIntoBlizzMove ();
46- end );
52+ self .currentCurrencyID = TUM .data .currency [currentSeasonID ] or 0 ;
53+ self .Currency :UpdateText ();
54+ end
4755
48- function UI :Init ()
56+ function UI :BuildUI ()
4957 do
5058 self :SetPoint (' CENTER' );
5159 self :SetSize (790 , 345 );
@@ -134,15 +142,15 @@ function UI:Init()
134142 classDropdown :EnableMouseWheel (true );
135143 local numClasses = GetNumClasses ();
136144 function classDropdown :Increment ()
137- local nextClass = UI .currentClass + 1 ;
145+ local nextClass = UI .selectedClass + 1 ;
138146 if nextClass > numClasses then
139147 nextClass = 1 ;
140148 end
141149 self :PickClass (nextClass );
142150 end
143151
144152 function classDropdown :Decrement ()
145- local prevClass = UI .currentClass - 1 ;
153+ local prevClass = UI .selectedClass - 1 ;
146154 if prevClass < 1 then
147155 prevClass = numClasses ;
148156 end
@@ -158,10 +166,10 @@ function UI:Init()
158166 end
159167
160168 local function isSelected (classID )
161- return classID == UI .currentClass ;
169+ return classID == UI .selectedClass ;
162170 end
163171 local function setSelected (classID )
164- UI .currentClass = classID ;
172+ UI .selectedClass = classID ;
165173 UI :DeferUpdateItems ();
166174 end
167175 local nameFormat = ' |Tinterface/icons/classicon_%s:16|t %s' ;
@@ -179,7 +187,7 @@ function UI:Init()
179187 end
180188 end
181189 end );
182- classDropdown :PickClass (UI .currentClass );
190+ classDropdown :PickClass (UI .selectedClass );
183191 end
184192
185193 local seasonDropdown = CreateFrame (' DropdownButton' , nil , self , ' WowStyle1DropdownTemplate' );
@@ -198,10 +206,10 @@ function UI:Init()
198206 end
199207
200208 local function isSelected (seasonID )
201- return seasonID == UI .currentSeason ;
209+ return seasonID == UI .selectedSeason ;
202210 end
203211 local function setSelected (seasonID )
204- UI .currentSeason = seasonID ;
212+ UI .selectedSeason = seasonID ;
205213 UI :DeferUpdateItems ();
206214 end
207215 local orderedSeasonIDs = {};
@@ -220,7 +228,7 @@ function UI:Init()
220228 );
221229 end
222230 end );
223- seasonDropdown :PickSeason (UI .currentSeason );
231+ seasonDropdown :PickSeason (UI .selectedSeason );
224232 end
225233
226234 local updateButton = CreateFrame (' Button' , nil , self );
@@ -359,7 +367,7 @@ function UI:Init()
359367 if InCombatLockdown () then
360368 GameTooltip_AddErrorLine (GameTooltip , ' You cannot open the Dressing Room while in combat' );
361369 end
362- if UI .currentClass == 13 and UI .currentSeason == 8 then
370+ if UI .selectedClass == 13 and UI .selectedSeason == 8 then
363371 GameTooltip_AddErrorLine (GameTooltip , ' Evokers have no SL S4 set' );
364372 end
365373 GameTooltip :Show ();
@@ -371,7 +379,7 @@ function UI:Init()
371379 if InCombatLockdown () then
372380 return ;
373381 end
374- if UI .currentClass == 13 and UI .currentSeason == 8 then
382+ if UI .selectedClass == 13 and UI .selectedSeason == 8 then
375383 inspectButton :SetAttribute (' macrotext' , ' ' );
376384 return ;
377385 end
@@ -471,6 +479,49 @@ function UI:Init()
471479 syndicatorMessage :SetWidth (350 );
472480 end
473481 end
482+
483+ local currency = CreateFrame (' Frame' , nil , self );
484+ self .Currency = currency ;
485+ do
486+ currency :SetPoint (' BOTTOMLEFT' , self , ' BOTTOMLEFT' , 15 , 5 );
487+ currency :SetSize (200 , 20 );
488+ currency :RegisterEvent (' CURRENCY_DISPLAY_UPDATE' );
489+ currency :SetScript (' OnEvent' , function (_ , event , currencyID )
490+ if event == ' CURRENCY_DISPLAY_UPDATE' and currencyID == self .currentCurrencyID then
491+ currency :UpdateText ();
492+ end
493+ end );
494+ function currency :UpdateText ()
495+ local currencyInfo = UI .currentCurrencyID ~= 0 and C_CurrencyInfo .GetCurrencyInfo (UI .currentCurrencyID );
496+
497+ if not currencyInfo then
498+ self .Text :SetText (' Catalyst Charges: N/A' );
499+ return ;
500+ end
501+ local textureMarkup = CreateSimpleTextureMarkup (currencyInfo .iconFileID , 18 );
502+ self .Text :SetFormattedText (' Catalyst Charges: |cFFFFFFFF%d/%d|r %s' , currencyInfo .quantity , currencyInfo .maxQuantity , textureMarkup );
503+ end
504+
505+ local text = currency :CreateFontString (nil , ' OVERLAY' , ' GameFontNormal' );
506+ currency .Text = text ;
507+ text :SetPoint (' LEFT' , currency , ' LEFT' , 0 , 0 );
508+
509+ text :SetScript (' OnEnter' , function ()
510+ if self .currentCurrencyID == 0 then
511+ GameTooltip :SetOwner (currency , ' ANCHOR_CURSOR_RIGHT' );
512+ GameTooltip :AddLine (' Catalyst Charges' );
513+ GameTooltip :AddLine (' Between seasons, or addon not updated for current season.' , 1 , 0.5 , 0.5 );
514+ GameTooltip :Show ();
515+ else
516+ GameTooltip :SetOwner (currency , ' ANCHOR_CURSOR_RIGHT' );
517+ GameTooltip :SetCurrencyByID (self .currentCurrencyID );
518+ end
519+ end );
520+ text :SetScript (' OnLeave' , function ()
521+ GameTooltip :Hide ();
522+ end );
523+ currency :UpdateText ();
524+ end
474525end
475526
476527function UI :ToggleUI ()
498549--- @param tier TUM_Tier
499550--- @return string slashCommand
500551function UI :CreateOutfitSlashCommand (tier )
501- local seasonID = self .currentSeason ;
502- local classID = self .currentClass ;
552+ local seasonID = self .selectedSeason ;
553+ local classID = self .selectedClass ;
503554 local itemTransmogInfoList = TransmogUtil .GetEmptyItemTransmogInfoList ();
504555
505556 for slotIndex , itemID in pairs (TUM .data .catalystItems [seasonID ][classID ]) do
@@ -521,6 +572,8 @@ function UI:OnUpdate()
521572 if self .deferUpdate then
522573 self .deferUpdate = false ;
523574 self :UpdateItems ();
575+ local showCurrency = self .selectedClass == playerClassID and self .selectedSeason == TUM .currentSeason ;
576+ self .Currency :SetShown (showCurrency );
524577 end
525578 if self .deferNewResult then
526579 self .deferNewResult = false ;
@@ -534,7 +587,7 @@ function UI:OnUpdate()
534587 local slot = column .slot ;
535588 local results = self .results and self .results [slot ] and self .results [slot ][tier ];
536589 column .results = results ;
537- column .isCollected = TUM :IsCatalystItemCollected (self .currentSeason , self .currentClass , slot , tier );
590+ column .isCollected = TUM :IsCatalystItemCollected (self .selectedSeason , self .selectedClass , slot , tier );
538591 if TUM .db .UI_treatOtherItemAsCollected and ' learnedFromOtherItem' == column .isCollected then
539592 column .isCollected = true ;
540593 end
@@ -737,7 +790,7 @@ local function handleResult(result)
737790 end
738791 local item = Item :CreateFromItemLink (result .itemLink );
739792 item :ContinueOnItemLoad (function ()
740- local info , upgradeInfo = checkResult (result , UI .currentClass , UI .currentSeason );
793+ local info , upgradeInfo = checkResult (result , UI .selectedClass , UI .selectedSeason );
741794 if info or upgradeInfo then
742795 UI .deferNewResult = true ;
743796 end
@@ -752,14 +805,14 @@ end
752805
753806function UI :UpdateItems ()
754807 self .deferUpdate = false ;
755- if self .pending == self .currentClass .. ' |' .. self .currentSeason then
808+ if self .pending == self .selectedClass .. ' |' .. self .selectedSeason then
756809 return ; -- already pending an update for this class and season
757810 end
758- self .pending = self .currentClass .. ' |' .. self .currentSeason ;
811+ self .pending = self .selectedClass .. ' |' .. self .selectedSeason ;
759812 self .results = initResults ();
760813 self .deferNewResult = true ;
761814 if isSyndicatorLoaded then
762- local term = buildSyndicatorSearchTerm (self .currentClass );
815+ local term = buildSyndicatorSearchTerm (self .selectedClass );
763816 --- @param results SyndicatorSearchResult[]
764817 Syndicator .Search .RequestSearchEverywhereResults (term , function (results ) --- @diagnostic disable-line : undefined-global
765818 for _ , result in pairs (results ) do
@@ -812,4 +865,3 @@ function UI:UpdateItems()
812865 self .pending = nil ;
813866 end
814867end
815-
0 commit comments