-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTmog.lua
3800 lines (3383 loc) · 120 KB
/
Tmog.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
-- Dressing room code - modified CosminPOP's Turtle_TransmogUI
-- Tooltip code - adapted from https://github.com/Zebouski/MoPGearTooltips/tree/masterturtle
local YELLOW = NORMAL_FONT_COLOR_CODE
local WHITE = HIGHLIGHT_FONT_COLOR_CODE
local GREEN = GREEN_FONT_COLOR_CODE
local GREY = GRAY_FONT_COLOR_CODE
local BLUE = "|cff0070de"
local version = GetAddOnMetadata("Tmog", "Version")
local debug = false
local _, playerClass = UnitClass("player")
local _, playerRace = UnitRace("player")
local playerModelLight = { 1, 0, -0.3, -1, -1, 0.55, 1.0, 1.0, 1.0, 0.8, 1.0, 1.0, 1.0 }
local previewNormalLight = { 1, 0, -0.3, 0, -1, 0.65, 1.0, 1.0, 1.0, 0.8, 1.0, 1.0, 1.0 }
local previewHighlight = { 1, 0, -0.3, 0, -1, 0.9, 1.0, 1.0, 1.0, 0.8, 1.0, 1.0, 1.0 }
local FSLight = { 1, 0, -0.5, -1, -0.7, 0.42, 1.0, 1.0, 1.0, 0.8, 1.0, 1.0, 1.0 }
local TmogTip = CreateFrame("Frame", "TmogTip", GameTooltip)
local TmogTooltip = TmogTooltip or CreateFrame("GameTooltip", "TmogTooltip", nil, "GameTooltipTemplate")
TmogTooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
local Tmog = CreateFrame("Frame")
Tmog:RegisterEvent("UNIT_INVENTORY_CHANGED")
Tmog:RegisterEvent("CHAT_MSG_ADDON")
Tmog:RegisterEvent("PLAYER_ENTERING_WORLD")
Tmog:RegisterEvent("ADDON_LOADED")
Tmog.currentGear = {}
Tmog.previewButtons = {}
Tmog.actualGear = {} -- actual gear + transmog
Tmog.sex = UnitSex("player") -- 3 - female, 2 - male
Tmog.race = string.lower(playerRace)
Tmog.currentType = "Cloth"
Tmog.currentSlot = nil
Tmog.currentPage = 1
Tmog.totalPages = 1
Tmog.currentTypesList = {} -- available types for current slot
Tmog.currentOutfit = nil
Tmog.collected = true -- check box
Tmog.notCollected = true -- check box
Tmog.onlyUsable = false -- check box
Tmog.ignoreLevel = false -- check box
Tmog.canDualWeild = playerClass == "WARRIOR" or playerClass == "HUNTER" or playerClass == "ROGUE"
Tmog.currentTab = "items"
Tmog.flush = true
Tmog.typesDefault = {
"Cloth",
"Leather",
"Mail",
"Plate",
}
Tmog.typesMisc = {
"Cloth",
"Leather",
"Mail",
"Plate",
"Miscellaneous",
}
Tmog.typesBack = {
"Cloth",
}
Tmog.typesShirt = {
"Miscellaneous",
}
Tmog.typesMh = {
"Daggers",
"One-Handed Axes",
"One-Handed Swords",
"One-Handed Maces",
"Fist Weapons",
"Polearms",
"Staves",
"Two-Handed Axes",
"Two-Handed Swords",
"Two-Handed Maces",
}
Tmog.typesOh = {
"Daggers",
"One-Handed Axes",
"One-Handed Swords",
"One-Handed Maces",
"Fist Weapons",
"Miscellaneous",
"Shields",
}
Tmog.typesRanged = {
"Bows",
"Guns",
"Crossbows",
"Wands",
}
-- store last selected type for each slot
Tmog.slots = {
[1] = "Cloth",
[3] = "Cloth",
[4] = "Miscellaneous",
[5] = "Cloth",
[6] = "Cloth",
[7] = "Cloth",
[8] = "Cloth",
[9] = "Cloth",
[10] = "Cloth",
[15] = "Cloth",
[16] = "Daggers",
[17] = "Daggers",
[18] = "Bows",
[19] = "Miscellaneous",
}
-- these slots change type together
Tmog.linkedSlots = {
[1] = true,
[3] = true,
[5] = true,
[6] = true,
[7] = true,
[8] = true,
[9] = true,
[10] = true
}
-- store last selected page for each slot and type
Tmog.pages = {
[1] = {
["Cloth"]=1,
["Leather"]=1,
["Mail"]=1,
["Plate"]=1,
["Miscellaneous"]=1,
},
[3] = {
["Cloth"]=1,
["Leather"]=1,
["Mail"]=1,
["Plate"]=1,
},
[4] = {
["Miscellaneous"]=1,
},
[5] = {
["Cloth"]=1,
["Leather"]=1,
["Mail"]=1,
["Plate"]=1,
["Miscellaneous"]=1,
},
[6] = {
["Cloth"]=1,
["Leather"]=1,
["Mail"]=1,
["Plate"]=1,
},
[7] = {
["Cloth"]=1,
["Leather"]=1,
["Mail"]=1,
["Plate"]=1,
},
[8] = {
["Cloth"]=1,
["Leather"]=1,
["Mail"]=1,
["Plate"]=1,
["Miscellaneous"]=1,
},
[9] = {
["Cloth"]=1,
["Leather"]=1,
["Mail"]=1,
["Plate"]=1,
},
[10] = {
["Cloth"]=1,
["Leather"]=1,
["Mail"]=1,
["Plate"]=1,
},
[15] = {
["Cloth"]=1
},
[16] = {
["Daggers"]=1,
["One-Handed Axes"]=1,
["One-Handed Swords"]=1,
["One-Handed Maces"]=1,
["Fist Weapons"]=1,
["Two-Handed Axes"]=1,
["Two-Handed Swords"]=1,
["Two-Handed Maces"]=1,
["Polearms"]=1,
["Staves"]=1,
},
[17] = {
["Daggers"]=1,
["One-Handed Axes"]=1,
["One-Handed Swords"]=1,
["One-Handed Maces"]=1,
["Fist Weapons"]=1,
["Miscellaneous"]=1,
["Shields"]=1,
},
[18] = {
["Bows"]=1,
["Guns"]=1,
["Crossbows"]=1,
["Wands"]=1,
},
[19] = {
["Miscellaneous"]=1,
},
}
-- bad items for "Ony Usable" check box
Tmog.unusable = {
[1] = {
["Cloth"] = {},
["Leather"] = {},
["Mail"] = {},
["Plate"] = {},
["Miscellaneous"] = {},
["SearchResult"] = {},
},
[3] = {
["Cloth"] = {},
["Leather"] = {},
["Mail"] = {},
["Plate"] = {},
["SearchResult"] = {},
},
[4] = {
["Miscellaneous"] = {},
["SearchResult"] = {},
},
[5] = {
["Cloth"] = {},
["Leather"] = {},
["Mail"] = {},
["Plate"] = {},
["Miscellaneous"] = {},
["SearchResult"] = {},
},
[6] = {
["Cloth"] = {},
["Leather"] = {},
["Mail"] = {},
["Plate"] = {},
["SearchResult"] = {},
},
[7] = {
["Cloth"] = {},
["Leather"] = {},
["Mail"] = {},
["Plate"] = {},
["SearchResult"] = {},
},
[8] = {
["Cloth"] = {},
["Leather"] = {},
["Mail"] = {},
["Plate"] = {},
["Miscellaneous"] = {},
["SearchResult"] = {},
},
[9] = {
["Cloth"] = {},
["Leather"] = {},
["Mail"] = {},
["Plate"] = {},
["SearchResult"] = {},
},
[10] = {
["Cloth"] = {},
["Leather"] = {},
["Mail"] = {},
["Plate"] = {},
["SearchResult"] = {},
},
[15] = {
["Cloth"] = {},
["SearchResult"] = {},
},
[16] = {
["Daggers"] = {},
["One-Handed Axes"] = {},
["One-Handed Swords"] = {},
["One-Handed Maces"] = {},
["Fist Weapons"] = {},
["Two-Handed Axes"] = {},
["Two-Handed Swords"] = {},
["Two-Handed Maces"] = {},
["Polearms"] = {},
["Staves"] = {},
["SearchResult"] = {},
},
[17] = {
["Daggers"] = {},
["One-Handed Axes"] = {},
["One-Handed Swords"] = {},
["One-Handed Maces"] = {},
["Fist Weapons"] = {},
["Miscellaneous"] = {},
["Shields"] = {},
["SearchResult"] = {},
},
[18] = {
["Bows"] = {},
["Guns"] = {},
["Crossbows"] = {},
["Wands"] = {},
["SearchResult"] = {},
},
[19] = {
["Miscellaneous"] = {},
["SearchResult"] = {},
},
}
Tmog.inventorySlots = {
["HeadSlot"] = 1,
["ShoulderSlot"] = 3,
["ChestSlot"] = 5,
["WaistSlot"] = 6,
["LegsSlot"] = 7,
["FeetSlot"] = 8,
["WristSlot"] = 9,
["HandsSlot"] = 10,
["BackSlot"] = 15,
["MainHandSlot"] = 16,
["SecondaryHandSlot"] = 17,
["RangedSlot"] = 18,
["ShirtSlot"] = 4,
["TabardSlot"] = 19
}
local InventoryTypeToSlot = {
["INVTYPE_HEAD"] = 1,
["INVTYPE_SHOULDER"] = 3,
["INVTYPE_CHEST"] = 5,
["INVTYPE_ROBE"] = 5,
["INVTYPE_WAIST"] = 6,
["INVTYPE_LEGS"] = 7,
["INVTYPE_FEET"] = 8,
["INVTYPE_WRIST"] = 9,
["INVTYPE_HAND"] = 10,
["INVTYPE_CLOAK"] = 15,
["INVTYPE_WEAPONMAINHAND"] = 16,
["INVTYPE_2HWEAPON"] = 16,
["INVTYPE_WEAPON"] = 16,
["INVTYPE_WEAPONOFFHAND"] = 17,
["INVTYPE_HOLDABLE"] = 17,
["INVTYPE_SHIELD"] = 17,
["INVTYPE_RANGED"] = 18,
["INVTYPE_RANGEDRIGHT"] = 18,
["INVTYPE_TABARD"] = 19,
["INVTYPE_BODY"] = 4,
["INVTYPE_RELIC"] = 18,
}
TMOG_CACHE = TMOG_CACHE or {
[1] = {}, --HeadSlot
[3] = {}, --ShoulderSlot
[5] = {}, --ChestSlot
[6] = {}, --WaistSlot
[7] = {}, --LegsSlot
[8] = {}, --FeetSlot
[9] = {}, --WristSlot
[10] = {}, --HandsSlot
[15] = {}, --BackSlot
[16] = {}, --MainHandSlot
[17] = {}, --SecondaryHandSlot
[18] = {} --RangedSlot
}
local druid = {
["Cloth"]=true,
["Leather"]=true,
["Staff"]=true,
["Mace"]=true,
["Dagger"]=true,
["Polearm"]=true,
["Fist Weapon"]=true,
["Daggers"] = true,
["One-Handed Maces"] = true,
["Fist Weapons"] = true,
["Two-Handed Maces"] = true,
["Polearms"] = true,
["Staves"] = true,
["Miscellaneous"] = true,
}
local shaman = {
["Cloth"]=true,
["Leather"]=true,
["Mail"]=true,
["Staff"]=true,
["Mace"]=true,
["Dagger"]=true,
["Axe"]=true,
["Fist Weapon"]=true,
["Shield"]=true,
["Daggers"] = true,
["One-Handed Axes"] = true,
["One-Handed Maces"] = true,
["Fist Weapons"] = true,
["Two-Handed Axes"] = true,
["Two-Handed Maces"] = true,
["Staves"] = true,
["Shields"] = true,
["Miscellaneous"] = true,
}
local paladin = {
["Cloth"]=true,
["Leather"]=true,
["Mail"]=true,
["Plate"]=true,
["Mace"]=true,
["Sword"]=true,
["Axe"]=true,
["Polearm"]=true,
["Shield"]=true,
["One-Handed Axes"] = true,
["One-Handed Swords"] = true,
["One-Handed Maces"] = true,
["Two-Handed Axes"] = true,
["Two-Handed Swords"] = true,
["Two-Handed Maces"] = true,
["Polearms"] = true,
["Shields"] = true,
["Miscellaneous"] = true,
}
local mage = {
["Cloth"]=true,
["Staff"]=true,
["Sword"]=true,
["Dagger"]=true,
["Wand"]=true,
["Staves"] = true,
["Daggers"] = true,
["One-Handed Swords"] = true,
["Wands"] = true,
["Miscellaneous"] = true,
}
local warlock = {
["Cloth"]=true,
["Staff"]=true,
["Sword"]=true,
["Dagger"]=true,
["Wand"]=true,
["Staves"] = true,
["Daggers"] = true,
["One-Handed Swords"] = true,
["Wands"] = true,
["Miscellaneous"] = true,
}
local priest = {
["Cloth"]=true,
["Staff"]=true,
["Mace"]=true,
["Dagger"]=true,
["Wand"]=true,
["Staves"] = true,
["Daggers"] = true,
["One-Handed Maces"] = true,
["Wands"] = true,
["Miscellaneous"] = true,
}
local warrior = {
["Cloth"]=true,
["Leather"]=true,
["Mail"]=true,
["Plate"]=true,
["Staff"]=true,
["Mace"]=true,
["Dagger"]=true,
["Polearm"]=true,
["Sword"]=true,
["Axe"]=true,
["Fist Weapon"]=true,
["Shield"]=true,
["Bow"]=true,
["Daggers"] = true,
["Fist Weapons"] = true,
["Staves"] = true,
["One-Handed Axes"] = true,
["One-Handed Swords"] = true,
["One-Handed Maces"] = true,
["Two-Handed Axes"] = true,
["Two-Handed Swords"] = true,
["Two-Handed Maces"] = true,
["Polearms"] = true,
["Shields"] = true,
["Bows"] = true,
["Guns"] = true,
["Crossbows"] = true,
["Miscellaneous"] = true,
}
local rogue = {
["Cloth"]=true,
["Leather"]=true,
["Mace"]=true,
["Dagger"]=true,
["Sword"]=true,
["Fist Weapon"]=true,
["Bow"]=true,
["Axe"]=true,
["Daggers"] = true,
["Fist Weapons"] = true,
["One-Handed Axes"] = true,
["One-Handed Swords"] = true,
["One-Handed Maces"] = true,
["Bows"] = true,
["Guns"] = true,
["Crossbows"] = true,
["Miscellaneous"] = true,
}
local hunter = {
["Cloth"]=true,
["Leather"]=true,
["Mail"]=true,
["Staff"]=true,
["Dagger"]=true,
["Sword"]=true,
["Polearm"]=true,
["Fist Weapon"]=true,
["Axe"]=true,
["Bow"]=true,
["Daggers"] = true,
["Fist Weapons"] = true,
["Staves"] = true,
["One-Handed Axes"] = true,
["One-Handed Swords"] = true,
["Two-Handed Axes"] = true,
["Two-Handed Swords"] = true,
["Polearms"] = true,
["Bows"] = true,
["Guns"] = true,
["Crossbows"] = true,
["Miscellaneous"] = true,
}
local function tmogprint(a)
local msg = a
if a == nil then
msg = "Attempt to print a nil value."
elseif type(msg) == "boolean" then
if a then
msg = "true"
else
msg = "false"
end
elseif type(a) == "table" then
msg = "Attempt to print a table value."
elseif type(a) == "userdata" then
msg = "Attempt to print a userdata value."
elseif type(a) == "function" then
msg = "Attempt to print a function value."
end
local time = GetTime()
DEFAULT_CHAT_FRAME:AddMessage(BLUE .."[Tmog]["..GREY..time.."]["..WHITE..msg.."]|r")
end
local function tmog_debug(a)
if debug ~= true then
return
end
tmogprint(a)
end
local function strsplit(str, delimiter)
local tinsert = table.insert
local result = {}
local from = 1
local delim_from, delim_to = string.find(str, delimiter, from, true)
while delim_from do
tinsert(result, string.sub(str, from, delim_from - 1))
from = delim_to + 1
delim_from, delim_to = string.find(str, delimiter, from, true)
end
tinsert(result, string.sub(str, from))
return result
end
local function strtrim(s)
return (string.gsub(s or "", "^%s*(.-)%s*$", "%1"))
end
local function AddToSet(set, key, value)
if not set or not key then
return
end
if not value then
set[key] = true
else
set[key] = value
end
end
local function SetContains(set, key, value)
if not set then
return false
end
if not key and value then
for _, v in pairs(set) do
if v == value then
return true
end
end
end
if key and not value then
return set[key] ~= nil
end
return set[key] == value
end
local function InvenotySlotFromItemID(itemID)
if not itemID then
return nil
end
local _, _, _, _, _, _, _, slot = GetItemInfo(itemID)
if SetContains(InventoryTypeToSlot, slot) then
return InventoryTypeToSlot[slot]
end
return nil
end
local function GetTableForClass(class)
if class == "DRUID" then
return druid
elseif class == "PALADIN" then
return paladin
elseif class == "SHAMAN" then
return shaman
elseif class == "MAGE" then
return mage
elseif class == "WARLOCK" then
return warlock
elseif class == "PRIEST" then
return priest
elseif class == "WARRIOR" then
return warrior
elseif class == "ROGUE" then
return rogue
elseif class == "HUNTER" then
return hunter
end
end
local lastSearchName = nil
local lastSearchID = nil
local function GetItemIDByName(name)
if name ~= lastSearchName then
for itemID = 1, 99999 do
local itemName = GetItemInfo(itemID)
if (itemName and itemName == name) then
lastSearchID = itemID
break
end
end
lastSearchName = name
end
return lastSearchID
end
local HookSetLootRollItem = GameTooltip.SetLootRollItem
function GameTooltip.SetLootRollItem(self, id)
local _, _, itemID = string.find(GetLootRollItemLink(id) or "", "item:(%d+)")
GameTooltip.itemID = itemID
return HookSetLootRollItem(self, id)
end
local HookSetLootItem = GameTooltip.SetLootItem
function GameTooltip.SetLootItem(self, slot)
local _, _, itemID = string.find(GetLootSlotLink(slot) or "", "item:(%d+)")
GameTooltip.itemID = itemID
HookSetLootItem(self, slot)
end
local HookSetMerchantItem = GameTooltip.SetMerchantItem
function GameTooltip.SetMerchantItem(self, merchantIndex)
local _, _, itemID = string.find(GetMerchantItemLink(merchantIndex) or "", "item:(%d+)")
GameTooltip.itemID = itemID
return HookSetMerchantItem(self, merchantIndex)
end
local HookSetQuestLogItem = GameTooltip.SetQuestLogItem
function GameTooltip.SetQuestLogItem(self, itemType, index)
local _, _, itemID = string.find(GetQuestLogItemLink(itemType, index) or "", "item:(%d+)")
GameTooltip.itemID = itemID
if not GameTooltip.itemID then
return
end
return HookSetQuestLogItem(self, itemType, index)
end
local HookSetQuestItem = GameTooltip.SetQuestItem
function GameTooltip.SetQuestItem(self, itemType, index)
local _, _, itemID = string.find(GetQuestItemLink(itemType, index) or "", "item:(%d+)")
GameTooltip.itemID = itemID
return HookSetQuestItem(self, itemType, index)
end
local HookSetHyperlink = GameTooltip.SetHyperlink
function GameTooltip.SetHyperlink(self, arg1)
if arg1 then
local _, _, linktype = string.find(arg1, "^(.-):(.+)$")
if linktype == "item" then
local _, _, id = string.find(arg1,"item:(%d+)")
GameTooltip.itemID = id
end
end
return HookSetHyperlink(self, arg1)
end
local HookSetBagItem = GameTooltip.SetBagItem
function GameTooltip.SetBagItem(self, container, slot)
if GetContainerItemLink(container, slot) then
local _, _, id = string.find(GetContainerItemLink(container, slot) or "","item:(%d+)")
GameTooltip.itemID = id
end
return HookSetBagItem(self, container, slot)
end
local HookSetInboxItem = GameTooltip.SetInboxItem
function GameTooltip.SetInboxItem(self, mailID, attachmentIndex)
local itemName = GetInboxItem(mailID)
if itemName then
GameTooltip.itemID = GetItemIDByName(itemName)
end
return HookSetInboxItem(self, mailID, attachmentIndex)
end
local HookSetInventoryItem = GameTooltip.SetInventoryItem
function GameTooltip.SetInventoryItem(self, unit, slot)
if GetInventoryItemLink(unit, slot) then
local _, _, id = string.find(GetInventoryItemLink(unit, slot) or "","item:(%d+)")
GameTooltip.itemID = id
end
return HookSetInventoryItem(self, unit, slot)
end
local HookSetCraftItem = GameTooltip.SetCraftItem
function GameTooltip.SetCraftItem(self, skill, slot)
if GetCraftReagentItemLink(skill, slot) then
local _, _, id = string.find(GetCraftReagentItemLink(skill, slot) or "","item:(%d+)")
GameTooltip.itemID = id
end
return HookSetCraftItem(self, skill, slot)
end
local HookSetCraftSpell = GameTooltip.SetCraftSpell
function GameTooltip.SetCraftSpell(self, slot)
local _, _, id = string.find(GetCraftItemLink(slot) or "", "item:(%d+)")
GameTooltip.itemID = id
return HookSetCraftSpell(self, slot)
end
local HookSetTradeSkillItem = GameTooltip.SetTradeSkillItem
function GameTooltip.SetTradeSkillItem(self, skillIndex, reagentIndex)
if reagentIndex then
if GetTradeSkillReagentItemLink(skillIndex, reagentIndex) then
local _, _, id = string.find(GetTradeSkillReagentItemLink(skillIndex, reagentIndex) or "","item:(%d+)")
GameTooltip.itemID = id
end
else
if GetTradeSkillItemLink(skillIndex) then
local _, _, id = string.find(GetTradeSkillItemLink(skillIndex) or "","item:(%d+)")
GameTooltip.itemID = id
end
end
return HookSetTradeSkillItem(self, skillIndex, reagentIndex)
end
local HookSetAuctionItem = GameTooltip.SetAuctionItem
function GameTooltip.SetAuctionItem(self, atype, index)
local itemName = GetAuctionItemInfo(atype, index)
if itemName then
GameTooltip.itemID = GetItemIDByName(itemName)
end
return HookSetAuctionItem(self, atype, index)
end
local HookSetAuctionSellItem = GameTooltip.SetAuctionSellItem
function GameTooltip.SetAuctionSellItem(self)
local itemName = GetAuctionSellItemInfo()
if itemName then
GameTooltip.itemID = GetItemIDByName(itemName)
end
return HookSetAuctionSellItem(self)
end
local HookSetTradePlayerItem = GameTooltip.SetTradePlayerItem
function GameTooltip.SetTradePlayerItem(self, index)
if GetTradePlayerItemLink(index) then
local _, _, id = string.find(GetTradePlayerItemLink(index) or "","item:(%d+)")
GameTooltip.itemID = id
end
return HookSetTradePlayerItem(self, index)
end
local HookSetTradeTargetItem = GameTooltip.SetTradeTargetItem
function GameTooltip.SetTradeTargetItem(self, index)
if GetTradeTargetItemLink(index) then
local _, _, id = string.find(GetTradeTargetItemLink(index) or "","item:(%d+)")
GameTooltip.itemID = id
end
return HookSetTradeTargetItem(self, index)
end
local HookSetItemRef = SetItemRef
SetItemRef = function(link, text, button)
local item, _, id = string.find(link, "item:(%d+)")
ItemRefTooltip.itemID = id
HookSetItemRef(link, text, button)
if not IsShiftKeyDown() and not IsControlKeyDown() and item then
TmogTip.extendTooltip(ItemRefTooltip)
end
end
local firstLoad = true
Tmog:SetScript("OnEvent", function()
if event == "PLAYER_ENTERING_WORLD" then
TmogFramePlayerModel:SetUnit("player")
if firstLoad then
Tmog_Reset()
firstLoad = false
end
if TmogFrame:IsVisible() then
TmogFrame:Hide()
end
return
end
if event == "ADDON_LOADED" and arg1 == "Tmog" then
Tmog:UnregisterEvent("ADDON_LOADED")
TmogFrameTitleText:SetText("Tmog v."..version)
SLASH_TMOG1 = "/tmog"
SlashCmdList["TMOG"] = function(msg)
Tmog_SlashCommand(msg)
end
if not TMOG_PLAYER_OUTFITS then
TMOG_PLAYER_OUTFITS = {}
end
if not TMOG_TRANSMOG_STATUS then
TMOG_TRANSMOG_STATUS = {}
end
if not TMOG_CACHE then
TMOG_CACHE = {
[1] = {}, --HeadSlot
[3] = {}, --ShoulderSlot
[5] = {}, --ChestSlot
[6] = {}, --WaistSlot
[7] = {}, --LegsSlot
[8] = {}, --FeetSlot
[9] = {}, --WristSlot
[10] = {}, --HandsSlot
[15] = {}, --BackSlot
[16] = {}, --MainHandSlot
[17] = {}, --SecondaryHandSlot
[18] = {} --RangedSlot
}
end
UIDropDownMenu_Initialize(TmogFrameTypeDropDown, Tmog_TypeDropDown_Initialize)
UIDropDownMenu_Initialize(TmogFrameOutfitsDropDown, Tmog_OutfitsDropDown_Initialize)
UIDropDownMenu_SetWidth(100, TmogFrameTypeDropDown)
UIDropDownMenu_SetWidth(115, TmogFrameOutfitsDropDown)
return
end
if event == "CHAT_MSG_ADDON" and string.find(arg1, "TW_TRANSMOG", 1, true) and arg4 == UnitName("player") then
if string.find(arg2, "AvailableTransmogs", 1, true) then
local ex = strsplit(arg2, ":")
local InventorySlotId = tonumber(ex[2])
for i, itemID in pairs(ex) do
if i > 3 then
itemID = tonumber(itemID)
if itemID then
local itemName = GetItemInfo(itemID)
if itemName then
if not SetContains(TMOG_CACHE[InventorySlotId], itemID, itemName) then
AddToSet(TMOG_CACHE[InventorySlotId], itemID, itemName)
end
-- check if it shares appearance with other items and add those if it does
if SetContains(DisplayIdDB, itemID) then
for _, id in pairs(DisplayIdDB[itemID]) do
Tmog:CacheItem(id)
local name = GetItemInfo(id)
if not SetContains(TMOG_CACHE[InventorySlotId], id, name) then
AddToSet(TMOG_CACHE[InventorySlotId], id, name)
end
end
end
end
end
end
end
elseif string.find(arg2, "NewTransmog", 1, true) then
local ex = strsplit(arg2, ":")
local itemID = tonumber(ex[2])
local slot = InvenotySlotFromItemID(itemID)
local itemName = GetItemInfo(itemID)
if slot and itemName then
AddToSet(TMOG_CACHE[slot], itemID, itemName)
-- check if it shares appearance with other items and add those if it does
if SetContains(DisplayIdDB, itemID, itemName) then
for _, id in pairs(DisplayIdDB[itemID]) do
Tmog:CacheItem(id)
local name = GetItemInfo(id)
if not SetContains(TMOG_CACHE[slot], id, name) then
AddToSet(TMOG_CACHE[slot], id, name)
end
end
end
end
elseif string.find(arg2, "TransmogStatus", 1, true) then
local dataEx = strsplit(arg2, "TransmogStatus:")
if dataEx[2] then
local TransmogStatus = strsplit(dataEx[2], ",")
if not TMOG_TRANSMOG_STATUS then
TMOG_TRANSMOG_STATUS = {}
end
for _, InventorySlotId in pairs(Tmog.inventorySlots) do
if not TMOG_TRANSMOG_STATUS[InventorySlotId] then
TMOG_TRANSMOG_STATUS[InventorySlotId] = {}
end
end
for _, d in pairs(TransmogStatus) do
local slotEx = strsplit(d, ":")
local InventorySlotId = tonumber(slotEx[1])
local itemID = tonumber(slotEx[2])
local link = GetInventoryItemLink("player", InventorySlotId)
local actualItemId = Tmog:IDFromLink(link) or 0
if actualItemId ~= 0 and InventorySlotId then
if not TMOG_TRANSMOG_STATUS[InventorySlotId][actualItemId] then
TMOG_TRANSMOG_STATUS[InventorySlotId][actualItemId] = 0
end
TMOG_TRANSMOG_STATUS[InventorySlotId][actualItemId] = itemID
end
end
end
end
return
end
if event == "UNIT_INVENTORY_CHANGED" and arg1 == "player" then
for slot in pairs(TMOG_CACHE) do
local link = GetInventoryItemLink("player", slot)
if link then
local itemID = Tmog:IDFromLink(link)
if itemID then
Tmog:CacheItem(itemID)
local itemName = GetItemInfo(itemID)
if not SetContains(TMOG_CACHE[slot], itemID, itemName) then
AddToSet(TMOG_CACHE[slot], itemID, itemName)
end
-- check if it shares appearance with other items and add those if it does
if SetContains(DisplayIdDB, itemID) then
for _, id in pairs(DisplayIdDB[itemID]) do
Tmog:CacheItem(id)
local name = GetItemInfo(id)
if not SetContains(TMOG_CACHE[slot], id, name) then