forked from ATTWoWAddon/AllTheThings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllTheThings.lua
12220 lines (11765 loc) · 420 KB
/
AllTheThings.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
--------------------------------------------------------------------------------
-- A L L T H E T H I N G S --
--------------------------------------------------------------------------------
-- Copyright 2017-2019 Dylan Fortune (Crieve-Sargeras) --
--------------------------------------------------------------------------------
local app = AllTheThings; -- Create a local (non global) reference
local L = app.L;
-- Performance Cache
-- While this may seem silly, caching references to commonly used APIs is actually a performance gain...
local C_ArtifactUI_GetAppearanceInfoByID = C_ArtifactUI.GetAppearanceInfoByID;
local C_MountJournal_GetMountInfoByID = C_MountJournal.GetMountInfoByID;
local C_MountJournal_GetMountInfoExtraByID = C_MountJournal.GetMountInfoExtraByID;
local C_TransmogCollection_GetAppearanceSourceInfo = C_TransmogCollection.GetAppearanceSourceInfo;
local C_TransmogCollection_GetAllAppearanceSources = C_TransmogCollection.GetAllAppearanceSources;
local C_TransmogCollection_GetIllusionSourceInfo = C_TransmogCollection.GetIllusionSourceInfo;
local C_TransmogCollection_PlayerHasTransmogItemModifiedAppearance = C_TransmogCollection.PlayerHasTransmogItemModifiedAppearance;
local C_TransmogCollection_GetIllusions = C_TransmogCollection.GetIllusions;
local C_TransmogCollection_GetSourceInfo = C_TransmogCollection.GetSourceInfo;
local C_TransmogSets_GetSetInfo = C_TransmogSets.GetSetInfo;
local C_ToyBox_GetToyInfo = C_ToyBox.GetToyInfo;
local C_ToyBox_GetToyLink = C_ToyBox.GetToyLink;
local C_Map_GetMapDisplayInfo = C_Map.GetMapDisplayInfo;
local C_Map_GetBestMapForUnit = C_Map.GetBestMapForUnit;
local SetPortraitTexture = _G["SetPortraitTexture"];
local SetPortraitTextureFromDisplayID = _G["SetPortraitTextureFromCreatureDisplayID"];
local EJ_GetCreatureInfo = _G["EJ_GetCreatureInfo"];
local EJ_GetEncounterInfo = _G["EJ_GetEncounterInfo"];
local GetAchievementCriteriaInfo = _G["GetAchievementCriteriaInfo"];
local GetAchievementInfo = _G["GetAchievementInfo"];
local GetAchievementLink = _G["GetAchievementLink"];
local GetClassInfo = _G["GetClassInfo"];
local GetDifficultyInfo = _G["GetDifficultyInfo"];
local GetFactionInfoByID = _G["GetFactionInfoByID"];
local GetItemInfo = _G["GetItemInfo"];
local GetItemInfoInstant = _G["GetItemInfoInstant"];
local GetItemSpecInfo = _G["GetItemSpecInfo"];
local GetTitleName = _G["GetTitleName"];
local IsDressableItem = _G["IsDressableItem"];
local PlayerHasToy = _G["PlayerHasToy"];
local IsTitleKnown = _G["IsTitleKnown"];
local InCombatLockdown = _G["InCombatLockdown"];
local MAX_CREATURES_PER_ENCOUNTER = 9;
local DESCRIPTION_SEPARATOR = "`";
-- Coroutine Helper Functions
app.RawData = {};
app.refreshing = {};
local function OnUpdate(self)
for i=#self.__stack,1,-1 do
if not self.__stack[i][1](self) then
table.remove(self.__stack, i);
if #self.__stack < 1 then
self:SetScript("OnUpdate", nil);
end
end
end
end
local function Push(self, name, method)
if not self.__stack then
self.__stack = {};
self:SetScript("OnUpdate", OnUpdate);
elseif #self.__stack < 1 then
self:SetScript("OnUpdate", OnUpdate);
end
--print("Push->" .. name);
table.insert(self.__stack, { method, name });
end
local function StartCoroutine(name, method)
if method and not app.refreshing[name] then
local instance = coroutine.create(method);
app.refreshing[name] = true;
Push(app, name, function()
-- Check the status of the coroutine
if instance and coroutine.status(instance) ~= "dead" then
local ok, err = coroutine.resume(instance);
if ok then return true; -- This means more work is required.
else
-- Show the error. Returning nothing is the same as canceling the work.
print(err);
end
end
app.refreshing[name] = nil;
end);
end
end
local constructor = function(id, t, typeID)
if not t then
return { [typeID] = id };
end
if not t.g and t[1] then
t = { ["g"] = t, [typeID] = id };
else
t[typeID] = id;
end
return t;
end
local contains = function(arr, value)
for i,value2 in ipairs(arr) do
if value2 == value then return true; end
end
end
local containsAny = function(arr, otherArr)
for i, v in ipairs(arr) do
for j, w in ipairs(otherArr) do
if v == w then return true; end
end
end
end
local containsValue = function(dict, value)
for key,value2 in pairs(dict) do
if value2 == value then return true; end
end
end
-- Data Lib
local AllTheThingsTempData = {}; -- For temporary data.
local AllTheThingsAD = {}; -- For account-wide data.
local function SetDataMember(member, data)
AllTheThingsAD[member] = data;
end
local function GetDataMember(member, default)
if AllTheThingsAD[member] == nil then AllTheThingsAD[member] = default; end
return AllTheThingsAD[member];
end
local function SetTempDataMember(member, data)
AllTheThingsTempData[member] = data;
end
local function GetTempDataMember(member, default)
if AllTheThingsTempData[member] == nil then AllTheThingsTempData[member] = default; end
return AllTheThingsTempData[member];
end
local function SetDataSubMember(member, submember, data)
if AllTheThingsAD[member] then AllTheThingsAD[member][submember] = data; end
end
local function GetDataSubMember(member, submember, default)
if not AllTheThingsAD[member] then AllTheThingsAD[member] = { }; end
if AllTheThingsAD[member][submember] == nil then AllTheThingsAD[member][submember] = default; end
return AllTheThingsAD[member][submember];
end
local function SetTempDataSubMember(member, submember, data)
if AllTheThingsTempData[member] then
AllTheThingsTempData[member][submember] = data;
end
end
local function GetTempDataSubMember(member, submember, default)
if AllTheThingsTempData[member] == nil then
AllTheThingsTempData[member] = { };
end
if AllTheThingsTempData[member][submember] == nil then
AllTheThingsTempData[member][submember] = default;
end
return AllTheThingsTempData[member][submember];
end
app.SetDataMember = SetDataMember;
app.GetDataMember = GetDataMember;
app.SetDataSubMember = SetDataSubMember;
app.GetDataSubMember = GetDataSubMember;
app.GetTempDataMember = GetTempDataMember;
app.GetTempDataSubMember = GetTempDataSubMember;
(function()
-- Map all Skill IDs to the old Skill IDs
local tradeSkillMap = {
-- Alchemy Skills
[171] = 171, -- Alchemy [7.3.5]
[2485] = 171, -- Classic Alchemy [8.0.1]
[2484] = 171, -- Outland Alchemy [8.0.1]
[2483] = 171, -- Northrend Alchemy [8.0.1]
[2482] = 171, -- Cataclysm Alchemy [8.0.1]
[2481] = 171, -- Pandaria Alchemy [8.0.1]
[2480] = 171, -- Draenor Alchemy [8.0.1]
[2479] = 171, -- Legion Alchemy [8.0.1]
[2478] = 171, -- Kul Tiran Alchemy [8.0.1]
-- Archaeology Skills
[794] = 794, -- Archaeology [7.3.5]
-- Blacksmithing Skills
[164] = 164, -- Blacksmithing [7.3.5]
[2477] = 164, -- Classic Blacksmithing [8.0.1]
[2476] = 164, -- Outland Blacksmithing [8.0.1]
[2475] = 164, -- Northrend Blacksmithing [8.0.1]
[2474] = 164, -- Cataclysm Blacksmithing [8.0.1]
[2473] = 164, -- Pandaria Blacksmithing [8.0.1]
[2472] = 164, -- Draenor Blacksmithing [8.0.1]
[2454] = 164, -- Legion Blacksmithing [8.0.1]
[2437] = 164, -- Kul Tiran Blacksmithing [8.0.1]
-- Cooking Skills
[185] = 185, -- Cooking [7.3.5]
[975] = 185, -- Way of the Grill
[976] = 185, -- Way of the Wok
[977] = 185, -- Way of the Pot
[978] = 185, -- Way of the Steamer
[979] = 185, -- Way of the Oven
[980] = 185, -- Way of the Brew
[2548] = 185, -- Classic Cooking [8.0.1]
[2547] = 185, -- Outland Cooking [8.0.1]
[2546] = 185, -- Northrend Cooking [8.0.1]
[2545] = 185, -- Cataclysm Cooking [8.0.1]
[2544] = 185, -- Pandaria Cooking [8.0.1]
[2543] = 185, -- Draenor Cooking [8.0.1]
[2542] = 185, -- Legion Cooking [8.0.1]
[2541] = 185, -- Kul Tiran Cooking [8.0.1]
-- Enchanting Skills
[333] = 333, -- Enchanting [7.3.5]
[2494] = 333, -- Classic Enchanting [8.0.1]
[2493] = 333, -- Outland Enchanting [8.0.1]
[2492] = 333, -- Northrend Enchanting [8.0.1]
[2491] = 333, -- Cataclysm Enchanting [8.0.1]
[2489] = 333, -- Pandaria Enchanting [8.0.1]
[2488] = 333, -- Draenor Enchanting [8.0.1]
[2487] = 333, -- Legion Enchanting [8.0.1]
[2486] = 333, -- Kul Tiran Enchanting [8.0.1]
-- Engineering Skills
[202] = 202, -- Engineering [7.3.5]
[2506] = 202, -- Classic Engineering [8.0.1]
[2505] = 202, -- Outland Engineering [8.0.1]
[2504] = 202, -- Northrend Engineering [8.0.1]
[2503] = 202, -- Cataclysm Engineering [8.0.1]
[2502] = 202, -- Pandaria Engineering [8.0.1]
[2501] = 202, -- Draenor Engineering [8.0.1]
[2500] = 202, -- Legion Engineering [8.0.1]
[2499] = 202, -- Kul Tiran Engineering [8.0.1]
-- First Aid Skills
[129] = 129, -- First Aid [7.3.5] [REMOVED FROM GAME]
-- Fishing Skills
[356] = 356, -- Fishing [7.3.5]
[2592] = 356, -- Classic Fishing [8.0.1]
[2591] = 356, -- Outland Fishing [8.0.1]
[2590] = 356, -- Northrend Fishing [8.0.1]
[2589] = 356, -- Cataclysm Fishing [8.0.1]
[2588] = 356, -- Pandaria Fishing [8.0.1]
[2587] = 356, -- Draenor Fishing [8.0.1]
[2586] = 356, -- Legion Fishing [8.0.1]
[2585] = 356, -- Kul Tiran Fishing [8.0.1]
-- Herbalism Skills
[182] = 182, -- Herbalism [7.3.5]
[2556] = 182, -- Classic Herbalism [8.0.1]
[2555] = 182, -- Outland Herbalism [8.0.1]
[2554] = 182, -- Northrend Herbalism [8.0.1]
[2553] = 182, -- Cataclysm Herbalism [8.0.1]
[2552] = 182, -- Pandaria Herbalism [8.0.1]
[2551] = 182, -- Draenor Herbalism [8.0.1]
[2550] = 182, -- Legion Herbalism [8.0.1]
[2549] = 182, -- Kul Tiran Herbalism [8.0.1]
-- Inscription Skills
[773] = 773, -- Inscription [7.3.5]
[2514] = 773, -- Classic Inscription [8.0.1]
[2513] = 773, -- Outland Inscription [8.0.1]
[2512] = 773, -- Northrend Inscription [8.0.1]
[2511] = 773, -- Cataclysm Inscription [8.0.1]
[2510] = 773, -- Pandaria Inscription [8.0.1]
[2509] = 773, -- Draenor Inscription [8.0.1]
[2508] = 773, -- Legion Inscription [8.0.1]
[2507] = 773, -- Kul Tiran Inscription [8.0.1]
-- Jewelcrafting Skills
[755] = 755, -- Jewelcrafting [7.3.5]
[2524] = 755, -- Classic Jewelcrafting [8.0.1]
[2523] = 755, -- Outland Jewelcrafting [8.0.1]
[2522] = 755, -- Northrend Jewelcrafting [8.0.1]
[2521] = 755, -- Cataclysm Jewelcrafting [8.0.1]
[2520] = 755, -- Pandaria Jewelcrafting [8.0.1]
[2519] = 755, -- Draenor Jewelcrafting [8.0.1]
[2518] = 755, -- Legion Jewelcrafting [8.0.1]
[2517] = 755, -- Kul Tiran Jewelcrafting [8.0.1]
-- Leatherworking Skills
[165] = 165, -- Leatherworking [7.3.5]
[2532] = 165, -- Classic Leatherworking [8.0.1]
[2531] = 165, -- Outland Leatherworking [8.0.1]
[2530] = 165, -- Northrend Leatherworking [8.0.1]
[2529] = 165, -- Cataclysm Leatherworking [8.0.1]
[2528] = 165, -- Pandaria Leatherworking [8.0.1]
[2527] = 165, -- Draenor Leatherworking [8.0.1]
[2526] = 165, -- Legion Leatherworking [8.0.1]
[2525] = 165, -- Kul Tiran Leatherworking [8.0.1]
-- Mining Skills
[186] = 186, -- Mining [7.3.5]
[2572] = 186, -- Classic Mining [8.0.1]
[2571] = 186, -- Outland Mining [8.0.1]
[2570] = 186, -- Northrend Mining [8.0.1]
[2569] = 186, -- Cataclysm Mining [8.0.1]
[2568] = 186, -- Pandaria Mining [8.0.1]
[2567] = 186, -- Draenor Mining [8.0.1]
[2566] = 186, -- Legion Mining [8.0.1]
[2565] = 186, -- Kul Tiran Mining [8.0.1]
-- Skinning Skills
[393] = 393, -- Skinning [7.3.5]
[2564] = 393, -- Classic Skinning [8.0.1]
[2563] = 393, -- Outland Skinning [8.0.1]
[2562] = 393, -- Northrend Skinning [8.0.1]
[2561] = 393, -- Cataclysm Skinning [8.0.1]
[2560] = 393, -- Pandaria Skinning [8.0.1]
[2559] = 393, -- Draenor Skinning [8.0.1]
[2558] = 393, -- Legion Skinning [8.0.1]
[2557] = 393, -- Kul Tiran Skinning [8.0.1]
-- Tailoring Skills
[197] = 197, -- Tailoring [7.3.5]
[2540] = 197, -- Classic Tailoring [8.0.1]
[2539] = 197, -- Outland Tailoring [8.0.1]
[2538] = 197, -- Northrend Tailoring [8.0.1]
[2537] = 197, -- Cataclysm Tailoring [8.0.1]
[2536] = 197, -- Pandaria Tailoring [8.0.1]
[2535] = 197, -- Draenor Tailoring [8.0.1]
[2534] = 197, -- Legion Tailoring [8.0.1]
[2533] = 197, -- Kul Tiran Tailoring [8.0.1]
};
app.GetBaseTradeSkillID = function(skillID)
return tradeSkillMap[skillID] or skillID;
end
app.GetTradeSkillLine = function()
return app.GetBaseTradeSkillID(C_TradeSkillUI.GetTradeSkillLine());
end
app.GetTradeSkillCache = function(invalidate)
local cache = GetTempDataMember("PROFESSION_CACHE");
if not cache or invalidate then
cache = {};
SetTempDataMember("PROFESSION_CACHE", cache);
local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions();
for i,j in ipairs({prof1 or 0, prof2 or 0, archaeology or 0, fishing or 0, cooking or 0, firstAid or 0}) do
if j ~= 0 then cache[app.GetBaseTradeSkillID(select(7, GetProfessionInfo(j)))] = true; end
end
end
return cache;
end
end)();
local backdrop = {
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
};
-- Game Tooltip Icon
local GameTooltipIcon = CreateFrame("FRAME", nil, GameTooltip);
GameTooltipIcon:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0);
GameTooltipIcon:SetSize(72, 72);
GameTooltipIcon.icon = GameTooltipIcon:CreateTexture(nil, "ARTWORK");
GameTooltipIcon.icon:SetAllPoints(GameTooltipIcon);
GameTooltipIcon.icon:Show();
GameTooltipIcon.icon.Background = GameTooltipIcon:CreateTexture(nil, "BACKGROUND");
GameTooltipIcon.icon.Background:SetAllPoints(GameTooltipIcon);
GameTooltipIcon.icon.Background:Show();
GameTooltipIcon.icon.Border = GameTooltipIcon:CreateTexture(nil, "BORDER");
GameTooltipIcon.icon.Border:SetAllPoints(GameTooltipIcon);
GameTooltipIcon.icon.Border:Show();
GameTooltipIcon:Hide();
-- Model is used to display the model of an NPC/Encounter.
local GameTooltipModel, model, fi = CreateFrame("FRAME", "ATTGameTooltipModel", GameTooltip);
GameTooltipModel:SetPoint("TOPRIGHT", GameTooltip, "TOPLEFT", 0, 0);
GameTooltipModel:SetSize(128, 128);
GameTooltipModel:SetBackdrop(backdrop);
GameTooltipModel:SetBackdropBorderColor(1, 1, 1, 1);
GameTooltipModel:SetBackdropColor(0, 0, 0, 1);
GameTooltipModel.Models = {};
GameTooltipModel.Model = CreateFrame("DressUpModel", nil, GameTooltipModel);
GameTooltipModel.Model:SetPoint("TOPLEFT", GameTooltipModel ,"TOPLEFT", 4, -4)
GameTooltipModel.Model:SetPoint("BOTTOMRIGHT", GameTooltipModel ,"BOTTOMRIGHT", -4, 4)
GameTooltipModel.Model:SetFacing(MODELFRAME_DEFAULT_ROTATION);
GameTooltipModel.Model:SetScript("OnUpdate", function(self, elapsed)
self:SetFacing(self:GetFacing() + elapsed);
end);
GameTooltipModel.Model:Hide();
for i=1,MAX_CREATURES_PER_ENCOUNTER do
model = CreateFrame("DressUpModel", "ATTGameTooltipModel" .. i, GameTooltipModel);
model:SetPoint("TOPLEFT", GameTooltipModel ,"TOPLEFT", 4, -4);
model:SetPoint("BOTTOMRIGHT", GameTooltipModel ,"BOTTOMRIGHT", -4, 4);
model:SetCamDistanceScale(1.7);
model:SetDisplayInfo(987);
model:SetFacing(MODELFRAME_DEFAULT_ROTATION);
fi = math.floor(i / 2);
model:SetPosition(fi * -0.1, (fi * (i % 2 == 0 and -1 or 1)) * ((MAX_CREATURES_PER_ENCOUNTER - i) * 0.1), fi * 0.2 - 0.3);
model:SetDepth(i);
model:Hide();
tinsert(GameTooltipModel.Models, model);
end
GameTooltipModel.HideAllModels = function(self)
for i=1,MAX_CREATURES_PER_ENCOUNTER do
GameTooltipModel.Models[i]:Hide();
end
GameTooltipModel.Model:Hide();
end
GameTooltipModel.SetCreatureID = function(self, creatureID)
GameTooltipModel.HideAllModels(self);
if creatureID > 0 then
self.Model:SetUnit("none");
self.Model:SetCreature(creatureID);
if not self.Model:GetModelFileID() then
Push(app, "SetCreatureID", function()
if self.lastModel == creatureID then
self:SetCreatureID(creatureID);
end
end);
end
end
self:Show();
end
GameTooltipModel.TrySetDisplayInfos = function(self, reference, displayInfos)
if displayInfos then
local rotation = reference.modelRotation and ((reference.modelRotation * math.pi) / 180) or MODELFRAME_DEFAULT_ROTATION;
local scale = reference.modelScale or 1;
local count = #displayInfos;
if count > 1 then
count = math.min(count, MAX_CREATURES_PER_ENCOUNTER);
local ratio = count / MAX_CREATURES_PER_ENCOUNTER;
if count < 3 then
for i=1,count do
model = self.Models[i];
model:SetDisplayInfo(displayInfos[i]);
model:SetCamDistanceScale(scale);
model:SetFacing(rotation);
model:SetPosition(0, (i % 2 == 0 and 0.5 or -0.5), 0);
model:Show();
end
else
scale = (1 + (ratio * 0.5)) * scale;
for i=1,count do
model = self.Models[i];
model:SetDisplayInfo(displayInfos[i]);
model:SetCamDistanceScale(scale);
model:SetFacing(rotation);
fi = math.floor(i / 2);
model:SetPosition(fi * -0.1, (fi * (i % 2 == 0 and -1 or 1)) * ((MAX_CREATURES_PER_ENCOUNTER - i) * 0.1), fi * 0.2 - (ratio * 0.15));
model:Show();
end
end
else
self.Model:SetFacing(rotation);
self.Model:SetCamDistanceScale(scale);
self.Model:SetDisplayInfo(displayInfos[1]);
self.Model:Show();
end
self:Show();
return true;
end
end
GameTooltipModel.TrySetModel = function(self, reference)
GameTooltipModel.HideAllModels(self);
if app.Settings:GetTooltipSetting("Models") then
self.lastModel = reference;
local displayInfos = reference.displayInfo;
if GameTooltipModel.TrySetDisplayInfos(self, reference, displayInfos) then
return true;
elseif reference.qgs then
if #reference.qgs > 1 then
displayInfos = {};
local markedKeys = {};
for i,creatureID in ipairs(reference.qgs) do
local displayID = app.NPCDB[creatureID];
if displayID and not markedKeys[displayID] then
tinsert(displayInfos, displayID);
markedKeys[displayID] = 1;
end
end
if GameTooltipModel.TrySetDisplayInfos(self, reference, displayInfos) then
return true;
end
else
local displayID = app.NPCDB[reference.qgs[1]];
if displayID then
self.Model:SetFacing(reference.modelRotation and ((reference.modelRotation * math.pi) / 180) or MODELFRAME_DEFAULT_ROTATION);
self.Model:SetCamDistanceScale(reference.modelScale or 1);
self.Model:SetDisplayInfo(displayID);
self.Model:Show();
self:Show();
return true;
end
end
end
if reference.displayID then
self.Model:SetFacing(reference.modelRotation and ((reference.modelRotation * math.pi) / 180) or MODELFRAME_DEFAULT_ROTATION);
self.Model:SetCamDistanceScale(reference.modelScale or 1);
self.Model:SetDisplayInfo(reference.displayID);
self.Model:Show();
self:Show();
return true;
elseif reference.modelID then
self.Model:SetFacing(reference.modelRotation and ((reference.modelRotation * math.pi) / 180) or MODELFRAME_DEFAULT_ROTATION);
self.Model:SetCamDistanceScale(reference.modelScale or 1);
self.Model:SetDisplayInfo(reference.modelID);
self.Model:Show();
self:Show();
return true;
elseif reference.unit and not reference.icon then
self.Model:SetFacing(reference.modelRotation and ((reference.modelRotation * math.pi) / 180) or MODELFRAME_DEFAULT_ROTATION);
self.Model:SetCamDistanceScale(reference.modelScale or 1);
self.Model:SetUnit(reference.unit);
self.Model:Show();
self:Show();
end
local s = reference.s;
if s then
if reference.artifactID then
-- Okay, fine.
elseif reference.g and #reference.g > 0 then
local npc = reference.g[1];
if npc and npc.npcID and npc.npcID <= -5200 and npc.npcID >= -5206 then
-- Okay, we're good.
else
s = nil;
end
else
s = nil;
end
end
if s then
local categoryID, appearanceID = C_TransmogCollection_GetAppearanceSourceInfo(s);
if appearanceID then
self.Model:SetCamDistanceScale(0.8);
self.Model:SetItemAppearance(appearanceID);
self.Model:Show();
self:Show();
return true;
end
end
if reference.model then
self.Model:SetFacing(reference.modelRotation and ((reference.modelRotation * math.pi) / 180) or MODELFRAME_DEFAULT_ROTATION);
self.Model:SetCamDistanceScale(reference.modelScale or 1);
self.Model:SetUnit("none");
self.Model:SetModel(reference.model);
self.Model:Show();
self:Show();
return true;
elseif reference.creatureID and reference.creatureID > 0 then
self.Model:SetFacing(reference.modelRotation and ((reference.modelRotation * math.pi) / 180) or MODELFRAME_DEFAULT_ROTATION);
self.Model:SetCamDistanceScale(reference.modelScale or 1);
self:SetCreatureID(reference.creatureID);
self.Model:Show();
return true;
end
if reference.atlas then
GameTooltipIcon:SetSize(64,64);
GameTooltipIcon.icon:SetAtlas(reference.atlas);
GameTooltipIcon:Show();
if reference["atlas-background"] then
GameTooltipIcon.icon.Background:SetAtlas(reference["atlas-background"]);
GameTooltipIcon.icon.Background:Show();
end
if reference["atlas-border"] then
GameTooltipIcon.icon.Border:SetAtlas(reference["atlas-border"]);
GameTooltipIcon.icon.Border:Show();
if reference["atlas-color"] then
local swatches = reference["atlas-color"];
GameTooltipIcon.icon.Border:SetVertexColor(swatches[1], swatches[2], swatches[3], swatches[4] or 1.0);
else
GameTooltipIcon.icon.Border:SetVertexColor(1, 1, 1, 1.0);
end
end
return true;
end
end
end
GameTooltipModel:Hide();
app.yell = function(msg)
UIErrorsFrame:AddMessage(msg or "nil", 1, 0, 0);
app:PlayRemoveSound();
end
app.print = function(...)
print(L["TITLE"], ...);
end
-- audio lib
local lastPlayedFanfare;
function app:PlayCompleteSound()
if app.Settings:GetTooltipSetting("Celebrate") then
-- Play a random complete sound
local t = app.Settings.AUDIO_COMPLETE_TABLE;
if t and type(t) == "table" then
local id = math.random(1, #t);
if t[id] then PlaySoundFile(t[id], "master"); end
end
end
end
function app:PlayFanfare()
if app.Settings:GetTooltipSetting("Celebrate") then
-- Don't spam the users. It's nice sometimes, but let's put a delay of at least 1 second on there.
local now = time();
if lastPlayedFanfare and (now - lastPlayedFanfare) < 1 then return nil; end
lastPlayedFanfare = now;
-- Play a random fanfare
local t = app.Settings.AUDIO_FANFARE_TABLE;
if t and type(t) == "table" then
local id = math.random(1, #t);
if t[id] then PlaySoundFile(t[id], "master"); end
end
end
end
function app:PlayRareFindSound()
if app.Settings:GetTooltipSetting("Celebrate") then
-- Play a random rarefind sound
local t = app.Settings.AUDIO_RAREFIND_TABLE;
if t and type(t) == "table" then
local id = math.random(1, #t);
if t[id] then PlaySoundFile(t[id], "master"); end
end
end
end
function app:PlayRemoveSound()
if app.Settings:GetTooltipSetting("Warn:Removed") then
-- Play a random fanfare
local t = app.Settings.AUDIO_REMOVE_TABLE;
if t and type(t) == "table" then
local id = math.random(1, #t);
if t[id] then PlaySoundFile(t[id], "master"); end
end
end
end
-- Color Lib
local CS = CreateFrame("ColorSelect", nil, app);
local function Colorize(str, color)
return "|c" .. color .. str .. "|r";
end
local function HexToARGB(hex)
return tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6)), tonumber("0x"..hex:sub(7,8));
end
local function HexToRGB(hex)
return tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6));
end
local function RGBToHex(r, g, b)
return string.format("ff%02x%02x%02x",
r <= 255 and r >= 0 and r or 0,
g <= 255 and g >= 0 and g or 0,
b <= 255 and b >= 0 and b or 0);
end
local function ConvertColorRgbToHsv(r, g, b)
CS:SetColorRGB(r, g, b);
local h,s,v = CS:GetColorHSV()
return {h=h,s=s,v=v}
end
local red, green = ConvertColorRgbToHsv(1,0,0), ConvertColorRgbToHsv(0,1,0);
local progress_colors = setmetatable({[1] = "ff15abff"}, {
__index = function(t, p)
local h;
p = tonumber(p);
if abs(red.h - green.h) > 180 then
local angle = (360 - abs(red.h - green.h)) * p;
if red.h < green.h then
h = floor(red.h - angle);
if h < 0 then h = 360 + h end
else
h = floor(red.h + angle);
if h > 360 then h = h - 360 end
end
else
h = floor(red.h-(red.h-green.h)*p)
end
CS:SetColorHSV(h, red.s-(red.s-green.s)*p, red.v-(red.v-green.v)*p);
local r,g,b = CS:GetColorRGB();
local color = RGBToHex(r * 255, g * 255, b * 255);
rawset(t, p, color);
return color;
end
});
local function GetNumberWithZeros(number, desiredLength)
if desiredLength > 0 then
local str = tostring(number);
local length = string.len(str);
local pos = string.find(str,"[.]");
if not pos then
str = str .. ".";
for i=desiredLength,1,-1 do
str = str .. "0";
end
else
local totalExtra = desiredLength - (length - pos);
for i=totalExtra,1,-1 do
str = str .. "0";
end
if totalExtra < 1 then
str = string.sub(str, 1, pos + desiredLength);
end
end
return str;
else
return tostring(floor(number));
end
end
local function GetProgressColor(p)
return progress_colors[p];
end
local function GetProgressColorText(progress, total)
if total and total > 0 then
local percent = progress / total;
return "|c" .. GetProgressColor(percent) .. tostring(progress) .. " / " .. tostring(total) .. " (" .. GetNumberWithZeros(percent * 100, app.Settings:GetTooltipSetting("Precision")) .. "%) |r";
end
end
local function GetCollectionIcon(state)
return L[(state and (state == 2 and "COLLECTED_APPEARANCE_ICON" or "COLLECTED_ICON")) or "NOT_COLLECTED_ICON"];
end
local function GetCollectionText(state)
return L[(state and (state == 2 and "COLLECTED_APPEARANCE" or "COLLECTED")) or "NOT_COLLECTED"];
end
local function GetCompletionIcon(state)
return L[state and "COMPLETE_ICON" or "NOT_COLLECTED_ICON"];
end
local function GetCompletionText(state)
return L[state and "COMPLETE" or "INCOMPLETE"];
end
local function GetProgressTextForRow(data)
if data.total and (data.total > 1 or (data.total > 0 and not data.collectible)) then
return GetProgressColorText(data.progress or 0, data.total);
elseif data.collectible then
return GetCollectionIcon(data.collected);
elseif data.trackable then
return GetCompletionIcon(data.saved);
end
end
local function GetProgressTextForTooltip(data)
if data.total and (data.total > 1 or (data.total > 0 and not data.collectible)) then
return GetProgressColorText(data.progress or 0, data.total);
elseif data.collectible then
return GetCollectionText(data.collected);
elseif data.trackable then
return GetCompletionText(data.saved);
end
end
CS:Hide();
-- Source ID Harvesting Lib
local DressUpModel = CreateFrame('DressUpModel');
local NPCModelHarvester = CreateFrame('DressUpModel', nil, OffScreenFrame);
local inventorySlotsMap = { -- Taken directly from CanIMogIt (Thanks!)
["INVTYPE_HEAD"] = {1},
["INVTYPE_NECK"] = {2},
["INVTYPE_SHOULDER"] = {3},
["INVTYPE_BODY"] = {4},
["INVTYPE_CHEST"] = {5},
["INVTYPE_ROBE"] = {5},
["INVTYPE_WAIST"] = {6},
["INVTYPE_LEGS"] = {7},
["INVTYPE_FEET"] = {8},
["INVTYPE_WRIST"] = {9},
["INVTYPE_HAND"] = {10},
["INVTYPE_RING"] = {11},
["INVTYPE_TRINKET"] = {12},
["INVTYPE_CLOAK"] = {15},
["INVTYPE_WEAPON"] = {16, 17},
["INVTYPE_SHIELD"] = {17},
["INVTYPE_2HWEAPON"] = {16, 17},
["INVTYPE_WEAPONMAINHAND"] = {16},
["INVTYPE_RANGED"] = {16},
["INVTYPE_RANGEDRIGHT"] = {16},
["INVTYPE_WEAPONOFFHAND"] = {17},
["INVTYPE_HOLDABLE"] = {17},
["INVTYPE_TABARD"] = {19},
};
local function BuildGroups(parent, g)
if g then
-- Iterate through the groups
for key, group in ipairs(g) do
-- Set the group's parent
group.parent = parent;
-- Build the groups
BuildGroups(group, group.g);
end
end
end
local function BuildSourceText(group, l)
if group.parent then
if l < 1 then
if group.dr then
return BuildSourceText(group.parent, l + 1) .. DESCRIPTION_SEPARATOR .. "|c" .. GetProgressColor(group.dr * 0.01) .. tostring(group.dr) .. "%|r";
else
return BuildSourceText(group.parent, l + 1);
end
else
return BuildSourceText(group.parent, l + 1) .. " -> " .. (group.text or "*");
end
end
return group.text or "*";
end
local function BuildSourceTextForChat(group, l)
if group.parent then
if l < 1 then
if group.dr then
return BuildSourceTextForChat(group.parent, l + 1) .. DESCRIPTION_SEPARATOR .. "|c" .. GetProgressColor(group.dr * 0.01) .. tostring(group.dr) .. "%|r";
else
return BuildSourceTextForChat(group.parent, l + 1);
end
else
return BuildSourceTextForChat(group.parent, l + 1) .. " -> " .. (group.text or "*");
end
return group.text or "*";
end
return "ATT";
end
local function BuildSourceTextForTSM(group, l)
if group.parent then
if l < 1 or not group.text then
return BuildSourceTextForTSM(group.parent, l + 1);
else
return BuildSourceTextForTSM(group.parent, l + 1) .. "`" .. group.text;
end
end
return L["TITLE"];
end
local function CloneData(data)
local clone = setmetatable({}, { __index = data });
if data.g then
clone.g = {};
for i,group in ipairs(data.g) do
local child = CloneData(group);
child.parent = clone;
tinsert(clone.g, child);
end
end
return clone;
end
local function GetSourceID(itemLink, itemID)
if IsDressableItem(itemLink) then
-- Updated function courtesy of CanIMogIt, Thanks AmiYuy and Team! :D
local sourceID = select(2, C_TransmogCollection.GetItemInfo(itemLink));
if sourceID then return sourceID, true; end
local itemID, _, _, slotName = GetItemInfoInstant(itemLink);
if slotName then
local slots = inventorySlotsMap[slotName];
if slots then
DressUpModel:SetUnit('player');
DressUpModel:Undress();
for i, slot in pairs(slots) do
DressUpModel:TryOn(itemLink, slot);
local sourceID = DressUpModel:GetSlotTransmogSources(slot);
if sourceID and sourceID ~= 0 then
-- Added 5/4/2018 - Account for DressUpModel lag... sigh
local sourceItemLink = select(6, C_TransmogCollection.GetAppearanceSourceInfo(sourceID));
if sourceItemLink and tonumber(sourceItemLink:match("item:(%d+)")) == itemID then
return sourceID, true;
end
end
end
end
end
return nil, true;
end
return nil, false;
end
app.IsComplete = function(o)
if o.total then return o.total == o.progress; end
if o.collectible then return o.collected; end
if o.trackable then return o.saved; end
end
app.GetSourceID = GetSourceID;
app.MaximumItemInfoRetries = 400;
local function GetDisplayID(data)
if data.displayID then
return data.displayID;
elseif data.creatureID then
local displayID = app.NPCDB[data.creatureID];
if displayID then
return displayID;
end
end
if data.qgs and #data.qgs > 0 then
return app.NPCDB[data.qgs[1]];
end
end
local function SetPortraitIcon(self, data, x)
self.lastData = data;
local displayID = GetDisplayID(data);
if displayID then
SetPortraitTextureFromDisplayID(self, displayID);
self:SetWidth(self:GetHeight());
self:SetTexCoord(0, 1, 0, 1);
return true;
elseif data.unit and not data.icon then
SetPortraitTexture(self, data.unit);
self:SetWidth(self:GetHeight());
self:SetTexCoord(0, 1, 0, 1);
return true;
end
-- Fallback to a traditional icon.
if data.atlas then
self:SetAtlas(data.atlas);
self:SetWidth(self:GetHeight());
self:SetTexCoord(0, 1, 0, 1);
if data["atlas-background"] then
self.Background:SetAtlas(data["atlas-background"]);
self.Background:SetWidth(self:GetHeight());
self.Background:Show();
end
if data["atlas-border"] then
self.Border:SetAtlas(data["atlas-border"]);
self.Border:SetWidth(self:GetHeight());
self.Border:Show();
if data["atlas-color"] then
local swatches = data["atlas-color"];
self.Border:SetVertexColor(swatches[1], swatches[2], swatches[3], swatches[4] or 1.0);
else
self.Border:SetVertexColor(1, 1, 1, 1.0);
end
end
return true;
elseif data.icon then
self:SetWidth(self:GetHeight());
self:SetTexture(data.icon);
local texcoord = data.texcoord;
if texcoord then
self:SetTexCoord(texcoord[1], texcoord[2], texcoord[3], texcoord[4]);
else
self:SetTexCoord(0, 1, 0, 1);
end
return true;
end
end
local function GetRelativeDifficulty(group, difficultyID)
if group then
if group.difficultyID then
if group.difficultyID == difficultyID then
return true;
end
if group.difficulties then
for i, difficulty in ipairs(group.difficulties) do
if difficulty == difficultyID then
return true;
end
end
end
return false;
end
if group.parent then
return GetRelativeDifficulty(group.parent, difficultyID);
else
return true;
end
end
end
local function GetRelativeMap(group, currentMapID)
if group then
if group.mapID then return group.mapID; end
if group.maps then
if contains(group.maps, currentMapID) then
return currentMapID;
else
return group.maps[1];
end
end
if group.parent then return GetRelativeMap(group.parent, currentMapID); end
end
return currentMapID;
end
local function GetRelativeField(group, field, value)
if group then
if group[field] then
if group[field] == value then
return true;
end
end
if group.parent then return GetRelativeField(group.parent, field, value); end
end
end
local function GetRelativeValue(group, field)
if group then
if group[field] then return group[field]; end
if group.parent then return GetRelativeValue(group.parent, field); end
end
end
-- Quest Completion Lib
local DirtyQuests = {};
local CompletedQuests = setmetatable({}, {__newindex = function (t, key, value)
DirtyQuests[key] = true;
rawset(t, key, value);
if app.Settings:GetTooltipSetting("Report:CompletedQuests") then
local searchResults = app.SearchForField("questID", key);
if searchResults and #searchResults > 0 then
if app.Settings:GetTooltipSetting("Report:UnsortedQuests") then
return true;
end
else
key = key .. " (Missing in ATT)";
end
print("Completed Quest ID #" .. key);
end