-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.lua
2728 lines (2378 loc) · 133 KB
/
Core.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
--------------------------------------------------------------------------------
--[[ HandyNotes: Loremaster ]]--
--
-- by erglo <[email protected]>
--
-- Copyright (C) 2023 Erwin D. Glockner (aka erglo)
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see http://www.gnu.org/licenses.
--
--
-- Ace3 API reference:
-- REF.: <https://www.wowace.com/projects/ace3/pages/getting-started>
--
-- HandyNotes API reference:
-- REF.: <https://www.curseforge.com/wow/addons/handynotes>
-- REF.: <https://github.com/Nevcairiel/HandyNotes/blob/master/HandyNotes.lua>
--
-- World of Warcraft API reference:
-- REF.: <https://www.townlong-yak.com/framexml/live/Helix/GlobalStrings.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_SharedXMLBase/TableUtil.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_APIDocumentationGenerated/QuestLogDocumentation.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_UIPanels_Game/QuestMapFrame.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_APIDocumentationGenerated/MapConstantsDocumentation.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_APIDocumentationGenerated/QuestConstantsDocumentation.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_FrameXMLBase/Constants.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_SharedXML/SharedConstants.lua>
-- (see also the function comments section for more reference)
--
--------------------------------------------------------------------------------
local AddonID, ns = ...
local loadSilent = true
local HandyNotes = LibStub("AceAddon-3.0"):GetAddon("HandyNotes", loadSilent)
if not HandyNotes then
error("Embedded library/addon required: HandyNotes", 0)
return
end
local LibQTip = LibStub('LibQTip-1.0')
local ContentTooltip, ZoneStoryTooltip, CampaignTooltip
local LibQTipUtil = ns.utils.libqtip
local LocalAchievementUtil = ns.utils.achieve
local LocalMapUtils = ns.utils.worldmap
local L = ns.L; --> <locales\L10nUtils.lua>
local LoreUtil = ns.lore --> <Data.lua>
LoreUtil.storyQuests = {}
local DBUtil = ns.DatabaseUtil --> <data\database.lua>
local LocalFactionInfo = ns.FactionInfo; --> <data\faction.lua>
local LocalQuestCache = ns.QuestCacheUtil --> <data\questcache.lua>
local LocalQuestFilter = ns.QuestFilter --> <data\questfilter.lua>
local LocalQuestInfo = ns.QuestInfo --> <data\questinfo.lua>
local LocalQuestTagUtil = ns.QuestTagUtil --> <data\questtypetags.lua>
local tostring, strtrim = tostring, strtrim
local tContains, tInsert = tContains, table.insert
local C_QuestLog, C_QuestLine, C_CampaignInfo = C_QuestLog, C_QuestLine, C_CampaignInfo
local QuestUtils_GetQuestName, QuestUtils_GetQuestTagAtlas = QuestUtils_GetQuestName, QuestUtils_GetQuestTagAtlas
local QuestUtils_IsQuestBonusObjective = QuestUtils_IsQuestBonusObjective
local QuestUtils_IsQuestDungeonQuest = QuestUtils_IsQuestDungeonQuest
local QuestUtil = QuestUtil
local GetQuestUiMapID, QuestHasPOIInfo = GetQuestUiMapID, QuestHasPOIInfo
local IsBreadcrumbQuest, IsQuestSequenced, IsStoryQuest = IsBreadcrumbQuest, IsQuestSequenced, IsStoryQuest
local GetQuestExpansion, UnitFactionGroup = GetQuestExpansion, UnitFactionGroup
local C_Map = C_Map -- C_TaskQuest
local C_QuestInfoSystem = C_QuestInfoSystem
local CreateAtlasMarkup = CreateAtlasMarkup
local GREEN_FONT_COLOR, NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR = GREEN_FONT_COLOR, NORMAL_FONT_COLOR, HIGHLIGHT_FONT_COLOR
local BRIGHTBLUE_FONT_COLOR, FACTION_GREEN_COLOR = BRIGHTBLUE_FONT_COLOR, FACTION_GREEN_COLOR
local LIGHTYELLOW_FONT_COLOR, NECROLORD_GREEN_COLOR = LIGHTYELLOW_FONT_COLOR, NECROLORD_GREEN_COLOR
--> TODO - Add color names for QL quest status
local CATEGORY_NAME_COLOR = GRAY_FONT_COLOR
local ZONE_STORY_HEADER_COLOR = ACHIEVEMENT_COLOR
local QUESTLINE_HEADER_COLOR = SCENARIO_STAGE_COLOR
local CAMPAIGN_HEADER_COLOR = CAMPAIGN_COMPLETE_COLOR
local YELLOW = function(txt) return YELLOW_FONT_COLOR:WrapTextInColorCode(txt) end
local GRAY = function(txt) return GRAY_FONT_COLOR:WrapTextInColorCode(txt) end
local GREEN = function(txt) return FACTION_GREEN_COLOR:WrapTextInColorCode(txt) end
local RED = function(txt) return RED_FONT_COLOR:WrapTextInColorCode(txt) end
local ORANGE = function(txt) return ORANGE_FONT_COLOR:WrapTextInColorCode(txt) end
local BLUE = function(txt) return BRIGHTBLUE_FONT_COLOR:WrapTextInColorCode(txt) end
local HIGHLIGHT = function(txt) return HIGHLIGHT_FONT_COLOR:WrapTextInColorCode(txt) end
-- local LibDD = LibStub:GetLibrary('LibUIDropDownMenu-4.0')
local nodes = {}
ns.nodes = nodes
----- Debugging -----
local DEV_MODE = false
local debug = {}
debug.isActive = DEV_MODE
debug.showChapterIDsInTooltip = DEV_MODE
debug.print = function(self, ...)
local prefix = "LM-DBG"
if type(...) == "table" then
local t = ...
if t.debug then
print(YELLOW(prefix..L.TEXT_DELIMITER..t.debug_prefix), select(2, ...))
end
elseif self.isActive then
print(YELLOW(prefix..":"), ...)
end
end
local HookUtils = { debug = false, debug_prefix = "HOOKS:" }
local CampaignUtils = { debug = false, debug_prefix = "CP:" }
local LocalQuestUtils = { debug = false, debug_prefix = ORANGE("QuestUtils:") }
local LocalQuestLineUtils = { debug = false, debug_prefix = "QL:" }
local ZoneStoryUtils = { debug = false, debug_prefix = "ZS:" }
-- MergeTable(LocalMapUtils, { debug = false, debug_prefix = "MAP:" })
local LocalUtils = {}
--> TODO: CampaignCache, QuestCache
-- In debug mode show additional infos in a quest icon's tooltip, eg. questIDs,
-- achievementIDs, etc.
function debug:AddDebugLineToLibQTooltip(tooltip, debugInfo)
local text = debugInfo and debugInfo.text
local addBlankLine = debugInfo and debugInfo.addBlankLine
if debug.isActive then
if text then LibQTipUtil:AddDisabledLine(tooltip, text) end
elseif addBlankLine then
LibQTipUtil:AddBlankLineToTooltip(tooltip)
end
end
-- In debug mode show additional quest data.
function debug:CreateDebugQuestInfoTooltip(pin)
pin.questInfo.pinMapID = GRAY(tostring(pin.mapID))
debug.tooltip = LibQTip:Acquire(AddonID.."DebugLibQTooltip", 2, "LEFT", "RIGHT")
LibQTipUtil:SetTitle(debug.tooltip, ns.pluginInfo.title, GRAY("questInfo"))
local lineIndex, Column1Color, Column2Color
for k, v in pairs(pin.questInfo) do
lineIndex = debug.tooltip:AddLine(k, tostring(v))
Column1Color = (v == true) and GREEN_FONT_COLOR or NORMAL_FONT_COLOR
Column2Color = (v == true) and GREEN_FONT_COLOR or HIGHLIGHT_FONT_COLOR
debug.tooltip:SetCellTextColor(lineIndex, 1, Column1Color:GetRGBA())
debug.tooltip:SetCellTextColor(lineIndex, 2, Column2Color:GetRGBA())
end
local tagInfoList = LocalQuestTagUtil:GetQuestTagInfoList(pin.questID, pin.questInfo)
if (#tagInfoList > 0) then
for _, tagInfo in ipairs(tagInfoList) do
local text = string.format("%s %s", tagInfo.atlasMarkup or '', tagInfo.tagName or L.UNKNOWN)
lineIndex = debug.tooltip:AddLine(text, tostring(tagInfo.tagID))
-- if tagInfo.alpha then
if pin.questInfo.isTrivial then --> TODO - Add to settings
local r, g, b = NORMAL_FONT_COLOR:GetRGB()
-- local LineColor = CreateColor(r, g, b, tagInfo.alpha)
debug.tooltip:SetCellTextColor(lineIndex, 1, r, g, b, tagInfo.alpha)
end
end
end
end
----- Main ---------------------------------------------------------------------
local LoremasterPlugin = LibStub("AceAddon-3.0"):NewAddon("Loremaster", "AceConsole-3.0", "AceEvent-3.0")
--> AceConsole is used for chat frame related functions, eg. printing or slash commands
--> AceEvent is used for global event handling
function LoremasterPlugin:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("LoremasterDB", ns.pluginInfo.defaultOptions)
--> Available AceDB sub-tables: char, realm, class, race, faction, factionrealm, factionrealmregion, profile, and global
ns.settings = self.db.profile --> All characters using the same profile share this database.
ns.data = self.db.global --> All characters on the same account share this database.
ns.charDB = self.db.char
self.options = ns.pluginInfo:InitializeOptions(LoremasterPlugin)
-- Register options to Ace3 for a standalone config window
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable(AddonID, self.options) --> TODO - Check if library files are needed
-- Register this addon + options to HandyNotes as a plugin
HandyNotes:RegisterPluginDB(AddonID, self, self.options)
ns.cprint = function(s, ...) self:Print(...) end
ns.cprintf = function(s, ...) self:Printf(...) end
self.slash_commands = {"lm", "loremaster"} --> TODO - Keep slash commands ???
self.hasRegisteredSlashCommands = false
self:RegisterHooks() --> TODO - Switch to AceHook for unhooking
-- LoreUtil:PrepareData()
-- print("num storyQuests:", #LoreUtil.storyQuests)
end
function LoremasterPlugin:OnEnable()
-- Register slash commands via AceConsole
for i, command in ipairs(self.slash_commands) do
self:RegisterChatCommand(command, "ProcessSlashCommands")
end
self.hasRegisteredSlashCommands = true
LocalQuestFilter:Init()
-- Clean-up
if ns.charDB["activeQuestlines"] then
Temp_ConvertActiveQuestlineQuests()
DBUtil:DeleteDbCategory("activeQuestlines")
end
-- if (Temp_CountOldActiveQuests() > 0) then
-- Temp_RemoveOldActiveQuests()
-- Temp_CountOldActiveQuests()
-- end
if ns.settings.showWelcomeMessage then
self:Printf(L.OPTION_STATUS_FORMAT_READY, YELLOW(ns.pluginInfo.title))
end
end
function LoremasterPlugin:OnDisable()
-- Unregister slash commands from via AceConsole
if self.hasRegisteredSlashCommands then
for i, command in ipairs(self.slash_commands) do
self:UnregisterChatCommand(command)
end
end
self.hasRegisteredSlashCommands = false
--> TODO - Add unhooking
self:Printf(L.OPTION_STATUS_FORMAT, YELLOW(ns.pluginInfo.title), L.OPTION_STATUS_DISABLED)
end
----- Slash Commands ----------
local function OpenHandyNotesPluginSettings()
-- HideUIPanel(WorldMapFrame)
Settings.OpenToCategory(HandyNotes.name)
LibStub('AceConfigDialog-3.0'):SelectGroup(HandyNotes.name, 'plugins', AddonID, "about")
end
function LoremasterPlugin:ProcessSlashCommands(msg)
-- Process the slash command ('input' contains whatever follows the slash command)
-- Registered in :OnEnable()
local input = strtrim(msg)
if (input == "help") then
-- Print usage message to chat
self:Print(L.SLASHCMD_USAGE, string.format(" '/%s <%s>'", self.slash_commands[1], YELLOW("arg")), "|",
string.format(" '/%s <%s>'", self.slash_commands[2], YELLOW("arg"))
)
elseif (input == "version") then
self:Print(ns.pluginInfo.version)
elseif (input == "config" or input == "about") then
OpenHandyNotesPluginSettings()
else
-- Without any input open stand-alone settings frame.
LibStub("AceConfigDialog-3.0"):Open(AddonID)
end
end
--------------------------------------------------------------------------------
----- Tooltip Data Handler -----------------------------------------------------
--------------------------------------------------------------------------------
local function GetCollapseTypeModifier(isComplete, varName)
local types = {
auto = (not isComplete) or IsShiftKeyDown(),
hide = IsShiftKeyDown(),
show = true,
singleLine = false,
}
return types[ns.settings[varName]]
end
function LibQTipUtil:AddPluginNameLine(tooltip)
local lineIndex = LibQTipUtil:AddColoredLine(tooltip, CATEGORY_NAME_COLOR, '')
tooltip:SetCell(lineIndex, 1, LoremasterPlugin.name, nil, "RIGHT") -- replaces line above with the new adjustments
end
function LibQTipUtil:AddCategoryNameLine(tooltip, name, categoryNameOnly)
local lineText, lineIndex
if categoryNameOnly then
lineText = ns.settings.showCategoryNames and name or " " --> string must not be empty or line won't be created
elseif (ns.settings.showPluginName or ns.settings.showCategoryNames) then
local pluginName = ns.settings.showPluginName and LoremasterPlugin.name or ''
local delimiter = (ns.settings.showPluginName and ns.settings.showCategoryNames) and L.DASH_ICON_STRING or ''
local categoryName = ns.settings.showCategoryNames and name or ''
lineText = pluginName .. delimiter .. categoryName
end
lineIndex = LibQTipUtil:AddColoredLine(tooltip, CATEGORY_NAME_COLOR, '')
tooltip:SetCell(lineIndex, 1, lineText, nil, "RIGHT") -- replaces line above with the new adjustments
end
-- Adds a custom line with an indention before a GRAY text to a `LibQTip.Tooltip`.
function LibQTipUtil:AddDescriptionLine(tooltip, text, leftPadding, justify, maxWidth)
local lineIndex = LibQTipUtil:AddDisabledLine(tooltip, '')
--> REF.: qTip:SetCell(lineNum, colNum, value[, font][, justification][, colSpan][, provider][, leftPadding][, rightPadding][, maxWidth][, minWidth][, ...])
tooltip:SetCell(lineIndex, 1, text, nil, justify or "LEFT", nil, nil, leftPadding or 20, nil, maxWidth or 400)
end
----- Zone Story ----------
ZoneStoryUtils.storiesOnMap = {} --> { [mapID] = {storyAchievementID, storyAchievementID2, storyMapInfo}, ... }
ZoneStoryUtils.achievements = {} --> { [achievementID] = achievementInfo, ... }
local ZoneExceptions = { LocalMapUtils.RUINS_OF_GILNEAS_MAP_ID }
-- Return the achievement ID for given zone.
-- **Note:** Shadowlands + Dragonflight have 2 story achievements per zone.
---@param mapID number
---@param prepareCache boolean|nil
---@return number|nil storyAchievementID
---@return number|nil storyAchievementID2
---@return number|nil storyMapInfo
--
function ZoneStoryUtils:GetZoneStoryInfo(mapID, prepareCache)
if not self.storiesOnMap[mapID] then
local storyAchievementID, storyMapID = C_QuestLog.GetZoneStoryInfo(mapID)
local achievementMapID = storyMapID or mapID
local manualStoryAchievementID, storyAchievementID2 = nil, nil
if (LoreUtil.AchievementsLocationMap[achievementMapID] ~= nil) then
manualStoryAchievementID, storyAchievementID2 = SafeUnpack(LoreUtil.AchievementsLocationMap[achievementMapID])
end
local achievementID = not tContains(ZoneExceptions, achievementMapID) and storyAchievementID or manualStoryAchievementID -- Prefer Blizzard's achievements
if not achievementID then return end
local mapInfo = LocalMapUtils:GetMapInfo(achievementMapID)
self.storiesOnMap[mapID] = {achievementID, storyAchievementID2, mapInfo}
debug:print(self, "Added zone story:", achievementID, achievementMapID, mapInfo.name)
if storyAchievementID2 then
debug:print(self, "Added 2nd zone story:", storyAchievementID2, achievementMapID, mapInfo.name)
end
end
if not prepareCache then
return SafeUnpack(self.storiesOnMap[mapID])
end
end
function ZoneStoryUtils:HasZoneStoryInfo(mapID)
if self.storiesOnMap[mapID] then
return true;
end
return C_QuestLog.GetZoneStoryInfo(mapID) ~= nil;
end
-- function ZoneStoryUtils:HasParentZoneStoryInfo(mapID)
-- local mapInfo = LocalMapUtils:GetMapInfo(mapID);
-- return self:HasZoneStoryInfo(mapInfo.parentMapID);
-- end
-- local function WasEarnedByMe(achievementInfo)
-- -- local isAccountWideAchievement = LoreUtil:IsAccountWideAchievement(achievementInfo.flags)
-- -- local earnedBy = achievementInfo.earnedBy
-- -- local wasEarnedByMe = achievementInfo.earnedBy == playerName
-- print(achievementInfo.achievementID, achievementInfo.earnedBy, playerName, achievementInfo.earnedBy == playerName)
-- return achievementInfo.earnedBy == playerName
-- end
-- Check if your current char or someone of your War Band has completed the given quest.
---@param questInfo QuestInfo|table
---@param questID number|nil
---@return boolean isCompleted
--
function LocalQuestUtils:IsQuestCompletedByAnyone(questInfo, questID)
if questID then
return C_QuestLog.IsQuestFlaggedCompleted(questID) or C_QuestLog.IsQuestFlaggedCompletedOnAccount(questID)
end
if questInfo then
return questInfo.isFlaggedCompleted or questInfo.isAccountCompleted
end
return false
end
function ZoneStoryUtils:GetAchievementInfo(achievementID)
if not achievementID then return end
if not self.achievements[achievementID] then
local achievementInfo = LocalAchievementUtil.GetWrappedAchievementInfo(achievementID)
achievementInfo.numCriteria = LocalAchievementUtil.GetWrappedAchievementNumCriteria(achievementID)
achievementInfo.numCompleted = 0 --> track char-specific progress
achievementInfo.criteriaList = {}
for criteriaIndex=1, achievementInfo.numCriteria do
local criteriaInfo = LocalAchievementUtil.GetWrappedAchievementCriteriaInfo(achievementID, criteriaIndex)
if criteriaInfo then
-- -- Note: Currently (WoW 11.0.0) many char-specific achievements became Account or Warband achievements.
-- if LoreUtil:IsHiddenCharSpecificAchievement(achievementID) then
-- if (criteriaInfo.criteriaType == LocalUtils.CriteriaType.Quest) then
-- criteriaInfo.completed = LocalQuestUtils:IsQuestCompletedByAnyone(criteriaInfo.assetID)
-- end
-- -- if C_AchievementInfo.IsValidAchievement(criteriaInfo.assetID) then
-- -- local criteriaAchievementInfo = LocalAchievementUtil.GetWrappedAchievementInfo(criteriaInfo.assetID)
-- -- criteriaInfo.completed = criteriaAchievementInfo.completed -- and WasEarnedByMe(achievementInfo)
-- -- -- criteriaInfo.completed = WasEarnedByMe(criteriaAchievementInfo)
-- -- end
-- end
if criteriaInfo.completed then
achievementInfo.numCompleted = achievementInfo.numCompleted + 1
end
tInsert(achievementInfo.criteriaList, criteriaInfo)
end
end
-- Note: By default achievementInfo.completed shows you the account-wide
-- Loremaster achievement progress. Count completed criteria (above) for
-- char specific progress.
if LoreUtil:IsHiddenCharSpecificAchievement(achievementID) then
achievementInfo.completed = (achievementInfo.numCompleted == achievementInfo.numCriteria)
end
-- achievementInfo.completed = (achievementInfo.numCompleted == achievementInfo.numCriteria)
-- Add some additional values
achievementInfo.isOptionalAchievement = LoreUtil:IsOptionalAchievement(achievementID)
achievementInfo.isAccountWide = LoreUtil:IsAccountWideAchievement(achievementInfo)
achievementInfo.parentAchievementID = LoreUtil:GetParentAchievementID(achievementID)
self.achievements[achievementID] = achievementInfo
debug:print(self, "> Added achievementInfo:", achievementID, achievementInfo.name)
end
return self.achievements[achievementID]
end
function ZoneStoryUtils:IsZoneStoryActive(pin, criteriaInfo)
if (criteriaInfo.criteriaType == LocalUtils.CriteriaType.Quest) then
local questID = criteriaInfo.assetID and criteriaInfo.assetID or criteriaInfo.criteriaID;
if (questID == pin.questID) then
return true;
end
local storyQuestLineInfo = LocalQuestLineUtils:GetCachedQuestLineInfo(questID);
local pinQuestLineInfo = LocalQuestLineUtils:GetCachedQuestLineInfo(pin.questID);
if (storyQuestLineInfo and pinQuestLineInfo and storyQuestLineInfo.questLineID == pinQuestLineInfo.questLineID) then
return true;
end
end
if pin.questInfo and pin.questInfo.hasQuestLineInfo then
if (pin.questInfo.currentQuestLineName == criteriaInfo.criteriaString) then
return true;
end
end
return false;
end
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_AchievementUI/Blizzard_AchievementUI.lua> (see "AchievementShield_OnEnter")
--
local function CreateEarnedByString(achievementInfo)
local msg = ''
if (achievementInfo.isAccountWide) then
msg = achievementInfo.completed and ACCOUNT_WIDE_ACHIEVEMENT_COMPLETED or ACCOUNT_WIDE_ACHIEVEMENT
end
if not L:StringIsEmpty(achievementInfo.earnedBy) then
local charName = achievementInfo.wasEarnedByMe and achievementInfo.earnedBy or UnitName("player")
msg = not L:StringIsEmpty(msg) and msg..L.NEW_LINE or msg
msg = msg..(achievementInfo.wasEarnedByMe and ACHIEVEMENT_COMPLETED_BY or L.ACHIEVEMENT_NOT_COMPLETED_BY)
return msg:format(HIGHLIGHT(charName))
elseif not achievementInfo.isAccountWide then
return CHARACTER_ACHIEVEMENT_DESCRIPTION
end
return msg
end
function ZoneStoryUtils:AddZoneStoryDetailsToTooltip(tooltip, pin)
debug:print(self, string.format(YELLOW("Scanning zone (%s) for stories..."), pin.mapID or "n/a"))
local storyAchievementID = pin.achievementInfo and pin.achievementInfo.achievementID or pin.achievementID
local is2nd = pin.achievementID == pin.achievementID2
local achievementInfo = self:GetAchievementInfo(storyAchievementID)
if not achievementInfo then return false end
if (not pin.isOnContinent and not ns.settings.showOptionalZoneStories and LoreUtil:IsOptionalAchievement(achievementInfo.achievementID) ) then return end
if (is2nd and ns.settings.collapseType_zoneStory ~= "singleLine") then
LibQTipUtil:AddBlankLineToTooltip(tooltip)
end
-- Plugin / category name
if not (is2nd or pin.pinTemplate == LocalUtils.HandyNotesPinTemplate) then
if tooltip == ContentTooltip and LocalUtils:CategoryNeedsExtraSpacing(pin) then
LibQTipUtil:AddBlankLineToTooltip(tooltip)
else
local categoryNameOnly = tooltip == ContentTooltip and (ns.settings.showPluginName and LocalUtils:HasBasicTooltipContent(pin))
LibQTipUtil:AddCategoryNameLine(tooltip, L.CATEGORY_NAME_ZONE_STORY, categoryNameOnly)
end
debug:AddDebugLineToLibQTooltip(tooltip, {text=string.format("> Q:%d - %s - %s_%s_%s", pin.questID, pin.pinTemplate, tostring(pin.questType), tostring(pin.questInfo.questType), pin.questInfo.isTrivial and "isTrivial" or pin.questInfo.isCampaign and "isCampaign" or "noHiddenType")})
end
debug:AddDebugLineToLibQTooltip(tooltip, {text=string.format("> A:%d \"%s\"", storyAchievementID, achievementInfo.name)})
debug:AddDebugLineToLibQTooltip(tooltip, {text="account: "..tostring(achievementInfo.isAccountWide)..", completed: "..tostring(achievementInfo.completed)..", earnedBy: "..tostring(achievementInfo.wasEarnedByMe).."-"..tostring(achievementInfo.earnedBy)})
-- Zone name
if not (is2nd or pin.pinTemplate == LocalUtils.HandyNotesPinTemplate) then
local storyName = pin.storyMapInfo and pin.storyMapInfo.name or achievementInfo.name
LibQTipUtil:SetColoredTitle(tooltip, ZONE_STORY_HEADER_COLOR, L.ZONE_NAME_FORMAT:format(storyName))
end
-- Achievement name
if not pin.isOnContinent then
local achievementNameTemplate = achievementInfo.completed and L.ZONE_ACHIEVEMENT_NAME_FORMAT_COMPLETE or L.ZONE_ACHIEVEMENT_NAME_FORMAT_INCOMPLETE
local achievementName = CONTENT_TRACKING_ACHIEVEMENT_FORMAT:format(achievementInfo.name)
achievementName = achievementInfo.isOptionalAchievement and achievementName..L.TEXT_DELIMITER..AUCTION_HOUSE_BUYOUT_OPTIONAL_LABEL or achievementName
LibQTipUtil:AddNormalLine(tooltip, achievementNameTemplate:format(achievementName))
else
local achievementHeaderNameTemplate = achievementInfo.completed and L.ZONE_ACHIEVEMENT_ICON_NAME_FORMAT_COMPLETE or L.ZONE_ACHIEVEMENT_ICON_NAME_FORMAT_INCOMPLETE
LibQTipUtil:SetColoredTitle(tooltip, ZONE_STORY_HEADER_COLOR, achievementHeaderNameTemplate:format(achievementInfo.icon, achievementInfo.name))
end
if (not pin.isOnContinent and ns.settings.collapseType_zoneStory == "singleLine") then return true end
if (pin.isOnContinent and ns.settings.collapseType_zoneStoryContinent == "singleLine") then return true end
-- Account + earnedBy info
if ns.settings.showEarnedByText then
local earnedByString = CreateEarnedByString(achievementInfo)
if earnedByString then
LibQTipUtil:AddDescriptionLine(tooltip, BLUE(earnedByString), 0, nil, 250)
end
end
-- Parent achievement
if achievementInfo.parentAchievementID then
local parentAchievementInfo = self:GetAchievementInfo(achievementInfo.parentAchievementID)
local parentAchievementName = HIGHLIGHT(parentAchievementInfo and parentAchievementInfo.name or tostring(achievementInfo.parentAchievementID))
LibQTipUtil:AddNormalLine(tooltip, "Part of: "..parentAchievementName) --> TODO - L10n
end
-- Chapter status
if not TableIsEmpty(achievementInfo.criteriaList) then
LibQTipUtil:AddHighlightLine(tooltip, QUEST_STORY_STATUS:format(achievementInfo.numCompleted, achievementInfo.numCriteria))
else
-- Show description for single achievements.
LibQTipUtil:AddDescriptionLine(tooltip, NORMAL_FONT_COLOR:WrapTextInColorCode(achievementInfo.description), 0)
end
-- Chapter list
if (not pin.isOnContinent and GetCollapseTypeModifier(achievementInfo.completed, "collapseType_zoneStory")) or
(pin.isOnContinent and GetCollapseTypeModifier(achievementInfo.completed, "collapseType_zoneStoryContinent")) then
local criteriaName
for i, criteriaInfo in ipairs(achievementInfo.criteriaList) do
criteriaName = criteriaInfo.criteriaString
if debug.showChapterIDsInTooltip then
if (not criteriaInfo.assetID) or (criteriaInfo.assetID == 0) then
criteriaName = string.format("|cffcc1919%03d %05d|r %s", criteriaInfo.criteriaType, criteriaInfo.criteriaID, criteriaName)
else
criteriaName = string.format("|cff808080%03d %05d|r %s", criteriaInfo.criteriaType, criteriaInfo.assetID, criteriaName)
end
end
local isActive = not pin.isOnContinent and self:IsZoneStoryActive(pin, criteriaInfo)
if (criteriaInfo.completed and isActive) then
LibQTipUtil:AddColoredLine(tooltip, GREEN_FONT_COLOR, L.CHAPTER_NAME_FORMAT_CURRENT:format(criteriaName))
elseif criteriaInfo.completed then
LibQTipUtil:AddColoredLine(tooltip, GREEN_FONT_COLOR, L.CHAPTER_NAME_FORMAT_COMPLETED:format(criteriaName))
elseif isActive then
LibQTipUtil:AddNormalLine(tooltip, L.CHAPTER_NAME_FORMAT_CURRENT:format(criteriaName))
else
LibQTipUtil:AddHighlightLine(tooltip, L.CHAPTER_NAME_FORMAT_NOT_COMPLETED:format(criteriaName))
end
-- Show chapter quests
if (not criteriaInfo.completed and criteriaInfo.criteriaType == LocalUtils.CriteriaType.Quest) then
if (not pin.isOnContinent and (ns.settings.showStoryChapterQuests or debug.isActive)) or
(pin.isOnContinent and ns.settings.showContinentStoryChapterQuests) then
-- Format quest name and optionally show to user
local questID = criteriaInfo.assetID and criteriaInfo.assetID or criteriaInfo.criteriaID
local questInfo = LocalQuestUtils:GetQuestInfo(questID, "basic", pin.storyMapInfo and pin.storyMapInfo.mapID or pin.mapID)
local criteriaQuestName = LocalQuestUtils:FormatAchievementQuestName(questInfo, criteriaName)
LibQTipUtil:AddDescriptionLine(tooltip, criteriaQuestName, 15)
if not tContains(LoreUtil.storyQuests, tostring(questID)) then
tinsert(LoreUtil.storyQuests, tostring(questID))
end
end
end
end
elseif not TableIsEmpty(achievementInfo.criteriaList) then
local textTemplate = (pin.pinTemplate == LocalUtils.QuestPinTemplate) and L.HINT_HOLD_KEY_FORMAT or L.HINT_HOLD_KEY_FORMAT_HOVER
textTemplate = (pin.pinTemplate == LocalUtils.HandyNotesPinTemplate) and L.HINT_VIEW_ACHIEVEMENT_CRITERIA or textTemplate
LibQTipUtil:AddInstructionLine(tooltip, textTemplate:format(GREEN(SHIFT_KEY)))
end
debug:print(self, string.format("Found story with %d |4chapter:chapters;.", achievementInfo.numCriteria))
return true
end
----- Faction Group Labels ----------
LocalUtils.QuestTag = {}
LocalUtils.QuestTag.Class = 21
LocalUtils.QuestTag.Escort = 84
LocalUtils.QuestTag.Artifact = 107
LocalUtils.QuestTag.WorldQuest = 109
LocalUtils.QuestTag.BurningLegionWorldQuest = 145
LocalUtils.QuestTag.BurningLegionInvasionWorldQuest = 146
LocalUtils.QuestTag.Profession = 267
-- LocalUtils.QuestTag.Threat = 268
LocalUtils.QuestTag.WarModePvP = 255
LocalUtils.QuestTag.Important = 282
-- Expand the default quest tag atlas map
-- **Note:** Before adding more tag icons, check if they're not already part of QUEST_TAG_ATLAS!
--
--> REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_FrameXMLBase/Constants.lua>
--> REF.: <https://warcraft.wiki.gg/wiki/API_C_QuestLog.GetQuestTagInfo>
--
QUEST_TAG_ATLAS[LocalUtils.QuestTag.Artifact] = "ArtifactQuest"
QUEST_TAG_ATLAS[LocalUtils.QuestTag.BurningLegionWorldQuest] = "worldquest-icon-burninglegion" --> Legion Invasion World Quest Wrapper (~= Enum.QuestTagType.Invasion)
QUEST_TAG_ATLAS[LocalUtils.QuestTag.BurningLegionInvasionWorldQuest] = "legioninvasion-map-icon-portal" --> Legion Invasion World Quest Wrapper (~= Enum.QuestTagType.Invasion)
QUEST_TAG_ATLAS[LocalUtils.QuestTag.Class] = "questlog-questtypeicon-class"
QUEST_TAG_ATLAS[LocalUtils.QuestTag.Escort] = "nameplates-InterruptShield"
QUEST_TAG_ATLAS[LocalUtils.QuestTag.Profession] = "Profession"
QUEST_TAG_ATLAS[LocalUtils.QuestTag.WorldQuest] = "worldquest-tracker-questmarker"
-- QUEST_TAG_ATLAS[LocalUtils.QuestTag.Threat] = "worldquest-icon-nzoth" -- "Ping_Map_Threat"
QUEST_TAG_ATLAS[LocalUtils.QuestTag.WarModePvP] = "questlog-questtypeicon-pvp"
QUEST_TAG_ATLAS["CAMPAIGN"] = "Quest-Campaign-Available"
QUEST_TAG_ATLAS["COMPLETED_CAMPAIGN"] = "Quest-Campaign-TurnIn"
QUEST_TAG_ATLAS["COMPLETED_DAILY_CAMPAIGN"] = "Quest-DailyCampaign-TurnIn"
QUEST_TAG_ATLAS["COMPLETED_IMPORTANT"] = "questlog-questtypeicon-importantturnin" -- "quest-important-turnin"
QUEST_TAG_ATLAS["COMPLETED_REPEATABLE"] = "QuestRepeatableTurnin"
QUEST_TAG_ATLAS["DAILY_CAMPAIGN"] = "Quest-DailyCampaign-Available"
QUEST_TAG_ATLAS["IMPORTANT"] = "questlog-questtypeicon-important" -- "quest-important-available"
QUEST_TAG_ATLAS[LocalUtils.QuestTag.Important] = "questlog-questtypeicon-important"
QUEST_TAG_ATLAS[Enum.QuestTag.Legendary] = "questlog-questtypeicon-legendary"
QUEST_TAG_ATLAS["TRIVIAL_CAMPAIGN"] = "Quest-Campaign-Available-Trivial"
QUEST_TAG_ATLAS["TRIVIAL_IMPORTANT"] = "quest-important-available-trivial"
QUEST_TAG_ATLAS["TRIVIAL_LEGENDARY"] = "quest-legendary-available-trivial"
QUEST_TAG_ATLAS["TRIVIAL"] = "TrivialQuests"
-- QUEST_TAG_ATLAS["MONTHLY"] = "questlog-questtypeicon-monthly"
local QuestTagNames = {
["CAMPAIGN"] = TRACKER_HEADER_CAMPAIGN_QUESTS,
["COMPLETED"] = COMPLETE,
["IMPORTANT"] = ENCOUNTER_JOURNAL_SECTION_FLAG5,
["LEGENDARY"] = MAP_LEGEND_LEGENDARY, -- ITEM_QUALITY5_DESC,
["STORY"] = LOOT_JOURNAL_LEGENDARIES_SOURCE_ACHIEVEMENT,
["TRIVIAL_CAMPAIGN"] = L.QUEST_TYPE_NAME_FORMAT_TRIVIAL:format(TRACKER_HEADER_CAMPAIGN_QUESTS),
["TRIVIAL_IMPORTANT"] = L.QUEST_TYPE_NAME_FORMAT_TRIVIAL:format(ENCOUNTER_JOURNAL_SECTION_FLAG5),
["TRIVIAL_LEGENDARY"] = L.QUEST_TYPE_NAME_FORMAT_TRIVIAL:format(ITEM_QUALITY5_DESC),
["TRIVIAL"] = L.QUEST_TYPE_NAME_FORMAT_TRIVIAL:format(UNIT_NAMEPLATES_SHOW_ENEMY_MINUS),
}
local leftSidedTags = {Enum.QuestTag.Dungeon, Enum.QuestTag.Raid, LocalUtils.QuestTag.WorldQuest, LocalUtils.QuestTag.BurningLegionInvasionWorldQuest, LocalUtils.QuestTag.Threat, LocalUtils.QuestTag.Important}
-- Add quest type tags (text or icon) to a quest name.
function LocalQuestUtils:FormatQuestName(questInfo)
local iconString, atlasName;
local isReady = questInfo.isReadyForTurnIn
local questTitle = LocalFactionInfo.QuestNameFactionGroupTemplate[questInfo.questFactionGroup]:format(questInfo.questName)
if not L:StringIsEmpty(questInfo.questName) then
if ( isReady and not (questInfo.isDaily or questInfo.isWeekly) ) then
if ns.settings.showQuestTypeAsText then
questTitle = BLUE(L.PARENS_TEMPLATE:format(QuestTagNames["COMPLETED"]))..L.TEXT_DELIMITER..questTitle
else
iconString = CreateAtlasMarkup(QUEST_TAG_ATLAS["COMPLETED"], 16, 16, -2)
questTitle = iconString..questTitle
end
end
if questInfo.isDaily then
if ns.settings.showQuestTypeAsText then
questTitle = BLUE(L.PARENS_TEMPLATE:format(L.DAILY))..L.TEXT_DELIMITER..questTitle
else
iconString = CreateAtlasMarkup(isReady and QUEST_TAG_ATLAS["COMPLETED_REPEATABLE"] or QUEST_TAG_ATLAS.DAILY, 16, 16, -2)
questTitle = iconString..questTitle
end
end
if questInfo.isWeekly then
if ns.settings.showQuestTypeAsText then
questTitle = BLUE(L.PARENS_TEMPLATE:format(L.WEEKLY))..L.TEXT_DELIMITER..questTitle
else
local iconTurnIn = CreateAtlasMarkup(QUEST_TAG_ATLAS["COMPLETED_REPEATABLE"], 16, 16, -1)
local iconAvailable = CreateAtlasMarkup(QUEST_TAG_ATLAS.WEEKLY, 16, 16)
iconString = isReady and iconTurnIn or iconAvailable
questTitle = iconString..L.TEXT_DELIMITER..questTitle
end
end
if questInfo.isStory then
if (ns.settings.highlightStoryQuests and not LocalQuestUtils:IsQuestCompletedByAnyone(questInfo)) then
questTitle = ORANGE(questTitle)
end
if ns.settings.showQuestTypeAsText then
questTitle = BLUE(L.PARENS_TEMPLATE:format(QuestTagNames["STORY"]))..L.TEXT_DELIMITER..questTitle
else
iconString = CreateAtlasMarkup(QUEST_TAG_ATLAS["STORY"], 16, 16)
questTitle = iconString..L.TEXT_DELIMITER..questTitle
end
end
if questInfo.isAccountCompleted then
if ns.settings.showQuestTypeAsText then
questTitle = BLUE(L.PARENS_TEMPLATE:format(ACCOUNT_COMPLETED_QUEST_LABEL))..L.TEXT_DELIMITER..questTitle
else
iconString = CreateAtlasMarkup("questlog-questtypeicon-account", 16, 16, 2)
-- questTitle = iconString..L.TEXT_DELIMITER..questTitle
questTitle = questTitle..iconString
end
end
if (questInfo.questType ~= 0) then
if ns.settings.showQuestTypeAsText then
questTitle = BLUE(L.PARENS_TEMPLATE:format(questInfo.questTagInfo.tagName))..L.TEXT_DELIMITER..questTitle
elseif (QUEST_TAG_ATLAS[questInfo.questType] == nil) then
-- This quest type is neither part of Blizzard's tag atlas variable, nor have I added it, yet.
questTitle = BLUE(L.PARENS_TEMPLATE:format(questInfo.questTagInfo.tagName or L.UNKNOWN))..L.TEXT_DELIMITER..questTitle
elseif tContains(leftSidedTags, questInfo.questType) then
-- -- Threat Object icons can vary, eg. N'Zoth vs. one of the Shadowlands main factions.
-- iconString = questInfo.questTagInfo.isThreat and QuestUtil.GetThreatPOIIcon(questInfo.questTagInfo.questID) or CreateAtlasMarkup(QUEST_TAG_ATLAS[questInfo.questType], 16, 16, -2)
iconString = CreateAtlasMarkup(QUEST_TAG_ATLAS[questInfo.questType], 16, 16, -2)
questTitle = iconString..questTitle
else
atlasName = QuestUtils_GetQuestTagAtlas(questInfo.questTagInfo.tagID, questInfo.questTagInfo.worldQuestType)
iconString = (questInfo.questType == LocalUtils.QuestTag.Escort) and CreateAtlasMarkup(atlasName, 14, 16, 2) or CreateAtlasMarkup(atlasName, 16, 16, 2, -1)
questTitle = questTitle..iconString
end
end
if questInfo.isLegendary then
if ns.settings.showQuestTypeAsText then
questTitle = BLUE(L.PARENS_TEMPLATE:format(QuestTagNames["LEGENDARY"]))..L.TEXT_DELIMITER..questTitle
else
iconString = CreateAtlasMarkup(isReady and QUEST_TAG_ATLAS["COMPLETED_LEGENDARY"] or QUEST_TAG_ATLAS[Enum.QuestTag.Legendary], 16, 16)
questTitle = iconString..L.TEXT_DELIMITER..questTitle
end
end
if questInfo.isOnQuest and not isReady then
if ns.settings.showQuestTypeAsText then
questTitle = BLUE(L.PARENS_TEMPLATE:format(MAP_LEGEND_INPROGRESS))..L.TEXT_DELIMITER..questTitle
else
local atlas = LocalQuestTagUtil:GetInProgressQuestTypeAtlas(questInfo)
iconString = CreateAtlasMarkup(atlas, 14, 16, -2)
questTitle = iconString..questTitle
end
end
if debug.showChapterIDsInTooltip then
local colorCodeString = questInfo.questType == 0 and GRAY_FONT_COLOR_CODE or LIGHTBLUE_FONT_COLOR_CODE
questTitle = string.format(colorCodeString.."%03d %05d|r %s", questInfo.questType, questInfo.questID, questTitle)
end
else
-- debug:print("Empty:", questInfo.questID, tostring(questTitle), tostring(questInfo.questName))
questTitle = RETRIEVING_DATA
if debug.isActive then
questTitle = string.format("> questFactionGroup: %s, questExpansionID: %d", tostring(questInfo.questFactionGroup), questInfo.questExpansionID)
end
if debug.showChapterIDsInTooltip then
local colorCodeString = questInfo.questType == 0 and GRAY_FONT_COLOR_CODE or LIGHTBLUE_FONT_COLOR_CODE
questTitle = string.format(colorCodeString.."%03d %05d|r %s", questInfo.questType, questInfo.questID, questTitle)
end
end
return questTitle
end
function LocalQuestUtils:FormatAchievementQuestName(questInfo, fallbackName)
if not L:StringIsEmpty(questInfo.questName) then
local iconString = CreateAtlasMarkup("SmallQuestBang", 16, 16, 1, -1)
local questTitle = iconString..LocalFactionInfo.QuestNameFactionGroupTemplate[questInfo.questFactionGroup]:format(questInfo.questName)
if (questInfo.questType ~= 0) then
iconString = (questInfo.questType == LocalUtils.QuestTag.Escort) and CreateAtlasMarkup(QUEST_TAG_ATLAS[questInfo.questType], 14, 16, 2) or CreateAtlasMarkup(QUEST_TAG_ATLAS[questInfo.questType], 16, 16, 2, -1)
questTitle = questTitle..iconString
end
return questTitle
end
return fallbackName
end
----- Quest Handler ----------
-- LocalQuestUtils.cache = {}
LocalQuestUtils.GetQuestName = function(self, questID)
-- REF.: <https://www.townlong-yak.com/framexml/live/QuestUtils.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_APIDocumentationGenerated/QuestLogDocumentation.lua>
-- if not HaveQuestData(questID) then
-- C_QuestLog.RequestLoadQuestByID(questID)
-- end
return QuestUtils_GetQuestName(questID) -- QuestCache:Get(questID).title
end
local classificationIgnoreTable = {
Enum.QuestClassification.Legendary,
Enum.QuestClassification.Campaign,
}
function LocalQuestUtils:AddQuestTagLinesToTooltip_New(tooltip, baseQuestInfo)
local tagInfoList, questInfo = LocalQuestTagUtil:GetQuestTagInfoList(baseQuestInfo.questID, baseQuestInfo)
if (#tagInfoList == 0) then return end
local LineColor = NORMAL_FONT_COLOR
for _, tagInfo in ipairs(tagInfoList) do
local text = string.format("%s %s", tagInfo.atlasMarkup or '', tagInfo.tagName or L.UNKNOWN)
local lineIndex = LibQTipUtil:AddColoredLine(tooltip, LineColor, text)
if (tooltip:GetWidth() < GameTooltip:GetWidth()) then
-- Don't wrap tag lines which are longer than the GameTooltip, but stretch smaller ones to fit its width.
tooltip:SetCell(lineIndex, 1, text, nil, "LEFT", nil, nil, nil, nil, GameTooltip:GetWidth(), GameTooltip:GetWidth()-20)
end
if (questInfo.isTrivial and ns.settings.showTagTransparency) then
local r, g, b = LineColor:GetRGB()
tooltip:SetCellTextColor(lineIndex, 1, r, g, b, 0.5)
end
end
end
-- Add daily and weekly quests to known quest types.
function LocalQuestUtils:AddQuestTagLinesToTooltip(tooltip, questInfo) --> TODO - Clean this up
local LineColor = questInfo.isOnQuest and TOOLTIP_DEFAULT_COLOR or NORMAL_FONT_COLOR
-- Blizzard's default tags
local tagInfo = questInfo.questTagInfo
if (tagInfo and not LocalQuestTagUtil:ShouldIgnoreQuestTypeTag(questInfo)) then
local tagID = tagInfo.tagID
local tagName = tagInfo.tagName
-- Account-wide quest types are usually only shown in the questlog
if (tagInfo.tagID == Enum.QuestTag.Account and questInfo.questFactionGroup ~= LocalFactionInfo.QuestFactionGroupID.Neutral) then
local factionString = questInfo.questFactionGroup == LE_QUEST_FACTION_HORDE and FACTION_HORDE or FACTION_ALLIANCE
tagID = questInfo.questFactionGroup == LE_QUEST_FACTION_HORDE and "HORDE" or "ALLIANCE"
tagName = tagName..L.TEXT_DELIMITER..L.PARENS_TEMPLATE:format(factionString)
end
if (tagInfo.worldQuestType ~= nil) then --> TODO - Add to '<utils\libqtip.lua>'
local atlas, width, height = QuestUtil.GetWorldQuestAtlasInfo(questInfo.questID, tagInfo, questInfo.isActive)
local atlasMarkup = CreateAtlasMarkup(atlas, 20, 20)
LibQTipUtil:AddNormalLine(tooltip, string.format("%s %s", atlasMarkup, tagInfo.tagName))
end
if (tagInfo.tagID == Enum.QuestTagType.Threat or questInfo.isThreat) then
local atlas = QuestUtil.GetThreatPOIIcon(questInfo.questID)
local atlasMarkup = CreateAtlasMarkup(atlas, 20, 20)
LibQTipUtil:AddNormalLine(tooltip, string.format("%s %s", atlasMarkup, tagInfo.tagName))
end
LibQTipUtil:AddQuestTagTooltipLine(tooltip, tagName, tagID, tagInfo.worldQuestType, LineColor)
end
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_APIDocumentationGenerated/QuestInfoSystemDocumentation.lua>
-- REF.: <https://www.townlong-yak.com/framexml/live/Blizzard_FrameXMLUtil/QuestUtils.lua>
-- local classificationInfo = C_QuestInfoSystem.GetQuestClassification(questInfo.questID);
-- local classificationString = QuestUtil.GetQuestClassificationString(questInfo.questID)
local classificationID, classificationText, classificationAtlas, clSize = QuestUtil.GetQuestClassificationDetails(questInfo.questID)
-- Custom tags
if questInfo.isDaily then
LibQTipUtil:AddQuestTagTooltipLine(tooltip, L.DAILY, "DAILY", nil, LineColor)
-- if questInfo.isCampaign then
-- local tagName = questInfo.isReadyForTurnIn and "COMPLETED_DAILY_CAMPAIGN" or "DAILY_CAMPAIGN"
-- LibQTipUtil:AddQuestTagTooltipLine(tooltip, DAILY, tagName, nil, LineColor)
-- else
-- local tagName = questInfo.isReadyForTurnIn and "COMPLETED_REPEATABLE" or "DAILY"
-- LibQTipUtil:AddQuestTagTooltipLine(tooltip, DAILY, tagName, nil, LineColor)
-- end
end
if questInfo.isWeekly then
LibQTipUtil:AddQuestTagTooltipLine(tooltip, L.WEEKLY, "WEEKLY", nil, LineColor)
-- if questInfo.isCampaign then
-- local tagName = questInfo.isReadyForTurnIn and "COMPLETED_DAILY_CAMPAIGN" or "DAILY_CAMPAIGN"
-- LibQTipUtil:AddQuestTagTooltipLine(tooltip, WEEKLY, tagName, nil, LineColor)
-- else
-- local tagName = questInfo.isReadyForTurnIn and "COMPLETED_REPEATABLE" or "WEEKLY"
-- LibQTipUtil:AddQuestTagTooltipLine(tooltip, WEEKLY, tagName, nil, LineColor)
-- end
end
if (classificationID and not tContains(classificationIgnoreTable, classificationID)) then
local atlasMarkup = CreateAtlasMarkup(classificationAtlas, 20, 20)
LibQTipUtil:AddNormalLine(tooltip, LineColor:WrapTextInColorCode(string.format("%s %s", atlasMarkup, classificationText)))
end
if questInfo.isTrivial then
if questInfo.isLegendary then
LibQTipUtil:AddQuestTagTooltipLine(tooltip, QuestTagNames["TRIVIAL_LEGENDARY"], "TRIVIAL_LEGENDARY", nil, LineColor)
-- elseif questInfo.isImportant then
-- LibQTipUtil:AddQuestTagTooltipLine(tooltip, QuestTagNames["TRIVIAL_IMPORTANT"], "TRIVIAL_IMPORTANT", nil, LineColor)
elseif questInfo.isCampaign then
LibQTipUtil:AddQuestTagTooltipLine(tooltip, QuestTagNames["TRIVIAL_CAMPAIGN"], "TRIVIAL_CAMPAIGN", nil, LineColor)
else
LibQTipUtil:AddQuestTagTooltipLine(tooltip, QuestTagNames["TRIVIAL"], "TRIVIAL", nil, LineColor)
end
else
if questInfo.isLegendary then
local tagName = questInfo.isReadyForTurnIn and "COMPLETED_LEGENDARY" or Enum.QuestTag.Legendary
LibQTipUtil:AddQuestTagTooltipLine(tooltip, QuestTagNames["LEGENDARY"], tagName, nil, LineColor)
end
-- if questInfo.isImportant then
-- local tagName = questInfo.isReadyForTurnIn and "COMPLETED_IMPORTANT" or "IMPORTANT"
-- LibQTipUtil:AddQuestTagTooltipLine(tooltip, QuestTagNames["IMPORTANT"], RED(tagName), nil, LineColor)
-- end
if questInfo.isCampaign then -- and not questInfo.isDaily and not questInfo.isWeekly) then
local tagName = questInfo.isReadyForTurnIn and "COMPLETED_CAMPAIGN" or "CAMPAIGN"
LibQTipUtil:AddQuestTagTooltipLine(tooltip, QuestTagNames["CAMPAIGN"], tagName, nil, LineColor)
end
end
if questInfo.isStory then
LibQTipUtil:AddQuestTagTooltipLine(tooltip, STORY_PROGRESS, "STORY", nil, LineColor)
end
-- if questInfo.isBonusObjective then
-- local atlas = "questbonusobjective"
-- local atlasMarkup = CreateAtlasMarkup(atlas, 20, 20)
-- LibQTipUtil:AddNormalLine(tooltip, string.format("%s %s", atlasMarkup, MAP_LEGEND_BONUSOBJECTIVE))
-- end
if (not tagInfo or tagInfo.tagID ~= Enum.QuestTag.Account) and (questInfo.questFactionGroup ~= LocalFactionInfo.QuestFactionGroupID.Neutral) then
-- Show faction group icon only when no tagInfo provided or not an account quest
local tagName = questInfo.questFactionGroup == LE_QUEST_FACTION_HORDE and ITEM_REQ_HORDE or ITEM_REQ_ALLIANCE
local tagID = questInfo.questFactionGroup == LE_QUEST_FACTION_HORDE and "HORDE" or "ALLIANCE"
LibQTipUtil:AddQuestTagTooltipLine(tooltip, tagName, tagID, nil, LineColor)
end
end
-- Retrieve different quest details.
--
function LocalQuestUtils:GetQuestInfo(questID, targetType, pinMapID)
local questName = self:GetQuestName(questID)
if (targetType == "questline") then
local questInfo = {
isAccountQuest = C_QuestLog.IsAccountQuest(questID),
-- isBounty = C_QuestLog.IsQuestBounty(questID),
-- isBreadcrumbQuest = IsBreadcrumbQuest(questID),
isCalling = C_QuestLog.IsQuestCalling(questID),
isCampaign = C_CampaignInfo.IsCampaignQuest(questID),
isComplete = C_QuestLog.IsComplete(questID),
isDaily = LocalQuestFilter:IsDaily(questID),
isDisabledForSession = C_QuestLog.IsQuestDisabledForSession(questID),
isFlaggedCompleted = C_QuestLog.IsQuestFlaggedCompleted(questID), -- self:IsQuestCompletedByAnyone(questInfo),
isAccountCompleted = C_QuestLog.IsQuestFlaggedCompletedOnAccount(questID),
isReadyForTurnIn = C_QuestLog.ReadyForTurnIn(questID),
isOnQuest = C_QuestLog.IsOnQuest(questID),
isImportant = C_QuestLog.IsImportantQuest(questID),
-- isInvasion = C_QuestLog.IsQuestInvasion(questID),
isLegendary = C_QuestLog.IsLegendaryQuest(questID),
isObsolete = LocalQuestFilter:IsObsolete(questID),
isRepeatable = C_QuestLog.IsRepeatableQuest(questID),
-- isReplayable = C_QuestLog.IsQuestReplayable(questID),
isSequenced = IsQuestSequenced(questID),
isStory = LocalQuestFilter:IsStory(questID),
isThreat = C_QuestLog.IsThreatQuest(questID),
isTrivial = C_QuestLog.IsQuestTrivial(questID),
isWeekly = LocalQuestFilter:IsWeekly(questID),
-- questDifficulty = C_PlayerInfo.GetContentDifficultyQuestForPlayer(questID), --> Enum.RelativeContentDifficulty
questExpansionID = GetQuestExpansion(questID),
questFactionGroup = LocalQuestFilter:GetQuestFactionGroup(questID),
questID = questID,
questMapID = GetQuestUiMapID(questID),
questName = questName,
questType = C_QuestLog.GetQuestType(questID), --> Enum.QuestTag
questTagInfo = LocalQuestInfo:GetQuestTagInfo(questID), --> QuestTagInfo table
questClassification = C_QuestInfoSystem.GetQuestClassification(questID),
isFailed = C_QuestLog.IsFailed(questID),
}
if ns.settings.saveRecurringQuests then
-- Enhance completion flagging for recurring quests
if (questInfo.isDaily and not questInfo.isFlaggedCompleted) then --> TODO - Check if need include account
questInfo.isFlaggedCompleted = DBUtil:IsCompletedRecurringQuest("Daily", questID)
end
if (questInfo.isWeekly and not questInfo.isFlaggedCompleted) then
questInfo.isFlaggedCompleted = DBUtil:IsCompletedRecurringQuest("Weekly", questID)
end
end
return questInfo
end
if (targetType == "pin") then
local questInfo = {
-- Test
questMapID = GetQuestUiMapID(questID),
hasPOIInfo = QuestHasPOIInfo(questID),
isBounty = C_QuestLog.IsQuestBounty(questID),
isCalling = C_QuestLog.IsQuestCalling(questID),
isDisabledForSession = C_QuestLog.IsQuestDisabledForSession(questID),
-- isInvasion = C_QuestLog.IsQuestInvasion(questID),
isRepeatable = C_QuestLog.IsRepeatableQuest(questID),
isReplayable = C_QuestLog.IsQuestReplayable(questID),
isReplayedRecently = C_QuestLog.IsQuestReplayedRecently(questID),
-- Keep
isAccountQuest = C_QuestLog.IsAccountQuest(questID),
isCampaign = C_CampaignInfo.IsCampaignQuest(questID),
isComplete = C_QuestLog.IsComplete(questID),
isDaily = LocalQuestFilter:IsDaily(questID),
isFlaggedCompleted = C_QuestLog.IsQuestFlaggedCompleted(questID), -- self:IsQuestCompletedByAnyone(questInfo),
isImportant = C_QuestLog.IsImportantQuest(questID),
isLegendary = C_QuestLog.IsLegendaryQuest(questID),
isOnQuest = C_QuestLog.IsOnQuest(questID),
isReadyForTurnIn = C_QuestLog.ReadyForTurnIn(questID),
isStory = LocalQuestFilter:IsStory(questID),