-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransmogTab.lua
702 lines (621 loc) · 27.7 KB
/
TransmogTab.lua
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
-----------------------
-- Namespaces
-----------------------
local SM, DB, DP, L, U = unpack(select(2, ...))
SM.TransmogOutfitsCollectionMixin = {};
SM.TransmogScrollFrameMixin = {};
SetMasterTransmogScrollFrameMixin = {}
SetMasterTransmogOutfitsCollectionMixin = {}
local IN_PROGRESS_FONT_COLOR = CreateColor(0.251, 0.753, 0.251);
local EXPANDED_BUTTON_HEIGHT = 86;
function SetMasterTransmogScrollFrameMixin:AddBlizzardMixins()
Mixin(self, {
OnHide = WardrobeSetsCollectionScrollFrameMixin.OnHide,
SetItemFrameQuality = WardrobeSetsCollectionMixin.SetItemFrameQuality,
SetAppearanceTooltip = WardrobeSetsCollectionMixin.SetAppearanceTooltip,
RefreshAppearanceTooltip = ExtSetsCollectionMixin.RefreshAppearanceTooltip
});
end
function SetMasterTransmogScrollFrameMixin:OnShow()
self:RegisterEvent("GET_ITEM_INFO_RECEIVED");
self:RegisterEvent("TRANSMOG_COLLECTION_ITEM_UPDATE");
self:RegisterEvent("TRANSMOG_COLLECTION_UPDATED");
self:RegisterEvent("TRANSMOG_COLLECTION_SOURCE_ADDED");
self:RegisterEvent("TRANSMOGRIFY_UPDATE");
self:Update();
end
function SetMasterTransmogScrollFrameMixin:OnEvent(event, ...)
if ( event == "TRANSMOG_SETS_UPDATE_FAVORITE" ) then
DP:RefreshFavorites();
end
self:Update();
end
function SetMasterTransmogScrollFrameMixin:OnLoad()
self.update = self.Update; -- HybridScrollFrames calls update(), and not Update()
HybridScrollFrame_CreateButtons(self, "OutfitsTransmogFrameScrollFrameButtonTemplate2", 0, 0);
HybridScrollFrame_SetDoNotHideScrollBar(self, true);
for i = 1, #self.buttons do
self.buttons[i].itemFramesPool = CreateFramePool("Frame", self.buttons[i], "WardrobeSetsDetailsItemFrameTemplate, SetMasterTransmogSetsIconFrame");
self.buttons[i]:ToggleSelected(false);
self.buttons[i]:ToggleTransmogged(false);
Mixin(self.buttons[i], {SetAppearanceTooltip = WardrobeSetsCollectionMixin.SetAppearanceTooltip})
end
end
function SetMasterTransmogScrollFrameMixin:Update()
local offset = HybridScrollFrame_GetOffset(self);
local buttons = self.buttons;
local baseSets = DP:GetBaseSets();
local currentSelectedSetID = self:GetParent():GetSelectedSetID()
local selectedBaseSetID = currentSelectedSetID and DP:C_GetBaseSetID(currentSelectedSetID)
for i = 1, #buttons do
local button = buttons[i];
local setIndex = i + offset;
if (setIndex <= #baseSets) then
local baseSet = baseSets[setIndex];
local variantSets = DP:GetVariantSets(DP:C_GetBaseSetID(baseSet.setID));
button.baseSetID = baseSet.setID
button.setID = self:GetParent():GetDefaultSetIDForBaseSet(baseSet.setID)
local setInfo = DP:C_GetSetInfo(button.setID)
local topSourcesCollected, topSourcesTotal = DP:GetSetSourceTopCounts(baseSet.setID);
local setCollected = (topSourcesCollected == topSourcesTotal);
local color = IN_PROGRESS_FONT_COLOR;
button.ApplyButton:Enable();
button.AddButton:Enable();
button.RemoveButton:Enable();
if ( setCollected ) then
color = NORMAL_FONT_COLOR;
elseif ( topSourcesCollected == 0 ) then
color = GRAY_FONT_COLOR;
button.ApplyButton:Disable();
button.AddButton:Disable();
button.RemoveButton:Disable();
end
if (baseSet.setID == selectedBaseSetID) then
HybridScrollFrame_ExpandButton(self, ((setIndex - 1)*self.buttonHeight), EXPANDED_BUTTON_HEIGHT)
button:Expand();
if(#variantSets > 1) then
button.VariantSetsButton:Show();
button.VariantSetsButton:SetText(setInfo.description);
end
button.Variant:SetText(nil)
else
button.VariantSetsButton:Hide();
button.VariantSetsButton:SetText("");
button.Variant:SetText(#variantSets > 1 and "("..setInfo.description..")")
button:Collapse();
end
button:ToggleTransmogged(baseSet.setID == selectedBaseSetID and self:GetParent():GetParent():GetParent().toTransmog == true)
button:ToggleSelected(baseSet.setID == selectedBaseSetID);
button:Show();
button.Name:SetText(baseSet.name);
button.Name:SetTextColor(color.r, color.g, color.b);
button.Variant:SetTextColor(color.r, color.g, color.b);
button.Variant:SetShown(baseSet.setID ~= selectedBaseSetID);
-- Fontstring showing the number of variants the set has
if (#variantSets > 0) then
button.NumVariants:SetText("("..#variantSets.." variants)");
else
button.NumVariants:SetText("")
end
button.Label:SetText(U:CreateSetLabel(baseSet));
button:DisplayItems();
else
button:Hide();
end
end
local extraHeight = (self.largeButtonHeight and self.largeButtonHeight - U.BASE_SET_BUTTON_HEIGHT) or 0;
local totalHeight = #baseSets * U.BASE_SET_BUTTON_HEIGHT + extraHeight;
HybridScrollFrame_Update(self, totalHeight, self:GetHeight());
end
function SetMasterTransmogOutfitsCollectionMixin:OnLoad()
self.searchType = U.SM_TRANSMOG_SEARCH_TYPE_OUTFITS;
self.BGCornerTopRight:Hide();
self.BGCornerTopLeft:Hide();
self.BGCornerBottomRight:Hide();
self.BGCornerBottomLeft:Hide();
if (not self.init) then
self.init = true;
self.selectedVariantSets = {};
self.toTransmog = false;
end
end
function SetMasterTransmogOutfitsCollectionMixin:OnShow()
self:RegisterEvent("GET_ITEM_INFO_RECEIVED");
self:RegisterEvent("TRANSMOG_COLLECTION_ITEM_UPDATE");
self:RegisterEvent("TRANSMOG_COLLECTION_UPDATED");
self:RegisterEvent("TRANSMOG_COLLECTION_SOURCE_ADDED");
self:UpdateProgressBar();
end
function SetMasterTransmogOutfitsCollectionMixin:OnHide()
self:UnregisterEvent("GET_ITEM_INFO_RECEIVED");
self:UnregisterEvent("TRANSMOG_COLLECTION_ITEM_UPDATE");
self:UnregisterEvent("TRANSMOG_COLLECTION_UPDATED");
self:UnregisterEvent("TRANSMOG_COLLECTION_SOURCE_ADDED");
end
function SetMasterTransmogOutfitsCollectionMixin:OnSearchUpdate()
DP:SetSearch(WardrobeCollectionFrameSearchBox:GetText())
DP:ClearBaseSets();
DP:ClearVariantSets();
DP:ClearUsableSets();
self.ScrollFrame:Update();
end
function SetMasterTransmogOutfitsCollectionMixin:AddBlizzardMixins()
Mixin(self, {
RefreshCameras = WardrobeSetsTransmogMixin.RefreshCameras,
OnUnitModelChangedEvent = WardrobeSetsTransmogMixin.OnUnitModelChangedEvent,
GetDefaultSetIDForBaseSet = ExtSetsCollectionMixin.GetDefaultSetIDForBaseSet,
GetSelectedSetID = WardrobeSetsCollectionMixin.GetSelectedSetID,
SelectSet = ExtSetsCollectionMixin.SelectSet,
});
end
function SetMasterTransmogOutfitsCollectionMixin:UpdateProgressBar()
WardrobeCollectionFrame_UpdateProgressBar(DP:C_GetBaseSetsCounts());
end
function SetMasterTransmogOutfitsCollectionMixin:SelectSetFromButton(setID)
CloseDropDownMenus();
if (self.selectedSetID == setID) then
self.toTransmog = true;
else
self:SelectSet(self:GetDefaultSetIDForBaseSet(setID));
end
end
function SetMasterTransmogOutfitsCollectionMixin:Refresh()
self.ScrollFrame:Update();
end
function TransmogItemFrame_OnEnter(self)
self:GetParent():SetAppearanceTooltip(self);
ItemModel = _G["SetMasterTransmogItemModelFrame"];
if ( self.New:IsShown() ) then
local transmogSlot = C_Transmog.GetSlotForInventoryType(self.invType);
local setID = WardrobeCollectionFrame.SetsCollectionFrame:GetSelectedSetID();
C_TransmogSets.ClearSetNewSourcesForSlot(setID, transmogSlot);
local baseSetID = C_TransmogSets.GetBaseSetID(setID);
SetsDataProvider:ResetBaseSetNewStatus(baseSetID);
WardrobeCollectionFrame.SetsCollectionFrame:Refresh();
end
end
function TransmogItemFrame_OnLeave(self)
ItemModel = _G["SetMasterTransmogItemModelFrame"];
ItemModel:Hide();
ResetCursor();
WardrobeCollectionFrame_HideAppearanceTooltip();
end
function TransmogItemFrame_OnUpdate(self, elapsed)
if(self.Glow:IsShown()) then
AnimateTexCoords(self.Ants, 256, 256, 48, 48, 22, elapsed, 0.01);
end
ItemModel = _G["SetMasterTransmogItemModelFrame"];
local itemFrame = GetMouseFocus();
if IsModifiedClick("DRESSUP") then
if (itemFrame and itemFrame.invType) then
ItemModel:SetFrameStrata("HIGH")
ItemModel:EnableMouse(false)
ItemModel:Show();
--ShowInspectCursor();
end
else
if (itemFrame and itemFrame.invType) then
ItemModel:Hide();
ResetCursor();
end
end
end
OutfitsTransmogButtonMixin = {};
function OutfitsTransmogButtonMixin:RefreshAppearanceTooltip()
if ( not self.tooltipTransmogSlot ) then
return;
end
local sources = DP:C_GetSourcesForSlot(self.setID, self.tooltipTransmogSlot);
if ( #sources == 0 ) then
-- can happen if a slot only has HiddenUntilCollected sources
local sourceInfo = C_TransmogCollection.GetSourceInfo(self.tooltipPrimarySourceID);
if (sourceInfo) then
tinsert(sources, sourceInfo);
end
end
WardrobeCollectionFrame_SortSources(sources, nil, self.tooltipPrimarySourceID);
WardrobeCollectionFrame_SetAppearanceTooltip(self, sources, self.tooltipPrimarySourceID);
end
function OutfitsTransmogButtonMixin:OnLoad()
Mixin (self, {
SetItemFrameQuality = WardrobeSetsCollectionMixin.SetItemFrameQuality
})
end
function OutfitsTransmogButtonMixin:OnShow()
self:RegisterEvent("MODIFIER_STATE_CHANGED")
end
function OutfitsTransmogButtonMixin:OnEvent(event, ...)
local currentSelectedSetID = self:GetParent():GetParent():GetParent():GetSelectedSetID()
local selectedBaseSetID = currentSelectedSetID and DP:C_GetBaseSetID(currentSelectedSetID)
local Model = _G["SetMasterTransmogModelFrame"];
if(GetMouseFocus() == self) then
if(event == "MODIFIER_STATE_CHANGED") then
local modifier, state = ...;
if(modifier == "RCTRL" or modifier == "LCTRL") then
Model.setID = state == 1 and self.setID;
Model:SetShown(state == 1 and true);
end
end
end
end
function OutfitsTransmogButtonMixin:OnEnter()
local Model = _G["SetMasterTransmogModelFrame"];
if(IsControlKeyDown()) then
Model.setID = self.setID;
Model:Show();
end
end
function OutfitsTransmogButtonMixin:OnLeave()
local Model = _G["SetMasterTransmogModelFrame"];
Model:Hide();
end
function OutfitsTransmogButtonMixin:ToggleSelected(status)
self.SelectedCornerTopLeft:SetShown(status)
self.SelectedLeft:SetShown(status)
self.SelectedCornerBottomLeft:SetShown(status)
self.SelectedTop:SetShown(status)
self.SelectedBottom:SetShown(status)
self.SelectedCornerBottomRight:SetShown(status)
self.SelectedRight:SetShown(status)
self.SelectedCornerTopRight:SetShown(status)
end
function OutfitsTransmogButtonMixin:ToggleTransmogged(status)
self.TMedCornerTopLeft:SetShown(status)
self.TMedLeft:SetShown(status)
self.TMedCornerBottomLeft:SetShown(status)
self.TMedTop:SetShown(status)
self.TMedBottom:SetShown(status)
self.TMedCornerBottomRight:SetShown(status)
self.TMedRight:SetShown(status)
self.TMedCornerTopRight:SetShown(status)
end
function OutfitsTransmogButtonMixin:Expand()
local largeButtonHeight = self:GetParent():GetParent().largeButtonHeight;
self:SetHeight(largeButtonHeight);
self.BgLeft:SetHeight(largeButtonHeight - self.BgCornerTopLeft:GetHeight() - self.BgCornerBottomLeft:GetHeight());
self.BgRight:SetHeight(largeButtonHeight - self.BgCornerTopRight:GetHeight() - self.BgCornerBottomRight:GetHeight());
self.SelectedLeft:SetHeight(largeButtonHeight - self.SelectedCornerTopLeft:GetHeight() - self.SelectedCornerBottomLeft:GetHeight());
self.SelectedRight:SetHeight(largeButtonHeight - self.SelectedCornerTopRight:GetHeight() - self.SelectedCornerBottomRight:GetHeight());
self.HoverLeft:SetHeight(largeButtonHeight - self.HoverCornerTopLeft:GetHeight() - self.HoverCornerBottomLeft:GetHeight());
self.HoverRight:SetHeight(largeButtonHeight - self.HoverCornerTopRight:GetHeight() - self.HoverCornerBottomRight:GetHeight());
self.ApplyButton:Show();
self.AddButton:Show();
self.RemoveButton:Show();
end
function OutfitsTransmogButtonMixin:Collapse()
local buttonHeight = self:GetParent():GetParent().buttonHeight;
self:SetHeight(buttonHeight);
self.BgLeft:SetHeight(buttonHeight - self.BgCornerTopLeft:GetHeight() - self.BgCornerBottomLeft:GetHeight());
self.BgRight:SetHeight(buttonHeight - self.BgCornerTopRight:GetHeight() - self.BgCornerBottomRight:GetHeight());
self.SelectedLeft:SetHeight(buttonHeight - self.SelectedCornerTopLeft:GetHeight() - self.SelectedCornerBottomLeft:GetHeight());
self.SelectedRight:SetHeight(buttonHeight - self.SelectedCornerTopRight:GetHeight() - self.SelectedCornerBottomRight:GetHeight());
self.HoverLeft:SetHeight(buttonHeight - self.HoverCornerTopLeft:GetHeight() - self.HoverCornerBottomLeft:GetHeight());
self.HoverRight:SetHeight(buttonHeight - self.HoverCornerTopRight:GetHeight() - self.HoverCornerBottomRight:GetHeight());
self.ApplyButton:Hide();
self.AddButton:Hide();
self.RemoveButton:Hide();
end
function OutfitsTransmogButtonMixin:OpenVariantSetsDropDown()
local selectedSetID = self.setID;
if ( not selectedSetID ) then
return;
end
local info = UIDropDownMenu_CreateInfo();
local baseSetID = DP:C_GetBaseSetID(selectedSetID);
local variantSets = DP:GetVariantSets(baseSetID);
for i = 1, #variantSets do
local variantSet = variantSets[i];
local numSourcesCollected, numSourcesTotal = DP:GetSetSourceCounts(variantSet.setID);
local colorCode = U.IN_PROGRESS_FONT_COLOR_CODE;
if ( numSourcesCollected == numSourcesTotal ) then
colorCode = NORMAL_FONT_COLOR_CODE;
elseif ( numSourcesCollected == 0 ) then
colorCode = GRAY_FONT_COLOR_CODE;
end
info.text = format(ITEM_SET_NAME, variantSet.description..colorCode, numSourcesCollected, numSourcesTotal);
info.checked = (variantSet.setID == selectedSetID);
info.func = function() self:SelectSet(variantSet.setID); end;
UIDropDownMenu_AddButton(info);
end
end
function OutfitsTransmogButtonMixin:SelectSet(setID)
local baseSetID = DP:C_GetBaseSetID(setID);
local variantSets = DP:GetVariantSets(baseSetID);
if ( #variantSets > 0 ) then
self:GetParent():GetParent():GetParent().selectedVariantSets[baseSetID] = setID;
end
self:GetParent():GetParent():Update();
end
function OutfitsTransmogButtonMixin:DisplayItems()
local currentSelectedSetID = self:GetParent():GetParent():GetParent():GetSelectedSetID()
local selectedBaseSetID = currentSelectedSetID and DP:C_GetBaseSetID(currentSelectedSetID)
local Model = _G["SetMasterTransmogModelFrame"];
local sources = DP:GetSortedSetSources(self.setID);
self.itemFramesPool:ReleaseAll();
for j = 1, #sources do
local itemFrame = self.itemFramesPool:Acquire();
itemFrame.sourceID = sources[j].sourceID;
local sourceInfo = C_TransmogCollection.GetSourceInfo(sources[j].sourceID);
itemFrame.itemID = sourceInfo.itemID;
itemFrame.collected = sourceInfo.isCollected;
itemFrame.invType = sourceInfo.invType;
itemFrame.visualID = sourceInfo.visualID;
local texture = C_TransmogCollection.GetSourceIcon(sources[j].sourceID);
itemFrame.Icon:SetTexture(texture);
itemFrame:Show();
---@diagnostic disable-next-line: undefined-field
itemFrame.Red:SetShown(sourceInfo.useError ~= nil and sourceInfo.isCollected);
itemFrame.Red:SetAlpha(0.45)
local equippedVisual = DP:GetEquippedVisual(C_Transmog.GetSlotForInventoryType(itemFrame.invType));
local pendingVisual, hasUndo = DP:GetPendingVisual(C_Transmog.GetSlotForInventoryType(itemFrame.invType));
local undoThisItem = hasUndo and equippedVisual == itemFrame.visualID;
itemFrame.StatusBorder:SetShown(itemFrame.visualID == equippedVisual and not hasUndo);
itemFrame.Glow:SetShown(itemFrame.visualID == pendingVisual or undoThisItem);
itemFrame.Ants:SetShown(itemFrame.visualID == pendingVisual or undoThisItem);
itemFrame.Undo:SetShown(undoThisItem);
if ( sourceInfo.isCollected ) then
itemFrame.Icon:SetDesaturated(false);
itemFrame.Icon:SetAlpha(1);
itemFrame.IconBorder:SetDesaturation(0);
itemFrame.IconBorder:SetAlpha(1);
local transmogSlot = C_Transmog.GetSlotForInventoryType(itemFrame.invType);
if ( DP:C_SetHasNewSourcesForSlot(self.setID, transmogSlot) ) then
itemFrame.New:Show();
itemFrame.New.Anim:Play();
else
itemFrame.New:Hide();
itemFrame.New.Anim:Stop();
end
else
itemFrame.Icon:SetDesaturated(true);
itemFrame.Icon:SetAlpha(0.3);
itemFrame.IconBorder:SetDesaturation(1);
itemFrame.IconBorder:SetAlpha(0.3);
itemFrame.New:Hide();
end
self:SetItemFrameQuality(itemFrame)
if (self.baseSetID ~= selectedBaseSetID) then
local FRAME_SIZE = 19;
itemFrame:SetScript("OnEnter", nil);
itemFrame:EnableMouse(false)
itemFrame:SetPoint("TOPLEFT", self.Name, "BOTTOMLEFT", (j-1) * (FRAME_SIZE + 1), -2);
itemFrame:SetSize(FRAME_SIZE,FRAME_SIZE)
itemFrame.IconBorder:ClearAllPoints();
itemFrame.IconBorder:SetPoint("TOPLEFT", itemFrame.Icon, "TOPLEFT", -4, 4)
itemFrame.IconBorder:SetPoint("BOTTOMRIGHT", itemFrame.Icon, "BOTTOMRIGHT", 4, -4)
itemFrame.IconBorder:SetSize(FRAME_SIZE,FRAME_SIZE)
itemFrame.Icon:SetSize(FRAME_SIZE - 4, FRAME_SIZE - 4);
itemFrame.StatusBorder:SetSize(FRAME_SIZE + 14, FRAME_SIZE + 15);
itemFrame.Glow:SetSize(FRAME_SIZE + 14, FRAME_SIZE + 15);
itemFrame.Ants:SetSize(FRAME_SIZE + 5, FRAME_SIZE + 6);
else
local FRAME_SIZE = 26;
itemFrame:EnableMouse(true)
itemFrame:SetScript("OnEnter", TransmogItemFrame_OnEnter);
itemFrame:SetPoint("TOPLEFT", self.Name, "BOTTOMLEFT", (j-1) * (FRAME_SIZE + 1), -2);
itemFrame:SetSize(FRAME_SIZE, FRAME_SIZE)
itemFrame.IconBorder:ClearAllPoints();
itemFrame.IconBorder:SetPoint("TOPLEFT", itemFrame.Icon, "TOPLEFT", -4, 4)
itemFrame.IconBorder:SetPoint("BOTTOMRIGHT", itemFrame.Icon, "BOTTOMRIGHT", 4, -4)
itemFrame.IconBorder:SetSize(FRAME_SIZE, FRAME_SIZE)
itemFrame.Icon:SetSize(FRAME_SIZE - 4, FRAME_SIZE - 4);
itemFrame.StatusBorder:SetSize(FRAME_SIZE, FRAME_SIZE);
itemFrame.StatusBorder:SetSize(FRAME_SIZE + 14, FRAME_SIZE + 15);
itemFrame.Glow:SetSize(FRAME_SIZE + 14, FRAME_SIZE + 15);
itemFrame.Ants:SetSize(FRAME_SIZE + 5, FRAME_SIZE + 6);
end
end
end
OutfitsTransmogButtonModelMixin = {};
function OutfitsTransmogButtonModelMixin:OnLoad()
self:RegisterEvent("UI_SCALE_CHANGED");
self:RegisterEvent("DISPLAY_SIZE_CHANGED");
self:SetScript("OnEnter", nil);
self:SetScript("OnLeave", nil);
self:SetScript("OnHide", nil);
self:EnableMouse(false);
self:SetAutoDress(false);
self.Border:ClearAllPoints();
self.Border:SetPoint("TOPLEFT", -20, 8);
self.Border:SetPoint("BOTTOMRIGHT", 18, -25);
self:SetUnit("player");
self:FreezeAnimation(0, 0, 0);
local x, y, z = self:TransformCameraSpaceToModelSpace(0.7, 0, 0);
self:SetPosition(x, y, z);
self:SetLight(true, false, -1, 1, -1, 1, 1, 1, 1, 0, 1, 1, 1);
end
function OutfitsTransmogButtonModelMixin:OnEvent()
self:RefreshCamera();
local x, y, z = self:TransformCameraSpaceToModelSpace(0.7, 0, 0);
self:SetPosition(x, y, z);
end
function OutfitsTransmogButtonModelMixin:OnModelLoaded()
if ( self.cameraID ) then
Model_ApplyUICamera(self, self.cameraID);
end
end
function OutfitsTransmogButtonModelMixin:OnShow()
self:SetFrameStrata("HIGH");
local sources = DP:GetSortedSetSources(self.setID or self:GetParent().setID);
local uiScale, x, y = UIParent:GetEffectiveScale(), GetCursorPosition();
self:ClearAllPoints();
self:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", (x / uiScale) + 2, (y / uiScale) + 2)
for i = 1, #sources do
self:TryOn(sources[i].sourceID)
end
self:RefreshCamera();
end
function OutfitsTransmogButtonModelMixin:OnUpdate()
local uiScale, x, y = self:GetEffectiveScale(), GetCursorPosition();
self:ClearAllPoints();
self:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMLEFT", (x / uiScale) - 2, (y / uiScale) + 2)
end
SetMasterItemTransmogFrameMixin = {};
function SetMasterItemTransmogFrameMixin:OnShow()
local itemFrame = GetMouseFocus();
if (not itemFrame or not itemFrame.invType) then
return;
end
self.oldslot = self.slot;
local slotType = C_Transmog.GetSlotForInventoryType(itemFrame.invType);
self.slot = TransmogUtil.CreateTransmogLocation(slotType, Enum.TransmogType.Appearance, Enum.TransmogModification.None);
self:ChangeModelsSlot();
if ( self.needsReload ) then
self:Reload(self.slot);
end
if (self.slot:IsEitherHand()) then
self:SetItem(itemFrame.itemID);
else
self:TryOn(itemFrame.sourceID);
end
self.cameraID = C_TransmogCollection.GetAppearanceCameraIDBySource(itemFrame.sourceID);
Model_ApplyUICamera(self, self.cameraID);
end
function SetMasterItemTransmogFrameMixin:ChangeModelsSlot()
local undressSlot, reloadModel;
local newSlotIsArmor = self.slot:GetArmorCategoryID();
local oldSlotName = self.oldSlot and self.oldSlot:GetSlotName();
local newSlotName = self.slot and self.slot:GetSlotName();
if (newSlotIsArmor) then
local oldSlotIsArmor = self.OldSlot and self.oldSlot:GetArmorCategoryID();
if (oldSlotIsArmor) then
if(SETMASTER_WARDROBE_MODEL_SETUP[oldSlotName].useTransmogSkin ~= SETMASTER_WARDROBE_MODEL_SETUP[newSlotName].useTransmogSkin) then
reloadModel = true;
else
undressSlot = true;
end
else
reloadModel = true;
end
end
if (reloadModel and not IsUnitModelReadyForUI("player")) then
self:ClearModel();
return;
end
if (undressSlot) then
local changedOldSlot = false;
for slot, equip in pairs(SETMASTER_WARDROBE_MODEL_SETUP[newSlotName].slots) do
if (equip ~= SETMASTER_WARDROBE_MODEL_SETUP[oldSlotName].slots[newSlotName]) then
if (equip) then
self:TryOn(SETMASTER_WARDROBE_MODEL_SETUP_GEAR(newSlotName));
else
self:UndressSlot(GetInventorySlotInfo(newSlotName));
end
if (newSlotName == oldSlotName) then
changedOldSlot = true;
end
end
end
if (not changedOldSlot) then
local slotID = GetInventorySlotInfo(oldSlotName);
self:UndressSlot(slotID);
end
elseif (reloadModel) then
self:Reload();
end
self.visualInfo= nil;
self.illusionWeaponID = nil;
end
function SetMasterItemTransmogFrameMixin:Reload()
local slot = self.slot:GetSlotName();
if (self:IsShown()) then
if (SETMASTER_WARDROBE_MODEL_SETUP[slot]) then
self:SetUseTransmogSkin(SETMASTER_WARDROBE_MODEL_SETUP[slot].useTransmogSkin);
self:SetUnit("player", false);
self:SetDoBlend(false);
for itemSlot, equip in pairs(SETMASTER_WARDROBE_MODEL_SETUP[slot].slots) do
if (equip) then
self:TryOn(SETMASTER_WARDROBE_MODEL_SETUP_GEAR[itemSlot]);
end
end
end
self:SetKeepModelOnHide(true);
self.cameraID = nil;
self.needsReload = nil;
else
self.needsReload = true;
end
end
function TransmogItemFrame_OnMouseDown(self, button)
if (not self.invType) then
return;
end
if (self.collected) then
local transmogLocation = TransmogUtil.CreateTransmogLocation(C_Transmog.GetSlotForInventoryType(self.invType), Enum.TransmogType.Appearance, Enum.TransmogModification.None)
local isTransmogrified, hasPending = C_Transmog.GetSlotInfo(transmogLocation);
if (button == "LeftButton") then
C_Transmog.SetPending(transmogLocation, self.sourceID);
elseif (button == "RightButton") then
if(hasPending) then
C_Transmog.ClearPending(transmogLocation);
elseif(isTransmogrified) then
C_Transmog.SetPending(transmogLocation, 0);
end
end
end
end
function ApplyButton_OnMouseDown(self)
if (not self:IsEnabled()) then
return;
end
local itemFrames = self:GetParent().itemFramesPool;
C_Transmog.ClearAllPending();
for itemFrame in itemFrames:EnumerateActive() do
local transmogLocation = TransmogUtil.CreateTransmogLocation(
C_Transmog.GetSlotForInventoryType(itemFrame.invType),
Enum.TransmogType.Appearance,
Enum.TransmogModification.None);
if (itemFrame.collected) then
C_Transmog.SetPending(transmogLocation, itemFrame.sourceID);
end
end
local cost = C_Transmog.GetCost();
local variants = "";
if (self:GetParent().VariantSetsButton:IsShown()) then
variants = " ("..self:GetParent().VariantSetsButton:GetText()..")";
end
local check = CreateFrame("CheckButton", "SetMastercheckButton", UIParent, "UICheckButtonTemplate");
---@diagnostic disable-next-line: undefined-field
check.text:SetText("Do not show again");
if (not SM.db.char.acceptedTransmogMoneyRisk) then
StaticPopup_Show("SETMASTER_APPLY_SET", self:GetParent().Name:GetText()..variants, GetCoinTextureString(cost), nil, check);
else
C_Transmog.ApplyAllPending();
end
end
function AddButton_OnMouseDown(self)
if (not self:IsEnabled()) then
return;
end
local itemFrames = self:GetParent().itemFramesPool;
for itemFrame in itemFrames:EnumerateActive() do
local transmogLocation = TransmogUtil.CreateTransmogLocation(
C_Transmog.GetSlotForInventoryType(itemFrame.invType),
Enum.TransmogType.Appearance,
Enum.TransmogModification.None)
if (itemFrame.collected) then
C_Transmog.SetPending(transmogLocation, itemFrame.sourceID);
end
end
end
function RemoveButton_OnMouseDown(self)
if (not self:IsEnabled()) then
return;
end
local itemFrames = self:GetParent().itemFramesPool;
for itemFrame in itemFrames:EnumerateActive() do
local transmogLocation = TransmogUtil.CreateTransmogLocation(
C_Transmog.GetSlotForInventoryType(itemFrame.invType),
Enum.TransmogType.Appearance,
Enum.TransmogModification.None)
if (itemFrame.collected) then
if (IsShiftKeyDown()) then
if (DP:GetEquippedVisual(C_Transmog.GetSlotForInventoryType(itemFrame.invType)) == itemFrame.visualID) then
C_Transmog.SetPending(transmogLocation, 0);
end
else
C_Transmog.ClearPending(transmogLocation);
end
end
end
end