-
Notifications
You must be signed in to change notification settings - Fork 3
/
CaerdonWardrobe.lua
1150 lines (973 loc) · 36.8 KB
/
CaerdonWardrobe.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
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
-- EQUIPPED_LAST=500 -- TODO: Temp fix for bag opening
local DEBUG_ENABLED = false
-- local DEBUG_ITEM = 82800
local ADDON_NAME, NS = ...
local L = NS.L
BINDING_HEADER_CAERDON = L["Caerdon Addons"]
BINDING_NAME_COPYMOUSEOVERLINK = L["Copy Mouseover Link"]
BINDING_NAME_PRINTMOUSEOVERLINKDETAILS = L["Print Mouseover Link Details"]
local availableFeatures = {}
local registeredFeatures = {}
CaerdonWardrobeMixin = {}
function CaerdonWardrobeMixin:OnLoad()
-- AddonCompartmentFrame:RegisterAddon({
-- text = 'Caerdon Wardrobe',
-- func = function ()
-- print("Do your thing here")
-- end,
-- icon = "Interface\\Store\\category-icon-featured"
-- })
self.waitingToProcess = {}
self:RegisterEvent "ADDON_LOADED"
self:RegisterEvent "PLAYER_LOGOUT"
self:RegisterEvent "PLAYER_ENTERING_WORLD"
self:RegisterEvent "TRANSMOG_COLLECTION_UPDATED"
self:RegisterEvent "EQUIPMENT_SETS_CHANGED"
self:RegisterEvent "UPDATE_EXPANSION_LEVEL"
self:RegisterEvent "VARIABLES_LOADED"
hooksecurefunc("EquipPendingItem", function(...) self:OnEquipPendingItem(...) end)
hooksecurefunc(BankFrame, "UpdateSearchResults", function(...) self:OnContainerFrameUpdateSearchResults(...) end)
end
local function OpenCloseTradeSkill()
-- TODO: Can open via book frame or from trade skill API. Having what appears to be cache clear happening for cooking recipes
-- so keeping some opening options around in case I find a way to force it to keep them around
-- ToggleFrame(ProfessionsBookFrame)
-- _G["SecondaryProfession1SpellButtonRight"]:Click()
-- ToggleFrame(ProfessionsBookFrame)
-- _G["PrimaryProfession1SpellButtonBottom"]:Click()
-- _G["PrimaryProfession2SpellButtonBottom"]:Click()
-- _G["SecondaryProfession1SpellButtonRight"]:Click()
-- _G["SecondaryProfession2SpellButtonRight"]:Click()
-- _G["SecondaryProfession2SpellButtonRight"]:Click()
-- _G["SecondaryProfession3SpellButtonRight"]:Click()
-- Retrieve player's professions
local prof1, prof2, archaeology, fishing, cooking = GetProfessions()
-- Get information about the first profession
local professionID = nil
if prof1 then
local name, _, _, _, _, _, skillLineID = GetProfessionInfo(prof1)
professionID = skillLineID
elseif prof2 then
local name, _, _, _, _, _, skillLineID = GetProfessionInfo(prof2)
professionID = skillLineID
end
-- local professionInfo = C_TradeSkillUI.GetProfessionInfoBySkillLineID(professionID)
-- EventRegistry:TriggerEvent("Professions.SelectSkillLine", professionInfo)
if cooking then
local name, _, skillLevel, maxSkillLevel, _, _, skillLineID = GetProfessionInfo(cooking)
C_TradeSkillUI.OpenTradeSkill(skillLineID)
else
C_TradeSkillUI.OpenTradeSkill(professionID)
end
-- Cooking doesn't seem to fully process the recipe data if you don't pump the frame first.
-- TODO: This has the side-effect of slightly showing the window... would be nice to not do that.
C_Timer.After(0, function()
C_TradeSkillUI.CloseTradeSkill()
end)
end
function CaerdonWardrobeMixin:CreateTradeSkillDialog()
local playerName = UnitName("player")
local realmName = GetRealmName()
if not self:IsTradeSkillDataLoaded() then
if CaerdonRecipeData and CaerdonRecipeData.globalRecipeNameToID and CaerdonProfessionData and CaerdonProfessionData[realmName] and CaerdonProfessionData[realmName][playerName] then
if next(CaerdonRecipeData.globalRecipeNameToID) ~= nil and next(CaerdonProfessionData[realmName][playerName]) ~= nil then
-- Cached recipe data is already available
return
end
end
if CaerdonWardrobeConfig.LoadBehavior.ShowProfessionLoad then
-- Create a frame for the dialog
local dialog = CreateFrame("Frame", "TradeSkillDialog", UIParent, "BasicFrameTemplateWithInset")
dialog:SetSize(350, 130) -- Set the size of the dialog
dialog:SetPoint("CENTER") -- Position the dialog in the center of the screen
-- Create a title for the dialog
dialog.title = dialog:CreateFontString(nil, "OVERLAY")
dialog.title:SetFontObject("GameFontHighlight")
dialog.title:SetPoint("TOP", dialog, "TOP", 0, -6)
dialog.title:SetText(L["Caerdon: Load Profession Info"])
-- Make the dialog movable
dialog:SetMovable(true)
dialog:EnableMouse(true)
dialog:RegisterForDrag("LeftButton")
dialog:SetScript("OnDragStart", dialog.StartMoving)
dialog:SetScript("OnDragStop", dialog.StopMovingOrSizing)
-- Create an explanatory text with wrapping
dialog.text = dialog:CreateFontString(nil, "OVERLAY", "GameFontNormal")
dialog.text:SetPoint("TOPLEFT", dialog, "TOPLEFT", 13, -20)
dialog.text:SetPoint("RIGHT", dialog, "RIGHT", -10, 0)
dialog.text:SetText(L["\nProfession data not yet evaluated - make sure to open up each of your professions to allow Caerdon to retrieve and store it. You should only need to do this once per toon."])
dialog.text:SetJustifyH("LEFT") -- Align text to the left
dialog.text:SetWidth(280) -- Set width for wrapping
-- Create the button
dialog.button = CreateFrame("Button", nil, dialog, "UIPanelButtonTemplate")
dialog.button:SetSize(120, 30)
dialog.button:SetText(L["Got it!"])
dialog.button:SetPoint("BOTTOM", dialog, "BOTTOM", 0, 10)
-- Set button click script
dialog.button:SetScript("OnClick", function()
-- Open and close the tradeskill window for the first profession found
OpenCloseTradeSkill()
-- Hide the dialog after clicking
dialog:UnregisterEvent("PLAYER_REGEN_DISABLED")
dialog:UnregisterEvent("PLAYER_REGEN_ENABLED")
dialog:Hide()
end)
local caerdon = self -- store off for dialog event
-- Hide dialog during combat
dialog:RegisterEvent("PLAYER_REGEN_DISABLED")
dialog:RegisterEvent("PLAYER_REGEN_ENABLED")
dialog:SetScript("OnEvent", function(self, event)
if event == "PLAYER_REGEN_DISABLED" then
self:Hide() -- Hide the dialog when entering combat
elseif event == "PLAYER_REGEN_ENABLED" then
if CaerdonWardrobeConfig.LoadBehavior.ShowProfessionLoad then
if not caerdon:IsTradeSkillDataLoaded() then
self:Show() -- Show the dialog again when leaving combat if data isn't loaded
end
end
end
end)
dialog.CloseButton:SetScript("OnClick", function()
dialog:UnregisterEvent("PLAYER_REGEN_DISABLED")
dialog:UnregisterEvent("PLAYER_REGEN_ENABLED")
dialog:Hide()
end)
if not InCombatLockdown() then
dialog:Show()
else
dialog:Hide()
end
end
end
end
-- Function to check if tradeskill data is already loaded
function CaerdonWardrobeMixin:IsTradeSkillDataLoaded()
local lines = C_TradeSkillUI.GetAllProfessionTradeSkillLines()
local lineIndex
for lineIndex = 1, #lines do
local professionInfo = C_TradeSkillUI.GetProfessionInfoBySkillLineID(lines[lineIndex])
if professionInfo.skillLevel and professionInfo.skillLevel > 0 then
return true
end
end
return false
end
-- TODO: Pretty sure I don't need to do this... get setID from GetItemInfo?
local function IsGearSetStatus(status, item)
return status and status ~= "" and status ~= L["BoA"] and status ~= L["BoE"]
end
local ICON_PROMINENT_SIZE = 20
local ICON_SIZE_DIFFERENTIAL = 0.8
function CaerdonWardrobeMixin:SetStatusIconPosition(icon, button, item, feature, locationInfo, options, mogStatus, bindingStatus)
if not item then return end
-- Scaling values if the icon is different than prominent-sized
local iconWidth, iconHeight = icon:GetSize()
local xAdjust = iconWidth / ICON_PROMINENT_SIZE
local yAdjust = iconHeight / ICON_PROMINENT_SIZE
local statusScale = options.statusScale or 1
local statusPosition = options.overrideStatusPosition or CaerdonWardrobeConfig.Icon.Position
local xOffset = 4 * xAdjust
if statusPosition == "TOP" or statusPosition == "BOTTOM" then
xOffset = 0
end
if options.statusOffsetX ~= nil then
xOffset = options.statusOffsetX
end
local yOffset = 4 * yAdjust
if statusPosition == "LEFT" or statusPosition == "RIGHT" then
yOffset = 0
end
if options.statusOffsetY ~= nil then
yOffset = options.statusOffsetY
end
if string.find(statusPosition, "TOP") then
yOffset = yOffset * -1
end
if string.find(statusPosition, "RIGHT") then
xOffset = xOffset * -1
end
local xBackgroundOffset = 0
if options.statusBackgroundOffsetX ~= nil then
xBackgroundOffset = options.statusBackgroundOffsetX
end
local yBackgroundOffset = 0
if options.statusBackgroundOffsetY ~= nil then
yBackgroundOffset = options.statusBackgroundOffsetY
end
if not options.fixedStatusPosition then
local background = icon.mogStatusBackground
if background then
background:ClearAllPoints()
background:SetPoint("CENTER", button.caerdonButton, statusPosition, xOffset + xBackgroundOffset, yOffset + yBackgroundOffset)
end
icon:ClearAllPoints()
icon:SetPoint("CENTER", button.caerdonButton, statusPosition, xOffset, yOffset)
end
end
function CaerdonWardrobeMixin:AddRotation(group, order, degrees, duration, smoothing, startDelay, endDelay)
local anim = group:CreateAnimation("Rotation")
group["anim" .. order] = anim
anim:SetDegrees(degrees)
anim:SetDuration(duration)
anim:SetOrder(order)
anim:SetSmoothing(smoothing)
if startDelay then
anim:SetStartDelay(startDelay)
end
if endDelay then
anim:SetEndDelay(endDelay)
end
end
function CaerdonWardrobeMixin:SetItemButtonMogStatusFilter(originalButton, isFiltered)
local button = originalButton.caerdonButton
if button then
local mogStatus = button.mogStatus
if mogStatus then
local mogStatusBackground = mogStatus.mogStatusBackground
if isFiltered then
mogStatusBackground:SetAlpha(0.3)
mogStatus:SetAlpha(0.3)
else
mogStatusBackground:SetAlpha(mogStatus.assignedAlpha)
mogStatus:SetAlpha(mogStatus.assignedAlpha)
end
end
local bindsOnText = button.bindsOnText
if bindsOnText then
if isFiltered then
bindsOnText:SetAlpha(0.3)
else
bindsOnText:SetAlpha(1.0)
end
end
end
end
function CaerdonWardrobeMixin:SetupCaerdonButton(originalButton, item, feature, locationInfo, options)
local button = originalButton.caerdonButton
if not button then
button = CreateFrame("Frame", nil, originalButton)
button.searchOverlay = originalButton.searchOverlay
originalButton.caerdonButton = button
end
if not button.mogStatus then
mogStatusBackground = button:CreateTexture(nil, "ARTWORK", nil, 1)
mogStatus = button:CreateTexture(nil, "ARTWORK", nil, 2)
mogStatus.mogStatusBackground = mogStatusBackground
button.mogStatus = mogStatus
end
if not button.bindsOnText then
button.bindsOnText = button:CreateFontString(nil, "ARTWORK", "SystemFont_Outline_Small") -- TODO: Note: placing directly on button to enable search fade - need to check on other addons
end
end
function CaerdonWardrobeMixin:SetItemButtonStatus(originalButton, item, feature, locationInfo, options, status, bindingStatus)
local button = originalButton.caerdonButton
-- Make sure it's sitting in front of the frame it's going to overlay
local levelCheckFrame = originalButton
if options and options.relativeFrame then
if options.relativeFrame:GetObjectType() == "Texture" then
levelCheckFrame = options.relativeFrame:GetParent()
else
levelCheckFrame = options.relativeFrame
end
end
if levelCheckFrame then
button:SetFrameStrata(levelCheckFrame:GetFrameStrata())
button:SetFrameLevel(levelCheckFrame:GetFrameLevel() + 1)
end
button:ClearAllPoints()
button:SetSize(0,0)
if options and options.relativeFrame then
button:SetAllPoints(options.relativeFrame)
else
button:SetAllPoints(originalButton)
end
-- Had some addons messing with frame level resulting in this getting covered by the parent button.
-- Haven't seen any negative issues with bumping it up, yet, but keep an eye on it if
-- the status icon overlaps something it shouldn't.
-- NOTE: Added logic above that hopefully addresses this more sanely...
-- button:SetFrameLevel(originalButton:GetFrameLevel() + 100)
local iconBackgroundAdjustment = 0
local mogStatus = button.mogStatus
local mogStatusBackground
if mogStatus then
mogStatusBackground = mogStatus.mogStatusBackground
end
local mogAnim = button.mogAnim
if not options then
options = {}
end
if not status then
if mogAnim and mogAnim:IsPlaying() then
mogAnim:Stop()
end
end
-- local mogFlash = button.mogFlash
-- if not mogFlash then
-- mogFlash = button:CreateTexture(nil, "OVERLAY")
-- mogFlash:SetAlpha(0)
-- mogFlash:SetBlendMode("ADD")
-- mogFlash:SetAtlas("bags-glow-flash", true)
-- mogFlash:SetPoint("CENTER")
-- button.mogFlash = mogFlash
-- end
local showAnim = false
if status == "waiting" then
showAnim = true
if mogAnim and not button.isWaitingIcon then
if mogAnim:IsPlaying() then
mogAnim:Finish()
end
mogAnim = nil
button.mogAnim = nil
button.isWaitingIcon = false
end
if not mogAnim or not button.isWaitingIcon then
mogAnim = mogStatus:CreateAnimationGroup()
self:AddRotation(mogAnim, 1, 360, 0.5, "IN_OUT")
mogAnim:SetLooping("REPEAT")
button.mogAnim = mogAnim
button.isWaitingIcon = true
end
else
if status == "readyToCombine" or status == "own" or status == "ownPlus" or status == "otherSpec" or status == "otherSpecPlus" or status == "refundable" or status == "openable" or status == "locked" or status == "upgradeNonEquipment" or status == "readyToCombine" then
showAnim = true
if mogAnim and button.isWaitingIcon then
if mogAnim:IsPlaying() then
mogAnim:Finish()
end
mogAnim = nil
button.mogAnim = nil
button.isWaitingIcon = false
end
if not mogAnim then
mogAnim = mogStatus:CreateAnimationGroup()
if status == "readyToCombine" then
self:AddRotation(mogAnim, 1, 360, 0.75, "NONE")
else
self:AddRotation(mogAnim, 1, 110, 0.2, "OUT")
self:AddRotation(mogAnim, 2, -155, 0.2, "OUT")
self:AddRotation(mogAnim, 3, 60, 0.2, "OUT")
self:AddRotation(mogAnim, 4, -15, 0.1, "OUT", 0, 2)
end
mogAnim:SetLooping("REPEAT")
button.mogAnim = mogAnim
button.isWaitingIcon = false
end
else
showAnim = false
end
end
-- if not mogAnim then
-- mogAnim = button:CreateAnimationGroup()
-- mogAnim:SetToFinalAlpha(true)
-- mogAnim.alpha1 = mogAnim:CreateAnimation("Alpha")
-- mogAnim.alpha1:SetChildKey("mogFlash")
-- mogAnim.alpha1:SetSmoothing("OUT");
-- mogAnim.alpha1:SetDuration(0.6)
-- mogAnim.alpha1:SetOrder(1)
-- mogAnim.alpha1:SetFromAlpha(1);
-- mogAnim.alpha1:SetToAlpha(0);
-- button.mogAnim = mogAnim
-- end
local displayInfo
if feature then
displayInfo = feature:GetDisplayInfoInternal(button, item, feature, locationInfo, options, mogStatus, bindingStatus)
end
local alpha = 1
mogStatusBackground:SetVertexColor(1, 1, 1)
mogStatusBackground:SetTexture("")
mogStatusBackground:SetTexCoord(0, 1, 0, 1)
mogStatus:SetVertexColor(1, 1, 1)
mogStatus:SetTexture("")
mogStatus:SetTexCoord(0, 1, 0, 1)
local isProminent = false
-- TODO: Possible gear set indicators
-- MINIMAP / TempleofKotmogu_ball_cyan.PNG
-- TempleofKotmogu_ball_green.PNG
-- TempleofKotmogu_ball_orange.PNG
-- TempleofKotmogu_ball_purple.PNG
-- MINIMAP/TRACKING/OBJECTICONS.PNG
if item and item.extraData and item.extraData.recipeInfo then
-- TODO: Marking recipe skill ups here for now... need to figure out how to refactor
if item.extraData.recipeInfo.firstCraft then
iconBackgroundAdjustment = 2
mogStatusBackground:SetTexCoord(91/1024, (91+30)/1024, 987/1024, (987+30)/1024)
mogStatusBackground:SetTexture("Interface\\Store\\ServicesAtlas")
end
end
-- TODO: Add options to hide these statuses
if status == "refundable" then
alpha = 0.9
mogStatus:SetTexture("Interface\\COMMON\\mini-hourglass")
elseif status == "openable" then
isProminent = true
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-free")
elseif status == "readable" then
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-services")
elseif status == "lowSkill" or status == "lowSkillPlus" then
mogStatus:SetTexCoord(6/64, 58/64, 6/64, 58/64)
mogStatus:SetTexture("Interface\\WorldMap\\Gear_64Grey")
if status == "lowSkillPlus" then
mogStatus:SetVertexColor(0.4, 1, 0)
end
-- mogStatus:SetTexture("Interface\\QUESTFRAME\\SkillUp-BG")
-- mogStatus:SetTexture("Interface\\DialogFrame\\UI-Dialog-Icon-AlertNew")
-- mogStatus:SetTexture("Interface\\Buttons\\JumpUpArrow")
elseif status == "upgradeNonEquipment" then
isProminent = false
iconBackgroundAdjustment = 4
mogStatusBackground:SetTexCoord((512-46-31)/512, (512-31)/512, 5/512, (5+46)/512)
mogStatusBackground:SetTexture("Interface\\HUD\\UIUnitFrameBoss2x")
mogStatusBackground:SetVertexColor(0, 1, 1)
mogStatus:SetTexCoord(-1/32, 33/32, -1/32, 33/32)
mogStatus:SetTexture("Interface\\Buttons\\JumpUpArrow")
elseif status == "upgrade" then
isProminent = false
if displayInfo and displayInfo.upgradeIcon.shouldShow then
iconBackgroundAdjustment = 4
mogStatusBackground:SetTexCoord((512-46-31)/512, (512-31)/512, 5/512, (5+46)/512)
mogStatusBackground:SetTexture("Interface\\HUD\\UIUnitFrameBoss2x")
mogStatusBackground:SetVertexColor(0, 1, 1)
mogStatus:SetTexCoord(-1/32, 33/32, -1/32, 33/32)
mogStatus:SetTexture("Interface\\Buttons\\JumpUpArrow")
end
elseif status == "upgradeLowSkill" then
isProminent = false
if displayInfo and displayInfo.upgradeIcon.shouldShow then
iconBackgroundAdjustment = 4
mogStatusBackground:SetTexCoord((512-46-31)/512, (512-31)/512, 5/512, (5+46)/512)
mogStatusBackground:SetTexture("Interface\\HUD\\UIUnitFrameBoss2x")
mogStatusBackground:SetVertexColor(0.4, 1, 0)
mogStatus:SetTexCoord(-1/32, 33/32, -1/32, 33/32)
mogStatus:SetTexture("Interface\\Buttons\\JumpUpArrow")
mogStatus:SetVertexColor(0.4, 1, 0)
end
elseif status == "locked" then
isProminent = true
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-key")
elseif status == "oldexpansion" and displayInfo and displayInfo.oldExpansionIcon.shouldShow then
alpha = 0.9
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-wow")
elseif status == "needForProfession" then
-- TODO: Need to improve to pass data for icon determination.
isProminent = true
if displayInfo and displayInfo.ownIcon.shouldShow then
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-featured")
-- mogStatus:SetTexture("Interface\\WorldMap\\worldquest-icon-enchanting")
end
elseif status == "canCombine" then
-- isProminent = true
if displayInfo and displayInfo.ownIcon.shouldShow then -- TODO: Add separate config for combine icon
-- mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
-- mogStatus:SetTexture("Interface\\PaperDollInfoFrame\\Character-Plus")
-- mogStatus:SetTexture("Interface\\BUTTONS\\UI-PlusButton-Up")
-- options.statusProminentSize = 256
-- mogStatus:SetTexCoord((512-23)/512, (512-7)/512, (172-18)/512, (172-3)/512)
-- mogStatus:SetTexture("Interface\\QUESTFRAME\\WorldQuest")
mogStatus:SetTexCoord(91/1024, (91+30)/1024, 987/1024, (987+30)/1024)
mogStatus:SetTexture("Interface\\Store\\ServicesAtlas")
-- if status == "ownPlus" then
-- mogStatus:SetVertexColor(0.4, 1, 0)
-- end
end
elseif status == "readyToCombine" then
-- isProminent = true
if displayInfo and displayInfo.ownIcon.shouldShow then -- TODO: Add separate config for combine icon
-- alpha = 0.9
-- mogStatus:SetTexCoord((512-23)/512, (512-7)/512, 172/512, (172+15)/512)
-- mogStatus:SetTexture("Interface\\QUESTFRAME\\WorldQuest")
iconBackgroundAdjustment = 4
-- mogStatusBackground:SetTexCoord(455/512, (455+28)/512, 1/256, (1+28)/256)
-- mogStatusBackground:SetTexture("Interface\\Store\\Shop")
-- mogStatusBackground:SetTexCoord(180/512, (180+46)/512, 5/512, (5+46)/512)
mogStatusBackground:SetTexCoord((512-46-31)/512, (512-31)/512, 5/512, (5+46)/512)
mogStatusBackground:SetTexture("Interface\\HUD\\UIUnitFrameBoss2x")
-- mogStatusBackground:SetVertexColor(0, 1, 0)
mogStatusBackground:SetVertexColor(80/256, 252/256, 80/256, 253/256)
mogStatus:SetTexCoord(305/512, (305+116)/512, 141/512, (141+116)/512)
mogStatus:SetTexture("Interface\\Animations\\PowerSwirlAnimation")
-- mogStatus:SetVertexColor(0, 1, 0)
mogStatus:SetVertexColor(80/256, 252/256, 80/256, 253/256)
-- mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
-- mogStatus:SetTexture("Interface\\HELPFRAME\\ReportLagIcon-AuctionHouse")
-- if status == "ownPlus" then
-- mogStatus:SetVertexColor(0.4, 1, 0)
-- end
end
elseif status == "own" or status == "ownPlus" then
isProminent = true
if displayInfo and displayInfo.ownIcon.shouldShow then
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-featured")
if status == "ownPlus" then
mogStatus:SetVertexColor(0.4, 1, 0)
end
end
elseif status == "other" or status == "otherPlus" then
isProminent = true
if displayInfo and displayInfo.otherIcon.shouldShow then
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-placeholder")
if status == "otherPlus" then
mogStatus:SetVertexColor(0.4, 1, 0)
end
end
elseif status == "otherNoLoot" or status == "otherPlusNoLoot" then
if displayInfo and displayInfo.otherIcon.shouldShow then
iconBackgroundAdjustment = 0
options.statusBackgroundOffsetX = -0.5
options.statusBackgroundOffsetY = -0.5
mogStatusBackground:SetTexCoord((512-46-31)/512, (512-31)/512, 5/512, (5+46)/512)
mogStatusBackground:SetTexture("Interface\\HUD\\UIUnitFrameBoss2x")
mogStatus:SetVertexColor(1, 1, 0)
mogStatus:SetTexture("Interface\\Buttons\\UI-GroupLoot-Pass-Up")
if status == "otherPlusNoLoot" then
mogStatusBackground:SetVertexColor(0.4, 1, 0)
end
end
elseif status == "otherSpec" or status == "otherSpecPlus" then
isProminent = true
if displayInfo and displayInfo.otherIcon.shouldShow then
mogStatus:SetTexture("Interface\\COMMON\\icon-noloot")
if status == "otherSpecPlus" then
mogStatus:SetVertexColor(0.4, 1, 0)
end
end
elseif status == "quest" and displayInfo and displayInfo.questIcon.shouldShow then
mogStatus:SetTexCoord(-1/32, 33/32, -1/32, 33/32)
mogStatus:SetTexture("Interface\\MINIMAP\\MapQuestHub_Icon32")
elseif status == "collected" then
if IsGearSetStatus(bindingStatus, item) and CaerdonWardrobeConfig.Binding.ShowGearSetsAsIcon then
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-clothes")
end
elseif status == "sellable" then
if displayInfo and displayInfo.sellableIcon.shouldShow then -- it's known and can be sold
alpha = 0.9
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Store\\category-icon-bag")
end
elseif status == "waiting" then
alpha = 0.5
mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
mogStatus:SetTexture("Interface\\Common\\StreamCircle")
-- elseif IsGearSetStatus(bindingStatus, item) and CaerdonWardrobeConfig.Binding.ShowGearSetsAsIcon then
-- mogStatus:SetTexCoord(16/64, 48/64, 16/64, 48/64)
-- mogStatus:SetTexture("Interface\\Store\\category-icon-clothes")
end
local iconSize = ICON_PROMINENT_SIZE
if options.statusProminentSize then
iconSize = options.statusProminentSize
end
if isProminent then
mogStatusBackground:SetSize(iconSize, iconSize)
mogStatus:SetSize(iconSize - iconBackgroundAdjustment, iconSize - iconBackgroundAdjustment)
else
iconSize = iconSize * ICON_SIZE_DIFFERENTIAL
mogStatusBackground:SetSize(iconSize, iconSize)
mogStatus:SetSize(iconSize - iconBackgroundAdjustment, iconSize - iconBackgroundAdjustment)
end
self:SetStatusIconPosition(mogStatus, originalButton, item, feature, locationInfo, options, status, bindingStatus)
mogStatusBackground:SetAlpha(alpha)
mogStatus:SetAlpha(alpha)
mogStatus.assignedAlpha = alpha
C_Timer.After(0, function()
if(button.searchOverlay and button.searchOverlay:IsShown()) then
mogStatusBackground:SetAlpha(0.3)
mogStatus:SetAlpha(0.3)
end
end)
if options.isFiltered then
if options.filterColor then
mogStatus:SetDesaturated(true)
mogStatus:SetVertexColor(options.filterColor:GetRGB())
else
mogStatusBackground:SetAlpha(0.3)
mogStatus:SetAlpha(0.3)
end
else
mogStatus:SetDesaturated(false)
end
if showAnim and CaerdonWardrobeConfig.Icon.EnableAnimation then
if mogAnim and not mogAnim:IsPlaying() then
mogAnim:Play()
end
else
if mogAnim and mogAnim:IsPlaying() then
mogAnim:Finish()
end
end
end
function CaerdonWardrobeMixin:SetItemButtonBindType(button, item, feature, locationInfo, options, mogStatus, bindingStatus)
local caerdonButton = button.caerdonButton
local bindsOnText = caerdonButton and caerdonButton.bindsOnText
if bindsOnText then
bindsOnText:SetText("")
end
if not feature then return end
local displayInfo = feature:GetDisplayInfoInternal(button, item, feature, locationInfo, options, mogStatus, bindingStatus)
if not bindingStatus or not displayInfo.bindingStatus.shouldShow then
return
end
local bindingText = ""
if IsGearSetStatus(bindingStatus, item) then -- is gear set
if CaerdonWardrobeConfig.Binding.ShowGearSets then
bindingText = "|cFFFFFFFF" .. bindingStatus .. "|r"
end
else
if mogStatus == "own" then
if bindingStatus == L["BoA"] then
local color = BAG_ITEM_QUALITY_COLORS[Enum.ItemQuality.Heirloom]
bindsOnText:SetTextColor(color.r, color.g, color.b, 1)
bindingText = bindingStatus
elseif bindingStatus then
bindingText = "|cFF00FF00" .. bindingStatus .. "|r"
end
elseif mogStatus == "other" then
bindingText = "|cFFFF0000" .. bindingStatus .. "|r"
elseif mogStatus == "collected" then
if bindingStatus == L["BoA"] then
local color = BAG_ITEM_QUALITY_COLORS[Enum.ItemQuality.Heirloom]
bindsOnText:SetTextColor(color.r, color.g, color.b, 1)
bindingText = bindingStatus
elseif bindingStatus == L["BoE"] then
bindingText = "|cFF00FF00" .. bindingStatus .. "|r"
else
bindingText = bindingStatus
end
else
if bindingStatus == L["BoA"] then
local color = BAG_ITEM_QUALITY_COLORS[Enum.ItemQuality.Heirloom]
bindsOnText:SetTextColor(color.r, color.g, color.b, 1)
bindingText = bindingStatus
elseif bindingStatus then
bindingText = "|cFF00FF00" .. bindingStatus .. "|r"
end
end
end
bindsOnText:SetText(bindingText)
-- Measure text and resize accordingly
bindsOnText:ClearAllPoints()
bindsOnText:SetSize(0,0)
bindsOnText:SetPoint("LEFT")
bindsOnText:SetPoint("RIGHT")
local newWidth = bindsOnText:GetStringWidth()
if newWidth > button:GetWidth() then
newWidth = button:GetWidth()
end
local newHeight = bindsOnText:GetHeight()
bindsOnText:ClearAllPoints()
bindsOnText:SetSize(newWidth, newHeight)
local bindingScale = options.bindingScale or 1
local bindingPosition = options.overrideBindingPosition or CaerdonWardrobeConfig.Binding.Position
local xOffset = 1
if options.bindingOffsetX ~= nil then
xOffset = options.bindingOffsetX
end
local yOffset = 2
if options.bindingOffsetY ~= nil then
yOffset = options.bindingOffsetY
end
local hasCount = (button.count and button.count > 1) or options.hasCount
if string.find(bindingPosition, "BOTTOM") then
if hasCount then
yOffset = options.itemCountOffset or 15
end
end
if string.find(bindingPosition, "TOP") then
yOffset = yOffset * -1
end
if string.find(bindingPosition, "RIGHT") then
xOffset = xOffset * -1
end
if options and options.relativeFrame then
bindsOnText:SetAllPoints(options.relativeFrame, xOffset, yOffset)
else
bindsOnText:SetPoint(bindingPosition, xOffset, yOffset)
end
if(options.bindingScale) then
bindsOnText:SetScale(options.bindingScale)
end
end
function CaerdonWardrobeMixin:ProcessItem(button, item, feature, locationInfo, options)
local mogStatus = nil
local bindingStatus = nil
local bindingResult = nil
if not options then
options = {}
end
local caerdonType = item:GetCaerdonItemType()
local itemData = item:GetItemData()
isReady, mogStatus, bindingStatus, bindingResult = item:GetCaerdonStatus(feature, locationInfo)
if not isReady then
self:UpdateButton(button, item, feature, locationInfo, options)
return
end
if caerdonType == CaerdonItemType.Equipment then
local transmogInfo = itemData:GetTransmogInfo()
if transmogInfo then
if transmogInfo.isTransmog then
-- TODO: Exceptions need to be broken out
-- TODO: Instead maybe: mogStatus = feature:UpdateMogStatus(mogStatus)
if feature:GetName() == "EncounterJournal" or feature:GetName() == "Merchant" or feature:GetName() == "CustomerOrders" then
if transmogInfo.needsItem and not feature:GetName() == "Merchant" then
if not transmogInfo.matchesLootSpec then
if mogStatus == "own" or mogStatus == "lowSkill" then
mogStatus = "otherSpecPlus"
else
if CaerdonWardrobeConfig.Icon.ShowLearnable.SameLookDifferentItem then
mogStatus = "otherSpec"
end
end
end
elseif transmogInfo.otherNeedsItem then
if bindingResult and bindingResult.isBindOnPickup then
if not transmogInfo.isCompletionistItem then
mogStatus = "otherNoLoot"
else
mogStatus = "otherPlusNoLoot"
end
end
end
end
end
end
end
if button then
self:SetItemButtonStatus(button, item, feature, locationInfo, options, mogStatus, bindingStatus)
self:SetItemButtonBindType(button, item, feature, locationInfo, options, mogStatus, bindingStatus)
end
end
function CaerdonWardrobeMixin:RegisterFeature(mixin)
local instance = CreateFromMixins(CaerdonWardrobeFeatureMixin, mixin)
local name = instance:GetName()
if not availableFeatures[name] then
availableFeatures[name] = instance
else
error(format("Caerdon Wardrobe: Feature name collision: %s already exists", name))
end
end
function CaerdonWardrobeMixin:ClearButton(button)
if button.caerdonButton then
self:SetItemButtonStatus(button)
self:SetItemButtonBindType(button)
end
end
function CaerdonWardrobeMixin:UpdateButton(button, item, feature, locationInfo, options)
self:SetupCaerdonButton(button, item, feature, locationInfo, options)
if item == nil then
self:ClearButton(button)
return
elseif item:IsItemEmpty() and item:GetCaerdonItemType() == CaerdonItemType.Empty then
self:ClearButton(button)
return
end
if not button.caerdonButton then
self:SetItemButtonStatus(button, item, feature, locationInfo, options, "waiting", nil)
end
local locationKey = locationInfo.locationKey
if item:HasItemLocationBankOrBags() then
local itemLocation = item:GetItemLocation()
local bag, slot = itemLocation:GetBagAndSlot()
locationKey = format("bag%d-slot%d", bag, slot)
end
if locationKey then -- opt-in to coroutine-based update
locationKey = format("%s-%s", feature:GetName(), locationKey)
button.caerdonKey = locationKey
if not item:IsItemEmpty() then
local itemID = item:GetItemID()
if not button.caerdonItemID or button.caerdonItemID ~= itemID then
button.caerdonItemID = itemID
self:ClearButton(button)
end
end
self.waitingToProcess[locationKey] = {
button = button,
item = item,
feature = feature,
locationInfo = locationInfo,
options = options
}
return
end
end
function CaerdonWardrobeMixin:ProcessItem_Coroutine()
if self.processQueue == nil then
self.processQueue = {}
local hasMore = true
while hasMore do
local isBatch = false
local itemCount = 0
for locationKey, processInfo in pairs(self.waitingToProcess) do
-- Don't process item if the key is different than expected
if processInfo.button.caerdonKey == locationKey then
itemCount = itemCount + 1
self.processQueue[locationKey] = processInfo
end
self.waitingToProcess[locationKey] = nil
if itemCount > 12 then -- Process a small batch at a time
isBatch = true
break
end
end
hasMore = isBatch
for locationKey, processInfo in pairs(self.processQueue) do
-- TODO: May have to look into cancelable continue to avoid timing issues
-- Need to figure out how to key this correctly (could have multiple of item in bags, for instance)
-- but in cases of rapid data update (AH scroll), we don't want to update an old button
-- Look into ContinuableContainer
local button = processInfo.button
local item = processInfo.item
local feature = processInfo.feature
local locationInfo = processInfo.locationInfo
local options = processInfo.options
if feature:IsSameItem(button, item, locationInfo) and button.caerdonKey == locationKey then
if item:IsItemEmpty() then -- BattlePet or something else - assuming item is ready.
self:ProcessItem(button, item, feature, locationInfo, options)
else
-- TODO: Note ContinueOnItemLoad appears to fail if called too often especially on things that are already in cache - check for other places it's being used
if item:IsItemDataCached() then
if button.caerdonKey == locationKey then
self:ProcessItem(button, item, feature, locationInfo, options)
else
self:ClearButton(button)
end
else
item:ContinueOnItemLoad(function ()
if button.caerdonKey == locationKey then
self:ProcessItem(button, item, feature, locationInfo, options)
else
self:ClearButton(button)
end
end)