forked from Tga123/WorldQuestTab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WorldQuestTab.lua
2845 lines (2420 loc) · 92.8 KB
/
WorldQuestTab.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
--
-- Info structure
--
-- questId [number] questId
-- isAllyQuest [boolean] is a quest for combat allies (Nazjatar)
-- isDaily [boolean] is a daily type quest (Nazjatar & threat quests)
-- isCriteria [boolean] is part of currently selected emissary
-- alwaysHide [boolean] If the quest should be hidden no matter what
-- passedFilter [boolean] passed current filters
-- isValid [boolean] true if the quest is valid. Quest are invalid when they are missing quest data
-- time [table] time related values
-- seconds [number] seconds remaining when the data was gathered (To check the difference between no time and expired time)
-- mapInfo [table] zone related values, for more accurate position use WQT_Utils:GetQuestMapLocation
-- mapX [number] x pin position
-- mapY [number] y pin position
-- Reward [table]
-- typeBits [bitfield] a combination of flags for all the types of rewards the quest provides. I.e. AP + gold + rep = 2^3 + 2^6 + 2^9 = 584 (1001001000)
-- rewardList [table] List of rewards sorted by priority and filter settings
-- iterative list of rewardInfo tables
--
-- questInfo Functions
--
-- GetRewardType() Type of the top reward
-- GetRewardId() Id of the top reward
-- GetRewardAmount() Amount of the top reward
-- GetRewardTexture() Texture of the top reward
-- GetRewardQuality() Quality of the top reward
-- GetRewardColor() Color of the top reward
-- GetRewardCanUpgrade() If the top reward has a chance of upgrading
-- TryDressUpReward() Try all of the rewards to be shown in the dressing room
-- IsExpired() Whether the quest time is expired or not
-- GetReward(index) Get a specific reward from the list. nil if index is not available
-- IterateRewards() Return ipairs of the rewards
-- RewardInfo structure
--
-- type [number] type of reward. See WQT_REWARDTYPE in Data.lua
-- texture [number/string] texture of the reward. can be string for things like gold or unknown reward
-- amount [amount] amount of items, gold, rep, or item level
-- id [number] itemId for reward. 0 if not applicable (i.e. gold)
-- quality [number] item quality; common, rare, epic, etc
-- canUpgrade [boolean, nullable] true if item has a chance to upgrade (e.g. ilvl 285+)
-- color [Color] color based on the type of reward
--
-- For other data use following functions
--
-- local title, factionId = C_TaskQuest.GetQuestInfoByQuestID(questId);
-- local mapInfo = WQT_Utils:GetCachedMapInfo(zoneId); | mapInfo = {[mapID] = number, [name] = string, [parenMapID] = number, [mapType] = Enum.UIMapType};
-- local mapInfo = WQT_Utils:GetMapInfoForQuest(questId); | Quick function that gets the zoneId from the questId first
-- local factionInfo = WQT_Utils:GetFactionDataInternal(factionId); | factionInfo = {[name] = string, [texture] = string/number, [playerFaction] = string, [expansion] = number}
-- local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex, displayTimeLeft = GetQuestTagInfo(questId);
-- local texture, sizeX, sizeY = WQT_Utils:GetCachedTypeIconData(worldQuestType, tradeskillLineIndex);
-- local timeLeftSeconds, timeString, color, timeStringShort, category = WQT_Utils:GetQuestTimeString(questInfo, fullString, unabreviated);
-- local x, y = WQT_Utils:GetQuestMapLocation(questId, mapId); | More up to date position than mapInfo
--
-- Callbacks (WQT_WorldQuestFrame:RegisterCallback(event, func, addonName))
--
-- "InitFilter" (self, level) After InitFilter finishes
-- "InitSettings" (self, level) After InitSettings finishes
-- "DisplayQuestList" (skipPins) After all buttons in the list have been updated
-- "FilterQuestList" () After the list has been filtered
-- "UpdateQuestList" () After the list has been both filtered and updated
-- "QuestsLoaded" () After the dataprovider updated its quest data
-- "WaitingRoomUpdated" () After data in the dataprovider's waitingroom got updated
-- "SortChanged" (category) After sort category was changed to a different one
-- "ListButtonUpdate" (button) After a button was updated and shown
-- "AnchorChanged" (anchor) After the anchor of the quest list has changed
-- "MapPinInitialized" (pin) After a map pin has been fully setup to be shown
-- "WorldQuestCompleted" (questId, questInfo) When a world quest is completed. questInfo gets cleared shortly after this callback is triggered
local addonName, addon = ...
local WQT = addon.WQT;
local ADD = LibStub("AddonDropDown-2.0");
local _L = addon.L
local _V = addon.variables;
local WQT_Utils = addon.WQT_Utils;
local WQT_Profiles = addon.WQT_Profiles;
local _; -- local trash
local _emptyTable = {};
local _playerFaction = GetPlayerFactionGroup();
local _playerName = UnitName("player");
local utilitiesStatus = select(5, GetAddOnInfo("WorldQuestTabUtilities"));
local _utilitiesInstalled = not utilitiesStatus or utilitiesStatus ~= "MISSING";
local _WFMLoaded = IsAddOnLoaded("WorldFlightMap");
-- Custom number abbreviation to fit inside reward icons in the list.
local function GetLocalizedAbbreviatedNumber(number)
if type(number) ~= "number" then return "NaN" end;
local intervals = _L["IS_AZIAN_CLIENT"] and _V["NUMBER_ABBREVIATIONS_ASIAN"] or _V["NUMBER_ABBREVIATIONS"];
for i = 1, #intervals do
local interval = intervals[i];
local value = interval.value;
local valueDivTen = value / 10;
if (number >= value) then
if (interval.decimal) then
local rest = number - floor(number/value)*value;
if (rest < valueDivTen) then
return interval.format:format(floor(number/value));
else
return interval.format:format(floor(number/valueDivTen)/10);
end
end
return interval.format:format(floor(number/valueDivTen));
end
end
return number;
end
local function slashcmd(msg)
if (msg == "debug") then
addon.debug = not addon.debug;
WQT_QuestScrollFrame:UpdateQuestList();
print("WQT: debug", addon.debug and "enabled" or "disabled");
return;
elseif (msg:find("^dump")) then
local addition = msg:sub(6)
WQT_DebugFrame:DumpDebug(addition);
return;
end
end
local function IsRelevantFilter(filterID, key)
-- Check any filter outside of factions if disabled by worldmap filter
if (filterID > _V["FILTER_TYPES"].faction) then return not WQT:FilterIsWorldMapDisabled(key) end
-- Faction filters that are a string get a pass
if (not key or type(key) == "string") then return true; end
-- Factions with an ID of which the player faction is matching or neutral pass
local data = WQT_Utils:GetFactionDataInternal(key);
if (data and not data.playerFaction or data.playerFaction == _playerFaction) then return true; end
return false;
end
local function FilterDDFunc(ddFrame)
local level = ddFrame.level;
local value = ddFrame.value;
local info = ddFrame:CreateButtonInfo();
if level == 1 then
-- Faction, reward, and type filters
info = ddFrame:CreateButtonInfo("expand");
for k, v in pairs(WQT.settings.filters) do
info.text = v.name;
info.value = k;
ddFrame:AddButton(info);
end
-- Quests types that ignore filters
info = ddFrame:CreateButtonInfo("expand");
info.text = _L["IGNORES_FILTERS"];
info.value = "VIQ";
ddFrame:AddButton(info);
-- Uninterested
info = ddFrame:CreateButtonInfo("checkbox");
info.text = _L["UNINTERESTED"];
info.tooltipTitle = _L["UNINTERESTED"];
info.tooltipText = _L["UNINTERESTED_TT"];
info.func = function(_, _, _, value)
WQT.settings.general.showDisliked = value;
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return WQT.settings.general.showDisliked end;
ddFrame:AddButton(info);
-- Emisarry only filter
info = ddFrame:CreateButtonInfo("checkbox");
info.text = _L["TYPE_EMISSARY"];
info.tooltipTitle = _L["TYPE_EMISSARY"];
info.tooltipText = _L["TYPE_EMISSARY_TT"];
info.func = function(_, _, _, value)
WQT_WorldQuestFrame.autoEmisarryId = nil;
WQT.settings.general.emissaryOnly = value;
WQT_QuestScrollFrame:UpdateQuestList();
-- If we turn it off, remove the auto set as well
if not value then
WQT_WorldQuestFrame.autoEmisarryId = nil;
end
end
info.checked = function() return WQT.settings.general.emissaryOnly end;
ddFrame:AddButton(info);
elseif level == 2 then
-- Filters
if value then
-- Faction filters
if value == _V["FILTER_TYPES"].faction then
--info.notCheckable = true;
info = ddFrame:CreateButtonInfo("option");
info.keepShownOnClick = true;
info.text = CHECK_ALL
info.func = function()
WQT:SetAllFilterTo(_V["FILTER_TYPES"].faction, true);
ddFrame:Refresh();
WQT_QuestScrollFrame:UpdateQuestList();
end
ddFrame:AddButton(info);
info.text = UNCHECK_ALL
info.func = function()
WQT:SetAllFilterTo(_V["FILTER_TYPES"].faction, false);
ddFrame:Refresh();
WQT_QuestScrollFrame:UpdateQuestList();
end
ddFrame:AddButton(info);
info = ddFrame:CreateButtonInfo("checkbox");
local filter = WQT.settings.filters[_V["FILTER_TYPES"].faction];
local options = filter.flags;
local order = WQT.filterOrders[_V["FILTER_TYPES"].faction]
local currExp = _V["CURRENT_EXPANSION"];
for k, flagKey in pairs(order) do
local factionInfo = type(flagKey) == "number" and WQT_Utils:GetFactionDataInternal(flagKey) or nil;
-- Only factions that are current expansion and match the player's faction
if (factionInfo and factionInfo.expansion == currExp and (not factionInfo.playerFaction or factionInfo.playerFaction == _playerFaction)) then
info.text = type(flagKey) == "number" and GetFactionInfoByID(flagKey) or flagKey;
info.func = function(_, _, _, value)
options[flagKey] = value;
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return options[flagKey] end;
ddFrame:AddButton(info);
end
end
-- Other
info.text = OTHER;
info.func = function(_, _, _, value)
filter.misc.other = value;
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return filter.misc.other end;
ddFrame:AddButton(info);
-- No faction
info.text = _L["NO_FACTION"];
info.func = function(_, _, _, value)
filter.misc.none = value;
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return filter.misc.none end;
ddFrame:AddButton(info);
-- Other expansions
info = ddFrame:CreateButtonInfo("expand");
-- Shadowlands
info.text = EXPANSION_NAME8;
info.value = 303;
ddFrame:AddButton(info);
-- BFA
info.text = EXPANSION_NAME7;
info.value = 302;
ddFrame:AddButton(info);
-- Legion
info.text = EXPANSION_NAME6;
info.value = 301;
ddFrame:AddButton(info);
-- Type and reward filters
elseif WQT.settings.filters[value] then
info = ddFrame:CreateButtonInfo("option");
info.keepShownOnClick = true;
info.text = CHECK_ALL
info.func = function()
WQT:SetAllFilterTo(value, true);
ddFrame:Refresh();
WQT_QuestScrollFrame:UpdateQuestList();
end
ddFrame:AddButton(info);
info.text = UNCHECK_ALL
info.func = function()
WQT:SetAllFilterTo(value, false);
ddFrame:Refresh();
WQT_QuestScrollFrame:UpdateQuestList();
end
ddFrame:AddButton(info);
info = ddFrame:CreateButtonInfo("checkbox");
info.tooltipWhileDisabled = true;
local options = WQT.settings.filters[value].flags;
local order = WQT.filterOrders[value]
local haveLabels = (_V["WQT_TYPEFLAG_LABELS"][value] ~= nil);
local hasOldContent = false;
for k, flagKey in pairs(order) do
if (not WQT_Utils:FilterIsOldContent(value, flagKey)) then
info.disabled = false;
info.tooltipTitle = nil;
info.text = haveLabels and _V["WQT_TYPEFLAG_LABELS"][value][flagKey] or flagKey;
info.func = function(_, _, _, value)
options[flagKey] = value;
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return options[flagKey] end;
info.funcEnter = nil;
info.funcLeave = nil;
info.funcDisabled = nil
if WQT:FilterIsWorldMapDisabled(flagKey) then
info.disabled = true;
info.tooltipTitle = _L["MAP_FILTER_DISABLED"];
info.tooltipText = _L["MAP_FILTER_DISABLED_BUTTON_INFO"];
info.funcEnter = function() WQT_WorldQuestFrame:ShowHighlightOnMapFilters(); end;
info.funcLeave = function() WQT_PoISelectIndicator:Hide(); end;
info.funcDisabled = function(listButton, button)
if (button == "RightButton") then
if (WQT_WorldQuestFrame:SetCvarValue(flagKey, true)) then
ddFrame:Refresh(true);
listButton.tooltipTitle = nil;
listButton.tooltipText = nil;
listButton.funcEnter = nil;
listButton.funcLeave = nil;
end
end
end;
end
ddFrame:AddButton(info);
else
hasOldContent = true;
end
end
if (hasOldContent) then
info = ddFrame:CreateButtonInfo("expand");
-- BFA
info.text = OTHER;
info.value = "OldFilters" .. value;
ddFrame:AddButton(info);
end
elseif (value == "VIQ") then
-- Callings
info = ddFrame:CreateButtonInfo("checkbox");
info.text = CALLINGS_QUESTS;
info.func = function(_, _, _, value)
WQT.settings.general.filterPasses.calling = value;
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return WQT.settings.general.filterPasses.calling end;
ddFrame:AddButton(info);
-- Threat
info = ddFrame:CreateButtonInfo("checkbox");
info.text = REPORT_THREAT;
info.func = function(_, _, _, value)
WQT.settings.general.filterPasses.threat = value;
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return WQT.settings.general.filterPasses.threat end;
ddFrame:AddButton(info);
end
end
elseif level == 3 then
info = ddFrame:CreateButtonInfo("checkbox");
if value == 301 then -- Legion factions
local options = WQT.settings.filters[1].flags;
local order = WQT.filterOrders[1]
local currExp = LE_EXPANSION_LEGION;
for k, flagKey in pairs(order) do
local factionInfo = type(flagKey) == "number" and WQT_Utils:GetFactionDataInternal(flagKey) or nil;
if (factionInfo and factionInfo.expansion == currExp and (not factionInfo.playerFaction or factionInfo.playerFaction == _playerFaction)) then
info.text = type(flagKey) == "number" and factionInfo.name or flagKey;
info.func = function(_, _, _, value)
options[flagKey] = value;
if (value) then
WQT_WorldQuestFrame.pinDataProvider:RefreshAllData()
end
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return options[flagKey] end;
ddFrame:AddButton(info);
end
end
elseif value == 302 then -- BfA
local options = WQT.settings.filters[1].flags;
local order = WQT.filterOrders[1]
local currExp = LE_EXPANSION_BATTLE_FOR_AZEROTH;
for k, flagKey in pairs(order) do
local factionInfo = type(flagKey) == "number" and WQT_Utils:GetFactionDataInternal(flagKey) or nil;
if (factionInfo and factionInfo.expansion == currExp and (not factionInfo.playerFaction or factionInfo.playerFaction == _playerFaction)) then
info.text = type(flagKey) == "number" and factionInfo.name or flagKey;
info.func = function(_, _, _, value)
options[flagKey] = value;
if (value) then
WQT_WorldQuestFrame.pinDataProvider:RefreshAllData()
end
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return options[flagKey] end;
ddFrame:AddButton(info);
end
end
elseif value == 303 then -- Shadowlands
local options = WQT.settings.filters[1].flags;
local order = WQT.filterOrders[1]
local currExp = LE_EXPANSION_SHADOWLANDS;
for k, flagKey in pairs(order) do
local factionInfo = type(flagKey) == "number" and WQT_Utils:GetFactionDataInternal(flagKey) or nil;
if (factionInfo and factionInfo.expansion == currExp and (not factionInfo.playerFaction or factionInfo.playerFaction == _playerFaction)) then
info.text = type(flagKey) == "number" and factionInfo.name or flagKey;
info.func = function(_, _, _, value)
options[flagKey] = value;
if (value) then
WQT_WorldQuestFrame.pinDataProvider:RefreshAllData()
end
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return options[flagKey] end;
ddFrame:AddButton(info);
end
end
elseif value:find("OldFilters") then
local filterID = tonumber(value:match("(%d+)"));
info = ddFrame:CreateButtonInfo("checkbox");
info.tooltipWhileDisabled = true;
local options = WQT.settings.filters[filterID].flags;
local order = WQT.filterOrders[filterID]
local haveLabels = (_V["WQT_TYPEFLAG_LABELS"][filterID] ~= nil);
local hasOldContent = false;
for k, flagKey in pairs(order) do
if (WQT_Utils:FilterIsOldContent(filterID, flagKey)) then
info.disabled = false;
info.tooltipTitle = nil;
info.text = haveLabels and _V["WQT_TYPEFLAG_LABELS"][filterID][flagKey] or flagKey;
info.func = function(_, _, _, filterID)
options[flagKey] = filterID;
WQT_QuestScrollFrame:UpdateQuestList();
end
info.checked = function() return options[flagKey] end;
info.funcEnter = nil;
info.funcLeave = nil;
info.funcDisabled = nil
if WQT:FilterIsWorldMapDisabled(flagKey) then
info.disabled = true;
info.tooltipTitle = _L["MAP_FILTER_DISABLED"];
info.tooltipText = _L["MAP_FILTER_DISABLED_BUTTON_INFO"];
info.funcEnter = function() WQT_WorldQuestFrame:ShowHighlightOnMapFilters(); end;
info.funcLeave = function() WQT_PoISelectIndicator:Hide(); end;
info.funcDisabled = function(listButton, button)
if (button == "RightButton") then
if (WQT_WorldQuestFrame:SetCvarValue(flagKey, true)) then
ddFrame:Refresh(true);
listButton.tooltipTitle = nil;
listButton.tooltipText = nil;
listButton.funcEnter = nil;
listButton.funcLeave = nil;
end
end
end;
end
ddFrame:AddButton(info);
else
hasOldContent = true;
end
end
end
end
WQT_WorldQuestFrame:TriggerCallback("InitFilter", ddFrame);
end
local function SettingsDDFunc(ddFrame)
local level = ddFrame.level;
local info = ddFrame:CreateButtonInfo();
info.keepShownOnClick = false;
info.tooltipWhileDisabled = true;
info.tooltipOnButton = true;
info.motionScriptsWhileDisabled = true;
info.disabled = nil;
if level == 1 then
info.checked = nil;
info.isNotRadio = true;
info.func = nil;
info.hasArrow = false;
info.notCheckable = true;
-- Settings button
info.text = SETTINGS;
info.func = function()
WQT_WorldQuestFrame:ShowOverlayFrame(WQT_SettingsFrame);
end
ddFrame:AddButton(info)
-- What's new
local newText = WQT.db.global.updateSeen and "" or "|TInterface\\FriendsFrame\\InformationIcon:14|t ";
info.text = newText .. _L["WHATS_NEW"];
info.tooltipTitle = _L["WHATS_NEW"];
info.tooltipText = _L["WHATS_NEW_TT"];
info.func = function()
local scrollFrame = WQT_VersionFrame;
local blockerText = scrollFrame.Text;
blockerText:SetText(_V["LATEST_UPDATE"]);
blockerText:SetHeight(blockerText:GetContentHeight());
scrollFrame.limit = max(0, blockerText:GetHeight() - scrollFrame:GetHeight());
scrollFrame.scrollBar:SetMinMaxValues(0, scrollFrame.limit)
scrollFrame.scrollBar:SetValue(0);
WQT.db.global.updateSeen = true;
WQT_WorldQuestFrame:ShowOverlayFrame(scrollFrame, 10, -18, -3, 3);
end
ddFrame:AddButton(info)
end
WQT_WorldQuestFrame:TriggerCallback("InitSettings", ddFrame);
end
-- Sort filters alphabetically regardless of localization
local function GetSortedFilterOrder(filterId)
local filter = WQT.settings.filters[filterId];
local tbl = {};
for k, v in pairs(filter.flags) do
table.insert(tbl, k);
end
table.sort(tbl, function(a, b)
if (filterId == _V["FILTER_TYPES"].faction) then
-- Compare 2 factions
if(type(a) == "number" and type(b) == "number")then
local nameA = GetFactionInfoByID(tonumber(a));
local nameB = GetFactionInfoByID(tonumber(b));
if nameA and nameB then
return nameA < nameB;
end
return a and not b;
end
else
-- Compare localized labels for tpye and
if (_V["WQT_TYPEFLAG_LABELS"][filterId]) then
return (_V["WQT_TYPEFLAG_LABELS"][filterId][a] or "") < (_V["WQT_TYPEFLAG_LABELS"][filterId][b] or "");
end
end
-- Failsafe
return tostring(a) < tostring(b);
end)
return tbl;
end
local function SortQuestList(a, b, sortID)
-- Invalid goes to the bottom
if (not a.isValid or not b.isValid) then
if (a.isValid == b.isValid) then
return a.questId < b.questId;
end;
return a.isValid and not b.isValid;
end
-- Filtered out quests go to the back (for debug view mainly)
if (not a.passedFilter or not b.passedFilter) then
if (a.passedFilter == b.passedFilter) then
return a.questId < b.questId;
end;
return a.passedFilter and not b.passedFilter;
end
-- Disliked quests go to the back of the list
local aDisliked = a:IsDisliked();
local bDisliked = b:IsDisliked();
if (aDisliked ~= bDisliked) then
return not aDisliked;
end
-- Sort by a list of filters depending on the current filter choice
local order = _V["SORT_OPTION_ORDER"][sortID];
if (not order) then
order = _emptyTable;
WQT:debugPrint("No sort order for", sortID);
return a.questId < b.questId;
end
for k, criteria in ipairs(order) do
if(_V["SORT_FUNCTIONS"][criteria]) then
local result = _V["SORT_FUNCTIONS"][criteria](a, b);
if (result ~= nil) then
return result
end;
else
WQT:debugPrint("Invalid sort criteria", criteria);
end
end
-- Worst case fallback
return a.questId < b.questId;
end
local function GetNewSettingData(old, default)
return old == nil and default or old;
end
local function ConvertOldSettings(version)
if (not version or version == "") then
WQT.db.global.versionCheck = "1";
-- It's a new user, their settings are perfect
-- Unless I change my mind again
return;
end
-- BfA
if (version < "8.0.1") then
-- In 8.0.01 factions use ids rather than name
local repFlags = WQT.db.global.filters[1].flags;
for name in pairs(repFlags) do
if (type(name) == "string" and name ~= "Other" and name ~= _L["NO_FACTION"]) then
repFlags[name] = nil;
end
end
end
-- Pin rework, turn off pin time by default
if (version < "8.2.01") then
WQT.db.global.showPinTime = false;
end
-- Reworked save structure
if (version < "8.2.02") then
WQT.db.global.general.defaultTab = GetNewSettingData(WQT.db.global.defaultTab, false);
WQT.db.global.general.saveFilters = GetNewSettingData(WQT.db.global.saveFilters, true);
WQT.db.global.general.emissaryOnly = GetNewSettingData(WQT.db.global.emissaryOnly, false);
WQT.db.global.general.useLFGButtons = GetNewSettingData(WQT.db.global.useLFGButtons, false);
WQT.db.global.general.autoEmisarry = GetNewSettingData(WQT.db.global.autoEmisarry, true);
WQT.db.global.general.questCounter = GetNewSettingData(WQT.db.global.questCounter, true);
WQT.db.global.general.bountyCounter = GetNewSettingData(WQT.db.global.bountyCounter, true);
WQT.db.global.general.useTomTom = GetNewSettingData(WQT.db.global.useTomTom, true);
WQT.db.global.general.TomTomAutoArrow = GetNewSettingData(WQT.db.global.TomTomAutoArrow, true);
WQT.db.global.list.typeIcon = GetNewSettingData(WQT.db.global.showTypeIcon, true);
WQT.db.global.list.factionIcon = GetNewSettingData(WQT.db.global.showFactionIcon, true);
WQT.db.global.list.showZone = GetNewSettingData(WQT.db.global.listShowZone, true);
WQT.db.global.list.amountColors = GetNewSettingData(WQT.db.global.rewardAmountColors, true);
WQT.db.global.list.alwaysAllQuests = GetNewSettingData(WQT.db.global.alwaysAllQuests, false);
WQT.db.global.list.fullTime = GetNewSettingData(WQT.db.global.listFullTime, false);
WQT.db.global.pin.typeIcon = GetNewSettingData(WQT.db.global.pinType, true);
WQT.db.global.pin.rewardTypeIcon = GetNewSettingData(WQT.db.global.pinRewardType, false);
WQT.db.global.pin.filterPoI = GetNewSettingData(WQT.db.global.filterPoI, true);
WQT.db.global.pin.bigPoI = GetNewSettingData(WQT.db.global.bigPoI, false);
WQT.db.global.pin.disablePoI = GetNewSettingData(WQT.db.global.disablePoI, false);
WQT.db.global.pin.reward = GetNewSettingData(WQT.db.global.showPinReward, true);
WQT.db.global.pin.timeLabel = GetNewSettingData(WQT.db.global.showPinTime, false);
WQT.db.global.pin.ringType = GetNewSettingData(WQT.db.global.ringType, _V["RING_TYPES"].time);
-- Clean up old data
local version = WQT.db.global.versionCheck;
local sortBy = WQT.db.global.sortBy;
local updateSeen = WQT.db.global.updateSeen;
if (WQT.settings) then
for k, v in pairs(WQT.settings) do
if (type(v) ~= "table") then
WQT.settings[k] = nil;
end
end
end
WQT.db.global.versionCheck = version;
WQT.db.global.sortBy = sortBy;
WQT.db.global.updateSeen = updateSeen;
end
if (version < "8.3.01") then
WQT.db.global.pin.scale = WQT.db.global.pin.bigPoI and 1.15 or 1;
WQT.db.global.pin.centerType = WQT.db.global.pin.reward and _V["PIN_CENTER_TYPES"].reward or _V["PIN_CENTER_TYPES"].blizzard;
end
if (version < "8.3.02") then
local factionFlags = WQT.db.global.filters[_V["FILTER_TYPES"].faction].flags;
-- clear out string keys
for k in pairs(factionFlags) do
if (type(k) == "string") then
factionFlags[k] = nil;
end
end
end
if (version < "8.3.03") then
-- Anchoring changed, reset to default position
if (not WQT.db.global.fullScreenButtonPos) then
WQT.db.global.fullScreenButtonPos = {};
end
WQT.db.global.fullScreenButtonPos.anchor = _V["WQT_DEFAULTS"].global.general.fullScreenButtonPos.anchor;
WQT.db.global.fullScreenButtonPos.x = _V["WQT_DEFAULTS"].global.general.fullScreenButtonPos.x;
WQT.db.global.fullScreenButtonPos.y = _V["WQT_DEFAULTS"].global.general.fullScreenButtonPos.y;
end
if (version < "8.3.04") then
-- Changes for profiles
if (WQT.db.global.sortBy) then
WQT.db.global.general.sortBy = WQT.db.global.sortBy;
WQT.db.global.sortBy = nil;
end
if (WQT.db.global.fullScreenButtonPos) then
WQT.db.global.general.fullScreenButtonPos = WQT.db.global.fullScreenButtonPos;
WQT.db.global.fullScreenButtonPos = nil;
end
if (WQT.db.global.fullScreenContainerPos) then
WQT.db.global.general.fullScreenContainerPos = WQT.db.global.fullScreenContainerPos;
WQT.db.global.fullScreenContainerPos = nil;
end
-- Forgot to clear this in 8.3.01
WQT.db.global.pin.bigPoI = nil;
WQT.db.global.pin.reward = nil;
end
if (version < "9.0.02") then
-- More specific options for map pins
WQT.db.global.pin.continentVisible = WQT.db.global.pin.continentPins and _V["ENUM_PIN_CONTINENT"].all or _V["ENUM_PIN_CONTINENT"].none;
WQT.db.global.pin.continentPins = nil
end
end
-- Display an indicator on the filter if some official map filters might hide quest
function WQT:UpdateFilterIndicator()
if (C_CVar.GetCVarBool("showTamers") and C_CVar.GetCVarBool("worldQuestFilterArtifactPower") and C_CVar.GetCVarBool("worldQuestFilterResources") and C_CVar.GetCVarBool("worldQuestFilterGold") and C_CVar.GetCVarBool("worldQuestFilterEquipment")) then
WQT_WorldQuestFrame.FilterButton.Indicator:Hide();
else
WQT_WorldQuestFrame.FilterButton.Indicator:Show();
end
end
function WQT:SetAllFilterTo(id, value)
local filter = WQT.settings.filters[id];
if (not filter) then return end;
local misc = filter.misc;
if (misc) then
for k, v in pairs(misc) do
misc[k] = value;
end
end
local flags = filter.flags;
for k, v in pairs(flags) do
flags[k] = value;
end
end
-- Wheter the quest is being filtered because of official map filter settings
function WQT:FilterIsWorldMapDisabled(filter)
if (filter == "Petbattle" and not C_CVar.GetCVarBool("showTamers")) or (filter == "Artifact" and not C_CVar.GetCVarBool("worldQuestFilterArtifactPower")) or (filter == "Currency" and not C_CVar.GetCVarBool("worldQuestFilterResources"))
or (filter == "Gold" and not C_CVar.GetCVarBool("worldQuestFilterGold")) or (filter == "Armor" and not C_CVar.GetCVarBool("worldQuestFilterEquipment")) then
return true;
end
return false;
end
function WQT:SortDDFunc(ddFrame)
local selectedValue = WQT.settings.general.sortBy;
local info = ddFrame:CreateButtonInfo();
info.func = function(self, category) WQT:Sort_OnClick(self, category) end
for k, option in pairs(_V["WQT_SORT_OPTIONS"]) do
info.text = option;
info.arg1 = k;
info.value = k;
if k == selectedValue then
info.checked = 1;
else
info.checked = nil;
end
ddFrame:AddButton(info);
end
end
function WQT:Sort_OnClick(self, category)
local dropdown = WQT_WorldQuestFrameSortButton;
if ( category and dropdown.active ~= category ) then
--ADD:CloseAll();
dropdown.active = category
WQT_WorldQuestFrameSortButton:SetDisplayText(_V["WQT_SORT_OPTIONS"][category]);
WQT.settings.general.sortBy = category;
WQT_QuestScrollFrame:UpdateQuestList();
WQT_WorldQuestFrame:TriggerCallback("SortChanged", category);
end
end
function WQT:TrackDDFunc(ddFrame)
local sourceParent = ddFrame:GetSourceParent();
local questInfo = sourceParent.questInfo;
if (not questInfo) then return; end
local questID = questInfo.questId;
local mapInfo = WQT_Utils:GetMapInfoForQuest(questID);
local info = ddFrame:CreateButtonInfo();
local tagInfo = questInfo:GetTagInfo();
-- Title
local title = C_TaskQuest.GetQuestInfoByQuestID(questID);
info = ddFrame:CreateButtonInfo("title");
info.text = title;
info.overflow = true;
ddFrame:AddButton(info);
-- Don't allow tracking for quests that don't support it in the ObjectiveTrackerFrame
if (tagInfo and tagInfo.worldQuestType) then
info = ddFrame:CreateButtonInfo("option");
info.tooltipFunc = function(tooltip)
GameTooltip_AddInstructionLine(tooltip, _L["SHORTCUT_TRACK"]);
end
-- Tracking
if (QuestUtils_IsQuestWatched(questID)) then
info.text = UNTRACK_QUEST;
info.func = function()
C_QuestLog.RemoveWorldQuestWatch(questID);
if WQT_WorldQuestFrame:GetAlpha() > 0 then
WQT_QuestScrollFrame:DisplayQuestList();
end
end
else
info.text = TRACK_QUEST;
info.func = function()
C_QuestLog.AddWorldQuestWatch(questID, Enum.QuestWatchType.Manual);
C_SuperTrack.SetSuperTrackedQuestID(questID);
if WQT_WorldQuestFrame:GetAlpha() > 0 then
WQT_QuestScrollFrame:DisplayQuestList();
end
end
end
ddFrame:AddButton(info);
end
-- New 9.0 waypoint system
info = ddFrame:CreateButtonInfo("option");
info.text = _L["PLACE_MAP_PIN"];
info.func = function()
questInfo:SetAsWaypoint();
C_SuperTrack.SetSuperTrackedUserWaypoint(true);
end
info.tooltipFunc = function(tooltip)
GameTooltip_AddInstructionLine(tooltip, _L["SHORTCUT_WAYPOINT"]);
end
ddFrame:AddButton(info);
-- LFG if possible
info = ddFrame:CreateButtonInfo("option");
if (WQT_WorldQuestFrame:ShouldAllowLFG(questInfo)) then
info.text = OBJECTIVES_FIND_GROUP;
info.func = function()
WQT_WorldQuestFrame:SearchGroup(questInfo);
end
ddFrame:AddButton(info);
end
-- Dislike toggle
info = ddFrame:CreateButtonInfo("checkbox");
info.keepShownOnClick = false;
info.text = _L["UNINTERESTED"];
info.func = function()
local dislike = not WQT_Utils:QuestIsDisliked(questID);
WQT_Utils:SetQuestDisliked(questID, dislike);
ddFrame:Refresh();
end
info.checked = function() return WQT_Utils:QuestIsDisliked(questID) end;
info.tooltipFunc = function(tooltip)
GameTooltip_AddInstructionLine(tooltip, _L["SHORTCUT_DISLIKE"]);
end
ddFrame:AddButton(info);
WQT_WorldQuestFrame:TriggerCallback("InitTrackDropDown", ddFrame)
info = ddFrame:CreateButtonInfo("cancel");
ddFrame:AddButton(info);
end
function WQT:IsWorldMapFiltering()
for k, cVar in pairs(_V["WQT_CVAR_LIST"]) do
if not C_CVar.GetCVarBool(cVar) then
return true;
end
end
return false;
end
function WQT:IsUsingFilterNr(id)
if not WQT.settings.filters[id] then return false end
local misSettings = WQT.settings.filters[id].misc;
if (misSettings) then
for k, flag in pairs(misSettings) do
if (WQT.settings.general.preciseFilters and flag) then
return true;
elseif (not WQT.settings.general.preciseFilters and not flag) then
return true;
end
end
end
local flags = WQT.settings.filters[id].flags;
for k, flag in pairs(flags) do
if (WQT.settings.general.preciseFilters and flag) then
return true;
elseif (not WQT.settings.general.preciseFilters and not flag) then
return true;
end
end
return false;
end
function WQT:IsFiltering()
if (WQT.settings.general.emissaryOnly or WQT_WorldQuestFrame.autoEmisarryId) then return true; end
if (not WQT.settings.general.showDisliked) then return true; end
for k, category in pairs(WQT.settings.filters)do
if (self:IsUsingFilterNr(k)) then return true; end
end
return false;
end
function WQT:PassesAllFilters(questInfo)
-- Filter pass
if(WQT_Utils:QuestIsVIQ(questInfo)) then return true; end
if (WQT.settings.general.emissaryOnly or WQT_WorldQuestFrame.autoEmisarryId) then
return questInfo:IsCriteria(WQT.settings.general.bountySelectedOnly or WQT_WorldQuestFrame.autoEmisarryId);
end
local filterTypes = _V["FILTER_TYPES"];
if (not WQT.settings.general.showDisliked and questInfo:IsDisliked()) then
return false;
end
-- For precise filters, all filters have to pass
if (WQT.settings.general.preciseFilters) then
if (not WQT:IsFiltering()) then
return true;
end
local passesAll = true;
if WQT:IsUsingFilterNr(filterTypes.faction) then passesAll = passesAll and WQT:PassesFactionFilter(questInfo, true) end
if WQT:IsUsingFilterNr(filterTypes.type) then passesAll = passesAll and WQT:PassesFlagId(filterTypes.type, questInfo, true) end
if WQT:IsUsingFilterNr(filterTypes.reward) then passesAll = passesAll and WQT:PassesFlagId(filterTypes.reward, questInfo, true) end
return passesAll;
end
if WQT:IsUsingFilterNr(filterTypes.faction) and not WQT:PassesFactionFilter(questInfo) then return false; end
if WQT:IsUsingFilterNr(filterTypes.type) and not WQT:PassesFlagId(filterTypes.type, questInfo) then return false; end
if WQT:IsUsingFilterNr(filterTypes.reward) and not WQT:PassesFlagId(filterTypes.reward, questInfo) then return false; end
return true;
end
function WQT:PassesFactionFilter(questInfo, checkPrecise)
-- Factions (1)
local filter = WQT.settings.filters[_V["FILTER_TYPES"].faction];
local flags = filter.flags
local factionNone = filter.misc.none;
local factionOther = filter.misc.other;
local _, factionId = C_TaskQuest.GetQuestInfoByQuestID(questInfo.questId);
local factionInfo = WQT_Utils:GetFactionDataInternal(factionId);
-- Specific filters (matches all)
if (checkPrecise) then
if (factionNone and factionId) then
return false;
end
if (factionOther and (not factionId or not factionInfo.unknown)) then
return false;
end
for flagKey, value in pairs(flags) do