forked from NanMetal/WorldQuestTab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorldQuestTab.lua
3166 lines (2764 loc) · 109 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 _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, C_AddOns.GetAddOnInfo("WorldQuestTabUtilities"))
local _utilitiesInstalled = not utilitiesStatus or utilitiesStatus ~= "MISSING"
local _WFMLoaded = C_AddOns.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 WQT_InitFilterDropdown(self)
-- Show X button if filtering
self:SetIsDefaultCallback(
function()
return not WQT:IsFiltering()
end
)
-- Set default filters on click
self:SetDefaultCallback(
function()
WQT_CoreMixin:FilterClearButtonOnClick()
end
)
self:SetupMenu(
function(dropdown, rootDescription)
rootDescription:SetTag("MENU_WQT_FILTER")
-- Faction, reward, and type filters
for k, v in pairs(WQT.settings.filters) do
local submenu = rootDescription:CreateButton(v.name)
submenu:CreateButton(
CHECK_ALL,
function()
WQT:SetAllFilterTo(k, true)
WQT_QuestScrollFrame:UpdateQuestList()
return MenuResponse.Refresh
end,
true
)
submenu:CreateButton(
UNCHECK_ALL,
function()
WQT:SetAllFilterTo(k, false)
WQT_QuestScrollFrame:UpdateQuestList()
return MenuResponse.Refresh
end,
false
)
-- Factions
if k == _V["FILTER_TYPES"]["faction"] then
-- Types and rewards
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"]
-- Title of current expansion
submenu:CreateDivider()
submenu:CreateTitle(_G["EXPANSION_NAME" .. currExp])
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
submenu:CreateCheckbox(
type(flagKey) == "number" and C_Reputation.GetFactionDataByID(flagKey).name or flagKey,
function()
return options[flagKey]
end,
function()
options[flagKey] = not options[flagKey]
WQT_QuestScrollFrame:UpdateQuestList()
end
)
end
end
-- Other expansions
submenu:CreateSpacer()
local expansionMenu = submenu:CreateButton(EXPANSION_FILTER_TEXT)
-- Dragonflight
local subexpansionMenu = expansionMenu:CreateButton(EXPANSION_NAME9)
local options = WQT.settings.filters[1].flags
local order = WQT.filterOrders[1]
local currExp = LE_EXPANSION_DRAGONFLIGHT
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
subexpansionMenu:CreateCheckbox(
type(flagKey) == "number" and factionInfo.name or flagKey,
function()
return options[flagKey]
end,
function()
options[flagKey] = not options[flagKey]
if (options[flagKey]) then
WQT_WorldQuestFrame.pinDataProvider:RefreshAllData()
end
WQT_QuestScrollFrame:UpdateQuestList()
end
)
end
end
-- Shadowlands
subexpansionMenu = expansionMenu:CreateButton(EXPANSION_NAME8)
options = WQT.settings.filters[1].flags
order = WQT.filterOrders[1]
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
subexpansionMenu:CreateCheckbox(
type(flagKey) == "number" and factionInfo.name or flagKey,
function()
return options[flagKey]
end,
function()
options[flagKey] = not options[flagKey]
if (options[flagKey]) then
WQT_WorldQuestFrame.pinDataProvider:RefreshAllData()
end
WQT_QuestScrollFrame:UpdateQuestList()
end
)
end
end
-- BFA
subexpansionMenu = expansionMenu:CreateButton(EXPANSION_NAME7)
options = WQT.settings.filters[1].flags
order = WQT.filterOrders[1]
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
subexpansionMenu:CreateCheckbox(
type(flagKey) == "number" and factionInfo.name or flagKey,
function()
return options[flagKey]
end,
function()
options[flagKey] = not options[flagKey]
if (options[flagKey]) then
WQT_WorldQuestFrame.pinDataProvider:RefreshAllData()
end
WQT_QuestScrollFrame:UpdateQuestList()
end
)
end
end
-- Legion
subexpansionMenu = expansionMenu:CreateButton(EXPANSION_NAME6)
options = WQT.settings.filters[1].flags
order = WQT.filterOrders[1]
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
subexpansionMenu:CreateCheckbox(
type(flagKey) == "number" and factionInfo.name or flagKey,
function()
return options[flagKey]
end,
function()
options[flagKey] = not options[flagKey]
if (options[flagKey]) then
WQT_WorldQuestFrame.pinDataProvider:RefreshAllData()
end
WQT_QuestScrollFrame:UpdateQuestList()
end
)
end
end
elseif k == _V["FILTER_TYPES"]["type"] or k == _V["FILTER_TYPES"]["reward"] then
local value = k
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
local subsubmenu =
submenu:CreateCheckbox(
haveLabels and _V["WQT_TYPEFLAG_LABELS"][value][flagKey] or flagKey,
function()
return options[flagKey]
end,
function()
options[flagKey] = not options[flagKey]
WQT_QuestScrollFrame:UpdateQuestList()
end
)
end
end
end
end
-- Quests types that ignore filters
local submenu = rootDescription:CreateButton(_L["IGNORES_FILTERS"])
-- Callings
submenu:CreateCheckbox(
CALLINGS_QUESTS,
function()
return WQT.settings.general.filterPasses.calling
end,
function()
WQT.settings.general.filterPasses.calling = not WQT.settings.general.filterPasses.calling
WQT_QuestScrollFrame:UpdateQuestList()
end
)
-- Threat
submenu:CreateCheckbox(
REPORT_THREAT,
function()
return WQT.settings.general.filterPasses.threat
end,
function()
WQT.settings.general.filterPasses.threat = not WQT.settings.general.filterPasses.threat
WQT_QuestScrollFrame:UpdateQuestList()
end
)
-- Uninterested
rootDescription:CreateCheckbox(
_L["UNINTERESTED"],
function()
return WQT.settings.general.showDisliked
end,
function()
WQT.settings.general.showDisliked = not WQT.settings.general.showDisliked
end
)
-- Emissary only filter
rootDescription:CreateCheckbox(
_L["TYPE_EMISSARY"],
function()
return WQT.settings.general.emissaryOnly
end,
function()
WQT.settings.general.emissaryOnly = not WQT.settings.general.emissaryOnly
WQT_WorldQuestFrame.autoEmissaryId = nil
WQT_QuestScrollFrame:UpdateQuestList()
if not WQT.settings.general.emissaryOnly then
WQT_WorldQuestFrame.autoEmissaryId = nil
end
end
)
end
)
end
local function WQT_InitSortDropdown(self)
-- Sort
self:SetupMenu(
function(dropdown, rootDescription)
rootDescription:SetTag("MENU_WQT_SORT")
for k, option in pairs(_V["WQT_SORT_OPTIONS"]) do
local submenu =
rootDescription:CreateRadio(
option,
function()
return k == WQT.settings.general.sortBy
end,
function(self, category)
WQT:Sort_OnClick(self, k)
end,
k
)
end
end
)
end
local function WQT_InitSettingsDropdown(self)
-- Settings
self:SetupMenu(
function(dropdown, rootDescription)
rootDescription:SetTag("MENU_WQT_SETTINGS")
rootDescription:CreateButton(
SETTINGS,
function()
WQT_WorldQuestFrame:ShowOverlayFrame(WQT_SettingsFrame)
return
end,
true
)
local newText = WQT.db.global.updateSeen and "" or "|TInterface\\FriendsFrame\\InformationIcon:14|t "
rootDescription:CreateButton(
newText .. _L["WHATS_NEW"],
function()
local scrollFrame = WQT_VersionFrame
local blockerText = scrollFrame.Text
blockerText:SetText(_V["LATEST_UPDATE"])
WQT.db.global.updateSeen = true
WQT_WorldQuestFrame:ShowOverlayFrame(scrollFrame)
return
end,
true
)
end
)
WQT_WorldQuestFrame:TriggerCallback("InitSettings", self)
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 = C_Reputation.GetFactionDataByID(tonumber(a))
local _, nameB = C_Reputation.GetFactionDataByID(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.autoEmissary = GetNewSettingData(WQT.db.global.autoEmissary, 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
if (version < "11.0.2.8") then
-- Enable warband bonus displays by default
WQT.db.global.pin.showWarbandBonus = true
WQT.db.global.list.showWarbandBonus = true
end
if (version < "11.0.5.1") then
-- Add new pin option
WQT.db.global.pin.optionalLabel = _V["OPTIONAL_LABEL_TYPES"].none
end
end
-- Display an indicator on the filter if some official map filters might hide quest
function WQT:UpdateFilterIndicator()
local isFilterUncheck = false
for k, cVar in pairs(_V["WQT_CVAR_LIST"]) do
if C_CVar.GetCVarBool(cVar) == false then
isFilterUncheck = true
break
end
end
if not isFilterUncheck 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:Sort_OnClick(self, category)
local dropdown = WQT_WorldQuestFrame.SortDropdown
if (category and dropdown.active ~= category) then
WQT.settings.general.sortBy = category
WQT_QuestScrollFrame:UpdateQuestList()
WQT_WorldQuestFrame:TriggerCallback("SortChanged", category)
end
end
function WQT:InitTrackContextMenu(self)
local questInfo = self.questInfo
if (not questInfo) then
return
end
local questID = questInfo.questID
local mapInfo = WQT_Utils:GetMapInfoForQuest(questID)
local tagInfo = questInfo:GetTagInfo()
local title = C_TaskQuest.GetQuestInfoByQuestID(questID)
MenuUtil.CreateContextMenu(
self,
function(owner, rootDescription)
rootDescription:SetTag("MENU_WQT_TRACK")
rootDescription:CreateTitle(title)
local button
-- Tracking
if (QuestUtils_IsQuestWatched(questID)) then
button =
rootDescription:CreateButton(
UNTRACK_QUEST,
function()
C_QuestLog.RemoveWorldQuestWatch(questID)
if WQT_WorldQuestFrame:GetAlpha() > 0 then
WQT_QuestScrollFrame:DisplayQuestList()
end
end,
true
)
else
button =
rootDescription:CreateButton(
TRACK_QUEST,
function()
C_QuestLog.RemoveWorldQuestWatch(questID)
C_QuestLog.AddWorldQuestWatch(questID, Enum.QuestWatchType.Manual)
C_SuperTrack.SetSuperTrackedQuestID(questID)
if WQT_WorldQuestFrame:GetAlpha() > 0 then
WQT_QuestScrollFrame:DisplayQuestList()
end
end,
true
)
end
button:SetTooltip(
function(tooltip, elementDescription)
GameTooltip_SetTitle(tooltip, MenuUtil.GetElementText(elementDescription))
GameTooltip_AddInstructionLine(tooltip, _L["SHORTCUT_TRACK"])
end
)
-- New 9.0 waypoint system
button =
rootDescription:CreateButton(
_L["PLACE_MAP_PIN"],
function()
questInfo:SetAsWaypoint()
C_SuperTrack.SetSuperTrackedUserWaypoint(true)
end,
true
)
button:SetTooltip(
function(tooltip, elementDescription)
GameTooltip_SetTitle(tooltip, MenuUtil.GetElementText(elementDescription))
GameTooltip_AddInstructionLine(tooltip, _L["SHORTCUT_WAYPOINT"])
end
)
-- LFG if possible
if (WQT_WorldQuestFrame:ShouldAllowLFG(questInfo)) then
button =
rootDescription:CreateButton(
OBJECTIVES_FIND_GROUP,
function()
WQT_WorldQuestFrame:SearchGroup(questInfo)
end,
true
)
end
-- Dislike toggle
button =
rootDescription:CreateCheckbox(
_L["UNINTERESTED"],
function()
return WQT_Utils:QuestIsDisliked(questID)
end,
function()
local dislike = not WQT_Utils:QuestIsDisliked(questID)
WQT_Utils:SetQuestDisliked(questID, dislike)
end
)
button:SetTooltip(
function(tooltip, elementDescription)
GameTooltip_SetTitle(tooltip, MenuUtil.GetElementText(elementDescription))
GameTooltip_AddInstructionLine(tooltip, _L["SHORTCUT_DISLIKE"])
end
)
WQT_WorldQuestFrame:TriggerCallback("InitTrackDropDown", owner, rootDescription)
--[[button = rootDescription:CreateButton(CANCEL, function ()
return MenuResponse.CloseAll;
end, true);]]
end
)
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.autoEmissaryId) 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.autoEmissaryId then
return questInfo:IsCriteria(WQT.settings.general.bountySelectedOnly or WQT_WorldQuestFrame.autoEmissaryId)
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
if (value and type(flagKey) == "number" and flagKey ~= factionId) then
return false
end
end
return true
end
-- General filters (matchs at least one)
if (not factionId) then
return factionNone
end