forked from ATTWoWAddon/AllTheThings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllTheThings.lua
14842 lines (14242 loc) · 506 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-2024 Dylan Fortune (Crieve-Sargeras) --
--------------------------------------------------------------------------------
-- App locals
local appName, app = ...;
local L = app.L;
local AssignChildren, CloneClassInstance, GetRelativeValue = app.AssignChildren, app.CloneClassInstance, app.GetRelativeValue;
local IsQuestFlaggedCompleted, IsQuestFlaggedCompletedForObject = app.IsQuestFlaggedCompleted, app.IsQuestFlaggedCompletedForObject;
-- Abbreviations
L.ABBREVIATIONS[L.UNSORTED .. " %> " .. L.UNSORTED] = "|T" .. app.asset("WindowIcon_Unsorted") .. ":0|t " .. L.SHORTTITLE .. " %> " .. L.UNSORTED;
-- Binding Localizations
BINDING_HEADER_ALLTHETHINGS = L.TITLE
BINDING_NAME_ALLTHETHINGS_TOGGLEACCOUNTMODE = L.TOGGLE_ACCOUNT_MODE
BINDING_NAME_ALLTHETHINGS_TOGGLECOMPLETIONISTMODE = L.TOGGLE_COMPLETIONIST_MODE
BINDING_NAME_ALLTHETHINGS_TOGGLEDEBUGMODE = L.TOGGLE_DEBUG_MODE
BINDING_NAME_ALLTHETHINGS_TOGGLEFACTIONMODE = L.TOGGLE_FACTION_MODE
BINDING_NAME_ALLTHETHINGS_TOGGLELOOTMODE = L.TOGGLE_LOOT_MODE
BINDING_HEADER_ALLTHETHINGS_PREFERENCES = PREFERENCES
BINDING_NAME_ALLTHETHINGS_TOGGLECOMPLETEDTHINGS = L.TOGGLE_COMPLETEDTHINGS
BINDING_NAME_ALLTHETHINGS_TOGGLECOMPLETEDGROUPS = L.TOGGLE_COMPLETEDGROUPS
BINDING_NAME_ALLTHETHINGS_TOGGLECOLLECTEDTHINGS = L.TOGGLE_COLLECTEDTHINGS
BINDING_NAME_ALLTHETHINGS_TOGGLEBOEITEMS = L.TOGGLE_BOEITEMS
BINDING_NAME_ALLTHETHINGS_TOGGLESOURCETEXT = L.TOGGLE_SOURCETEXT
BINDING_HEADER_ALLTHETHINGS_MODULES = L.MODULES
BINDING_NAME_ALLTHETHINGS_TOGGLEMAINLIST = L.TOGGLE_MAINLIST
BINDING_NAME_ALLTHETHINGS_TOGGLEMINILIST = L.TOGGLE_MINILIST
BINDING_NAME_ALLTHETHINGS_TOGGLE_PROFESSION_LIST = L.TOGGLE_PROFESSION_LIST
BINDING_NAME_ALLTHETHINGS_TOGGLE_RAID_ASSISTANT = L.TOGGLE_RAID_ASSISTANT
BINDING_NAME_ALLTHETHINGS_TOGGLE_WORLD_QUESTS_LIST = L.TOGGLE_WORLD_QUESTS_LIST
BINDING_NAME_ALLTHETHINGS_TOGGLERANDOM = L.TOGGLE_RANDOM
BINDING_NAME_ALLTHETHINGS_REROLL_RANDOM = L.REROLL_RANDOM
-- Performance Cache
local print, rawget, rawset, tostring, ipairs, pairs, tonumber, wipe, select, setmetatable, getmetatable, tinsert, tremove, type, math_floor
= print, rawget, rawset, tostring, ipairs, pairs, tonumber, wipe, select, setmetatable, getmetatable, tinsert, tremove, type, math.floor
-- Global WoW API Cache
local C_CreatureInfo_GetRaceInfo = C_CreatureInfo.GetRaceInfo;
local C_Map_GetMapInfo = C_Map.GetMapInfo;
local GetAchievementCriteriaInfo = _G.GetAchievementCriteriaInfo;
local GetAchievementInfo = _G.GetAchievementInfo;
local GetAchievementLink = _G.GetAchievementLink;
local InCombatLockdown = _G.InCombatLockdown;
local GetTimePreciseSec = GetTimePreciseSec
-- WoW API Cache
local GetFactionName = app.WOWAPI.GetFactionName;
local GetFactionBonusReputation = app.WOWAPI.GetFactionBonusReputation;
local GetItemInfo = app.WOWAPI.GetItemInfo;
local GetItemID = app.WOWAPI.GetItemID;
local GetItemIcon = app.WOWAPI.GetItemIcon;
local GetItemInfoInstant = app.WOWAPI.GetItemInfoInstant;
local GetSpellName = app.WOWAPI.GetSpellName;
local GetSpellIcon = app.WOWAPI.GetSpellIcon;
local GetSpellLink = app.WOWAPI.GetSpellLink;
local C_TradeSkillUI = C_TradeSkillUI;
local C_TradeSkillUI_GetCategories, C_TradeSkillUI_GetCategoryInfo, C_TradeSkillUI_GetRecipeInfo, C_TradeSkillUI_GetRecipeSchematic, C_TradeSkillUI_GetTradeSkillLineForRecipe
= C_TradeSkillUI.GetCategories, C_TradeSkillUI.GetCategoryInfo, C_TradeSkillUI.GetRecipeInfo, C_TradeSkillUI.GetRecipeSchematic, C_TradeSkillUI.GetTradeSkillLineForRecipe;
---@return number[]
local function GetCategoryIDs()
return { C_TradeSkillUI_GetCategories() };
end
---@class ATTGameTooltip: GameTooltip
local GameTooltip = GameTooltip;
-- App & Module locals
local ArrayAppend, constructor = app.ArrayAppend, app.constructor;
local CacheFields, SearchForField, SearchForFieldContainer, SearchForObject
= app.CacheFields, app.SearchForField, app.SearchForFieldContainer, app.SearchForObject
local AttachTooltipSearchResults = app.Modules.Tooltip.AttachTooltipSearchResults;
local IsRetrieving = app.Modules.RetrievingData.IsRetrieving;
local GetProgressColorText = app.Modules.Color.GetProgressColorText;
local TryColorizeName = app.TryColorizeName;
local DESCRIPTION_SEPARATOR = app.DESCRIPTION_SEPARATOR;
local ATTAccountWideData;
-- Color Lib
local GetProgressColor = app.Modules.Color.GetProgressColor;
local Colorize = app.Modules.Color.Colorize;
local HexToARGB = app.Modules.Color.HexToARGB;
-- Print/Debug/Testing Functions
app.PrintGroup = function(group,depth)
depth = depth or 0;
if group then
local p = "";
for i=0,depth,1 do
p = p .. "-";
end
p = p .. tostring(group.key or group.text) .. ":" .. tostring(group[group.key or "NIL"]);
print(p);
if group.g then
for i,sg in ipairs(group.g) do
app.PrintGroup(sg,depth + 1);
end
end
end
print("---")
end
--[[]]
app.PrintMemoryUsage = function(...)
-- update memory value for ATT
UpdateAddOnMemoryUsage();
if ... then app.print(..., GetAddOnMemoryUsage(appName));
else app.print("Memory",GetAddOnMemoryUsage(appName)); end
end
-- app.PrintMemoryUsage("ATT.lua")
--]]
-- Coroutine Helper Functions
local Push = app.Push;
local StartCoroutine = app.StartCoroutine;
local Callback = app.CallbackHandlers.Callback;
local DelayedCallback = app.CallbackHandlers.DelayedCallback;
local AfterCombatCallback = app.CallbackHandlers.AfterCombatCallback;
local AfterCombatOrDelayedCallback = app.CallbackHandlers.AfterCombatOrDelayedCallback;
app.UpdateRunner = app.CreateRunner("update");
app.FillRunner = app.CreateRunner("fill");
local LocalizeGlobal = app.LocalizeGlobal
local LocalizeGlobalIfAllowed = app.LocalizeGlobalIfAllowed
local contains = app.contains;
local containsAny = app.containsAny;
local containsValue = app.containsValue;
local indexOf = app.indexOf;
-- Data Lib
local attData;
local AllTheThingsAD = {}; -- For account-wide data.
local function SetDataMember(member, data)
AllTheThingsAD[member] = data;
end
app.SetDataMember = SetDataMember;
local function GetDataMember(member, default)
attData = AllTheThingsAD[member];
if attData == nil then
AllTheThingsAD[member] = default;
return default;
else
return attData;
end
end
app.GetDataMember = GetDataMember;
-- Returns an object which contains no data, but can return values from an overrides table, and be loaded/created when a specific field is attempted to be referenced
-- i.e. Create a data group which contains no information but will attempt to populate itself when [loadField] is referenced
app.DelayLoadedObject = function(objFunc, loadField, overrides, ...)
local o;
local params = {...};
local loader = {
__index = function(t, key)
-- load the object if it matches the load field and not yet loaded
if not o and key == loadField then
o = objFunc(unpack(params))
if not o then
error("DLO failed to generate an Object when loading!",unpack(params))
end
-- parent of the underlying object should correspond to the hierarchical parent of t (dlo)
local dloParent = rawget(t, "parent");
rawset(o, "parent", dloParent);
rawset(t, "__o", o);
-- allow the object to reference the DLO if needed
o.__dlo = t;
-- app.PrintDebug("DLO:Loaded",o.hash,"parent:",dloParent,dloParent and dloParent.hash)
-- DLOs can now have an OnLoad function which runs here when loaded for the first time
if overrides.OnLoad then overrides.OnLoad(o); end
end
-- override for the object
local override = overrides and overrides[key];
if override ~= nil then
-- app.PrintDebug("DLO:override",key,":",override)
-- overrides can also be a function which will execute once the object has been created
if o and type(override) == "function" then
return override(o, key);
else
return override;
end
-- existing object, then reference the respective key
elseif o then
return o[key];
-- otherwise ensure visible
elseif key == "visible" then
-- app.PrintDebug("dlo.visible",unpack(params))
return true;
end
end,
-- transfer field sets to the underlying object if the field does not have an override for the object
__newindex = function(t, key, val)
if o then
if not overrides[key] then
-- app.PrintDebug("DLO:__newindex:",o.hash,key,val)
rawset(o, key, val);
end
elseif key == "parent" then
rawset(t, key, val);
end
end,
};
-- data is just an empty table with a loader metatable
local dlo = setmetatable({__dlo=true}, loader);
return dlo;
end
local function RoundNumber(number, decimalPlaces)
local ret;
if number < 60 then
ret = number .. " second(s)";
else
ret = (("%%.%df"):format(decimalPlaces)):format(number/60) .. " minute(s)";
end
return ret;
end
local function formatNumericWithCommas(amount)
local k
while true do
amount, k = tostring(amount):gsub("^(-?%d+)(%d%d%d)", '%1,%2')
if k == 0 then
break
end
end
return amount
end
local function GetMoneyString(amount)
if amount > 0 then
local formatted
local gold,silver,copper = math_floor(amount / 100 / 100), math_floor((amount / 100) % 100), math_floor(amount % 100)
if gold > 0 then
formatted = formatNumericWithCommas(gold) .. "|TInterface\\MONEYFRAME\\UI-GoldIcon:0|t"
end
if silver > 0 then
formatted = (formatted or "") .. silver .. "|TInterface\\MONEYFRAME\\UI-SilverIcon:0|t"
end
if copper > 0 then
formatted = (formatted or "") .. copper .. "|TInterface\\MONEYFRAME\\UI-CopperIcon:0|t"
end
return formatted
end
return amount
end
local function GetDisplayID(data)
-- don't create a displayID for groups with a sourceID/itemID/difficultyID/mapID
if data.sourceID or data.itemID or data.difficultyID or data.mapID then return end
local displayID = data.displayID
if displayID then
return displayID
end
local npcID = data.npcID or data.creatureID
if npcID then
displayID = app.NPCDisplayIDFromID[npcID]
if displayID then
return displayID
end
end
local qgs = data.qgs
if qgs and #qgs > 0 then
return app.NPCDisplayIDFromID[qgs[1]]
end
local providers = data.providers
if providers and #providers > 0 then
local lookup = app.NPCDisplayIDFromID
for _,v in ipairs(providers) do
-- if one of the providers is an NPC, we should show its texture regardless of other providers
if v[1] == "n" then
return lookup[v[2]]
end
end
end
end
local function GetIconFromProviders(group)
if group.providers then
local icon;
for k,v in ipairs(group.providers) do
if v[2] > 0 then
if v[1] == "o" then
icon = app.ObjectIcons[v[2]];
elseif v[1] == "i" then
icon = GetItemIcon(v[2]);
end
if icon then return icon; end
end
end
end
end
local function GetNameFromProviders(group)
if group.providers then
local name;
for k,v in ipairs(group.providers) do
if v[2] > 0 then
if v[1] == "o" then
name = app.ObjectNames[v[2]];
elseif v[1] == "i" then
name = GetItemInfo(v[2]);
elseif v[1] == "n" then
name = app.NPCNameFromID[v[2]];
end
if name then return name; end
end
end
end
end
app.GetIconFromProviders = GetIconFromProviders;
app.GetNameFromProviders = GetNameFromProviders;
do -- TradeSkill Functionality
local tradeSkillSpecializationMap = {
[202] = { -- Engineering
20219, -- Gnomish Engineering
20222 -- Goblin Engineering
},
[164] = { -- Blacksmithing
9788, -- Armorsmith
9787, -- Weaponsmith
},
};
local specializationTradeSkillMap = {
-- Engineering Skills
[20219] = 202, -- Gnomish Engineering
[20222] = 202, -- Goblin Engineering
-- Blacksmithing Skills
[9788] = 9788, -- Armorsmith
[9787] = 9787, -- Weaponsmith
[17041] = 17041, -- Master Axesmith
[17040] = 17040, -- Master Hammersmith
[17039] = 17039, -- Master Swordsmith
-- Leatherworking
[10656] = 10656, -- Dragonscale Leatherworking
[10658] = 10658, -- Elemental Leatherworking
[10660] = 10660, -- Tribal Leatherworking
-- Tailoring
[26801] = 26801, -- Shadoweave Tailoring
[26797] = 26797, -- Spellfire Tailoring
[26798] = 26798, -- Mooncloth Tailoring
};
-- 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]
[2750] = 171, -- Shadowlands Alchemy [9.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]
[2751] = 164, -- Shadowlands Blacksmithing [9.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]
[2752] = 185, -- Shadowlands Cooking [9.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]
[2753] = 333, -- Shadowlands 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]
[2755] = 202, -- Shadowlands Engineering [9.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]
[2754] = 356, -- Shadowlands Fishing [9.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]
[2760] = 182, -- Shadowlands Herbalism [9.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]
[2756] = 773, -- Shadowlands 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]
[2757] = 755, -- Shadowlands Jewelcrafting [9.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]
[2758] = 165, -- Shadowlands Leatherworking [9.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]
[2761] = 186, -- Shadowlands Mining [9.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]
[2762] = 393, -- Shadowlands Skinning [9.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]
[2759] = 197, -- Shadowlands Tailoring [9.0.1]
};
local function GetBaseTradeSkillID(skillID)
return tradeSkillMap[skillID] or skillID;
end
local function GetTradeSkillSpecialization(skillID)
return tradeSkillSpecializationMap[skillID];
end
app.GetTradeSkillLine = function()
local profInfo = C_TradeSkillUI.GetBaseProfessionInfo();
return GetBaseTradeSkillID(profInfo.professionID);
end
app.GetSpecializationBaseTradeSkill = function(specializationID)
return specializationTradeSkillMap[specializationID];
end
-- Refreshes the known Trade Skills/Professions of the current character (app.CurrentCharacter.Professions)
local function RefreshTradeSkillCache()
local cache = app.CurrentCharacter.Professions;
wipe(cache);
-- "Professions" that anyone can "know"
cache[2720] = 1; -- Junkyard Tinkering
cache[2787] = 1; -- Abominable Stitching
cache[2791] = 1; -- Ascension Crafting
cache[2811] = 1; -- Stygia Crafting
cache[2819] = 1; -- Protoform Synthesis
cache[2847] = 1; -- Tuskarr Fishing Gear
cache[2886] = 1; -- Supply Shipments
-- app.PrintDebug("RefreshTradeSkillCache");
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
local prof = select(7, GetProfessionInfo(j));
cache[GetBaseTradeSkillID(prof)] = true;
-- app.PrintDebug("KnownProfession",j,GetProfessionInfo(j));
local specializations = GetTradeSkillSpecialization(prof);
if specializations ~= nil then
for _,spellID in pairs(specializations) do
if spellID and app.IsSpellKnownHelper(spellID) then
cache[spellID] = true;
end
end
end
end
end
end
app.AddEventHandler("OnStartup", RefreshTradeSkillCache)
app.AddEventHandler("OnStartup", function()
local conversions = app.Settings.InformationTypeConversionMethods;
conversions.professionName = function(spellID)
return GetSpellName(app.SkillIDToSpellID[spellID] or 0) or C_TradeSkillUI.GetTradeSkillDisplayName(spellID) or RETRIEVING_DATA;
end;
end);
app.AddEventRegistration("SKILL_LINES_CHANGED", function()
-- app.PrintDebug("SKILL_LINES_CHANGED")
-- seems to be a reliable way to notice a player has changed professions? not sure how else often it actually triggers... hopefully not too excessive...
DelayedCallback(RefreshTradeSkillCache, 2);
end)
end -- TradeSkill Functionality
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 "INCOMPLETE_ICON"];
end
local function GetCompletionText(state)
return L[(state == 2 and "COMPLETE_OTHER") or (state and "COMPLETE") or "INCOMPLETE"];
end
local function GetSavedText(state)
return L[state and "SAVED" or "INCOMPLETE"];
end
local function GetCollectibleIcon(data, iconOnly)
if data.collectible then
local collected = data.collected
if not collected and data.collectedwarband then
return iconOnly and L["COLLECTED_WARBAND_ICON"] or L["COLLECTED_WARBAND"];
end
return iconOnly and GetCollectionIcon(collected) or GetCollectionText(collected);
end
end
local function GetTrackableIcon(data, iconOnly, forSaved)
if data.trackable then
local saved = data.saved;
-- only show if the data is saved, or is not repeatable
if saved or not rawget(data, "repeatable") then
if forSaved then
-- if for saved, we ignore if it is un-saved for less clutter
if saved then
return iconOnly and GetCompletionIcon(saved) or GetSavedText(saved);
end
else
return iconOnly and GetCompletionIcon(saved) or GetCompletionText(saved);
end
end
end
end
local function GetCostIconForRow(data, iconOnly)
-- cost only for filled groups, or if itself is a cost
if data.filledCost or data.isCost or (data.progress == data.total and ((data.costTotal or 0) > 0)) then
return L[iconOnly and "COST_ICON" or "COST_TEXT"];
end
end
local function GetCostIconForTooltip(data, iconOnly)
-- cost only if itself is a cost
if data.filledCost or data.collectibleAsCost then
return L[iconOnly and "COST_ICON" or "COST_TEXT"];
end
end
local function GetUpgradeIconForRow(data, iconOnly)
-- upgrade only for filled groups, or if itself is an upgrade
if data.filledUpgrade or data.isUpgrade or (data.progress == data.total and ((data.upgradeTotal or 0) > 0)) then
return L[iconOnly and "UPGRADE_ICON" or "UPGRADE_TEXT"];
end
end
local function GetUpgradeIconForTooltip(data, iconOnly)
-- upgrade only if itself has an upgrade
if data.filledUpgrade or data.collectibleAsUpgrade then
return L[iconOnly and "UPGRADE_ICON" or "UPGRADE_TEXT"];
end
end
local function GetReagentIcon(data, iconOnly)
if data.filledReagent then
return L[iconOnly and "REAGENT_ICON" or "REAGENT_TEXT"];
end
end
local function GetStateIcon(data, iconOnly)
return GetCollectibleIcon(data, iconOnly) or GetTrackableIcon(data, iconOnly);
end
local function GetProgressTextForRow(data)
-- build the row text from left to right with possible info
local text = {}
-- Reagent (show reagent icon)
local icon = GetReagentIcon(data, true);
if icon then
tinsert(text, icon)
end
-- Cost (show cost icon)
icon = GetCostIconForRow(data, true);
if icon then
tinsert(text, icon)
end
-- Upgrade (show upgrade icon)
icon = GetUpgradeIconForRow(data, true);
if icon then
tinsert(text, icon)
end
-- Collectible
local stateIcon = GetCollectibleIcon(data, true)
if stateIcon then
tinsert(text, stateIcon)
end
-- Container
local total = data.total;
local isContainer = total and (total > 1 or (total > 0 and not data.collectible));
if isContainer then
local textContainer = GetProgressColorText(data.progress or 0, total)
tinsert(text, textContainer)
end
-- Non-collectible/total Container (only contains visible, non-collectibles...)
local g = data.g;
if not stateIcon and not isContainer and g and #g > 0 then
local headerText;
if data.expanded then
headerText = "---";
else
headerText = "+++";
end
tinsert(text, headerText)
end
-- Trackable (Only if no other text available)
if #text == 0 then
stateIcon = GetTrackableIcon(data, true)
if stateIcon then
tinsert(text, stateIcon)
end
end
return app.TableConcat(text, nil, "", " ");
end
local function GetProgressTextForTooltip(data)
-- build the row text from left to right with possible info
local text = {}
local iconOnly = app.Settings:GetTooltipSetting("ShowIconOnly");
-- Reagent (show reagent icon)
local icon = GetReagentIcon(data, iconOnly);
if icon then
tinsert(text, icon)
end
-- Cost (show cost icon)
icon = GetCostIconForTooltip(data, iconOnly);
if icon then
tinsert(text, icon)
end
-- Upgrade (show upgrade icon)
icon = GetUpgradeIconForTooltip(data, iconOnly);
if icon then
tinsert(text, icon)
end
-- Collectible
local stateIcon = GetCollectibleIcon(data, iconOnly)
if stateIcon then
tinsert(text, stateIcon)
end
-- Saved (only certain data types)
if data.npcID then
stateIcon = GetTrackableIcon(data, iconOnly, true)
if stateIcon then
tinsert(text, stateIcon)
end
end
-- Container
local total = data.total;
local isContainer = total and (total > 1 or (total > 0 and not data.collectible));
if isContainer then
local textContainer = GetProgressColorText(data.progress or 0, total)
if textContainer then
tinsert(text, textContainer)
end
end
-- Trackable (Only if no other text available)
if #text == 0 then
stateIcon = GetTrackableIcon(data, iconOnly)
if stateIcon then
tinsert(text, stateIcon)
end
end
return app.TableConcat(text, nil, "", " ");
end
app.GetCollectionIcon = GetCollectionIcon;
app.GetCollectionText = GetCollectionText;
app.GetCompletionIcon = GetCompletionIcon;
app.GetCompletionText = GetCompletionText;
app.GetProgressTextForRow = GetProgressTextForRow;
app.GetProgressTextForTooltip = GetProgressTextForTooltip;
-- Fields which are dynamic or pertain only to the specific ATT window and should never merge automatically
-- Maybe build from /base.lua:DefaultFields since those always are able to be dynamic
app.MergeSkipFields = {
-- true -> never
expanded = true,
indent = true,
g = true,
nmr = true,
nmc = true,
progress = true,
total = true,
visible = true,
modItemID = true,
rawlink = true,
sourceIgnored = true,
isCost = true,
costTotal = true,
isUpgrade = true,
upgradeTotal = true,
iconPath = true,
hash = true,
-- fields added to a group from GetSearchResults
tooltipInfo = true,
working = true,
-- update cached info
TLUG = true,
-- 1 -> only when cloning
e = 1,
u = 1,
c = 1,
up = 1,
pb = 1,
pvp = 1,
races = 1,
isDaily = 1,
isWeekly = 1,
isMonthly = 1,
isYearly = 1,
OnUpdate = 1,
requireSkill = 1,
};
-- Fields on a Thing which are specific to where the Thing is Sourced or displayed in a ATT window
app.SourceSpecificFields = {
-- Returns the 'most obtainable' event value from the provided set of event values
["e"] = function(...)
-- print("GetMostObtainableValue:")
-- app.PrintTable(vals)
local e;
local vals = select("#", ...);
for i=1,vals do
e = select(i, ...);
-- missing e value means NOT requiring an event
if not e then return; end
end
return e;
end,
-- Returns the 'most obtainable' unobtainable value from the provided set of unobtainable values
["u"] = function(...)
-- print("GetMostObtainableValue:")
local max, check, new = -1, nil, nil;
-- app.PrintTable(vals)
local conditions = L.AVAILABILITY_CONDITIONS;
local condition, u;
local vals = select("#", ...);
for i=1,vals do
u = select(i, ...);
-- missing u value means NOT unobtainable
if not u then return; end
condition = conditions[u];
if condition then
check = condition[1];
else
-- otherwise it's an invalid unobtainable filter
app.print("Invalid Unobtainable Filter:",u);
return;
end
-- track the highest unobtainable value, which is the most obtainable (according to AVAILABILITY_CONDITIONS)
if check > max then
new = u;
max = check;
end
end
-- print("new:",new)
return new;
end,
-- Returns the 'highest' Removed with Patch value from the provided set of `rwp` values
["rwp"] = function(...)
local max, rwp = -1,nil;
local vals = select("#", ...);
for i=1,vals do
rwp = select(i, ...);
-- missing rwp value means NOT removed
if not rwp then return; end
-- track the highest rwp value, which is the furthest-future patch
if rwp > max then
max = rwp;
end
end
-- print("max:",max)
return max;
end,
-- Simple boolean
["pvp"] = true,
["pb"] = true,
["requireSkill"] = true,
};
-- Merges the properties of the t group into the g group, making sure not to alter the filterability of the group.
-- Additionally can specify that the object is being cloned so as to skip special merge restrictions
local function MergeProperties(g, t, noReplace, clone)
if g and t then
if g ~= t then
g.__merge = t
end
local skips = app.MergeSkipFields;
if noReplace then
for k,v in pairs(t) do
-- certain keys should never transfer to the merge group directly
if k == "parent" then
if not rawget(g, "sourceParent") then
g.sourceParent = v;
end
elseif not skips[k] then
if rawget(g, k) == nil then
g[k] = v;
end
end
end
elseif clone then
for k,v in pairs(t) do
-- certain keys should never transfer to the merge group directly
if k == "parent" then
if not rawget(g, "sourceParent") then
g.sourceParent = v;
end
elseif skips[k] ~= true then
g[k] = v;
end
end
else
for k,v in pairs(t) do
-- certain keys should never transfer to the merge group directly
if k == "parent" then
if not rawget(g, "sourceParent") then
g.sourceParent = v;
end
elseif not skips[k] then
g[k] = v;
end
end
end
-- custom special logic for fields which need to represent the commonality between all Sources of a group
-- loop through specific fields for custom logic
-- initial creation of a g object, has no key
if not g.key then
for k,_ in pairs(app.SourceSpecificFields) do
g[k] = t[k];
end
else
local gk, tk;
for k,f in pairs(app.SourceSpecificFields) do
-- existing is set
gk = g[k];
if gk then
tk = t[k];
-- no value on merger
if tk == nil then
-- app.PrintDebug(g.hash,"remove",k,gk,tk)
g[k] = nil;
elseif f and type(f) == "function" then
-- two different values with a compare function
-- app.PrintDebug(g.hash,"compare",k,gk,tk)
g[k] = f(gk, tk);
-- app.PrintDebug(g.hash,"result",g[k])
end
end
end
end
-- only copy metatable to g if another hasn't been set already
if not getmetatable(g) and getmetatable(t) then
setmetatable(g, getmetatable(t));
end
end
end
app.MergeProperties = MergeProperties;
-- The base logic for turning a Table of data into an 'object' that provides dynamic information concerning the type of object which was identified
-- based on the priority of possible key values
local function CreateObject(t, rootOnly)
-- app.PrintDebug("CO",t);
-- Commented this part out because there aren't enough class definitions exposed to the logic yet
-- Retail class design is still wildin' and doesn't use the CreateClass functionality
--local object = app.CloneClassInstance(t, rootOnly);
--if object and getmetatable(object) then return object; end
if not t then return {}; end
-- already an object, so need to create a new instance of the same data
if t.key then
local result = {};
-- app.PrintDebug("CO.key",t.key,t[t.key],"=>",result);
MergeProperties(result, t, nil, true);
-- include the raw g since it will be replaced at the end with new objects
result.g = t.g;
t = result;
-- if not getmetatable(t) then
-- app.PrintDebug(Colorize("Bad CreateObject (key without metatable) used:",app.Colors.ChatLinkError))
-- app.PrintTable(t)
-- end
-- app.PrintDebug("Merge done",result.key,result[result.key], t, result);
-- is it an array of raw datas which needs to be turned into an array of usable objects
elseif t[1] then
local result = {};
-- array
-- app.PrintDebug("CO.[]","=>",result);
for i,o in ipairs(t) do
result[i] = CreateObject(o, rootOnly);
end
return result;
-- use the highest-priority piece of data which exists in the table to turn it into an object
else
-- a table which somehow has a metatable which doesn't include a 'key' field
local meta = getmetatable(t);
if meta then
app.PrintDebug(Colorize("Bad CreateObject (metatable without key) used:",app.Colors.ChatLinkError))
app.PrintTable(t)
local result = {};
-- app.PrintDebug("CO.meta","=>",result);
MergeProperties(result, t, nil, true);
if not rootOnly and t.g then
local newg = {}
result.g = newg
for i,o in ipairs(t.g) do
newg[#newg+1] = CreateObject(o)
end
end
setmetatable(result, meta);
return result;
end
if t.mapID then
t = app.CreateMap(t.mapID, t);
elseif t.explorationID then
t = app.CreateExploration(t.explorationID, t);
elseif t.sourceID then
t = app.CreateItemSource(t.sourceID, t.itemID, t);
elseif t.encounterID then
t = app.CreateEncounter(t.encounterID, t);
elseif t.instanceID then
t = app.CreateInstance(t.instanceID, t);