Repository navigation
Expand file tree
/
Copy pathDressingRoomFrame.lua
More file actions
3574 lines (3053 loc) · 123 KB
/
Copy pathDressingRoomFrame.lua
File metadata and controls
3574 lines (3053 loc) · 123 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
StaticPopupDialogs["MCU_DR_BUY_OUTFIT_SLOT"] = {
text = CONFIRM_BUY_OUTFIT_SLOT,
button1 = YES,
button2 = NO,
OnAccept = function(_dialog, _data)
local nextOutfitCost = C_TransmogOutfitInfo.GetNextOutfitCost();
if GetMoney() < nextOutfitCost then
UIErrorsFrame:AddMessage(ERR_TRANSMOG_OUTFIT_SLOT_CANNOT_AFFORD, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b);
return;
end
MCUDressingRoomFrame.OutfitPopup.mode = IconSelectorPopupFrameModes.New;
MCUDressingRoomFrame.OutfitPopup:Show();
end,
OnShow = function(dialog, _data)
local nextOutfitCost = C_TransmogOutfitInfo.GetNextOutfitCost();
MoneyFrame_Update(dialog.MoneyFrame, nextOutfitCost);
end,
hasMoneyFrame = 1,
timeout = 0,
hideOnEscape = 1
};
StaticPopupDialogs["MCU_DR_OUTFIT_INVALID_NAME"] = {
text = TRANSMOG_OUTFIT_INVALID_NAME,
button1 = OKAY,
button2 = CANCEL,
OnAccept = function(_dialog, data)
MCUDressingRoomFrame.OutfitPopup.mode = data.mode;
MCUDressingRoomFrame.OutfitPopup.outfitData = data.outfitData;
MCUDressingRoomFrame.OutfitPopup:Show();
end,
timeout = 0,
hideOnEscape = 1
};
StaticPopupDialogs["MCU_DR_PENDING_CHANGES"] = {
text = TRANSMOG_PENDING_CHANGES,
button1 = OKAY,
button2 = CANCEL,
OnAccept = function(_dialog, data)
if data.confirmCallback then
data.confirmCallback();
end
end,
timeout = 0,
hideOnEscape = 1
};
StaticPopupDialogs["MCU_DR_USABLE_DISCOUNT"] = {
text = TRANSMOG_USABLE_DISCOUNT_CONFIRM,
button1 = TRANSMOG_USABLE_DISCOUNT_CLAIM,
button2 = TRANSMOG_USABLE_DISCOUNT_USE_GOLD,
button3 = CANCEL,
selectCallbackByIndex = true,
OnButton1 = function()
local useAvailableDiscount = true;
C_TransmogOutfitInfo.CommitAndApplyAllPending(useAvailableDiscount);
end,
OnButton2 = function()
local useAvailableDiscount = false;
C_TransmogOutfitInfo.CommitAndApplyAllPending(useAvailableDiscount);
end,
OnButton3 = function()
end,
OnShow = function(dialog, _data)
local cost = C_TransmogOutfitInfo.GetPendingTransmogCost();
local canAfford = cost and cost <= GetMoney();
dialog:GetButton2():SetEnabled(canAfford);
end,
timeout = 0,
hideOnEscape = 1
};
MCUDR_FrameMixin = {
DYNAMIC_EVENTS = {
"TRANSMOG_OUTFITS_CHANGED",
"TRANSMOG_CUSTOM_SETS_CHANGED",
"TRANSMOG_DISPLAYED_OUTFIT_CHANGED",
"VIEWED_TRANSMOG_OUTFIT_SLOT_REFRESH",
"VIEWED_TRANSMOG_OUTFIT_SITUATIONS_CHANGED",
"PLAYER_SPECIALIZATION_CHANGED",
"DISPLAY_SIZE_CHANGED",
"UI_SCALE_CHANGED"
};
STATIC_POPUPS = {
"MCU_DR_BUY_OUTFIT_SLOT",
"MCU_DR_OUTFIT_INVALID_NAME",
"MCU_DR_PENDING_CHANGES",
"MCU_DR_USABLE_DISCOUNT",
"CONFIRM_DELETE_TRANSMOG_CUSTOM_SET",
"TRANSMOG_CUSTOM_SET_NAME",
"TRANSMOG_CUSTOM_SET_CONFIRM_OVERWRITE"
};
HELP_PLATE_INFO = {
FramePos = { x = 0, y = -21 },
-- Base positions and sizes to reference, as the transmog frame uses the 'checkFit' UIPanel setting to adjust its scale.
-- Actual positions and sizes set in RefreshHelpPlate.
FrameSizeBase = { width = 1618, height = 861 },
[1] = { ButtonPosBase = { x = 133, y = -328 }, HighLightBoxBase = { x = 3, y = -99, width = 308, height = 758 }, ToolTipDir = "DOWN", ToolTipText = TRANSMOG_HELP_1 },
[2] = { ButtonPosBase = { x = 618, y = -328 }, HighLightBoxBase = { x = 315, y = -3, width = 651, height = 854 }, ToolTipDir = "DOWN", ToolTipText = TRANSMOG_HELP_2 },
[3] = { ButtonPosBase = { x = 1269, y = -328 }, HighLightBoxBase = { x = 970, y = -3, width = 644, height = 854 }, ToolTipDir = "DOWN", ToolTipText = TRANSMOG_HELP_3 },
};
};
function MCUDR_FrameMixin:OnLoad()
self:SetPortraitAtlasRaw("transmog-icon-ui");
self:SetTitle(DRESSUP_FRAME or "Dressing Room");
self:SetMovable(true);
self:SetClampedToScreen(true);
self:RegisterForDrag("LeftButton");
self:SetScript("OnDragStart", function(s) s:StartMoving(); end);
self:SetScript("OnDragStop", function(s)
s:StopMovingOrSizing();
local addonNS = s._addonNS;
if addonNS and addonNS.db and addonNS.db.global then
local point, _, relativePoint, xOfs, yOfs = s:GetPoint();
addonNS.db.global.dressingRoomPosition = { point, relativePoint, xOfs, yOfs };
end
end);
if not MCUDR_HelpPlatesSupported() then
self.HelpPlateButton:Hide();
end
self.HelpPlateButton:SetScript("OnClick", function()
if not HelpPlate.IsShowingHelpInfo(self.HELP_PLATE_INFO) then
self:RefreshHelpPlate();
HelpPlate.Show(self.HELP_PLATE_INFO, self, self.HelpPlateButton);
else
local userToggled = true;
HelpPlate.Hide(userToggled);
end
end);
local function OutfitCollectionFrameCollapsedCallback()
self:SetWidth(self.collapsedWidth);
local point, _, _, offsetX, offsetY = self.OutfitCollection:GetPoint();
self.CharacterPreview:ClearAllPoints();
self.CharacterPreview:SetPoint(point, offsetX, offsetY);
end;
self.OutfitCollection.CollapsedCallback = OutfitCollectionFrameCollapsedCallback;
self.WardrobeCollection.GetSelectedSlotCallback = GenerateClosure(self.CharacterPreview.GetSelectedSlotData, self.CharacterPreview);
self.WardrobeCollection.GetCurrentTransmogInfoCallback = GenerateClosure(self.CharacterPreview.GetCurrentTransmogInfo, self.CharacterPreview);
self.WardrobeCollection.GetItemTransmogInfoListCallback = GenerateClosure(self.CharacterPreview.GetItemTransmogInfoList, self.CharacterPreview);
self.WardrobeCollection.GetSlotFrameCallback = GenerateClosure(self.CharacterPreview.GetSlotFrame, self.CharacterPreview);
self:RegisterEvent("DISPLAY_SIZE_CHANGED");
self:RegisterEvent("UI_SCALE_CHANGED");
self:HookScript("OnEvent", function(s, event)
if event == "DISPLAY_SIZE_CHANGED" or event == "UI_SCALE_CHANGED" then
s:FitToScreen();
end
end);
self:HookScript("OnShow", function(s) s:FitToScreen(); end);
end
-- ESC to close: must be at file scope (not inside OnLoad) to avoid taint.
-- This matches how our character panel does it in MainFrame.lua.
tinsert(UISpecialFrames, "MCUDressingRoomFrame");
function MCUDR_FrameMixin:FitToScreen()
local frameW, frameH = self:GetSize();
local screenW, screenH = GetScreenWidth(), GetScreenHeight();
if frameW <= 0 or frameH <= 0 or screenW <= 0 or screenH <= 0 then return; end
local userScale = 1;
local addonNS = self._addonNS;
if addonNS and addonNS.db and addonNS.db.global then
userScale = (addonNS.db.global.dressingRoomScale or 100) / 100;
end
local scaleX = (screenW - 40) / frameW;
local scaleY = (screenH - 40) / frameH;
local fitScale = min(scaleX, scaleY, 1);
self:SetScale(fitScale * userScale);
end
function MCUDR_FrameMixin:OnShow()
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_OPEN);
local addonNS = self._addonNS;
if addonNS and addonNS.db and addonNS.db.global and addonNS.db.global.dressingRoomPosition then
local pos = addonNS.db.global.dressingRoomPosition;
self:ClearAllPoints();
self:SetPoint(pos[1], UIParent, pos[2], pos[3], pos[4]);
end
FrameUtil.RegisterFrameForEvents(self, self.DYNAMIC_EVENTS);
self:SetPortraitToUnit("player");
if self.OutfitCollection and self.OutfitCollection.AppearancesTitle then
self.OutfitCollection.AppearancesTitle:SetText(WARDROBE_OUTFITS or "Saved Appearances");
end
if self.WardrobeCollection then
if not self.WardrobeCollection.CollectionTitle then
local title = self.WardrobeCollection:CreateFontString(nil, "OVERLAY", "GameFontNormalHuge");
title:SetPoint("TOP", 0, -62);
title:SetSize(644, 20);
title:SetJustifyH("CENTER");
title:SetTextColor(1, 0.82, 0, 1);
self.WardrobeCollection.CollectionTitle = title;
local divider = self.WardrobeCollection:CreateTexture(nil, "OVERLAY");
divider:SetAtlas("transmog-outfit-dividerline", true);
divider:SetPoint("TOP", self.WardrobeCollection, "TOP", 0, -102);
self.WardrobeCollection.TabHeaders:ClearAllPoints();
self.WardrobeCollection.TabHeaders:SetPoint("TOPLEFT", 32, -84);
self.WardrobeCollection.TabContent:ClearAllPoints();
self.WardrobeCollection.TabContent:SetPoint("TOPLEFT", 0, -107);
end
self.WardrobeCollection.CollectionTitle:SetText("Collection");
end
if self.OutfitCollection then
if self.OutfitCollection.ShowEquippedGearSpellFrame then
self.OutfitCollection.ShowEquippedGearSpellFrame:Hide();
end
if self.OutfitCollection.MoneyFrame then
self.OutfitCollection.MoneyFrame:Hide();
end
if self.OutfitCollection.SaveOutfitButton then
self.OutfitCollection.SaveOutfitButton:Hide();
end
if self.OutfitCollection.PurchaseOutfitButton then
self.OutfitCollection.PurchaseOutfitButton:SetText(SAVE or "Save Appearance");
end
end
if self.CharacterPreview and self.CharacterPreview.ClearAllPendingButton then
self.CharacterPreview.ClearAllPendingButton:Hide();
end
if not self._drButtonsCreated and self.CharacterPreview then
self._drButtonsCreated = true;
local preview = self.CharacterPreview;
local btnW, btnH = 80, 26;
local btnBar = CreateFrame("Frame", nil, preview);
btnBar:SetPoint("BOTTOMLEFT", preview, "BOTTOMLEFT", 0, 0);
btnBar:SetPoint("BOTTOMRIGHT", preview, "BOTTOMRIGHT", 0, 0);
btnBar:SetHeight(44);
btnBar:SetFrameLevel(preview:GetFrameLevel() + 50);
local resetBtn = CreateFrame("Button", nil, btnBar, "UIPanelButtonTemplate");
resetBtn:SetSize(btnW, btnH);
resetBtn:SetPoint("BOTTOMLEFT", 24, 12);
resetBtn:SetText(RESET or "Reset");
-- Shared function to reset from mount/furniture mode back to character mode
local function ResetToCharacterMode()
if preview._characterButtons then
for _, btn in ipairs(preview._characterButtons) do btn:Show() end
end
if preview.ModelScene and preview.ModelScene._mountActor then
preview.ModelScene._mountActor:ClearModel();
preview.ModelScene._mountActor = nil;
end
if preview.ModelScene and preview.ModelScene._furnitureActor then
preview.ModelScene._furnitureActor:ClearModel();
preview.ModelScene._furnitureActor = nil;
end
if preview.ModelScene and preview.ModelScene._petActor then
preview.ModelScene._petActor:ClearModel();
preview.ModelScene._petActor = nil;
end
if preview.ModelScene then
preview.ModelScene:TransitionToModelSceneID(290, CAMERA_TRANSITION_TYPE_IMMEDIATE, CAMERA_MODIFICATION_TYPE_DISCARD, true);
end
local actor = preview.ModelScene and preview.ModelScene:GetPlayerActor();
if actor then
actor:Show();
actor:SetModelByUnit("player", false, true, false,
PlayerUtil.ShouldUseNativeFormInModelScene and PlayerUtil.ShouldUseNativeFormInModelScene());
end
if preview.drSlotFrames then
preview:SetupSlots();
end
if preview.MountNameLabel then preview.MountNameLabel:Hide(); end
if preview.FurnitureNameLabel then preview.FurnitureNameLabel:Hide(); end
if preview.FurnitureIconFallback then preview.FurnitureIconFallback:Hide(); end
if preview.PetNameLabel then preview.PetNameLabel:Hide(); end
local controlFrame = preview.ModelScene and preview.ModelScene.ControlFrame;
if controlFrame then
controlFrame:ClearAllPoints();
controlFrame:SetPoint("TOP", 0, -18);
end
local addonNS = MCUDressingRoomFrame._addonNS;
if addonNS and addonNS.HideMountCollection then addonNS:HideMountCollection(); end
if addonNS and addonNS.HidePetCollection then addonNS:HidePetCollection(); end
if addonNS and addonNS.HideFurnitureCollection then addonNS:HideFurnitureCollection(); end
MCUDR_PreviewedSlots = {};
if self.OutfitCollection and self.OutfitCollection.OutfitList
and self.OutfitCollection.OutfitList.ScrollBox then
self.OutfitCollection.OutfitList.ScrollBox:ForEachFrame(function(frame)
if frame.OutfitButton and frame.OutfitButton.Selected then
frame.OutfitButton.Selected:Hide();
end
if frame.OutfitButton and frame.OutfitButton.SelectedPurple then
frame.OutfitButton.SelectedPurple:SetAlpha(0);
end
end);
end
if addonNS then addonNS.drPreviewClassID = nil; end
if C_TransmogCollection.SetClassFilter then
local playerClassID = select(3, UnitClass("player"));
if playerClassID then C_TransmogCollection.SetClassFilter(playerClassID); end
end
C_Timer.After(0.3, function()
if preview.RefreshDressingRoomSlots then preview:RefreshDressingRoomSlots(); end
end);
end
resetBtn:SetScript("OnClick", function()
PlaySound(SOUNDKIT.UI_TRANSMOG_REVERTING_GEAR_SLOT);
ResetToCharacterMode();
end);
local undressBtn = CreateFrame("Button", nil, btnBar, "UIPanelButtonTemplate");
undressBtn:SetSize(btnW, btnH);
undressBtn:SetPoint("LEFT", resetBtn, "RIGHT", 8, 0);
undressBtn:SetText(UNDRESS or "Undress");
undressBtn:SetScript("OnClick", function()
PlaySound(SOUNDKIT.UI_TRANSMOG_REVERTING_GEAR_SLOT);
local actor = preview.ModelScene and preview.ModelScene:GetPlayerActor();
if actor then actor:Undress(); end
MCUDR_PreviewedSlots = {};
C_Timer.After(0.3, function()
if preview.RefreshDressingRoomSlots then preview:RefreshDressingRoomSlots(); end
end);
end);
local linkBtn = CreateFrame("Button", nil, btnBar, "UIPanelButtonTemplate");
linkBtn:SetSize(btnW, btnH);
linkBtn:SetPoint("LEFT", undressBtn, "RIGHT", 8, 0);
linkBtn:SetText(LINK_BUTTON or "Link");
linkBtn:SetScript("OnClick", function()
local link;
local actor = preview.ModelScene and preview.ModelScene:GetPlayerActor();
local infoList = actor and actor.GetItemTransmogInfoList and actor:GetItemTransmogInfoList();
if infoList and C_TransmogCollection.GetCustomSetHyperlinkFromItemTransmogInfoList then
link = C_TransmogCollection.GetCustomSetHyperlinkFromItemTransmogInfoList(infoList);
end
if not link then
local addonNS = MCUDressingRoomFrame._addonNS;
link = addonNS and addonNS.drLastLink;
end
if link then
if not ChatFrameUtil.InsertLink(link) then
ChatFrameUtil.OpenChat(link);
end
end
end);
local closeBtn = CreateFrame("Button", nil, btnBar, "UIPanelButtonTemplate");
closeBtn:SetSize(btnW, btnH);
closeBtn:SetPoint("BOTTOMRIGHT", -24, 12);
closeBtn:SetText(CLOSE or "Close");
closeBtn:SetScript("OnClick", function() MCUDressingRoomFrame:Hide(); end);
-- Store character-mode-only buttons for tab switching
preview._characterButtons = { resetBtn, undressBtn, linkBtn };
local function HideCharacterElements()
if preview._characterButtons then
for _, btn in ipairs(preview._characterButtons) do btn:Hide() end
end
if preview.drSlotFrames then
for _, sf in pairs(preview.drSlotFrames) do sf:Hide() end
end
end
-- Tab-based navigation (Character / Mounts / Furniture)
local drTab1 = CreateFrame("Button", "MCUDressingRoomTab1", MCUDressingRoomFrame, "PanelTabButtonTemplate");
drTab1:SetID(1);
drTab1:SetText(CHARACTER or "Character");
drTab1:SetPoint("TOPLEFT", MCUDressingRoomFrame, "BOTTOMLEFT", 11, 2);
PanelTemplates_TabResize(drTab1, 0);
local drTab2 = CreateFrame("Button", "MCUDressingRoomTab2", MCUDressingRoomFrame, "PanelTabButtonTemplate");
drTab2:SetID(2);
drTab2:SetText("Mounts");
drTab2:SetPoint("TOPLEFT", drTab1, "TOPRIGHT", 1, 0);
PanelTemplates_TabResize(drTab2, 0);
local drTab3 = CreateFrame("Button", "MCUDressingRoomTab3", MCUDressingRoomFrame, "PanelTabButtonTemplate");
drTab3:SetID(3);
drTab3:SetText("Pets");
drTab3:SetPoint("TOPLEFT", drTab2, "TOPRIGHT", 1, 0);
PanelTemplates_TabResize(drTab3, 0);
local numTabs = 3;
local lastTab = drTab3;
drTab3:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB);
HideCharacterElements();
ResetToCharacterMode();
PanelTemplates_SetTab(MCUDressingRoomFrame, 3);
local addonNS = MCUDressingRoomFrame._addonNS;
if addonNS and addonNS.ShowPetCollection then
addonNS:ShowPetCollection(nil);
addonNS:EnterPetMode();
end
end);
if C_HousingCatalog then
local drTab4 = CreateFrame("Button", "MCUDressingRoomTab4", MCUDressingRoomFrame, "PanelTabButtonTemplate");
drTab4:SetID(4);
drTab4:SetText("Furniture");
drTab4:SetPoint("TOPLEFT", drTab3, "TOPRIGHT", 1, 0);
PanelTemplates_TabResize(drTab4, 0);
numTabs = 4;
lastTab = drTab4;
drTab4:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB);
HideCharacterElements();
ResetToCharacterMode();
PanelTemplates_SetTab(MCUDressingRoomFrame, 4);
local addonNS = MCUDressingRoomFrame._addonNS;
if addonNS and addonNS.EnterFurnitureMode then
addonNS:EnterFurnitureMode();
end
end);
end
MCUDressingRoomFrame.numTabs = numTabs;
PanelTemplates_SetNumTabs(MCUDressingRoomFrame, numTabs);
PanelTemplates_SetTab(MCUDressingRoomFrame, 1);
drTab1:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB);
ResetToCharacterMode();
PanelTemplates_SetTab(MCUDressingRoomFrame, 1);
end);
drTab2:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB);
HideCharacterElements();
ResetToCharacterMode();
PanelTemplates_SetTab(MCUDressingRoomFrame, 2);
local addonNS = MCUDressingRoomFrame._addonNS;
if addonNS and addonNS.PreviewMount then
local defaultMountID;
for i = 1, C_MountJournal.GetNumDisplayedMounts() do
local _, _, _, _, _, _, _, _, _, _, isCollected, mountID = C_MountJournal.GetDisplayedMountInfo(i);
if isCollected then defaultMountID = mountID; break; end
end
if not defaultMountID then defaultMountID = C_MountJournal.GetDisplayedMountID(1); end
if defaultMountID then addonNS:PreviewMount(defaultMountID); end
end
end);
end
local selectActiveOutfit = true;
self:RefreshOutfits(selectActiveOutfit);
end
function MCUDR_FrameMixin:OnHide()
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_CLOSE);
PanelTemplates_SetTab(MCUDressingRoomFrame, 1);
FrameUtil.UnregisterFrameForEvents(self, self.DYNAMIC_EVENTS);
if self.OutfitPopup then
self.OutfitPopup:Hide();
end
local userToggled = false;
if HelpPlate and HelpPlate.Hide then
HelpPlate.Hide(userToggled);
end
MCUDR_PreviewedSlots = {};
local addonNS = self._addonNS;
if addonNS then
addonNS.drPreviewClassID = nil;
end
if C_TransmogCollection.SetClassFilter then
local playerClassID = select(3, UnitClass("player"));
if playerClassID then
C_TransmogCollection.SetClassFilter(playerClassID);
end
end
if self.CharacterPreview and self.CharacterPreview.ModelScene then
local ms = self.CharacterPreview.ModelScene;
if ms._mountActor then
ms._mountActor:ClearModel();
ms._mountActor = nil;
end
if ms._furnitureActor then
ms._furnitureActor:ClearModel();
ms._furnitureActor = nil;
end
if ms._petActor then
ms._petActor:ClearModel();
ms._petActor = nil;
end
ms:TransitionToModelSceneID(290, CAMERA_TRANSITION_TYPE_IMMEDIATE, CAMERA_MODIFICATION_TYPE_DISCARD, true);
end
if self.CharacterPreview then
if self.CharacterPreview.MountNameLabel then self.CharacterPreview.MountNameLabel:Hide(); end
if self.CharacterPreview.FurnitureNameLabel then self.CharacterPreview.FurnitureNameLabel:Hide(); end
if self.CharacterPreview.FurnitureIconFallback then self.CharacterPreview.FurnitureIconFallback:Hide(); end
if self.CharacterPreview.PetNameLabel then self.CharacterPreview.PetNameLabel:Hide(); end
local controlFrame = self.CharacterPreview.ModelScene and self.CharacterPreview.ModelScene.ControlFrame;
if controlFrame then
controlFrame:ClearAllPoints();
controlFrame:SetPoint("TOP", 0, -18);
end
end
local addonNS = self._addonNS;
if addonNS and addonNS.HideMountCollection then addonNS:HideMountCollection(); end
if addonNS and addonNS.HidePetCollection then addonNS:HidePetCollection(); end
if addonNS and addonNS.HideFurnitureCollection then addonNS:HideFurnitureCollection(); end
if self.CharacterPreview and self.CharacterPreview.ModelScene then
local actor = self.CharacterPreview.ModelScene:GetPlayerActor();
if actor then
actor:Show();
actor:SetModelByUnit("player", false, true, false,
PlayerUtil.ShouldUseNativeFormInModelScene and PlayerUtil.ShouldUseNativeFormInModelScene());
end
end
if self.CharacterPreview and self.CharacterPreview.RefreshDressingRoomSlots then
self.CharacterPreview:RefreshDressingRoomSlots();
end
if self.OutfitCollection and self.OutfitCollection.OutfitList
and self.OutfitCollection.OutfitList.ScrollBox then
self.OutfitCollection.OutfitList.ScrollBox:ForEachFrame(function(frame)
if frame.OutfitButton and frame.OutfitButton.Selected then
frame.OutfitButton.Selected:Hide();
end
if frame.OutfitButton and frame.OutfitButton.SelectedPurple then
frame.OutfitButton.SelectedPurple:SetAlpha(0);
end
end);
end
end
function MCUDR_FrameMixin:OnEvent(event, ...)
if event == "TRANSMOG_OUTFITS_CHANGED" or event == "TRANSMOG_CUSTOM_SETS_CHANGED" then
local newOutfitID = ...;
local selectActiveOutfit = false;
self:RefreshOutfits(selectActiveOutfit);
if newOutfitID and event == "TRANSMOG_OUTFITS_CHANGED" then
self.OutfitCollection:AnimateOutfitAdded(newOutfitID);
end
elseif event == "TRANSMOG_DISPLAYED_OUTFIT_CHANGED" then
local selectActiveOutfit = false;
self:RefreshOutfits(selectActiveOutfit);
elseif event == "VIEWED_TRANSMOG_OUTFIT_SLOT_REFRESH" or event == "VIEWED_TRANSMOG_OUTFIT_SITUATIONS_CHANGED" then
self:UpdateCostDisplay();
elseif event == "PLAYER_SPECIALIZATION_CHANGED" then
self:RefreshSlots();
elseif event == "DISPLAY_SIZE_CHANGED" or event == "UI_SCALE_CHANGED" then
self:RefreshHelpPlate();
end
end
function MCUDR_FrameMixin:RefreshOutfits(selectActiveOutfit)
local dataProvider = CreateDataProvider();
if C_TransmogCollection and C_TransmogCollection.GetCustomSets then
local setIDs = C_TransmogCollection.GetCustomSets();
if setIDs then
for _, setID in ipairs(setIDs) do
local setName, setIcon = C_TransmogCollection.GetCustomSetInfo(setID);
local onClickCallback = function()
if self.CharacterPreview and self.CharacterPreview.ModelScene then
local infoList = C_TransmogCollection.GetCustomSetItemTransmogInfoList(setID);
local actor = self.CharacterPreview.ModelScene:GetPlayerActor();
if actor and infoList then
MCUDR_PreviewedSlots = {};
for slotID, info in pairs(infoList) do
actor:SetItemTransmogInfo(info, slotID);
if info.appearanceID and info.appearanceID > 0 then
local sourceInfo = C_TransmogCollection.GetSourceInfo(info.appearanceID);
local itemIcon;
-- GetSourceInfo doesn't reliably return icon; get it from the item instead
if sourceInfo then
local itemID = sourceInfo.itemID or C_TransmogCollection.GetSourceItemID(info.appearanceID);
if itemID then
itemIcon = C_Item.GetItemIconByID(itemID) or select(5, C_Item.GetItemInfoInstant(itemID));
end
end
if sourceInfo and sourceInfo.name then
MCUDR_PreviewedSlots[slotID] = {
icon = itemIcon,
sourceID = info.appearanceID,
name = sourceInfo.name,
quality = sourceInfo.quality,
};
end
end
end
-- Refresh immediately with what we have, then retry
-- to pick up source info that wasn't cached yet
if self.CharacterPreview.RefreshDressingRoomSlots then
self.CharacterPreview:RefreshDressingRoomSlots();
end
local capturedSelf = self;
local capturedInfoList = infoList;
C_Timer.After(0.5, function()
-- Re-populate slots with source info that may now be cached
for sID, sInfo in pairs(capturedInfoList) do
if sInfo.appearanceID and sInfo.appearanceID > 0 and not MCUDR_PreviewedSlots[sID] then
local si = C_TransmogCollection.GetSourceInfo(sInfo.appearanceID);
if si and si.name then
local itemIcon;
local itemID = si.itemID or C_TransmogCollection.GetSourceItemID(sInfo.appearanceID);
if itemID then
itemIcon = C_Item.GetItemIconByID(itemID) or select(5, C_Item.GetItemInfoInstant(itemID));
end
MCUDR_PreviewedSlots[sID] = {
icon = itemIcon,
sourceID = sInfo.appearanceID,
name = si.name,
quality = si.quality,
};
end
end
end
if capturedSelf.CharacterPreview and capturedSelf.CharacterPreview.RefreshDressingRoomSlots then
capturedSelf.CharacterPreview:RefreshDressingRoomSlots();
end
end);
end
end
end;
local onEditCallback = function()
StaticPopup_Show("MCU_DR_RENAME_CUSTOM_SET", setName, nil, {
setID = setID,
name = setName,
icon = setIcon,
});
end;
local outfitData = {
outfitID = setID,
name = setName or ("Set " .. setID),
icon = setIcon or 136516,
onClickCallback = onClickCallback,
onEditCallback = onEditCallback,
};
dataProvider:Insert(outfitData);
end
end
end
self.OutfitCollection:Refresh(dataProvider, selectActiveOutfit);
end
function MCUDR_FrameMixin:RefreshSlots()
local clearCurrentWeaponOptionInfo = false;
self.CharacterPreview:RefreshSlotWeaponOptions(clearCurrentWeaponOptionInfo);
self.CharacterPreview:RefreshSlots();
self.WardrobeCollection:UpdateSlot(self.CharacterPreview:GetSelectedSlotData());
end
function MCUDR_FrameMixin:RefreshHelpPlate()
local relativeScale = self:GetEffectiveScale() / HelpPlate.GetEffectiveScale();
self.HELP_PLATE_INFO.FrameSize = {
width = self.HELP_PLATE_INFO.FrameSizeBase.width * relativeScale,
height = self.HELP_PLATE_INFO.FrameSizeBase.height * relativeScale
};
local function UpdateHelpPlateSection(helpPlate)
helpPlate.ButtonPos = {
x = helpPlate.ButtonPosBase.x * relativeScale,
y = helpPlate.ButtonPosBase.y * relativeScale
};
helpPlate.HighLightBox = {
x = helpPlate.HighLightBoxBase.x * relativeScale,
y = helpPlate.HighLightBoxBase.y * relativeScale,
width = helpPlate.HighLightBoxBase.width * relativeScale,
height = helpPlate.HighLightBoxBase.height * relativeScale
};
end
UpdateHelpPlateSection(self.HELP_PLATE_INFO[1]);
UpdateHelpPlateSection(self.HELP_PLATE_INFO[2]);
UpdateHelpPlateSection(self.HELP_PLATE_INFO[3]);
if HelpPlate.IsShowingHelpInfo(self.HELP_PLATE_INFO) then
HelpPlate.Show(self.HELP_PLATE_INFO, self, self.HelpPlateButton);
end
end
function MCUDR_FrameMixin:UpdateCostDisplay()
end
function MCUDR_FrameMixin:SelectSlot(slotFrame, forceRefresh)
self.CharacterPreview:UpdateSlot(slotFrame.slotData, forceRefresh);
self.WardrobeCollection:UpdateSlot(slotFrame.slotData, forceRefresh);
end
function MCUDR_FrameMixin:GetViewedOutfitIcons()
return self.CharacterPreview:GetCurrentTransmogIcons();
end
MCUDR_OutfitCollectionMixin = {
DYNAMIC_EVENTS = {
"VIEWED_TRANSMOG_OUTFIT_CHANGED",
"VIEWED_TRANSMOG_OUTFIT_SLOT_SAVE_SUCCESS"
};
HELPTIP_INFO = {
[Enum.FrameTutorialAccount.TransmogOutfits] =
{
text = TRANSMOG_OUTFITS_HELPTIP,
buttonStyle = HelpTip.ButtonStyle.Close,
targetPoint = HelpTip.Point.RightEdgeTop,
alignment = HelpTip.Alignment.Center,
offsetX = -33,
offsetY = -33,
system = "TransmogOutfitCollection",
acknowledgeOnHide = true,
cvarBitfield = "closedInfoFramesAccountWide",
bitfieldFlag = Enum.FrameTutorialAccount.TransmogOutfits
},
[Enum.FrameTutorialAccount.TransmogTrialOfStyle] =
{
text = TRANSMOG_TRIAL_OF_STYLE_HELPTIP,
buttonStyle = HelpTip.ButtonStyle.Close,
targetPoint = HelpTip.Point.RightEdgeTop,
alignment = HelpTip.Alignment.Center,
offsetX = -33,
offsetY = -33,
system = "TransmogOutfitCollection",
acknowledgeOnHide = true,
cvarBitfield = "closedInfoFramesAccountWide",
bitfieldFlag = Enum.FrameTutorialAccount.TransmogTrialOfStyle
}
};
CollapsedCallback = nil;
};
function MCUDR_OutfitCollectionMixin:OnLoad()
local view = CreateScrollBoxListLinearView();
view:SetElementInitializer("MCUDR_OutfitEntryTemplate", function(frame, elementData)
frame:Init(elementData);
end);
local padTop = 8;
local pad = 0;
local spacing = 2;
view:SetPadding(padTop, pad, pad, pad, spacing);
ScrollUtil.InitScrollBoxListWithScrollBar(self.OutfitList.ScrollBox, self.OutfitList.ScrollBar, view);
ScrollUtil.AddResizableChildrenBehavior(self.OutfitList.ScrollBox);
self.PurchaseOutfitButton:SetScript("OnMouseDown", function(button)
button.Icon:SetPoint("LEFT", 16, -2);
end);
self.PurchaseOutfitButton:SetScript("OnMouseUp", function(button)
button.Icon:SetPoint("LEFT", 14, 0);
end);
self.PurchaseOutfitButton:SetText(SAVE or "Save Appearance");
self.PurchaseOutfitButton:SetScript("OnEnter", function(button)
GameTooltip:SetOwner(button, "ANCHOR_RIGHT");
GameTooltip:SetText("Save current appearance as a custom set");
GameTooltip:Show();
end);
self.PurchaseOutfitButton:SetScript("OnLeave", GameTooltip_Hide);
self.PurchaseOutfitButton:SetScript("OnClick", function()
StaticPopup_Show("MCU_DR_SAVE_CUSTOM_SET");
end);
self:InitSaveOutfitElements();
end
StaticPopupDialogs["MCU_DR_SAVE_CUSTOM_SET"] = {
text = "Enter a name for this appearance:",
button1 = ACCEPT,
button2 = CANCEL,
hasEditBox = true,
OnAccept = function(self)
local eb = self.editBox or self.EditBox;
local name = strtrim(eb:GetText() or "");
if name ~= "" and MCUDressingRoomFrame and MCUDressingRoomFrame.CharacterPreview then
local modelScene = MCUDressingRoomFrame.CharacterPreview.ModelScene;
if modelScene then
local actor = modelScene:GetPlayerActor();
if actor and actor.GetItemTransmogInfoList then
local infoList = actor:GetItemTransmogInfoList();
if infoList and C_TransmogCollection and C_TransmogCollection.NewCustomSet then
local headTex = GetInventoryItemTexture("player", 1) or 136516;
C_TransmogCollection.NewCustomSet(name, headTex, infoList);
end
end
end
end
end,
EditBoxOnEnterPressed = function(self)
local parent = self:GetParent();
StaticPopupDialogs["MCU_DR_SAVE_CUSTOM_SET"].OnAccept(parent);
parent:Hide();
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
};
StaticPopupDialogs["MCU_DR_RENAME_CUSTOM_SET"] = {
text = "Enter a new name for this appearance:",
button1 = ACCEPT,
button2 = CANCEL,
hasEditBox = true,
OnShow = function(self)
local eb = self.editBox or self.EditBox;
if eb and self.data and self.data.name then
eb:SetText(self.data.name);
eb:HighlightText();
end
end,
OnAccept = function(self)
local eb = self.editBox or self.EditBox;
local newName = strtrim(eb and eb:GetText() or "");
local data = self.data;
if newName ~= "" and data and data.setID and C_TransmogCollection then
local infoList = C_TransmogCollection.GetCustomSetItemTransmogInfoList(data.setID);
C_TransmogCollection.DeleteCustomSet(data.setID);
if infoList then
C_TransmogCollection.NewCustomSet(newName, data.icon or 136516, infoList);
end
if MCUDressingRoomFrame then
MCUDressingRoomFrame:RefreshOutfits();
end
end
end,
EditBoxOnEnterPressed = function(self)
local parent = self:GetParent();
StaticPopupDialogs["MCU_DR_RENAME_CUSTOM_SET"].OnAccept(parent);
parent:Hide();
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
};
StaticPopupDialogs["MCU_DR_DELETE_CUSTOM_SET"] = {
text = "Delete appearance \"%s\"?",
button1 = YES,
button2 = NO,
OnAccept = function(self, data)
if data and C_TransmogCollection and C_TransmogCollection.DeleteCustomSet then
C_TransmogCollection.DeleteCustomSet(data);
if MCUDressingRoomFrame then
MCUDressingRoomFrame:RefreshOutfits();
end
end
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
};
function MCUDR_OutfitCollectionMixin:InitSaveOutfitElements()
if self.SaveOutfitButton then self.SaveOutfitButton:Hide(); end
if self.MoneyFrame then self.MoneyFrame:Hide(); end
end
function MCUDR_OutfitCollectionMixin:OnShow()
if self.DYNAMIC_EVENTS then
FrameUtil.RegisterFrameForEvents(self, self.DYNAMIC_EVENTS);
end
self.canScrollToOutfit = true;
if self.OutfitList and self.OutfitList.ScrollBox then
self.OutfitList.ScrollBox:ScrollToBegin();
end
end
function MCUDR_OutfitCollectionMixin:OnHide()
FrameUtil.UnregisterFrameForEvents(self, self.DYNAMIC_EVENTS);
end
function MCUDR_OutfitCollectionMixin:OnEvent(event, ...)
if event == "VIEWED_TRANSMOG_OUTFIT_CHANGED" then
self:UpdateSelectedOutfit();
elseif event == "VIEWED_TRANSMOG_OUTFIT_SLOT_SAVE_SUCCESS" then
local _slot, _type, _weaponOption = ...;
self:RefreshUsableDiscountText();
-- Already set to true, do not restart animations if multiple slots are changing.
if self:GetOutfitSavedState() then
return;
end
self:AnimateViewedOutfitSaved();
end
end
function MCUDR_OutfitCollectionMixin:Refresh(dataProvider, selectActiveOutfit)
self.OutfitList.ScrollBox:SetDataProvider(dataProvider, ScrollBoxConstants.RetainScrollPosition);
self:UpdateShowEquippedGearButton();
self:CheckShowHelptips();
-- Active outfit is the outfit the player is wearing out in the world, viewed is what is being viewed in the transmog frame.
local viewedOutfitID = C_TransmogOutfitInfo.GetCurrentlyViewedOutfitID();
local outfitID = selectActiveOutfit and C_TransmogOutfitInfo.GetActiveOutfitID() or viewedOutfitID;
if outfitID == 0 then
local firstElementData = dataProvider:Find(1);
outfitID = firstElementData.outfitID;
end
if selectActiveOutfit or outfitID ~= viewedOutfitID then
C_TransmogOutfitInfo.ChangeViewedOutfit(outfitID);
end
local source = Enum.TransmogOutfitEntrySource.PlayerPurchased;
local unlockedOutfitCount = C_TransmogOutfitInfo.GetNumberOfOutfitsUnlockedForSource(source);
local maxOutfitCount = C_TransmogOutfitInfo.GetMaxNumberOfTotalOutfitsForSource(source);
local hasOutfitsToPurchase = unlockedOutfitCount < maxOutfitCount;
local hasOutfitsToSelect = C_TransmogOutfitInfo.GetMaxNumberOfUsableOutfits() > 1;
self.PurchaseOutfitButton:SetEnabled(hasOutfitsToPurchase);
self.PurchaseOutfitButton.Icon:SetDesaturated(not hasOutfitsToPurchase);
if(not hasOutfitsToPurchase and not hasOutfitsToSelect) then
self:Collapse();
end
end
function MCUDR_OutfitCollectionMixin:Collapse()
self:Hide();
self.CollapsedCallback();
end
function MCUDR_OutfitCollectionMixin:RefreshUsableDiscountText()
self.UsableDiscountText:SetShown(C_TransmogOutfitInfo.IsUsableDiscountAvailable());
end
function MCUDR_OutfitCollectionMixin:CheckShowHelptips()
local showTrialOfStyleHelptip = not GetCVarBitfield("closedInfoFramesAccountWide", Enum.FrameTutorialAccount.TransmogTrialOfStyle) and C_TransmogOutfitInfo.TransmogEventActive();
-- Use OutfitList as the parent for helptips here instead of any scroll box element to prevent the help tip being masked.
if not GetCVarBitfield("closedInfoFramesAccountWide", Enum.FrameTutorialAccount.TransmogOutfits) then
local helptipInfo = self.HELPTIP_INFO[Enum.FrameTutorialAccount.TransmogOutfits];
if showTrialOfStyleHelptip then
helptipInfo.onAcknowledgeCallback = function()
self:CheckShowHelptips();
end;
end
HelpTip:Show(self.OutfitList, helptipInfo);
elseif showTrialOfStyleHelptip then
HelpTip:Show(self.OutfitList, self.HELPTIP_INFO[Enum.FrameTutorialAccount.TransmogTrialOfStyle]);
end
end
function MCUDR_OutfitCollectionMixin:UpdateShowEquippedGearButton()
local overlayFX = self.ShowEquippedGearSpellFrame.OverlayFX;
local activeOutfit = C_TransmogOutfitInfo.IsEquippedGearOutfitDisplayed();
overlayFX.OverlayActive:SetShown(activeOutfit);
self.ShowEquippedGearSpellFrame.Label:SetFontObject(activeOutfit and "GameFontHighlight" or "GameFontNormal");
self.ShowEquippedGearSpellFrame.Checkmark:SetShown(activeOutfit);
local isLockedOutfit = C_TransmogOutfitInfo.IsEquippedGearOutfitLocked();
overlayFX.OverlayLocked:SetShown(isLockedOutfit);
overlayFX.OverlayLocked:ShowAutoCastEnabled(isLockedOutfit);
local inTransmogEvent = C_TransmogOutfitInfo.InTransmogEvent();
self.ShowEquippedGearSpellFrame.Button:SetEnabled(not inTransmogEvent);
self.ShowEquippedGearSpellFrame.Button.Icon:SetDesaturated(inTransmogEvent);
end
function MCUDR_OutfitCollectionMixin:UpdateSelectedOutfit()
local viewedOutfitID = C_TransmogOutfitInfo.GetCurrentlyViewedOutfitID();
if self.canScrollToOutfit then
local alignment = ScrollBoxConstants.AlignNearest;
self:ScrollToOutfit(viewedOutfitID, alignment);
self.canScrollToOutfit = false;
end