-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcollectionUi.lua
More file actions
1276 lines (1157 loc) · 51.6 KB
/
collectionUi.lua
File metadata and controls
1276 lines (1157 loc) · 51.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local addonName = ...;
--- @class TUM_NS
local ns = select(2, ...);
local TUM = ns.core;
local data = TUM.data;
local constants = data.constants;
local isSyndicatorLoaded = C_AddOns.IsAddOnLoaded('Syndicator');
local CATALYST_MARKUP = CreateAtlasMarkup('CreationCatalyst-32x32', 18, 18)
local UPGRADE_MARKUP = CreateAtlasMarkup('CovenantSanctum-Upgrade-Icon-Available', 18, 18)
local CATALYST_UPGRADE_MARKUP = CreateSimpleTextureMarkup([[Interface\AddOns\TransmogUpgradeMaster\media\CatalystUpgrade.png]], 18, 18)
local WARBAND_MARKUP = CreateAtlasMarkup('warbands-icon', 18, 18)
local OK_MARKUP = "|TInterface\\RaidFrame\\ReadyCheck-Ready:0|t"
local NOK_MARKUP = "|TInterface\\RaidFrame\\ReadyCheck-NotReady:0|t"
local OTHER_MARKUP = CreateAtlasMarkup('QuestRepeatableTurnin', 14, 16)
local playerClassFile, playerClassID = select(2, UnitClass('player'));
local playerFullName;
--- @class TransmogUpgradeMaster_CollectionUI: Frame, ButtonFrameTemplate
local UI = CreateFrame('Frame', 'TransmogUpgradeMaster_CollectionUI', UIParent, 'ButtonFrameTemplate');
ns.UI = UI;
--- @class TUM_UI_TodoList: Frame, ButtonFrameTemplate
local TodoList = CreateFrame('Frame', nil, UI, 'ButtonFrameTemplate');
UI.TodoList = TodoList;
function UI:Init()
playerFullName = UnitNameUnmodified('player') .. '-' .. GetRealmName();
self.selectedClass = playerClassID;
self.selectedSeason = TUM.currentSeason;
self.currentCurrencyID = 0; -- will be set later when the season is initialized
--- @type nil|table<Enum.InventoryType, table<TUM_Tier, TUM_UI_ResultData[]>>
self.results = nil;
self:BuildUI();
self:RegisterIntoBlizzMove();
self:RegisterEvent("TRANSMOG_COLLECTION_UPDATED");
self:SetScript("OnEvent", function()
self:DeferUpdateItems();
TodoList:DeferUpdateItems();
end);
end
function UI:InitSeason(currentSeasonID)
self.selectedSeason = currentSeasonID;
for seasonID, _ in pairs(constants.seasonNames) do
if seasonID > UI.selectedSeason then
constants.seasonNames[seasonID] = nil;
end
end
self.currentCurrencyID = data.currency[currentSeasonID] or 0;
self.Currency:UpdateText();
end
function UI:BuildUI()
do
self:SetPoint('CENTER');
self:SetSize(790, 345);
self:SetFrameStrata('MEDIUM');
self:SetToplevel(true);
self:SetMovable(true);
self:EnableMouse(true);
self:SetClampedToScreen(true);
self:SetTitle('Transmog Upgrade Master ' .. WHITE_FONT_COLOR:WrapTextInColorCode('Collections'));
self:SetScript('OnShow', self.UpdateItems);
self:SetScript('OnUpdate', self.OnUpdate);
ButtonFrameTemplate_HidePortrait(self);
table.insert(UISpecialFrames, self:GetName());
self:Hide();
end
local titleBar = CreateFrame('Frame', nil, self, 'PanelDragBarTemplate');
self.TitleBar = titleBar;
do
titleBar:SetPoint('TOPLEFT', 0, 0);
titleBar:SetPoint('BOTTOMRIGHT', self, 'TOPRIGHT', 0, -32);
end
local settings = CreateFrame('DropdownButton', nil, self);
self.Settings = settings;
do
settings:SetFrameStrata('HIGH');
settings:SetPoint('RIGHT', self.TitleBar, 'RIGHT', -20, 3);
settings:SetSize(32, 32);
do -- icon
settings.atlasKey = 'GM-icon-settings';
settings:SetNormalAtlas(settings.atlasKey);
Mixin(settings, ButtonStateBehaviorMixin);
function settings:OnButtonStateChanged()
local atlas = self.atlasKey;
if self:IsDownOver() or self:IsOver() then
atlas = atlas .. '-hover';
elseif self:IsDown() then
atlas = atlas .. '-pressed';
end
self:GetNormalTexture():SetAtlas(atlas, TextureKitConstants.IgnoreAtlasSize);
end
settings:OnLoad();
settings:HookScript('OnEnter', settings.OnEnter);
settings:HookScript('OnLeave', settings.OnLeave);
settings:HookScript('OnMouseDown', settings.OnMouseDown);
settings:HookScript('OnMouseUp', settings.OnMouseUp);
end
settings:HookScript('OnEnter', function()
GameTooltip:SetOwner(settings, 'ANCHOR_TOPRIGHT');
GameTooltip:SetText('Settings');
GameTooltip_AddInstructionLine(GameTooltip, CreateAtlasMarkup('NPE_LeftClick', 18, 18) .. ' to open settings');
GameTooltip:Show();
end);
settings:HookScript('OnLeave', function()
GameTooltip:Hide();
end);
--- @param rootDescription RootMenuDescriptionProxy
settings:SetupMenu(function(_, rootDescription)
rootDescription:CreateButton(CreateAtlasMarkup('GM-icon-settings', 20, 20) .. ' Open General TUM Settings', function() TUM.Config:OpenSettings(); end);
rootDescription:CreateTitle('Collection UI Settings');
rootDescription:CreateCheckbox(
'Treat "From Another Item" as collected',
function()
return TUM.db.UI_treatOtherItemAsCollected;
end,
function()
TUM.db.UI_treatOtherItemAsCollected = not TUM.db.UI_treatOtherItemAsCollected;
UI.deferNewResult = true;
end
);
end);
end
local classDropdown = CreateFrame('DropdownButton', nil, self, 'WowStyle1DropdownTemplate');
self.ClassDropdown = classDropdown;
do
classDropdown:SetPoint('TOPRIGHT', self, 'TOPRIGHT', -18, -32);
classDropdown:SetWidth(150);
classDropdown:EnableMouseWheel(true);
local numClasses = GetNumClasses();
function classDropdown:Increment()
local nextClass = UI.selectedClass + 1;
if nextClass > numClasses then
nextClass = 1;
end
self:PickClass(nextClass);
end
function classDropdown:Decrement()
local prevClass = UI.selectedClass - 1;
if prevClass < 1 then
prevClass = numClasses;
end
self:PickClass(prevClass);
end
function classDropdown:PickClass(classID)
MenuUtil.TraverseMenu(self:GetMenuDescription(), function(description)
if description.data == classID then
self:Pick(description, MenuInputContext.None);
end
end);
end
local function isSelected(classID)
return classID == UI.selectedClass;
end
local function setSelected(classID)
UI.selectedClass = classID;
UI:DeferUpdateItems();
end
local nameFormat = '|Tinterface/icons/classicon_%s:16|t %s';
--- @param rootDescription RootMenuDescriptionProxy
classDropdown:SetupMenu(function(_, rootDescription)
for classID = 1, numClasses do
local classInfo = C_CreatureInfo.GetClassInfo(classID);
if classInfo then
rootDescription:CreateRadio(
nameFormat:format(classInfo.classFile, classInfo.className),
isSelected,
setSelected,
classID
)
end
end
end);
classDropdown:PickClass(UI.selectedClass);
end
local seasonDropdown = CreateFrame('DropdownButton', nil, self, 'WowStyle1DropdownTemplate');
self.SeasonDropdown = seasonDropdown;
do
seasonDropdown:SetPoint('RIGHT', classDropdown, 'LEFT', -10, 0);
seasonDropdown:SetWidth(100);
seasonDropdown:EnableMouseWheel(true);
function seasonDropdown:PickSeason(seasonID)
MenuUtil.TraverseMenu(self:GetMenuDescription(), function(description)
if description.data == seasonID then
self:Pick(description, MenuInputContext.None);
end
end);
end
local function isSelected(seasonID)
return seasonID == UI.selectedSeason;
end
local function setSelected(seasonID)
UI.selectedSeason = seasonID;
UI:DeferUpdateItems();
end
--- @param rootDescription RootMenuDescriptionProxy
seasonDropdown:SetupMenu(function(_, rootDescription)
local orderedSeasonIDs = {};
for seasonID, _ in pairs(constants.seasonNames) do
table.insert(orderedSeasonIDs, seasonID);
end
table.sort(orderedSeasonIDs);
for _, seasonID in ipairs(orderedSeasonIDs) do
rootDescription:CreateRadio(
constants.seasonNames[seasonID],
isSelected,
setSelected,
seasonID
);
end
end);
seasonDropdown:PickSeason(UI.selectedSeason);
end
local updateButton = CreateFrame('Button', nil, self);
self.UpdateButton = updateButton;
do
updateButton:SetPoint('RIGHT', self.SeasonDropdown, 'LEFT', -6, 0);
updateButton:SetSize(32, 32);
updateButton:SetHitRectInsets(4, 4, 4, 4);
updateButton:SetNormalTexture('Interface\\Buttons\\UI-SquareButton-Up');
updateButton:SetPushedTexture('Interface\\Buttons\\UI-SquareButton-Down');
updateButton:SetDisabledTexture('Interface\\Buttons\\UI-SquareButton-Disabled');
updateButton:SetHighlightTexture('Interface\\Buttons\\UI-Common-MouseHilight', 'ADD');
local updateIcon = updateButton:CreateTexture('OVERLAY');
updateButton.Icon = updateIcon;
do
updateIcon:SetSize(16, 16);
updateIcon:SetPoint('CENTER', -1, -1);
updateIcon:SetBlendMode('ADD');
updateIcon:SetTexture('Interface\\Buttons\\UI-RefreshButton');
updateButton:SetScript('OnEnter', function(self)
GameTooltip:SetOwner(self, 'ANCHOR_RIGHT', -6, -4);
GameTooltip:AddLine('Refresh');
GameTooltip:Show();
end);
updateButton:SetScript('OnLeave', function()
GameTooltip:Hide();
end);
updateButton:SetScript('OnMouseDown', function(self)
if self:IsEnabled() then
self.Icon:SetPoint('CENTER', 1, 1);
end
end);
updateButton:SetScript('OnMouseUp', function(self)
if self:IsEnabled() then
self.Icon:SetPoint('CENTER', -1, -1);
end
end);
updateButton:SetScript('OnClick', function()
UI:DeferUpdateItems();
end);
updateButton:SetScript('OnShow', function(self)
self.Icon:SetPoint('CENTER', -1, -1);
end);
end
end
-- grid table
do
local ROW_HEIGHT = 25;
local COLUMN_WIDTH = 175;
self.Inset:SetPoint('TOPLEFT', 8, -86);
self.Inset:SetPoint('BOTTOMRIGHT', -4, 30);
local COLUMN_INFO = {
{
title = 'Slot',
width = 80,
parentKey = 'Slot',
},
{
title = PLAYER_DIFFICULTY3, -- LFR
width = COLUMN_WIDTH,
parentKey = 'Lfr',
tier = constants.tiers.lfr,
},
{
title = PLAYER_DIFFICULTY1, -- Normal
width = COLUMN_WIDTH,
parentKey = 'Normal',
tier = constants.tiers.normal,
},
{
title = PLAYER_DIFFICULTY2, -- Heroic
width = COLUMN_WIDTH,
parentKey = 'Heroic',
tier = constants.tiers.heroic,
},
{
title = PLAYER_DIFFICULTY6, -- Mythic
width = COLUMN_WIDTH,
parentKey = 'Mythic',
tier = constants.tiers.mythic,
},
};
local SLOT_ORDER = {
Enum.InventoryType.IndexHeadType,
Enum.InventoryType.IndexShoulderType,
Enum.InventoryType.IndexCloakType,
Enum.InventoryType.IndexChestType,
Enum.InventoryType.IndexWristType,
Enum.InventoryType.IndexHandType,
Enum.InventoryType.IndexWaistType,
Enum.InventoryType.IndexLegsType,
Enum.InventoryType.IndexFeetType,
};
local headers = CreateFrame('Frame', '$parentHeaders', self, 'ColumnDisplayTemplate');
self.Headers = headers;
do
headers:SetPoint('BOTTOMLEFT', self.Inset, 'TOPLEFT', 1, -1);
headers:SetPoint('BOTTOMRIGHT', self.Inset, 'TOPRIGHT', 0, -1);
headers:LayoutColumns(COLUMN_INFO);
headers:SetHeight(1);
headers.Background:Hide();
headers.TopTileStreaks:Hide();
local magnifyingGlassAtlas = 'common-search-magnifyingglass'
--- @type FramePool<BUTTON, ColumnDisplayButtonTemplate>
local headerPool = headers.columnHeaders
for header in headerPool:EnumerateActive() do
--- @type ColumnDisplayButtonTemplate
local header = header;
local index = header:GetID();
if index > 1 then
local text = header:GetFontString();
--- @class TUM_UI_ColumnHeader_InspectButton: Button, InsecureActionButtonTemplate
local inspectButton = CreateFrame('Button', nil, header, 'InsecureActionButtonTemplate');
header.InspectButton = inspectButton;
do
inspectButton.tier = COLUMN_INFO[index].tier;
inspectButton:SetPoint('LEFT', text, 'RIGHT', 5, 0);
inspectButton:SetSize(14, 14);
inspectButton:SetNormalTexture(magnifyingGlassAtlas);
inspectButton:SetAttribute('type', 'macro');
inspectButton:SetAttribute('useOnKeyDown', true);
inspectButton:RegisterForClicks('AnyDown');
inspectButton:SetScript('OnEnter', function()
GameTooltip:SetOwner(inspectButton, 'ANCHOR_CURSOR_RIGHT');
GameTooltip:AddLine('View set in Dressing Room');
if InCombatLockdown() then
GameTooltip_AddErrorLine(GameTooltip, 'You cannot open the Dressing Room while in combat');
end
if UI.selectedClass == 13 and UI.selectedSeason == 8 then
GameTooltip_AddErrorLine(GameTooltip, 'Evokers have no SL S4 set');
end
GameTooltip:Show();
end);
inspectButton:SetScript('OnLeave', function()
GameTooltip:Hide();
end);
inspectButton:SetScript('PreClick', function()
if InCombatLockdown() then
return;
end
if UI.selectedClass == 13 and UI.selectedSeason == 8 then
inspectButton:SetAttribute('macrotext', '');
return;
end
inspectButton:SetAttribute('macrotext', UI:CreateOutfitSlashCommand(inspectButton.tier));
end);
end
end
end
end
--- @type TUM_UI_Row[]
self.rows = {};
--- @param column TUM_UI_Column
local function OnEnter(column)
if column.isCollected == true then return; end
GameTooltip:SetOwner(column, 'ANCHOR_CURSOR_RIGHT');
GameTooltip:AddLine('Transmog Upgrade Master');
if column.results and next(column.results) then
for _, result in ipairs(column.results) do
local text = result.itemLink;
if result.requiresUpgrade and result.requiresCatalyse then
text = CATALYST_UPGRADE_MARKUP .. ' ' .. text;
elseif result.requiresUpgrade then
text = UPGRADE_MARKUP .. ' ' .. text;
elseif result.requiresCatalyse then
text = CATALYST_MARKUP .. ' ' .. text;
end
if result.distance > 0 then
text = WARBAND_MARKUP .. ' ' .. text;
end
if result.upgradeLevel > 0 then
text = text .. (' %d/%d'):format(result.upgradeLevel, result.maxUpgradeLevel);
end
GameTooltip:AddDoubleLine(text, result.location, 1, 1, 1, 1, 1, 1);
end
else
GameTooltip:AddLine('No items found that can be catalysed or upgraded', 1, 0.5, 0.5);
if not isSyndicatorLoaded then
GameTooltip_AddInstructionLine(GameTooltip, 'Install the addon "Syndicator" to scan items from your bank and alts');
end
end
GameTooltip:Show();
end
local function OnLeave()
GameTooltip:Hide();
end
for i, slot in ipairs(SLOT_ORDER) do
--- @class TUM_UI_Row: Button
local row = CreateFrame('Button', '$parentRow' .. i, self);
self.rows[i] = row;
row.slot = slot;
row:SetPoint('TOPLEFT', headers, 'BOTTOMLEFT', 5, -((i - 1) * ROW_HEIGHT));
row:SetPoint('TOPRIGHT', headers, 'BOTTOMRIGHT', -5, -((i - 1) * ROW_HEIGHT));
row:SetHeight(ROW_HEIGHT);
row:SetHighlightTexture('Interface\\BUTTONS\\WHITE8X8')
row:GetHighlightTexture():SetVertexColor(0.1, 0.1, 0.1, 0.75)
--- @type TUM_UI_Column[]
row.columns = {};
local offset = 2;
local padding = 2;
for j, columnInfo in ipairs(COLUMN_INFO) do
--- @class TUM_UI_Column: Frame
local column = CreateFrame('Frame', '$parentColumn' .. columnInfo.parentKey, row);
row.columns[columnInfo.parentKey] = column;
column:SetSize(columnInfo.width - (padding * 1.25), ROW_HEIGHT);
column.tier = columnInfo.tier;
column.slot = slot;
--- @type nil|TUM_UI_ResultData[]
column.results = nil; -- will be filled later when results are available
--- @type boolean|'learnedFromOtherItem'|nil
column.isCollected = nil;
if j ~= 1 then
column:SetScript('OnEnter', OnEnter)
column:SetScript('OnLeave', OnLeave);
column:SetPropagateMouseMotion(true);
end
column:SetPoint('LEFT', row, 'LEFT', offset, 0);
offset = offset + columnInfo.width - padding;
local colText = column:CreateFontString('$parentText', 'OVERLAY', 'GameFontNormal');
column.Text = colText;
colText:SetPoint('LEFT', column, 'LEFT', 0, 0);
local text = j == 1 and C_Item.GetItemInventorySlotInfo(slot) or 'loading...';
colText:SetText(text);
end
end
end
if not isSyndicatorLoaded then
local syndicatorMessage = self:CreateFontString(nil, 'OVERLAY', 'GameFontNormal');
self.SyndicatorMessage = syndicatorMessage;
do
syndicatorMessage:SetPoint('TOPLEFT', self, 'TOPLEFT', 12, -30);
syndicatorMessage:SetText('Items from the bank or from alts can only be scanned if you have the addon "Syndicator" enabled.');
syndicatorMessage:SetJustifyH('LEFT');
syndicatorMessage:SetWidth(350);
end
end
local currency = CreateFrame('Frame', nil, self);
self.Currency = currency;
do
currency:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 15, 5);
currency:SetSize(200, 20);
currency:RegisterEvent('CURRENCY_DISPLAY_UPDATE');
currency:SetScript('OnShow', function()
currency:UpdateText();
end);
currency:SetScript('OnEvent', function(_, event, currencyID)
if event == 'CURRENCY_DISPLAY_UPDATE' and currencyID == self.currentCurrencyID then
currency:UpdateText();
end
end);
function currency:UpdateText()
local currencyInfo = UI.currentCurrencyID ~= 0 and C_CurrencyInfo.GetCurrencyInfo(UI.currentCurrencyID);
if not currencyInfo then
self.Text:SetText('Catalyst Charges: N/A');
return;
end
local textureMarkup = CreateSimpleTextureMarkup(currencyInfo.iconFileID, 18);
self.Text:SetFormattedText('Catalyst Charges: |cFFFFFFFF%d/%d|r %s', currencyInfo.quantity, currencyInfo.maxQuantity, textureMarkup);
end
local text = currency:CreateFontString(nil, 'OVERLAY', 'GameFontNormal');
currency.Text = text;
text:SetPoint('LEFT', currency, 'LEFT', 0, 0);
text:SetScript('OnEnter', function()
if self.currentCurrencyID == 0 then
GameTooltip:SetOwner(currency, 'ANCHOR_CURSOR_RIGHT');
GameTooltip:AddLine('Catalyst Charges');
GameTooltip:AddLine('Between seasons, or addon not updated for current season.', 1, 0.5, 0.5);
GameTooltip:Show();
else
GameTooltip:SetOwner(currency, 'ANCHOR_CURSOR_RIGHT');
GameTooltip:SetCurrencyByID(self.currentCurrencyID);
end
end);
text:SetScript('OnLeave', function()
GameTooltip:Hide();
end);
currency:UpdateText();
end
--- @class TUM_UI_TodoList: Frame, ButtonFrameTemplate
local todoList = self.TodoList;
do
-- todoList setup
do
todoList:SetPoint('TOPLEFT', self, 'TOPRIGHT', 0, 0);
todoList:SetPoint('BOTTOMLEFT', self, 'BOTTOMRIGHT', 0, 0);
todoList:SetWidth(540);
todoList.Inset:SetPoint("BOTTOMRIGHT", -4, 4);
todoList:SetTitle('Todo list');
todoList:EnableMouse(true);
todoList:SetScript("OnMouseDown", function() self:Raise() end);
todoList.results = {};
ButtonFrameTemplate_HidePortrait(todoList);
if TUM.db.UI_todoListShown == false then
todoList:Hide();
end
todoList:SetScript('OnShow', todoList.UpdateItems);
todoList:SetScript('OnUpdate', todoList.OnUpdate);
end
local todoListTitleBar = CreateFrame('Frame', nil, todoList, 'PanelDragBarTemplate');
todoList.TitleBar = todoListTitleBar;
do
todoListTitleBar:SetTarget(self);
todoListTitleBar:SetPoint('TOPLEFT', 0, 0);
todoListTitleBar:SetPoint('BOTTOMRIGHT', todoList, 'TOPRIGHT', 0, -32);
end
local todoUpdateButton = CreateFrame('Button', nil, todoList);
self.UpdateButton = todoUpdateButton;
do
todoUpdateButton:SetPoint('TOPRIGHT', todoList, 'TOPRIGHT', -22, -26);
todoUpdateButton:SetSize(32, 32);
todoUpdateButton:SetHitRectInsets(4, 4, 4, 4);
todoUpdateButton:SetNormalTexture('Interface\\Buttons\\UI-SquareButton-Up');
todoUpdateButton:SetPushedTexture('Interface\\Buttons\\UI-SquareButton-Down');
todoUpdateButton:SetDisabledTexture('Interface\\Buttons\\UI-SquareButton-Disabled');
todoUpdateButton:SetHighlightTexture('Interface\\Buttons\\UI-Common-MouseHilight', 'ADD');
local updateIcon = todoUpdateButton:CreateTexture('OVERLAY');
todoUpdateButton.Icon = updateIcon;
do
updateIcon:SetSize(16, 16);
updateIcon:SetPoint('CENTER', -1, -1);
updateIcon:SetBlendMode('ADD');
updateIcon:SetTexture('Interface\\Buttons\\UI-RefreshButton');
todoUpdateButton:SetScript('OnEnter', function(self)
GameTooltip:SetOwner(self, 'ANCHOR_RIGHT', -6, -4);
GameTooltip:AddLine('Refresh');
GameTooltip:Show();
end);
todoUpdateButton:SetScript('OnLeave', function()
GameTooltip:Hide();
end);
todoUpdateButton:SetScript('OnMouseDown', function(self)
if self:IsEnabled() then
self.Icon:SetPoint('CENTER', 1, 1);
end
end);
todoUpdateButton:SetScript('OnMouseUp', function(self)
if self:IsEnabled() then
self.Icon:SetPoint('CENTER', -1, -1);
end
end);
todoUpdateButton:SetScript('OnClick', function()
TodoList:DeferUpdateItems();
end);
todoUpdateButton:SetScript('OnShow', function(self)
self.Icon:SetPoint('CENTER', -1, -1);
end);
end
end
local scrollbar = CreateFrame("EventFrame", nil, todoList.Inset, "WowTrimScrollBar");
do
scrollbar:SetPoint("TOPRIGHT");
scrollbar:SetPoint("BOTTOMRIGHT");
end
local scrollbox = CreateFrame("Frame", nil, todoList.Inset, "WowScrollBoxList");
do
scrollbox:SetPoint("TOPLEFT", 6, -3);
scrollbox:SetPoint("BOTTOMRIGHT", scrollbar, "BOTTOMLEFT", -2, 5);
end
local scrollView = CreateScrollBoxListLinearView();
do
scrollView:SetElementExtent(20); -- Fixed height for each row; required as we're not using XML.
scrollView:SetElementInitializer("Button", function(frame, entry)
todoList:InitTodoListEntry(frame, entry);
end);
end
ScrollUtil.InitScrollBoxWithScrollBar(scrollbox, scrollbar, scrollView);
--- @param dataProvider DataProviderMixin
function todoList:SetDataProvider(dataProvider)
scrollbox:SetDataProvider(dataProvider);
end
local toggleTodoListButton = CreateFrame("Button", nil, self, "WowStyle2IconButtonTemplate");
self.ToggleTodoListButton = toggleTodoListButton;
do
toggleTodoListButton:SetSize(22, 22);
toggleTodoListButton:SetFrameStrata("HIGH");
toggleTodoListButton.normalAtlas = TUM.db.UI_todoListShown and "common-dropdown-icon-back" or "common-dropdown-icon-next";
toggleTodoListButton:SetPoint("RIGHT", self, "TOPRIGHT", 10, -48);
toggleTodoListButton:HookScript("OnEnter", function()
GameTooltip:SetOwner(toggleTodoListButton, "ANCHOR_RIGHT");
GameTooltip:SetText("Toggle Todo List");
GameTooltip:Show();
end);
toggleTodoListButton:HookScript("OnLeave", function() GameTooltip:Hide(); end);
toggleTodoListButton:HookScript("OnClick", function() todoList:SetShown(not todoList:IsShown()); end);
toggleTodoListButton:OnButtonStateChanged();
end
todoList:HookScript("OnShow", function()
toggleTodoListButton.normalAtlas = "common-dropdown-icon-back";
toggleTodoListButton:OnButtonStateChanged();
TUM.db.UI_todoListShown = todoList:IsShown();
end);
todoList:HookScript("OnHide", function()
toggleTodoListButton.normalAtlas = "common-dropdown-icon-next";
toggleTodoListButton:OnButtonStateChanged();
TUM.db.UI_todoListShown = todoList:IsShown();
end);
end
end
function UI:ToggleUI()
self:SetShown(not self:IsShown());
end
function UI:RegisterIntoBlizzMove()
--- @type BlizzMoveAPI?
local BlizzMoveAPI = BlizzMoveAPI; ---@diagnostic disable-line: undefined-global
if BlizzMoveAPI then
local frameName = self:GetName();
BlizzMoveAPI:RegisterAddOnFrames(
{
[addonName] = {
[self:GetName()] = {
SubFrames = {
[frameName .. '.TitleBar'] = {},
[frameName .. '.TodoList'] = {
Detachable = true,
SubFrames = {
[frameName .. '.TodoList.TitleBar'] = {},
},
},
},
},
},
}
);
end
end
--- @param tier TUM_Tier
--- @return string slashCommand
function UI:CreateOutfitSlashCommand(tier)
local seasonID = self.selectedSeason;
local classID = self.selectedClass;
local itemTransmogInfoList = TransmogUtil.GetEmptyItemTransmogInfoList();
for slotIndex, itemID in pairs(data.catalystItems[seasonID][classID]) do
local invSlot = constants.catalystSlots[slotIndex];
local sourceIDs = TUM:GetSourceIDsForItemID(itemID)
if sourceIDs and sourceIDs[tier] then
itemTransmogInfoList[invSlot] = ItemUtil.CreateItemTransmogInfo(sourceIDs[tier]);
end
end
itemTransmogInfoList[INVSLOT_MAINHAND] = ItemUtil.CreateItemTransmogInfo(4231); -- Knuckleduster, smallest I could find
return TransmogUtil.CreateCustomSetSlashCommand(itemTransmogInfoList);
end
function UI:DeferUpdateItems()
self.deferUpdate = true;
end
function UI:OnUpdate()
if self.deferUpdate then
self.deferUpdate = false;
self:UpdateItems();
local showCurrency = self.selectedClass == playerClassID and self.selectedSeason == TUM.currentSeason;
self.Currency:SetShown(showCurrency);
end
if self.deferNewResult then
self.deferNewResult = false;
local ok = ' ' .. OK_MARKUP .. GREEN_FONT_COLOR:WrapTextInColorCode(' Collected')
local nok = ' ' .. NOK_MARKUP .. RED_FONT_COLOR:WrapTextInColorCode(' Not Collected')
local other = OTHER_MARKUP .. BLUE_FONT_COLOR:WrapTextInColorCode(' From Another Item')
for _, row in ipairs(self.rows) do
for _, column in pairs(row.columns) do
local tier = column.tier;
if tier then
local slot = column.slot;
local results = self.results and self.results[slot] and self.results[slot][tier];
column.results = results;
column.isCollected = TUM:IsCatalystItemCollected(self.selectedSeason, self.selectedClass, slot, tier);
if TUM.db.UI_treatOtherItemAsCollected and 'learnedFromOtherItem' == column.isCollected then
column.isCollected = true;
end
if true == column.isCollected then
column.Text:SetText(ok);
else
local text = nok;
if 'learnedFromOtherItem' == column.isCollected then
text = other;
end
if results and next(results) then
table.sort(results, function(a, b)
-- Order as Catalyse, then Upgrade, then CatalyseUpgrade.
if a.requiresUpgrade ~= b.requiresUpgrade then
return not a.requiresUpgrade and b.requiresUpgrade;
end
if a.requiresCatalyse ~= b.requiresCatalyse then
return not a.requiresCatalyse and b.requiresCatalyse;
end
if a.distance ~= b.distance then
return a.distance < b.distance;
end
if a.upgradeLevel ~= b.upgradeLevel then
return a.upgradeLevel > b.upgradeLevel;
end
if a.location ~= b.location then
return a.location > b.location;
end
return a.itemLink > b.itemLink;
end);
local firstResult = results[1];
if firstResult.requiresUpgrade and firstResult.requiresCatalyse then
text = ' ' .. CATALYST_UPGRADE_MARKUP .. text;
elseif firstResult.requiresUpgrade then
text = ' ' .. UPGRADE_MARKUP .. text;
elseif firstResult.requiresCatalyse then
text = ' ' .. CATALYST_MARKUP .. text;
end
if firstResult.distance > 0 then
text = ' ' .. WARBAND_MARKUP .. text;
end
end
column.Text:SetText(text);
end
end
end
end
end
end
function TodoList:DeferUpdateItems()
self.deferUpdate = true;
end
function TodoList:OnUpdate()
if self.deferUpdate then
self.deferUpdate = false;
self:UpdateItems();
end
if self.deferNewResult then
self.deferNewResult = false;
local dataProvider = CreateDataProvider(self.results)
dataProvider:SetSortComparator(function(entryA, entryB)
if entryA.distance ~= entryB.distance then
return entryA.distance < entryB.distance;
end
if entryA.location ~= entryB.location then
return entryA.location < entryB.location;
end
if entryA.upgradeLevel ~= entryB.upgradeLevel then
return entryA.upgradeLevel > entryB.upgradeLevel;
end
return entryA.itemLink < entryB.itemLink;
end);
self:SetDataProvider(dataProvider);
end
end
--- @param frame TUM_UI_TodoList_ElementFrame
--- @param entry TUM_UI_ResultData
function TodoList:InitTodoListEntry(frame, entry)
--- @class TUM_UI_TodoList_ElementFrame
local frame = frame;
if not frame.ItemText then
frame.ItemText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
frame.ItemText:SetJustifyH("LEFT");
frame.ItemText:SetPoint("TOPLEFT", frame, "TOPLEFT");
frame.ItemText:SetWidth(270);
frame.ItemText:SetWordWrap(false);
end
if not frame.LocationCharacterText then
frame.LocationCharacterText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
frame.LocationCharacterText:SetJustifyH("LEFT");
frame.LocationCharacterText:SetPoint("TOPLEFT", frame.ItemText, "TOPRIGHT", 5, 0);
frame.LocationCharacterText:SetWidth(160);
frame.LocationCharacterText:SetWordWrap(false);
end
if not frame.LocationContainerText then
frame.LocationContainerText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
frame.LocationContainerText:SetJustifyH("LEFT");
frame.LocationContainerText:SetPoint("TOPLEFT", frame.LocationCharacterText, "TOPRIGHT", 5, 0);
frame.LocationContainerText:SetPoint("TOPRIGHT", frame, "TOPRIGHT");
frame.LocationContainerText:SetWordWrap(false);
end
if not frame.HighlightBackground then
frame.HighlightBackground = frame:CreateTexture(nil, "BACKGROUND");
frame.HighlightBackground:SetAllPoints(frame);
frame.HighlightBackground:Hide();
frame.HighlightBackground:SetColorTexture(1, 1, 1, 0.1);
end
local text = UPGRADE_MARKUP .. ' ' .. entry.itemLink;
if entry.distance > 0 then
text = WARBAND_MARKUP .. ' ' .. text;
end
if entry.upgradeLevel > 0 then
text = text .. (' %d/%d'):format(entry.upgradeLevel, entry.maxUpgradeLevel);
end
frame.ItemText:SetText(text);
frame.LocationCharacterText:SetText(entry.locationCharacter);
frame.LocationContainerText:SetText(entry.locationContainer);
frame:SetScript("OnEnter", function()
GameTooltip:SetOwner(frame, "ANCHOR_RIGHT", -80, 0);
GameTooltip:AddDoubleLine("Location", entry.location, 1, 1, 1, 1, 1, 1);
GameTooltip:AppendInfoWithSpacer("GetHyperlink", entry.itemLink);
GameTooltip:Show();
frame.HighlightBackground:Show();
end);
frame:SetScript("OnLeave", function()
GameTooltip:Hide();
frame.HighlightBackground:Hide();
end);
end
local ARMOR_SEARCH_TERMS = {
[Enum.ItemArmorSubclass.Cloth] = '#cloth',
[Enum.ItemArmorSubclass.Leather] = '#leather',
[Enum.ItemArmorSubclass.Mail] = '#mail',
[Enum.ItemArmorSubclass.Plate] = '#plate',
};
local SLOT_SEARCH_TERMS = {
[Enum.InventoryType.IndexHeadType] = '#head',
[Enum.InventoryType.IndexShoulderType] = '#shoulder',
[Enum.InventoryType.IndexChestType] = '#chest',
[Enum.InventoryType.IndexWaistType] = '#waist',
[Enum.InventoryType.IndexLegsType] = '#legs',
[Enum.InventoryType.IndexFeetType] = '#feet',
[Enum.InventoryType.IndexWristType] = '#wrist',
[Enum.InventoryType.IndexHandType] = '#hands',
[Enum.InventoryType.IndexCloakType] = '#back',
};
--- @param classID number
--- @return string searchTerm
local function buildSyndicatorSearchTerm(classID)
local slotTerms = {};
for slot, term in pairs(SLOT_SEARCH_TERMS) do
if slot ~= Enum.InventoryType.IndexCloakType then
tinsert(slotTerms, term);
end
end
local armorType = constants.classArmorTypeMap[classID];
local searchTerms = string.format(
'%s|(%s&(%s))',
SLOT_SEARCH_TERMS[Enum.InventoryType.IndexCloakType],
ARMOR_SEARCH_TERMS[armorType],
table.concat(slotTerms, '|')
);
return string.format('#epic&((%s)|#tier token)', searchTerms);
end
local function initResults()
local results = {};
for slot in pairs(constants.catalystSlots) do
results[slot] = {
[constants.tiers.lfr] = {},
[constants.tiers.normal] = {},
[constants.tiers.heroic] = {},
[constants.tiers.mythic] = {},
};
end
return results;
end
--- @param scanResult SyndicatorSearchResult
--- @param classID number
--- @param seasonID number
--- @return nil|TUM_UI_ResultData catalystInfo
--- @return nil|TUM_UI_ResultData upgradedCatalystInfo
local function checkResult(scanResult, classID, seasonID)
if
scanResult.source.guild -- ignore guild banks, might add some filter setting later
or seasonID ~= TUM:GetItemSeason(scanResult.itemLink)
then
return;
end
local scanClassFile = playerClassFile;
local characterInfo = isSyndicatorLoaded and Syndicator.API.GetCharacter(scanResult.source.character); ---@diagnostic disable-line: undefined-global
if characterInfo then
scanClassFile = characterInfo.details.className;
end
local isToken = scanResult.itemID and TUM:IsToken(scanResult.itemID);
local tokenInfo = isToken and TUM:GetTokenInfo(scanResult.itemID, scanResult.itemLink);
if tokenInfo and (not tokenInfo.classList[classID] or tokenInfo.season ~= seasonID) then
return;
end
local itemSlot = tokenInfo and tokenInfo.slot or C_Item.GetItemInventoryTypeByID(scanResult.itemLink);
if itemSlot == Enum.InventoryType.IndexRobeType then
-- robes catalyse into chest pieces
itemSlot = Enum.InventoryType.IndexChestType;
end
local isItemCatalysed = TUM:IsItemCatalysed(scanResult.itemID);
if isItemCatalysed and data.catalystItems[seasonID][classID][itemSlot] ~= scanResult.itemID then
return;
end
if not isItemCatalysed and scanResult.source.character and scanResult.isBound and isSyndicatorLoaded then
--- @type SyndicatorCharacterData?
if not characterInfo or characterInfo.details.class ~= classID then
return; -- item is bound, and the location is a character of the wrong class
end
end
local tumResult = TUM:IsAppearanceMissing(scanResult.itemLink, classID);
if
not tumResult.catalystAppearanceMissing
and not tumResult.catalystUpgradeAppearanceMissing
and not (isItemCatalysed and tumResult.upgradeAppearanceMissing)
then
return;
end
local location, locationCharacter, locationContainer;
local distance = 0;
if scanResult.source.character then