forked from belazor-wow/WorldQuestTab
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Templates.lua
1292 lines (1115 loc) · 40.1 KB
/
Templates.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
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 ADD = LibStub("AddonDropDown-2.0");
--------------------------------
-- WQT_MiniIconMixin
--------------------------------
WQT_MiniIconMixin = {};
function WQT_MiniIconMixin:Reset()
self:Hide();
self.Icon:Show();
self.Icon:SetTexture(nil);
self.Icon:SetScale(1);
self.Icon:SetSize(10, 10);
self.Icon:SetTexCoord(0, 1, 0, 1);
self.Icon:SetVertexColor(1, 1, 1);
self.Icon:SetDesaturated(false);
self.BG:Show();
self.BG:SetTexture("Interface/GLUES/Models/UI_MainMenu_Legion/UI_Legion_Shadow");
self.BG:SetScale(1);
self.BG:SetVertexColor(1, 1, 1);
self.BG:SetAlpha(0.75);
self.texure = "";
self.scale = 1;
self.left = nil;
self.right = nil;
self.top = nil;
self.bottom = nil;
self.isDesaturated = false;
self.hasCustomColor = false;
self.r = 1;
self.g = 1;
self.b = 1;
end
function WQT_MiniIconMixin:SetIconColor(color)
self:SetIconColorRGBA(color:GetRGB());
end
function WQT_MiniIconMixin:SetIconColorRGBA(r, g, b, a)
self.r = r;
self.g = g;
self.b = b;
self.hasCustomColor = true;
self:Update();
end
function WQT_MiniIconMixin:SetDesaturated(desaturate)
self.isDesaturated = desaturate;
self:Update();
end
function WQT_MiniIconMixin:SetIconCoords(left, right, top, bottom)
self.l = left;
self.r = right;
self.t = top;
self.b = bottom;
self:Update();
end
function WQT_MiniIconMixin:SetIconScale(scale)
self.scale = scale;
self:Update();
end
function WQT_MiniIconMixin:SetIconSize(width, height)
self.Icon:SetSize(width, height);
end
function WQT_MiniIconMixin:SetBackgroundScale(scale)
self.BG:SetScale(scale);
end
function WQT_MiniIconMixin:SetBackgroundShown(value)
self.BG:SetShown(value);
end
function WQT_MiniIconMixin:SetupIcon(texture, left, right, top, bottom)
self:Reset();
if (not texture) then return; end
self.texture = texture;
self.left = left;
self.right = right;
self.top = top;
self.bottom = bottom;
self:Update();
self:Show();
end
function WQT_MiniIconMixin:SetupRewardIcon(rewardType, subType)
self:Reset();
local rewardTypeAtlas = WQT_Utils:GetRewardIconInfo(rewardType, subType);
if not (rewardTypeAtlas) then
return;
end
self.texture = rewardTypeAtlas.texture;
self.left = rewardTypeAtlas.l;
self.right = rewardTypeAtlas.r;
self.top = rewardTypeAtlas.t;
self.bottom = rewardTypeAtlas.b;
self.scale = rewardTypeAtlas.scale;
if (rewardTypeAtlas.color) then
self.r, self.g, self.b = rewardTypeAtlas.color:GetRGB();
end
self:Update();
self:Show();
end
function WQT_MiniIconMixin:Update()
if (self.left) then
self.Icon:SetTexture(self.texture);
self.Icon:SetTexCoord(self.left, self.right, self.top, self.bottom);
else
self.Icon:SetTexCoord(0, 1, 0, 1);
self.Icon:SetAtlas(self.texture);
end
self.Icon:SetScale(self.scale);
local r, g, b = 1, 1, 1;
self.Icon:SetDesaturated(false);
if (self.isDesaturated) then
if(self.hasCustomColor) then
r, g, b = self.r, self.g, self.b;
elseif (self.left) then
r, g, b = 0.8, 0.8, 0.8;
else
self.Icon:SetDesaturated(true);
end
else
if (self.r) then
r, g, b = self.r, self.g, self.b;
end
end
self.Icon:SetVertexColor(r, g, b);
end
--------------------------------
-- WQT_ScrollFrameMixin
--------------------------------
WQT_ScrollFrameMixin = {};
function WQT_ScrollFrameMixin:OnLoad()
self.offset = 0;
self.scrollStep = 30;
self.max = 0;
self.ScrollBar:SetMinMaxValues(0, 0);
self.ScrollBar:SetValue(0);
self.ScrollChild:SetPoint("RIGHT", self)
end
function WQT_ScrollFrameMixin:OnShow()
self:SetChildHeight(self.ScrollChild:GetHeight());
end
function WQT_ScrollFrameMixin:UpdateChildFramePosition()
if (self.ScrollChild) then
self.ScrollChild:SetPoint("TOPLEFT", self, 0, self.offset);
end
end
function WQT_ScrollFrameMixin:ScrollValueChanged(value)
self.offset = max(0, min(value, self.max));
self:UpdateChildFramePosition();
end
function WQT_ScrollFrameMixin:OnMouseWheel(delta)
self.offset = self.offset - delta * self.scrollStep;
self.offset = max(0, min(self.offset, self.max));
self:UpdateChildFramePosition();
self.ScrollBar:SetValue(self.offset);
end
function WQT_ScrollFrameMixin:SetChildHeight(height)
self.ScrollChild:SetHeight(height);
self.max = max(0, height - self:GetHeight());
self.offset = min(self.offset, self.max);
self.ScrollBar:SetMinMaxValues(0, self.max);
end
----------------------------
-- Containers
----------------------------
WQT_ContainerButtonMixin = {};
function WQT_ContainerButtonMixin:OnClick()
self:SetSelected(not self.isSelected);
end
function WQT_ContainerButtonMixin:SetSelected(isSelected)
self.isSelected = isSelected;
if (self.container) then
if (self.isSelected) then
self.container:Show();
self.Selected:SetAlpha(0.5);
WQT_WorldQuestFrame:SelectTab(WQT_TabWorld);
else
self.container:Hide();
self.Selected:SetAlpha(0);
WQT_WorldQuestFrame:SelectTab(WQT_TabNormal);
end
end
end
function WQT_ContainerButtonMixin:OnEnter()
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
GameTooltip:SetText(TRACKER_HEADER_WORLD_QUESTS, 1, 1, 1, true);
GameTooltip:Show();
end
function WQT_ContainerButtonMixin:OnLeave()
GameTooltip:Hide();
end
----------------------------
-- WQT_MiniIconOverlayMixin
----------------------------
WQT_MiniIconOverlayMixin = {};
function WQT_MiniIconOverlayMixin:Init(anchor, startAngle, distance, spacingAngle)
self.miniIconPool = CreateFramePool("FRAME", anchor, "WQT_MiniIconTemplate");
self.anchor = anchor;
self.startAngle = startAngle or 270;
self.distance = distance or 20;
self.spacingAngle = spacingAngle or 32;
self.activeIcons = {};
end
function WQT_MiniIconOverlayMixin:Reset()
self.miniIconPool:ReleaseAll();
wipe(self.activeIcons);
end
function WQT_MiniIconOverlayMixin:Create()
local icon = self.miniIconPool:Acquire();
tinsert(self.activeIcons, icon);
icon:Show();
self:UpdatePlacement();
return icon;
end
function WQT_MiniIconOverlayMixin:UpdatePlacement()
local numIcons = self.miniIconPool:GetNumActive();
-- Counters
local offsetAngle = self.spacingAngle;
local startAngle = self.startAngle;
-- position of first counter
startAngle = startAngle - offsetAngle * (numIcons -1) /2
for k, icon in ipairs(self.activeIcons) do
local x = cos(startAngle) * self.distance;
local y = sin(startAngle) * self.distance;
icon:SetPoint("CENTER", self.anchor, "CENTER", x, y);
icon:SetParent(self.anchor);
icon:Show();
-- Offset next counter
startAngle = startAngle + offsetAngle;
end
end
----------------------------
-- Utilities
----------------------------
local cachedTypeData = {};
local cachedZoneInfo = {};
function WQT_Utils:GetSetting(...)
local settings = WQT.settings;
local index = 1;
local param = select(index, ...);
while (param ~= nil) do
if(settings[param] == nil) then
return nil
end;
settings = settings[param];
index = index + 1;
param = select(index, ...);
end
if (type(settings) == "table") then
return nil
end;
return settings;
end
function WQT_Utils:GetLocal(key)
return _L[key or ""];
end
function WQT_Utils:GetVariable(key)
local val = _V[key or ""];
if (not val) then return; end
if (type(val) == "table") then
return CopyTable(val);
end
return val;
end
function WQT_Utils:GetCachedMapInfo(zoneId)
zoneId = zoneId or 0;
local zoneInfo = cachedZoneInfo[zoneId];
if (not zoneInfo) then
zoneInfo = C_Map.GetMapInfo(zoneId);
if (zoneInfo and zoneInfo.name) then
cachedZoneInfo[zoneId] = zoneInfo;
end
end
return zoneInfo;
end
function WQT_Utils:GetFactionDataInternal(id)
if (not id) then
-- No faction
return _V["WQT_NO_FACTION_DATA"];
end;
local factionData = _V["WQT_FACTION_DATA"];
if (not factionData[id]) then
-- Add new faction in case it's not in our data yet
factionData[id] = { ["expansion"] = 0 ,["faction"] = nil ,["texture"] = 134400, ["unknown"] = true }
factionData[id].name = GetFactionInfoByID(id) or UNKNOWN;
WQT:debugPrint("Added new faction", id,factionData[id].name);
end
return factionData[id];
end
function WQT_Utils:GetCachedTypeIconData(questInfo, pinVersion)
if (C_QuestLog.IsQuestCalling(questInfo.questId)) then
if (pinVersion) then
return "QuestDaily", 17, 17, true;
else
return "Callings-Available", 16, 21, true;
--return "quest-dailycampaign-available", 17, 17, true;
end
elseif (questInfo.isDaily or questInfo.isAllyQuest) then
return "QuestDaily", 17, 17, true;
elseif (questInfo.isQuestStart) then
return "QuestNormal", 17, 17, true;
elseif (C_QuestLog.IsThreatQuest(questInfo.questId)) then
local themeInfo = C_QuestLog.GetQuestDetailsTheme(questInfo.questId);
local atlas = themeInfo and themeInfo.poiIcon or "worldquest-icon-nzoth";
return atlas, 16, 16, true;
end
local tagInfo = questInfo:GetTagInfo();
-- If there is no tag info, it's a bonus objective
if (not tagInfo) then
return "QuestBonusObjective", 21, 21, true;
end
local isNew = false;
local originalType = tagInfo.worldQuestType;
tagInfo.worldQuestType = tagInfo.worldQuestType or _V["WQT_TYPE_BONUSOBJECTIVE"];
local cachedData = cachedTypeData[tagInfo.worldQuestType];
if (not cachedData) then
-- creating basetype
cachedTypeData[tagInfo.worldQuestType] = {};
cachedData = cachedTypeData[tagInfo.worldQuestType];
isNew = true;
end
if (tagInfo.tradeskillLineID) then
local cachedSubType = cachedData[tagInfo.tradeskillLineID];
if (not cachedSubType) then
-- creating subtype
cachedData[tagInfo.tradeskillLineID] = {};
cachedSubType = cachedData[tagInfo.tradeskillLineID];
isNew = true;
end
-- cachedData becomes subtype
cachedData = cachedSubType;
end
if (isNew) then
local atlasTexture, sizeX, sizeY = QuestUtil.GetWorldQuestAtlasInfo(originalType, false, tagInfo.tradeskillLineID);
cachedData.texture = atlasTexture;
cachedData.x = sizeX;
cachedData.y = sizeY;
end
return cachedData.texture or "", cachedData.x or 0, cachedData.y or 0;
end
function WQT_Utils:GetQuestTimeString(questInfo, fullString, unabreviated)
local timeLeftMinutes = 0
local timeLeftSeconds = 0
local timeString = "";
local timeStringShort = "";
local color = _V["WQT_COLOR_CURRENCY"];
local category = _V["TIME_REMAINING_CATEGORY"].none;
if (not questInfo or not questInfo.questId) then return timeLeftSeconds, timeString, color ,timeStringShort, timeLeftMinutes, category end
-- Time ran out, waiting for an update
if (questInfo:IsExpired()) then
timeString = RAID_INSTANCE_EXPIRES_EXPIRED;
timeStringShort = "Exp."
color = GRAY_FONT_COLOR;
return 0, timeString, color,timeStringShort , 0, _V["TIME_REMAINING_CATEGORY"].expired;
end
timeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes(questInfo.questId) or 0;
timeLeftSeconds = C_TaskQuest.GetQuestTimeLeftSeconds(questInfo.questId) or 0;
if ( timeLeftSeconds and timeLeftSeconds > 0) then
local displayTime = timeLeftSeconds
if (displayTime < SECONDS_PER_HOUR and displayTime >= SECONDS_PER_MIN ) then
displayTime = displayTime + SECONDS_PER_MIN ;
end
if ( timeLeftSeconds < WORLD_QUESTS_TIME_CRITICAL_MINUTES * SECONDS_PER_MIN ) then
color = WQT_Utils:GetColor(_V["COLOR_IDS"].timeCritical);--RED_FONT_COLOR;
timeString = SecondsToTime(displayTime, displayTime > SECONDS_PER_MIN and true or false, unabreviated);
category = _V["TIME_REMAINING_CATEGORY"].critical;
elseif displayTime < SECONDS_PER_HOUR then
timeString = SecondsToTime(displayTime, true);
color = WQT_Utils:GetColor(_V["COLOR_IDS"].timeShort);--_V["WQT_ORANGE_FONT_COLOR"];
category = _V["TIME_REMAINING_CATEGORY"].short
elseif displayTime < SECONDS_PER_DAY then
if (fullString) then
timeString = SecondsToTime(displayTime, true, unabreviated);
else
timeString = D_HOURS:format(displayTime / SECONDS_PER_HOUR);
end
color = WQT_Utils:GetColor(_V["COLOR_IDS"].timeMedium);--_V["WQT_GREEN_FONT_COLOR"];
category = _V["TIME_REMAINING_CATEGORY"].medium;
else
if (fullString) then
timeString = SecondsToTime(displayTime, true, unabreviated);
else
timeString = D_DAYS:format(displayTime / SECONDS_PER_DAY );
end
local tagInfo = questInfo:GetTagInfo();
local isWeek = tagInfo and tagInfo.isElite and tagInfo.quality == Enum.WorldQuestQuality.Epic
if (isWeek) then
color = WQT_Utils:GetColor(_V["COLOR_IDS"].timeVeryLong);
category = _V["TIME_REMAINING_CATEGORY"].veryLong;
else
color = WQT_Utils:GetColor(_V["COLOR_IDS"].timeLong);
category = _V["TIME_REMAINING_CATEGORY"].long;
end
end
end
-- start with default, for CN and KR
timeStringShort = timeString;
local t, str = string.match(timeString:gsub(" |4", ""), '(%d+)(%a)');
if t and str then
timeStringShort = t..str;
end
return timeLeftSeconds, timeString, color, timeStringShort ,timeLeftMinutes, category;
end
function WQT_Utils:GetPinTime(questInfo)
local seconds, _, color, timeStringShort, _, category = WQT_Utils:GetQuestTimeString(questInfo);
local start = 0;
local timeLeft = seconds;
local total = 0;
local maxTime, offset;
if (timeLeft > 0) then
if timeLeft >= 1440*60 then
maxTime = 5760*60;
offset = -720*60;
local tagInfo = questInfo:GetTagInfo();
if (timeLeft > maxTime or tagInfo and (tagInfo.isElite and tagInfo.quality == Enum.WorldQuestQuality.Epic)) then
maxTime = 1440 * 7*60;
offset = 0;
end
elseif timeLeft >= 60*59 then --Minute display doesn't start until 59min left
maxTime = 1440*60;
offset = 60*60;
elseif timeLeft >= 15*60 then
maxTime= 60*60;
offset = -10*60;
else
maxTime = 15*60;
offset = 0;
end
start = (maxTime - timeLeft);
total = (maxTime + offset);
timeLeft = (timeLeft + offset);
end
return start, total, timeLeft, seconds, color, timeStringShort, category;
end
function WQT_Utils:GetMapInfoForQuest(questId)
local zoneId = C_TaskQuest.GetQuestZoneID(questId);
return WQT_Utils:GetCachedMapInfo(zoneId);
end
function WQT_Utils:ItterateAllBonusObjectivePins(func)
if(WorldMapFrame.pinPools.BonusObjectivePinTemplate) then
for mapPin in pairs(WorldMapFrame.pinPools.BonusObjectivePinTemplate.activeObjects) do
func(mapPin)
end
end
if(WorldMapFrame.pinPools.ThreatObjectivePinTemplate) then
for mapPin in pairs(WorldMapFrame.pinPools.ThreatObjectivePinTemplate.activeObjects) do
func(mapPin)
end
end
end
-- Copy of QuestUtils_AddQuestRewardsToTooltip to prevent SetTooltipMoney from causing taint
-- Edited to prevent items from overwriting currencies
local function _AddQuestRewardsToTooltip(tooltip, questID, style)
local hasAnySingleLineRewards = false;
local isWarModeDesired = C_PvP.IsWarModeDesired();
local questHasWarModeBonus = C_QuestLog.QuestCanHaveWarModeBonus(questID);
-- xp
local totalXp, baseXp = GetQuestLogRewardXP(questID);
if ( baseXp > 0 ) then
GameTooltip_AddColoredLine(tooltip, BONUS_OBJECTIVE_EXPERIENCE_FORMAT:format(baseXp), HIGHLIGHT_FONT_COLOR);
if (isWarModeDesired and questHasWarModeBonus) then
tooltip:AddLine(WAR_MODE_BONUS_PERCENTAGE_XP_FORMAT:format(C_PvP.GetWarModeRewardBonus()));
end
hasAnySingleLineRewards = true;
end
local artifactXP = GetQuestLogRewardArtifactXP(questID);
if ( artifactXP > 0 ) then
GameTooltip_AddColoredLine(tooltip, BONUS_OBJECTIVE_ARTIFACT_XP_FORMAT:format(artifactXP), HIGHLIGHT_FONT_COLOR);
hasAnySingleLineRewards = true;
end
-- currency
if not style.atLeastShowAzerite then
local numQuestRewards = GetNumQuestLogRewards(questID);
local itemToolTip = tooltip.ItemTooltip
-- If one of the rewards is an item, don't allow currencies to use the use the item tooltip
-- In official code this causes the item to overwrite the currency
if (GetNumQuestLogRewards(questID) > 0) then
itemToolTip = nil;
end
local numAddedQuestCurrencies, usingCurrencyContainer = QuestUtils_AddQuestCurrencyRewardsToTooltip(questID, tooltip, itemToolTip);
if ( numAddedQuestCurrencies > 0 ) then
hasAnySingleLineRewards = not usingCurrencyContainer or numAddedQuestCurrencies > 1;
end
end
-- honor
local honorAmount = GetQuestLogRewardHonor(questID);
if ( honorAmount > 0 ) then
GameTooltip_AddColoredLine(tooltip, BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT:format("Interface\\ICONS\\Achievement_LegionPVPTier4", honorAmount, HONOR), HIGHLIGHT_FONT_COLOR);
hasAnySingleLineRewards = true;
end
-- money
local money = GetQuestLogRewardMoney(questID);
if ( money > 0 ) then
GameTooltip_AddColoredLine(tooltip, GetMoneyString(money), HIGHLIGHT_FONT_COLOR);
if (isWarModeDesired and QuestUtils_IsQuestWorldQuest(questID) and questHasWarModeBonus) then
tooltip:AddLine(WAR_MODE_BONUS_PERCENTAGE_FORMAT:format(C_PvP.GetWarModeRewardBonus()));
end
hasAnySingleLineRewards = true;
end
-- items
local showRetrievingData = false;
local numQuestRewards = GetNumQuestLogRewards(questID);
local numCurrencyRewards = GetNumQuestLogRewardCurrencies(questID);
local showingItem = false;
if numQuestRewards > 0 and (not style.prioritizeCurrencyOverItem or numCurrencyRewards == 0) then
if style.fullItemDescription then
-- we want to do a full item description
local itemIndex, rewardType = QuestUtils_GetBestQualityItemRewardIndex(questID); -- Only support one item reward currently
if not EmbeddedItemTooltip_SetItemByQuestReward(tooltip.ItemTooltip, itemIndex, questID, rewardType) then
showRetrievingData = true;
end
-- check for item compare input of flag
if not showRetrievingData then
if IsModifiedClick("COMPAREITEMS") or GetCVarBool("alwaysCompareItems") then
GameTooltip_ShowCompareItem(tooltip.ItemTooltip.Tooltip, tooltip.BackdropFrame);
else
for i, tooltip in ipairs(tooltip.ItemTooltip.Tooltip.shoppingTooltips) do
tooltip:Hide();
end
end
end
else
-- we want to do an abbreviated item description
local name, texture, numItems, quality, isUsable = GetQuestLogRewardInfo(1, questID);
local text;
if (numItems > 1) then
text = string.format(BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT, texture, HIGHLIGHT_FONT_COLOR:WrapTextInColorCode(numItems), name);
elseif (texture and name) then
text = string.format(BONUS_OBJECTIVE_REWARD_FORMAT, texture, name);
end
if (text) then
local color = ITEM_QUALITY_COLORS[quality];
tooltip:AddLine(text, color.r, color.g, color.b);
end
end
end
-- spells
if C_QuestInfoSystem.HasQuestRewardSpells(questID) and not tooltip.ItemTooltip:IsShown() then
if not EmbeddedItemTooltip_SetSpellByQuestReward(tooltip.ItemTooltip, 1, questID) then
showRetrievingData = true;
end
end
-- atLeastShowAzerite: show azerite if nothing else is awarded
-- and in the case of double azerite, only show the currency container one
if style.atLeastShowAzerite and not hasAnySingleLineRewards and not tooltip.ItemTooltip:IsShown() then
local numAddedQuestCurrencies, usingCurrencyContainer = QuestUtils_AddQuestCurrencyRewardsToTooltip(questID, tooltip, tooltip.ItemTooltip);
if ( numAddedQuestCurrencies > 0 ) then
hasAnySingleLineRewards = not usingCurrencyContainer or numAddedQuestCurrencies > 1;
if usingCurrencyContainer and numAddedQuestCurrencies > 1 then
EmbeddedItemTooltip_Clear(tooltip.ItemTooltip);
tooltip.ItemTooltip:Hide();
tooltip:Show();
end
end
end
return hasAnySingleLineRewards, showRetrievingData;
end
-- Copy of GameTooltip_AddQuestRewardsToTooltip to prevent SetTooltipMoney from causing taint
function WQT_Utils:AddQuestRewardsToTooltip(tooltip, questID, style)
style = style or TOOLTIP_QUEST_REWARDS_STYLE_DEFAULT;
if ( GetQuestLogRewardXP(questID) > 0 or GetNumQuestLogRewardCurrencies(questID) > 0 or GetNumQuestLogRewards(questID) > 0 or
GetQuestLogRewardMoney(questID) > 0 or GetQuestLogRewardArtifactXP(questID) > 0 or GetQuestLogRewardHonor(questID) > 0 or
C_QuestInfoSystem.HasQuestRewardSpells(questID)) then
if tooltip.ItemTooltip then
tooltip.ItemTooltip:Hide();
end
GameTooltip_AddBlankLinesToTooltip(tooltip, style.prefixBlankLineCount);
if style.headerText and style.headerColor then
GameTooltip_AddColoredLine(tooltip, style.headerText, style.headerColor, style.wrapHeaderText);
end
GameTooltip_AddBlankLinesToTooltip(tooltip, style.postHeaderBlankLineCount);
local hasAnySingleLineRewards, showRetrievingData = _AddQuestRewardsToTooltip(tooltip, questID, style);
if hasAnySingleLineRewards and tooltip.ItemTooltip and tooltip.ItemTooltip:IsShown() then
GameTooltip_AddBlankLinesToTooltip(tooltip, 1);
if showRetrievingData then
GameTooltip_AddColoredLine(tooltip, RETRIEVING_DATA, RED_FONT_COLOR);
end
end
end
end
function WQT_Utils:ShowQuestTooltip(button, questInfo, style)
style = style or _V["TOOLTIP_STYLES"].default;
WQT:ShowDebugTooltipForQuest(questInfo, button);
GameTooltip:SetOwner(button, "ANCHOR_RIGHT");
-- In case we somehow don't have data on this quest, even through that makes no sense at this point
if (not questInfo.questId or not HaveQuestData(questInfo.questId)) then
GameTooltip_SetTitle(GameTooltip, RETRIEVING_DATA, RED_FONT_COLOR);
GameTooltip_SetTooltipWaitingForData(GameTooltip, true);
GameTooltip:Show();
return;
end
local title, factionID, capped = C_TaskQuest.GetQuestInfoByQuestID(questInfo.questId);
local tagInfo = questInfo:GetTagInfo();
local qualityColor = WORLD_QUEST_QUALITY_COLORS[tagInfo and tagInfo.quality or Enum.WorldQuestQuality.Common];
-- title
GameTooltip_SetTitle(GameTooltip, title, qualityColor.color, true);
-- type
if (not style.hideType) then
if (questInfo:IsQuestOfType(WQT_QUESTTYPE.calling)) then
GameTooltip_AddNormalLine(GameTooltip, COVENANT_CALLINGS_AVAILABLE);
elseif (questInfo.isAllyQuest) then
GameTooltip_AddColoredLine(GameTooltip, AVAILABLE_FOLLOWER_QUEST, HIGHLIGHT_FONT_COLOR, true);
elseif (tagInfo and tagInfo.worldQuestType) then
QuestUtils_AddQuestTypeToTooltip(GameTooltip, questInfo.questId, NORMAL_FONT_COLOR);
end
end
-- faction
if ( factionID ) then
local factionName = GetFactionInfoByID(factionID);
if ( factionName ) then
if (capped) then
GameTooltip:AddLine(factionName, GRAY_FONT_COLOR:GetRGB());
else
GameTooltip:AddLine(factionName);
end
end
end
-- Add time
local seconds, timeString, timeColor, _, _, category = WQT_Utils:GetQuestTimeString(questInfo, true, true)
if (seconds > 0 or category == _V["TIME_REMAINING_CATEGORY"].expired) then
timeColor = seconds <= SECONDS_PER_HOUR and timeColor or NORMAL_FONT_COLOR;
GameTooltip_AddColoredLine(GameTooltip, BONUS_OBJECTIVE_TIME_LEFT:format(timeString), timeColor);
end
if (not style.hideObjectives) then
local numObjectives = C_QuestLog.GetNumQuestObjectives(questInfo.questId);
for objectiveIndex = 1, numObjectives do
local objectiveText, objectiveType, finished = GetQuestObjectiveInfo(questInfo.questId, objectiveIndex, false);
if ( objectiveText and #objectiveText > 0 ) then
local objectiveColor = finished and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR;
GameTooltip:AddLine(QUEST_DASH .. objectiveText, objectiveColor.r, objectiveColor.g, objectiveColor.b, true);
end
-- Add a progress bar if that's the type
if(objectiveType == "progressbar") then
local percent = GetQuestProgressBarPercent(questInfo.questId);
GameTooltip_ShowProgressBar(GameTooltip, 0, 100, percent, PERCENTAGE_STRING:format(percent));
end
end
end
if (questInfo.reward.type == WQT_REWARDTYPE.missing) then
GameTooltip:AddLine(RETRIEVING_DATA, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b);
else
self:AddQuestRewardsToTooltip(GameTooltip, questInfo.questId);
-- reposition compare frame
if((questInfo.reward.type == WQT_REWARDTYPE.equipment or questInfo.reward.type == WQT_REWARDTYPE.weapon) and GameTooltip.ItemTooltip:IsShown()) then
if IsModifiedClick("COMPAREITEMS") or C_CVar.GetCVarBool("alwaysCompareItems") then
-- Setup compare tootltips
GameTooltip_ShowCompareItem(GameTooltip.ItemTooltip.Tooltip);
-- If there is room to the right, give priority to show compare tooltips to the right of the tooltip
local totalWidth = 0;
if ( ShoppingTooltip1:IsShown() ) then
totalWidth = totalWidth + ShoppingTooltip1:GetWidth();
end
if ( ShoppingTooltip2:IsShown() ) then
totalWidth = totalWidth + ShoppingTooltip2:GetWidth();
end
if GameTooltip.ItemTooltip.Tooltip:GetRight() + totalWidth < GetScreenWidth() and ShoppingTooltip1:IsShown() then
ShoppingTooltip1:ClearAllPoints();
ShoppingTooltip1:SetPoint("TOPLEFT", GameTooltip.ItemTooltip.Tooltip, "TOPRIGHT");
ShoppingTooltip2:ClearAllPoints();
ShoppingTooltip2:SetPoint("TOPLEFT", ShoppingTooltip1, "TOPRIGHT");
end
-- Set higher frame level in case things overlap
local level = GameTooltip:GetFrameLevel();
ShoppingTooltip1:SetFrameLevel(level +2);
ShoppingTooltip2:SetFrameLevel(level +1);
end
end
end
GameTooltip:Show();
end
-- Climb map parents until the first continent type map it can find.
function WQT_Utils:GetContinentForMap(mapId)
local info = WQT_Utils:GetCachedMapInfo(mapId);
if not info then return mapId; end
local parent = info.parentMapID;
if not parent or info.mapType <= Enum.UIMapType.Continent then
return mapId, info.mapType
end
return self:GetContinentForMap(parent)
end
function WQT_Utils:GetMapWQProvider()
if WQT.mapWQProvider then return WQT.mapWQProvider; end
for k in pairs(WorldMapFrame.dataProviders) do
for k1 in pairs(k) do
if k1=="IsMatchingWorldMapFilters" then
WQT.mapWQProvider = k;
break;
end
end
end
return WQT.mapWQProvider;
end
function WQT_Utils:GetFlightWQProvider()
if (WQT.FlightmapPins) then return WQT.FlightmapPins; end
if (not FlightMapFrame) then return nil; end
for k in pairs(FlightMapFrame.dataProviders) do
if (type(k) == "table") then
for k2 in pairs(k) do
if (k2 == "activePins") then
WQT.FlightmapPins = k;
break;
end
end
end
end
return WQT.FlightmapPins;
end
function WQT_Utils:RefreshOfficialDataProviders()
-- Have to force remove the WQ data from the map because RefreshAllData doesn't do it
local mapWQProvider = WQT_Utils:GetMapWQProvider();
if (mapWQProvider) then
mapWQProvider:RemoveAllData();
end
-- If there are no dataproviders, we haven't opened the map yet, so don't force a refresh on it
if (#WorldMapFrame.dataProviders > 0) then
WorldMapFrame:RefreshAllDataProviders();
end
-- Flight map world quests
local flightWQProvider = WQT_Utils:GetFlightWQProvider();
if (flightWQProvider) then
flightWQProvider:RemoveAllData();
flightWQProvider:RefreshAllData();
end
end
-- Compatibility with the TomTom add-on
function WQT_Utils:AddTomTomArrowByQuestId(questId)
if (not questId) then return; end
local zoneId = C_TaskQuest.GetQuestZoneID(questId);
if (zoneId) then
local title = C_TaskQuest.GetQuestInfoByQuestID(questId);
local x, y = C_TaskQuest.GetQuestLocation(questId, zoneId)
if (title and x and y) then
TomTom:AddWaypoint(zoneId, x, y, {["title"] = title, ["crazy"] = true});
end
end
end
function WQT_Utils:RemoveTomTomArrowbyQuestId(questId)
if (not questId) then return; end
local zoneId = C_TaskQuest.GetQuestZoneID(questId);
if (zoneId) then
local title = C_TaskQuest.GetQuestInfoByQuestID(questId);
local x, y = C_TaskQuest.GetQuestLocation(questId, zoneId)
if (title and x and y) then
local key = TomTom:GetKeyArgs(zoneId, x, y, title);
local wp = TomTom.waypoints[zoneId] and TomTom.waypoints[zoneId][key];
if (wp) then
TomTom:RemoveWaypoint(wp);
end
end
end
end
function WQT_Utils:QuestIncorrectlyCounts(questLogIndex)
local questInfo = C_QuestLog.GetInfo(questLogIndex);
if (not questInfo or questInfo.isHeader or questInfo.isTask or questInfo.isBounty) then
return false, questInfo.isHidden;
end
local tagInfo = C_QuestLog.GetQuestTagInfo(questInfo.questID);
if (tagInfo and tagInfo.tagID == 102) then
return true, questInfo.isHidden;
end
end
function WQT_Utils:QuestCountsToCap(questLogIndex)
local questInfo = C_QuestLog.GetInfo(questLogIndex);
if (not questInfo or questInfo.isHeader or questInfo.isTask or questInfo.isBounty) then
return false, questInfo.isHidden;
end
local tagInfo = C_QuestLog.GetQuestTagInfo(questInfo.questID);
local counts = true;
if (tagInfo and tagInfo.tagID and _V["QUESTS_NOT_COUNTING"][tagInfo.tagID]) then
counts = false;
end
return counts, questInfo.isHidden;
end
-- Count quests counting to the quest log cap and collect the ones that shouldn't count
function WQT_Utils:GetQuestLogInfo(list)
local numEntries, questCount = C_QuestLog.GetNumQuestLogEntries();
local maxQuests = C_QuestLog.GetMaxNumQuestsCanAccept();
if (list) then
wipe(list);
end
for questLogIndex = 1, numEntries do
-- Remove the ones that shouldn't be counted
if (WQT_Utils:QuestIncorrectlyCounts(questLogIndex)) then
questCount = questCount - 1;
if (list) then
tinsert(list, questLogIndex);
end
end
end
local color = questCount >= maxQuests and RED_FONT_COLOR or (questCount >= maxQuests-2 and _V["WQT_ORANGE_FONT_COLOR"] or _V["WQT_WHITE_FONT_COLOR"]);
return questCount, maxQuests, color;
end
function WQT_Utils:QuestIsWatchedManual(questId)
return questId and C_QuestLog.GetQuestWatchType(questId) == Enum.QuestWatchType.Manual;
end
function WQT_Utils:QuestIsWatchedAutomatic(questId)
return questId and C_QuestLog.GetQuestWatchType(questId) == Enum.QuestWatchType.Automatic;
end
function WQT_Utils:GetQuestMapLocation(questId, mapId)
local isSameMap = true;
if (mapId) then
local mapInfo = WQT_Utils:GetMapInfoForQuest(questId);
if (not mapInfo) then
return 0, 0;
end
isSameMap = mapInfo.mapID == mapId;
end
-- Threat quest specific
if (isSameMap and C_QuestLog.IsThreatQuest(questId)) then
local completed, x, y = QuestPOIGetIconInfo(questId);
if (x and y) then
return x, y;
end
end
-- General tasks
local x, y = C_TaskQuest.GetQuestLocation(questId, mapId);
if (x and y) then
return x, y;
end
-- Could not get a position
return 0, 0;
end
function WQT_Utils:RewardTypePassesFilter(rewardType)
local rewardFilters = WQT.settings.filters[_V["FILTER_TYPES"].reward].flags;
if(rewardType == WQT_REWARDTYPE.equipment or rewardType == WQT_REWARDTYPE.weapon) then
return rewardFilters.Armor;
end
if(rewardType == WQT_REWARDTYPE.spell or rewardType == WQT_REWARDTYPE.item) then
return rewardFilters.Item;
end
if(rewardType == WQT_REWARDTYPE.gold) then
return rewardFilters.Gold;
end
if(rewardType == WQT_REWARDTYPE.currency) then
return rewardFilters.Currency;
end
if(rewardType == WQT_REWARDTYPE.artifact) then
return rewardFilters.Artifact;
end
if(rewardType == WQT_REWARDTYPE.relic) then
return rewardFilters.Relic;
end
if(rewardType == WQT_REWARDTYPE.xp) then
return rewardFilters.Experience;
end
if(rewardType == WQT_REWARDTYPE.honor) then
return rewardFilters.Honor ;
end
if(rewardType == WQT_REWARDTYPE.reputation) then
return rewardFilters.Reputation;
end
return true;
end
function WQT_Utils:GetQuestRewardIcon(questID)
local texture;
-- Item
texture = select(2, GetQuestLogRewardInfo(1, questID));
if (texture) then return texture; end
-- Spell
texture = GetQuestLogRewardSpell(1, questID);