-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathWorldQuestTracker.lua
1618 lines (1342 loc) · 58.5 KB
/
WorldQuestTracker.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 addonId, wqtInternal = ...
--new 8.1.5 C_TaskQuest.GetQuestTimeLeftSeconds
hooksecurefunc (WorldQuestDataProviderMixin, "RefreshAllData", function (self, fromOnShow)
--is triggering each 0.5 seconds
--print ("WorldQuestDataProviderMixin.RefreshAllData", "fromOnShow", fromOnShow)
end)
hooksecurefunc (WorldQuestPinMixin, "RefreshVisuals", function (pin)
--print ("WorldQuestDataProviderMixin.RefreshVisuals", "pin id:", pin.questID)
end)
--details! framework
local DF = _G ["DetailsFramework"]
if (not DF) then
print ("|cFFFFAA00World Quest Tracker: framework not found, if you just installed or updated the addon, please restart your client.|r")
return
end
local L = DF.Language.GetLanguageTable(addonId)
if (true) then
--return - nah, not today
end
local WorldQuestTracker = WorldQuestTrackerAddon
local ff = WorldQuestTrackerFinderFrame
local rf = WorldQuestTrackerRareFrame
local HaveQuestData = HaveQuestData
local isWorldQuest = QuestUtils_IsQuestWorldQuest
local GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID
local GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
local GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID or C_TaskQuest.GetQuestsOnMap
local _
WorldQuestTracker.QuestTrackList = {} --place holder until OnInit is triggered
WorldQuestTracker.AllTaskPOIs = {}
WorldQuestTracker.JustAddedToTracker = {}
WorldQuestTracker.Cache_ShownQuestOnWorldMap = {}
WorldQuestTracker.Cache_ShownQuestOnZoneMap = {}
WorldQuestTracker.Cache_ShownWidgetsOnZoneMap = {}
WorldQuestTracker.WorldMapSupportWidgets = {}
WorldQuestTracker.PartyQuestsPool = {}
WorldQuestTracker.CurrentZoneQuests = {}
WorldQuestTracker.CachedQuestData = {}
WorldQuestTracker.CachedConduitData = {}
WorldQuestTracker.CurrentMapID = 0
WorldQuestTracker.LastWorldMapClick = 0
WorldQuestTracker.MapSeason = 0
WorldQuestTracker.MapOpenedAt = 0
WorldQuestTracker.WorldQuestButton_Click = 0
WorldQuestTracker.Temp_HideZoneWidgets = 0
WorldQuestTracker.lastZoneWidgetsUpdate = 0
WorldQuestTracker.lastMapTap = 0
WorldQuestTracker.LastGFSearch = 0
WorldQuestTracker.SoundPitch = math.random (2)
WorldQuestTracker.RarityColors = {
[3] = "|cff2292FF",
[4] = "|cffc557FF",
}
WorldQuestTracker.GameLocale = GetLocale()
WorldQuestTracker.COMM_PREFIX = "WQTC"
local LibWindow = LibStub ("LibWindow-1.1")
if (not LibWindow) then
print ("|cFFFFAA00World Quest Tracker|r: libwindow not found, did you just updated the addon? try reopening the client.|r")
end
local WorldMapScrollFrame = WorldMapFrame.ScrollContainer
----------------------------------------------------------------------------------------------------------------------------------------------------------------
--> initialize the addon
local reGetTrackerList = function()
C_Timer.After (.2, WorldQuestTracker.GetTrackedQuestsOnDB)
end
function WorldQuestTracker.GetTrackedQuestsOnDB()
local GUID = UnitGUID ("player")
if (not GUID) then
reGetTrackerList()
WorldQuestTracker.QuestTrackList = {}
return
end
local questList = WorldQuestTracker.db.profile.quests_tracked [GUID]
if (not questList) then
questList = {}
WorldQuestTracker.db.profile.quests_tracked [GUID] = questList
end
WorldQuestTracker.QuestTrackList = questList
--> faz o cliente carregar as quests antes de realmente verificar o tempo restante
if (not WorldQuestTracker.CheckTimeLeftOnQuestsFromTracker_Load) then
print ("WorldQuestTracker.CheckTimeLeftOnQuestsFromTracker_Load MISSING")
return
end
C_Timer.After (3, WorldQuestTracker.CheckTimeLeftOnQuestsFromTracker_Load)
C_Timer.After (4, WorldQuestTracker.CheckTimeLeftOnQuestsFromTracker_Load)
C_Timer.After (6, WorldQuestTracker.CheckTimeLeftOnQuestsFromTracker_Load)
C_Timer.After (10, WorldQuestTracker.CheckTimeLeftOnQuestsFromTracker)
WorldQuestTracker.RefreshTrackerWidgets()
end
function WorldQuestTracker.Debug (message, color)
if (WorldQuestTracker.debug) then
if (color == 1) then
print ("|cFFFFFF44[WQT]|r", "|cFFDDDDDD(debug)|r", "|cFFFF8800" .. message .. "|r")
elseif (color == 2) then
print ("|cFFFFFF44[WQT]|r", "|cFFDDDDDD(debug)|r", "|cFFFFFF00" .. message .. "|r")
else
print ("|cFFFFFF44[WQT]|r", "|cFFDDDDDD(debug)|r", message)
end
end
end
WorldQuestTracker.ExtraMapTextures = {}
function WorldQuestTracker.UpdateExtraMapTextures()
local mapID = WorldQuestTracker.GetCurrentMapAreaID()
for texturePath, textureInfo in pairs (WorldQuestTracker.ExtraMapTextures) do
if (textureInfo.MapID == mapID) then
textureInfo.Pin:Show()
else
textureInfo.Pin:Hide()
end
end
--alternative way to deal with it:
--[=[
local map = WorldQuestTrackerDataProvider:GetMap()
for pin in map:EnumeratePinsByTemplate("WorldQuestTrackerWorldMapPinTemplate") do
if (pin.MapTextureInfo.MapID ~= WorldMapFrame.mapID) then
pin.Texture:Hide()
else
pin.Texture:Show()
end
end
--]=]
end
---@param mapID number the mapID to show the texture, if the map does not match, the texture won't be shown
---@param texturePath any
---@param x number the x position of the texture
---@param y number the y position of the texture
---@param width number
---@param height number
---@param onClickMapID number the mapID to switch when the texture is clicked
function WorldQuestTracker.AddExtraMapTexture(mapID, texturePath, x, y, width, height, onClickMapID)
local mapTextureInfo = WorldQuestTracker.ExtraMapTextures[texturePath]
if (not mapTextureInfo) then
width = width * 4
height = height * 4
local pin = WorldQuestTrackerDataProvider:GetMap():AcquirePin("WorldQuestTrackerExtraMapTextureTemplate", "questPin")
pin:SetPosition(x, y)
pin:SetSize(width, height)
local texture = pin:CreateTexture(nil, "overlay")
texture:SetTexture(texturePath)
texture:SetSize(width, height)
texture:SetPoint("topleft", pin, "topleft", 0, 0)
texture:SetAlpha(0.834)
pin.Child = texture
local textureHighlight = pin:CreateTexture(nil, "overlay")
textureHighlight:SetTexture(texturePath)
textureHighlight:SetSize(width, height)
textureHighlight:SetPoint("topleft", pin, "topleft", 0, 0)
textureHighlight:SetAlpha(0.15)
textureHighlight:SetVertexColor(1, 0.7, 0)
textureHighlight:SetBlendMode("ADD")
textureHighlight:Hide()
pin:SetScript("OnEnter", function()
textureHighlight:Show()
end)
pin:SetScript("OnLeave", function()
textureHighlight:Hide()
end)
pin:SetScript("OnMouseUp", function()
WorldMapFrame:SetMapID(onClickMapID)
WorldQuestTracker.UpdateZoneWidgets(true)
end)
mapTextureInfo = {
MapID = mapID,
Texture = texture,
Pin = pin
}
pin.MapTextureInfo = mapTextureInfo
WorldQuestTracker.ExtraMapTextures[texturePath] = mapTextureInfo
--debug
--print("WorldQuestTracker.AddExtraMapTexture", texturePath, x, y, width, height)
--print(texture, pin, mapTextureInfo)
--DetailsFramework:DebugVisibility(texture)
--DetailsFramework:DebugVisibility(pin)
end
end
function WorldQuestTracker:OnInit()
do
local languageCurrentVersion = 1
if (not WQTrackerLanguage) then
WQTrackerLanguage = {
language = GetLocale(),
version = languageCurrentVersion,
}
end
if (WQTrackerLanguage.version < languageCurrentVersion) then
--do stuff in the future
end
DF.Language.SetCurrentLanguage(addonId, WQTrackerLanguage.language)
end
for hubMapID, defaultScale in pairs(WorldQuestTracker.MapData.HubMapIconsScale) do
if (not WorldQuestTracker.db.profile.world_map_hubscale[hubMapID]) then
WorldQuestTracker.db.profile.world_map_hubscale[hubMapID] = defaultScale
end
if (WorldQuestTracker.db.profile.world_map_hubenabled[hubMapID] == nil) then
WorldQuestTracker.db.profile.world_map_hubenabled[hubMapID] = true
end
end
hooksecurefunc(_G, "StaticPopup_Show", function(token)
if (token == "ABANDON_QUEST") then
if (WorldQuestTracker.db.profile.close_blizz_popups.ABANDON_QUEST) then
---@diagnostic disable-next-line: undefined-global
StaticPopup1Button1:Click()
end
end
end)
WorldQuestTracker.InitAt = GetTime()
WorldQuestTracker.LastMapID = WorldQuestTracker.GetCurrentMapAreaID()
WorldQuestTracker.CreateLoadingIcon()
C_Timer.After (.5, WorldQuestTracker.InitializeWorldWidgets)
WQTrackerDBChr = WQTrackerDBChr or {}
WorldQuestTracker.dbChr = WQTrackerDBChr
WorldQuestTracker.dbChr.ActiveQuests = WorldQuestTracker.dbChr.ActiveQuests or {}
local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
SharedMedia:Register("statusbar", "Iskar Serenity", [[Interface\AddOns\WorldQuestTracker\media\bar_serenity]])
C_Timer.After (5, function()
WorldQuestTracker.InitiateFlyMasterTracker()
end)
if (WorldQuestTracker.db:GetCurrentProfile() ~= "Default") then
WorldQuestTracker.db:SetProfile("Default")
end
WorldQuestTracker.TrackerFrameOnInit()
WorldQuestTracker.GetTrackedQuestsOnDB()
C_Timer.After(2, function()
-- ~review disabling scale since it have some issues for some users
WorldQuestTracker.db.profile.map_frame_scale_enabled = false
--this options is deprecated, switching it to false for all users
WorldQuestTracker.db.profile.disable_world_map_widgets = false
end)
WorldQuestTracker.TomTomUIDs = {}
if (LibWindow) then
if (WorldQuestTracker.db:GetCurrentProfile() == "Default") then
if (not WorldQuestTrackerFinderFrame.IsRegistered) then
WorldQuestTracker.RegisterGroupFinderFrameOnLibWindow()
end
end
end
if (WorldQuestTracker.db.profile.raredetected and WorldQuestTracker.MapData.RaresToScan) then
for npcId, _ in pairs (WorldQuestTracker.db.profile.raredetected) do
WorldQuestTracker.MapData.RaresToScan [npcId] = true
end
end
function WorldQuestTracker:CleanUpJustBeforeGoodbye()
WorldQuestTracker.AllCharactersQuests_CleanUp()
end
WorldQuestTracker.db.RegisterCallback (WorldQuestTracker, "OnDatabaseShutdown", "CleanUpJustBeforeGoodbye") --more info at https://www.youtube.com/watch?v=GXFnT4YJLQo
local save_player_name = function()
local guid = UnitGUID ("player")
local name = UnitName ("player")
local realm = GetRealmName()
if (guid and name and name ~= "" and realm and realm ~= "") then
local playerTable = WorldQuestTracker.db.profile.player_names [guid]
if (not playerTable) then
playerTable = {}
WorldQuestTracker.db.profile.player_names [guid] = playerTable
end
playerTable.name = name
playerTable.realm = realm
playerTable.class = playerTable.class or select (2, UnitClass ("player"))
end
end
WorldQuestTracker.MapChangedTime = time()-1
C_Timer.After (3, save_player_name)
C_Timer.After (10, save_player_name)
local canLoad = C_QuestLog.IsQuestFlaggedCompleted(WORLD_QUESTS_AVAILABLE_QUEST_ID)
local re_ZONE_CHANGED_NEW_AREA = function()
WorldQuestTracker:ZONE_CHANGED_NEW_AREA()
end
function WorldQuestTracker.FinishedUpdate_Zone()
return true
end
function WorldQuestTracker.FinishedUpdate_World()
return true
end
function WorldQuestTracker.IsInvasionPoint()
if (ff:IsShown()) then
return
end
local mapInfo = WorldQuestTracker.GetMapInfo()
local mapFileName = mapInfo and mapInfo.name
--> we are using where the map file name which always start with "InvasionPoint"
--> this makes easy to localize group between different languages on the group finder
--> this won't work with greater invasions which aren't scenarios
if (mapFileName and mapFileName:find ("InvasionPoint")) then
--the player is inside a invasion
local invasionName = C_Scenario.GetInfo()
if (invasionName) then
--> is search for invasions enabled?
if (WorldQuestTracker.db.profile.groupfinder.invasion_points) then
--> can queue?
if (not IsInGroup() and not QueueStatusMinimapButton:IsShown()) then
local callback = nil
local ENNameFromMapFileName = mapFileName:gsub ("InvasionPoint", "")
if (ENNameFromMapFileName and WorldQuestTracker.db.profile.rarescan.always_use_english) then
WorldQuestTracker.FindGroupForCustom ("Invasion Point: " .. (ENNameFromMapFileName or ""), invasionName, L["S_GROUPFINDER_ACTIONS_SEARCH"], "Doing Invasion Point " .. invasionName .. ". Group created with World Quest Tracker #EN Invasion Point: " .. (ENNameFromMapFileName or "") .. " ", 0, callback)
else
WorldQuestTracker.FindGroupForCustom (invasionName, invasionName, L["S_GROUPFINDER_ACTIONS_SEARCH"], "Doing Invasion Point " .. invasionName .. ". Group created with World Quest Tracker #EN Invasion Point: " .. (ENNameFromMapFileName or "") .. " ", 0, callback)
end
else
WorldQuestTracker:Msg (L["S_GROUPFINDER_QUEUEBUSY2"])
end
end
end
end
end
function WorldQuestTracker:ZONE_CHANGED_NEW_AREA()
if (IsInInstance()) then
WorldQuestTracker:FullTrackerUpdate()
else
WorldQuestTracker:FullTrackerUpdate()
if (WorldMapFrame:IsShown()) then
return WorldQuestTracker:WaitUntilWorldMapIsClose()
else
C_Timer.After (.5, WorldQuestTracker.UpdateCurrentStandingZone)
end
end
if (WorldQuestTracker.DoesMapHasWorldQuests(WorldMapFrame.mapID)) then
WorldQuestTracker.PreloadWorldQuestsForMap(WorldMapFrame.mapID)
end
WorldQuestTracker.UpdateExtraMapTextures()
local mapInfo = WorldQuestTracker.GetMapInfo()
local mapFileName = mapInfo and mapInfo.name
if (not mapFileName) then
C_Timer.After (3, WorldQuestTracker.IsInvasionPoint)
else
WorldQuestTracker.IsInvasionPoint()
--> trigger once more since on some clientes MapInfo() is having a delay on update the correct map
C_Timer.After (1, WorldQuestTracker.IsInvasionPoint)
C_Timer.After (2, WorldQuestTracker.IsInvasionPoint)
end
end
-- ~reward ~questcompleted
local oneday = 60*60*24
local days_amount = {
[WQT_DATE_1WEEK] = 8,
[WQT_DATE_2WEEK] = 15,
[WQT_DATE_MONTH] = 30,
}
function WorldQuestTracker.GetDateString (t)
if (t == WQT_DATE_TODAY) then
return date ("%y%m%d")
elseif (t == WQT_DATE_YESTERDAY) then
return date ("%y%m%d", time() - oneday)
elseif (t == WQT_DATE_1WEEK or t == WQT_DATE_2WEEK or t == WQT_DATE_MONTH) then
local days = days_amount [t]
local result = {}
for i = 1, days do
tinsert (result, date ("%y%m%d", time() - (oneday * (i-1) )))
end
return result
else
return t
end
end
function WorldQuestTracker.GetCharInfo (guid)
local t = WorldQuestTracker.db.profile.player_names [guid]
if (t) then
return t.name, t.realm, t.class
else
return "Unknown", "Unknown", "PRIEST"
end
end
function WorldQuestTracker.QueryHistory (queryType, dbLevel, arg1, arg2, arg3)
local db = WorldQuestTracker.db.profile.history
db = db [queryType]
db = db [dbLevel]
if (dbLevel == WQT_QUERYDB_LOCAL) then
db = db [UnitGUID ("player")]
if (not db) then
return
end
end
if (not arg1) then
return db
end
if (queryType == WQT_QUERYTYPE_REWARD) then
return db [arg1] --arg1 = the reward type (gold, resource, artifact)
elseif (queryType == WQT_QUERYTYPE_QUEST) then
return db [arg1] --arg1 = the questID
elseif (queryType == WQT_QUERYTYPE_PERIOD) then
local dateString = WorldQuestTracker.GetDateString (arg1)
if (type (dateString) == "table") then --mais de 1 dia
--quer saber da some total ou quer dia a dia para fazer um gr�fico
local result = {}
local total = 0
local dayTable = dateString
for i = 1, #dayTable do --table com v�rias strings representando dias
local day = db [dayTable [i]]
if (day) then
if (arg2) then
total = total + (day [arg2] or 0)
else
tinsert (result, {["day"] = dayTable [i], ["table"] = day})
end
end
end
if (arg2) then
return total
else
return result
end
else --um unico dia
if (arg2) then --pediu apenas 1 reward
db = db [dateString] --tabela do dia
if (db) then
return db [arg2] --quantidade de recursos
end
return
end
return db [dateString] --arg1 = data0 / retorna a tabela do dia com todos os rewards
end
end
end
-- ~completed ~questdone
function WorldQuestTracker:QUEST_TURNED_IN(event, questID, XP, gold)
if (isWorldQuest(questID)) then
WorldQuestTracker.AllCharactersQuests_Remove(questID)
WorldQuestTracker.RemoveQuestFromTracker(questID)
--FlashClientIcon()
WorldQuestTracker.RemoveQuestFromCache(questID)
if (isWorldQuest(questID)) then --wait, is this inception?
local title, factionID, tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex, allowDisplayPastCritical, gold, goldFormated, rewardName, rewardTexture, numRewardItems, itemName, itemTexture, itemLevel, quantity, quality, isUsable, itemID, isArtifact, artifactPower, isStackable, stackAmount = WorldQuestTracker.GetOrLoadQuestData (questID)
local questHistory = WorldQuestTracker.db.profile.history
--check if the map is opened in the player screen
if (WorldMapFrame and WorldMapFrame:IsShown()) then
C_Timer.After(1, function()
--update quest on current map shown
if (WorldQuestTrackerAddon.GetCurrentZoneType() == "world") then
WorldQuestTracker.UpdateWorldQuestsOnWorldMap(true)
elseif (WorldQuestTrackerAddon.GetCurrentZoneType() == "zone") then
WorldQuestTracker.UpdateZoneWidgets()
end
end)
end
local guid = UnitGUID("player")
local today = date("%y%m%d") --YYMMDD
local itemName, itemTexture, itemLevel, quantity, quality, isUsable, itemID, isArtifact, artifactPower, isStackable = WorldQuestTracker.GetQuestReward_Item (questID)
--store reward amount
local rewardHistory = questHistory.reward
local _global = rewardHistory.global
local _local = rewardHistory.character[guid]
if (not _local) then
_local = {}
rewardHistory.character[guid] = _local
end
if (gold and gold > 0) then
_global["gold"] = _global["gold"] or 0
_local["gold"] = _local["gold"] or 0
_global["gold"] = _global["gold"] + gold
_local["gold"] = _local["gold"] + gold
--print ("Gold added:", _global["gold"], _local["gold"])
end
if (isArtifact) then
_global["artifact"] = _global["artifact"] or 0
_local["artifact"] = _local["artifact"] or 0
_global["artifact"] = _global["artifact"] + artifactPower
_local["artifact"] = _local["artifact"] + artifactPower
--print ("Artifact added:", _global["artifact"], _local["artifact"])
end
if (rewardName) then --class hall resource
_global["resource"] = _global["resource"] or 0
_local["resource"] = _local["resource"] or 0
_global["resource"] = _global["resource"] + numRewardItems
_local["resource"] = _local["resource"] + numRewardItems
--print ("Resource added:", _global["resource"], _local["resource"])
end
--trade skill - blood of sargeras
if (itemID == 124124) then
_global["blood"] = (_global["blood"] or 0) + quantity
_local["blood"] = (_local["blood"] or 0) + quantity
end
--professions
if (tradeskillLineIndex) then
local tradeskillLineID = tradeskillLineIndex and select (7, GetProfessionInfo(tradeskillLineIndex))
if (tradeskillLineID) then
if (itemID) then
--print ("eh profissao 3", itemID)
_global["profession"] = _global["profession"] or {}
_local["profession"] = _local["profession"] or {}
_global["profession"][itemID] = (_global["profession"][itemID] or 0) + 1
_local["profession"][itemID] = (_local["profession"][itemID] or 0) + 1
--print ("local global 3", _local["profession"][itemID], _global["profession"][itemID])
end
end
end
--quais quest ja foram completadas e quantas vezes
local questDoneHistory = questHistory.quest
local _global = questDoneHistory.global
local _local = questDoneHistory.character[guid]
if (not _local) then
_local = {}
questDoneHistory.character[guid] = _local
end
_global[questID] = (_global[questID] or 0) + 1
_local[questID] = (_local[questID] or 0) + 1
_global["total"] = (_global["total"] or 0) + 1
_local["total"] = (_local["total"] or 0) + 1
--estat�sticas dia a dia
local periodHistory = questHistory.period
local _global = periodHistory.global
local _local = periodHistory.character[guid]
if (not _local) then
_local = {}
periodHistory.character[guid] = _local
end
local _globalToday = _global[today]
local _localToday = _local[today]
if (not _globalToday) then
_globalToday = {}
_global[today] = _globalToday
end
if (not _localToday) then
_localToday = {}
_local[today] = _localToday
end
_globalToday["quest"] = (_globalToday["quest"] or 0) + 1
_localToday["quest"] = (_localToday["quest"] or 0) + 1
if (itemID == 124124) then
_globalToday["blood"] = (_globalToday["blood"] or 0) + quantity
_localToday["blood"] = (_localToday["blood"] or 0) + quantity
end
if (tradeskillLineIndex) then
--print ("eh profissao today 4", tradeskillLineIndex)
local tradeskillLineID = tradeskillLineIndex and select (7, GetProfessionInfo (tradeskillLineIndex))
if (tradeskillLineID) then
--print ("eh profissao today 5", tradeskillLineID)
if (itemID) then
--print ("eh profissao today 6", itemID)
_globalToday["profession"] = _globalToday["profession"] or {}
_localToday["profession"] = _localToday["profession"] or {}
_globalToday["profession"][itemID] = (_globalToday["profession"][itemID] or 0) + 1
_localToday["profession"][itemID] = (_localToday["profession"][itemID] or 0) + 1
--print ("local global today 6", _localToday["profession"][itemID], _globalToday["profession"][itemID])
end
end
end
if (gold and gold > 0) then
_globalToday["gold"] = _globalToday["gold"] or 0
_localToday["gold"] = _localToday["gold"] or 0
_globalToday["gold"] = _globalToday["gold"] + gold
_localToday["gold"] = _localToday["gold"] + gold
end
if (isArtifact) then
_globalToday["artifact"] = _globalToday["artifact"] or 0
_localToday["artifact"] = _localToday["artifact"] or 0
_globalToday["artifact"] = _globalToday["artifact"] + artifactPower
_localToday["artifact"] = _localToday["artifact"] + artifactPower
end
if (rewardName) then --class hall resource
_globalToday["resource"] = _globalToday["resource"] or 0
_localToday["resource"] = _localToday["resource"] or 0
_globalToday["resource"] = _globalToday["resource"] + numRewardItems
_localToday["resource"] = _localToday["resource"] + numRewardItems
end
end
end
end
function WorldQuestTracker:QUEST_LOOT_RECEIVED(event, questID, item, amount, ...)
if (isWorldQuest(questID)) then
-- local title, questType, texture, factionID, tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex, selected, isSpellTarget, timeLeft, isCriteria, gold, goldFormated, rewardName, rewardTexture, numRewardItems, itemName, itemTexture, itemLevel, quantity, quality, isUsable, itemID, isArtifact, artifactPower, isStackable = WorldQuestTracker:GetQuestFullInfo (questID)
-- print ("QINFO:", goldFormated, rewardName, numRewardItems, itemName, isArtifact, artifactPower)
end
end
WorldQuestTracker:RegisterEvent("TAXIMAP_OPENED")
WorldQuestTracker:RegisterEvent("TAXIMAP_CLOSED")
WorldQuestTracker:RegisterEvent("ZONE_CHANGED_NEW_AREA")
WorldQuestTracker:RegisterEvent("QUEST_TURNED_IN")
WorldQuestTracker:RegisterEvent("QUEST_LOOT_RECEIVED")
WorldQuestTracker:RegisterEvent("PLAYER_STARTED_MOVING")
WorldQuestTracker:RegisterEvent("PLAYER_STOPPED_MOVING")
C_Timer.After(.5, WorldQuestTracker.ZONE_CHANGED_NEW_AREA)
C_Timer.After(.5, WorldQuestTracker.UpdateArrowFrequence)
C_Timer.After(5, WorldQuestTracker.UpdateArrowFrequence)
C_Timer.After(10, WorldQuestTracker.UpdateArrowFrequence)
end
local onStartClickAnimation = function(self)
self:GetParent():Show()
end
local onEndClickAnimation = function(self)
self:GetParent():Hide()
end
--format the quest time left
local D_HOURS = "%dH"
local D_DAYS = "%dD"
function WorldQuestTracker.GetQuest_TimeLeft(questID, formated)
local timeLeftMinutes = GetQuestTimeLeftMinutes(questID)
if (timeLeftMinutes) then
if (formated) then
local timeString
if ( timeLeftMinutes <= WORLD_QUESTS_TIME_CRITICAL_MINUTES ) then
timeString = SecondsToTime (timeLeftMinutes * 60)
elseif timeLeftMinutes <= 60 + WORLD_QUESTS_TIME_CRITICAL_MINUTES then
timeString = SecondsToTime ((timeLeftMinutes - WORLD_QUESTS_TIME_CRITICAL_MINUTES) * 60)
elseif timeLeftMinutes < 24 * 60 + WORLD_QUESTS_TIME_CRITICAL_MINUTES then
timeString = D_HOURS:format(math.floor(timeLeftMinutes - WORLD_QUESTS_TIME_CRITICAL_MINUTES) / 60)
else
timeString = D_DAYS:format(math.floor(timeLeftMinutes - WORLD_QUESTS_TIME_CRITICAL_MINUTES) / 1440)
end
return timeString
else
return timeLeftMinutes
end
else
--since 20/12/2018 time left sometimes is returning nil
return 60
end
end
--pega os dados da quest
function WorldQuestTracker.GetQuest_Info(questID)
if (not HaveQuestData(questID)) then
if (WorldQuestTracker.__debug) then
WorldQuestTracker:Msg("no HaveQuestData(1) for quest", questID)
end
return
end
local title, factionID = GetQuestInfoByQuestID(questID)
local tagInfo = C_QuestLog.GetQuestTagInfo(questID)
if (not tagInfo) then
if (WorldQuestTracker.__debug) then
WorldQuestTracker:Msg("no tagInfo(3) for quest", questID)
end
return
end
local tagID = tagInfo.tagID
local tagName = tagInfo.tagName
local worldQuestType = tagInfo.worldQuestType
local rarity = tagInfo.quality
local isElite = tagInfo.isElite
return title, factionID, tagID, tagName, worldQuestType, rarity, isElite
end
--pega o icone para as quest que dao gold
local goldCoords = {0, 1, 0, 1}
function WorldQuestTracker.GetGoldIcon()
return [[Interface\AddOns\WorldQuestTracker\media\icon_gold]], goldCoords
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--saved quests on other characters
--pega a lista de quests que o jogador tem dispon�vel
function WorldQuestTracker.SavedQuestList_GetList()
if (type(WorldQuestTracker.dbChr) ~= "table") then
WorldQuestTracker:Msg("WorldQuestTracker.SavedQuestList_GetList failed: invalid dbChr, type: ", type(WorldQuestTracker.dbChr))
return
end
return WorldQuestTracker.dbChr.ActiveQuests
end
-- ~saved ~pool ~data ~allquests �ll
local map_seasons = {}
function WorldQuestTracker.SavedQuestList_IsNew (questID)
if (WorldQuestTracker.MapSeason == 0) then
--o mapa esta carregando e n�o mandou o primeiro evento ainda
return false
end
local ActiveQuests = WorldQuestTracker.SavedQuestList_GetList()
if (ActiveQuests [questID]) then --a quest esta armazenada
if (map_seasons [questID] == WorldQuestTracker.MapSeason) then
--a quest j� esta na lista por�m foi adicionada nesta season do mapa
return true
else
--apenas retornar que n�o � nova
return false
end
else --a quest n�o esta na lista
local timeLeft = WorldQuestTracker.GetQuest_TimeLeft (questID)
if (timeLeft and timeLeft > 0) then
--adicionar a quest a lista de quets
ActiveQuests [questID] = time() + (timeLeft*60)
map_seasons [questID] = WorldQuestTracker.MapSeason
--retornar que a quest � nova
return true
else
--o tempo da quest expirou.
return false
end
end
end
function WorldQuestTracker.SavedQuestList_CleanUp()
local ActiveQuests = WorldQuestTracker.SavedQuestList_GetList()
local now = time()
for questID, expireAt in pairs (ActiveQuests) do
if (expireAt < now) then
ActiveQuests [questID] = nil
end
end
end
------------
function WorldQuestTracker.AllCharactersQuests_Add (questID, timeLeft, iconTexture, iconText)
local guid = UnitGUID ("player")
local t = WorldQuestTracker.db.profile.quests_all_characters [guid]
if (not t) then
t = {}
WorldQuestTracker.db.profile.quests_all_characters [guid] = t
end
local questInfo = t [questID]
if (not questInfo) then
questInfo = {}
t [questID] = questInfo
end
questInfo.expireAt = time() + (timeLeft*60) --timeLeft = minutes left
questInfo.rewardTexture = iconTexture or ""
questInfo.rewardAmount = iconText or ""
end
function WorldQuestTracker.AllCharactersQuests_Remove (questID)
local guid = UnitGUID ("player")
local t = WorldQuestTracker.db.profile.quests_all_characters [guid]
if (t) then
t [questID] = nil
end
end
function WorldQuestTracker.AllCharactersQuests_CleanUp()
local guid = UnitGUID ("player")
local t = WorldQuestTracker.db.profile.quests_all_characters [guid]
if (t) then
local now = time()
for questID, questInfo in pairs (t) do
if (questInfo.expireAt < now) then
t [questID] = nil
end
end
end
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------
--> build up our standing frame
--point of interest frame ~poiframe ~frame ~start
--local worldFramePOIs = CreateFrame ("frame", "WorldQuestTrackerWorldMapPOI", WorldMapFrame.BorderFrame)
local worldFramePOIs = CreateFrame ("frame", "WorldQuestTrackerWorldMapPOI", WorldMapFrame.ScrollContainer, "BackdropTemplate")
worldFramePOIs:SetAllPoints()
worldFramePOIs:SetFrameLevel(6701)
local fadeInAnimation = worldFramePOIs:CreateAnimationGroup()
local step1 = fadeInAnimation:CreateAnimation ("Alpha")
step1:SetOrder (1)
step1:SetFromAlpha (0)
step1:SetToAlpha (1)
step1:SetDuration (0.3)
worldFramePOIs.fadeInAnimation = fadeInAnimation
fadeInAnimation:SetScript("OnFinished", function()
worldFramePOIs:SetAlpha(1)
end)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
--> tutorials
--WorldQuestTracker.db.profile.TutorialPopupID = nil
-- ~tutorial
local re_ShowTutorialAlert = function()
WorldQuestTracker ["ShowTutorialAlert"]()
end
local hook_AlertCloseButton = function(self)
re_ShowTutorialAlert()
end
local wait_ShowTutorialAlert = function()
WorldQuestTracker.TutorialAlertOnHold = nil
WorldQuestTracker.ShowTutorialAlert()
end
function WorldQuestTracker.ShowTutorialAlert()
if (true) then
--disabled tutorials for 9.0.1, due to "MicroButtonAlertTemplate" being nil, need to replace with the new animation
return
end
WorldQuestTracker.db.profile.TutorialPopupID = WorldQuestTracker.db.profile.TutorialPopupID or 1
--WorldQuestTracker.db.profile.TutorialPopupID = 3
if (WorldQuestTracker.db.profile.TutorialPopupID == 1) then
if (WorldQuestTracker.TutorialAlertOnHold) then
return
end
if (not WorldMapFrame:IsShown() or not C_QuestLog.IsQuestFlaggedCompleted (WORLD_QUESTS_AVAILABLE_QUEST_ID or 1) or InCombatLockdown()) then
C_Timer.After (10, wait_ShowTutorialAlert)
WorldQuestTracker.TutorialAlertOnHold = true
return
end
WorldMapFrame:SetMapID (WorldQuestTracker.MapData.ZoneIDs.KULTIRAS)
WorldQuestTracker.UpdateWorldQuestsOnWorldMap (true)
return
elseif (WorldQuestTracker.db.profile.TutorialPopupID == 2) then
--C_Timer.After (.5, tutorial_two)
return
elseif (WorldQuestTracker.db.profile.TutorialPopupID == 3) then
--C_Timer.After (.5, tutorial_three)
return
elseif (WorldQuestTracker.db.profile.TutorialPopupID == 4) then
--C_Timer.After (.5, tutorial_four)
return
end
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--loading icon
function WorldQuestTracker.UpdateLoadingIconAnchor()
local adjust_anchor = false
if (GetCVarBool ("questLogOpen")) then
if (not WorldMapFrame.isMaximized) then
adjust_anchor = true
end
end
if (adjust_anchor) then
WorldQuestTracker.LoadingAnimation:SetPoint("bottom", WorldMapScrollFrame, "top", 0, -75)
else
WorldQuestTracker.LoadingAnimation:SetPoint("bottom", WorldMapScrollFrame, "top", 0, -75)
end
end
function WorldQuestTracker.NeedUpdateLoadingIconAnchor()
if (WorldQuestTracker.LoadingAnimation.FadeIN:IsPlaying()) then
WorldQuestTracker.UpdateLoadingIconAnchor()
elseif (WorldQuestTracker.LoadingAnimation.FadeOUT:IsPlaying()) then
WorldQuestTracker.UpdateLoadingIconAnchor()
elseif (WorldQuestTracker.LoadingAnimation.Loop:IsPlaying()) then
WorldQuestTracker.UpdateLoadingIconAnchor()
end
end
hooksecurefunc ("QuestMapFrame_Open", function()
WorldQuestTracker.NeedUpdateLoadingIconAnchor()
end)
hooksecurefunc ("QuestMapFrame_Close", function()
WorldQuestTracker.NeedUpdateLoadingIconAnchor()
end)
function WorldQuestTracker.CreateLoadingIcon()
local f = CreateFrame ("frame", nil, WorldMapFrame, "BackdropTemplate")
f:SetSize(48, 48)
f:SetPoint("bottom", WorldMapScrollFrame, "top", 0, -75) --289/2 = 144
f:SetFrameLevel(3000)
local animGroup1 = f:CreateAnimationGroup()
local anim1 = animGroup1:CreateAnimation ("Alpha")
anim1:SetOrder (1)
anim1:SetFromAlpha (0)
anim1:SetToAlpha (0.834)
anim1:SetDuration (2)
f.FadeIN = animGroup1
local animGroup2 = f:CreateAnimationGroup()
local anim2 = animGroup2:CreateAnimation ("Alpha")
f.FadeOUT = animGroup2
anim2:SetOrder (2)
anim2:SetFromAlpha (0.834)
anim2:SetToAlpha (0)
anim2:SetDuration (4)
animGroup2:SetScript("OnFinished", function()
f:Hide()