comparison WorldQuests.lua @ 69:31de7e9e7849

stop hiding pins when the timeleft returns 0; use C_TQ.IsActive
author Nenue
date Wed, 05 Apr 2017 11:36:06 -0400
parents 96183f981acb
children d6c0bed32c51
comparison
equal deleted inserted replaced
68:cce68795f955 69:31de7e9e7849
11 local TQ_GetQuestZoneID = C_TaskQuest.GetQuestZoneID 11 local TQ_GetQuestZoneID = C_TaskQuest.GetQuestZoneID
12 local TQ_IsActive = C_TaskQuest.IsActive 12 local TQ_IsActive = C_TaskQuest.IsActive
13 local pairs, ipairs, tinsert, tremove, wipe = pairs, ipairs, tinsert, tremove, table.wipe 13 local pairs, ipairs, tinsert, tremove, wipe = pairs, ipairs, tinsert, tremove, table.wipe
14 local GetTaskInfo, GetTasksTable, HaveQuestData = GetTaskInfo, GetTasksTable, HaveQuestData 14 local GetTaskInfo, GetTasksTable, HaveQuestData = GetTaskInfo, GetTasksTable, HaveQuestData
15 local GetTime = GetTime 15 local GetTime = GetTime
16 local SpellCanTargetQuest = SpellCanTargetQuest 16 local SpellCanTargetQuest, IsQuestIDValidSpellTarget = SpellCanTargetQuest, IsQuestIDValidSpellTarget
17 local tonumber, abs = tonumber, math.abs 17 local tonumber, abs = tonumber, math.abs
18 local GetQuestLogRewardInfo = GetQuestLogRewardInfo 18 local GetQuestLogRewardInfo = GetQuestLogRewardInfo
19 local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID 19 local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID
20 20
21 21
23 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end 23 local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end
24 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end 24 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
25 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end 25 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
26 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end 26 local mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end
27 27
28 local ToggleButton = {}
29 local callbacks = {}
28 local PinBaseIndex = 1200 30 local PinBaseIndex = 1200
29 local BROKEN_ISLES_ID, DALARAN_ID, AZSUNA_ID, VALSHARAH_ID, HIGHMOUNTAIN_ID, STORMHEIM_ID, SURAMAR_ID, EOA_ID = 1007, 1014, 1015,1018, 1024, 1017, 1033, 1096 31 local BROKEN_ISLES_ID, DALARAN_ID, AZSUNA_ID, VALSHARAH_ID, HIGHMOUNTAIN_ID, STORMHEIM_ID, SURAMAR_ID, EOA_ID = 1007, 1014, 1015,1018, 1024, 1017, 1033, 1096
30 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah", 32 local WORLD_QUEST_MAPS = { [DALARAN_ID] = 'Dalaran70', [AZSUNA_ID] = 'Azsuna', [VALSHARAH_ID] = "Val'sharah",
31 [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', } 33 [HIGHMOUNTAIN_ID] = 'Highmountain', [STORMHEIM_ID] = 'Stormheim', [SURAMAR_ID] = 'Suramar', [EOA_ID] = 'EyeOfAszhara', }
32 34
37 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS 39 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS
38 local SCALE_FACTORS = { 40 local SCALE_FACTORS = {
39 0.25, 0.7, 1 41 0.25, 0.7, 1
40 } 42 }
41 43
42 local ToggleButton = {} 44 local currentScale = WorldMapDetailFrame:GetScale()
45 local canTargetQuests
43 local numShown = 0 46 local numShown = 0
44 local numLoaded = 0 47 local numLoaded = 0
45 local isDataLoaded 48 local isDataLoaded = true
46 local numPins = 0 49 local numOverlays = 1
47 local NumPinFrames = 1
48 local scaleConstant = 1 50 local scaleConstant = 1
49 Module.TasksByID = {} 51 Module.TasksByID = {}
50 52
51 --%debug% 53 --%debug%
52 local SetTimedCallbackForAllPins = function(seconds, callback) 54 local SetTimedCallbackForAllPins = function(seconds, callback)
67 self:UpdateQueuedPins() 69 self:UpdateQueuedPins()
68 end 70 end
69 71
70 end 72 end
71 73
72 local currentScale = WorldMapDetailFrame:GetScale()
73 function Module:RefreshIfChanged()
74 local scaleCheck = WorldMapDetailFrame:GetScale()
75 if scaleCheck ~= currentScale then
76 print('|cFF00FF88scale changed from', currentScale, 'to', scaleCheck)
77 self:Refresh()
78 currentScale = scaleCheck
79 end
80 end
81 74
82 function Module:Setup() 75 function Module:Setup()
83 print('|cFFFF4400'..self:GetName()..':Setup()') 76 print('|cFFFF4400'..self:GetName()..':Setup()')
84
85 for mapID, mapName in pairs(WORLD_QUEST_MAPS) do 77 for mapID, mapName in pairs(WORLD_QUEST_MAPS) do
86 db.QuestsByZone[mapID] = {} 78 db.QuestsByZone[mapID] = {}
87 end 79 end
88 80 for target, arg in pairs(callbacks) do
89 hooksecurefunc("ClickWorldMapActionButton", function () self:OnClickWorldMapActionButton() end) 81 print(type(target))
90 hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", function() 82 if type(target) == 'table' then
91 print("WorldMapScrollFrame_ReanchorQuestPOIs") 83 local callerName = target:GetName()
92 self:RefreshIfChanged() 84 for name, method in pairs(arg) do
93 end) 85 print(callerName, arg)
94 hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () 86 hooksecurefunc(target, name, function(...)
95 self:OnUpdateQuestBonusObjectives() 87 self:OnSecureHook(callerName .. '.' .. arg, method, ...)
96 end) 88 end)
97 hooksecurefunc("WorldMapFrame_UpdateMap", function() 89 end
98 print("WorldMapFrame_UpdateMap") 90 else
99 self:RefreshIfChanged() 91 hooksecurefunc(target, function(...)
100 end) 92 self:OnSecureHook(target, arg, ...)
101 WorldMapFrame.UIElementsFrame.BountyBoard:SetSelectedBountyChangedCallback(function() 93 end)
102 self:OnSelectedBountyChanged() 94 end
103 end); 95 end
104 WorldMapFrame.UIElementsFrame.ActionButton:SetOnCastChangedCallback(function()
105 print("CastChangedCallback")
106 self:Refresh(true)
107 end);
108 96
109 self.Status = CreateFrame('Frame', nil, self) 97 self.Status = CreateFrame('Frame', nil, self)
110 self.Status:SetPoint('TOPLEFT', WorldMapPOIFrame, 'TOPLEFT', 0, 0) 98 self.Status:SetPoint('TOPLEFT', WorldMapPOIFrame, 'TOPLEFT', 0, 0)
111 self.Status:SetPoint('BOTTOMRIGHT', WorldMapPOIFrame, 'TOPRIGHT', 0, -4) 99 self.Status:SetPoint('BOTTOMRIGHT', WorldMapPOIFrame, 'TOPRIGHT', 0, -4)
112 self.Status.t = self.Status:CreateTexture(nil, 'OVERLAY') 100 self.Status.t = self.Status:CreateTexture(nil, 'OVERLAY')
125 status.t:SetWidth(translateTo) 113 status.t:SetWidth(translateTo)
126 else 114 else
127 translateTo = numShown * status:GetWidth() 115 translateTo = numShown * status:GetWidth()
128 status.t:SetWidth(translateTo) 116 status.t:SetWidth(translateTo)
129 end 117 end
130
131
132 end) 118 end)
133 119
134 self:SetAllPoints(WorldMapPOIFrame) 120 self:SetAllPoints(WorldMapPOIFrame)
135 for k,v in pairs( ToggleButton) do 121 for k,v in pairs( ToggleButton) do
136 self.Toggle:SetScript(k,v) 122 self.Toggle:SetScript(k,v)
137 end 123 end
138 self:Show() 124 self:Show()
139 end 125 end
126 callbacks.ClickWorldMapActionButton = function(WorldQuests)
127 WorldQuests:GetUsedPOIs()
128 end
129 callbacks.WorldMap_UpdateQuestBonusObjectives = function(WorldQuests)
130 WorldQuests:GetUsedPOIs()
131 end
132 callbacks.WorldMapFrame_UpdateMap = function(WorldQuests)
133 WorldQuests:RefreshIfChanged()
134 end
135 callbacks.WorldMapScrollFrame_ReanchorQuestPOIs = function (WorldQuests)
136 WorldQuests:RefreshIfChanged()
137 end
138 callbacks[WorldMapFrame.UIElementsFrame.BountyBoard] = {
139 SetSelectedBountyIndex = function(WorldQuests)
140 WorldQuests:UpdateBountyInfo()
141 end
142 }
143 callbacks[WorldMapFrame.UIElementsFrame.ActionButton] = {
144 UpdateCastingState = function(WorldQuests)
145 WorldQuests:Refresh(true)
146 end
147 }
148
140 149
141 local GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestFlaggedCompleted = GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestFlaggedCompleted 150 local GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestFlaggedCompleted = GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestFlaggedCompleted
142 function Module:UpdateBountyInfo() 151 function Module:UpdateBountyInfo()
143 wipe(db.BountyInfo) 152 wipe(db.BountyInfo)
144 db.selectedBounty = nil 153 db.selectedBounty = nil
179 end 188 end
180 end 189 end
181 db.BountyUpdate = nil 190 db.BountyUpdate = nil
182 end 191 end
183 192
184 function Module:OnSelectedBountyChanged()
185 self:UpdateBountyInfo()
186 end
187
188 function Module:OnConfigUpdate() 193 function Module:OnConfigUpdate()
189 print('|cFFFFFF00OnConfigUpdate()|r') 194 print('|cFFFFFF00OnConfigUpdate()|r')
190 if db.Config.FadeWhileGrouped then 195 if db.Config.FadeWhileGrouped then
191 db.PinAlpha = 0.15 196 db.PinAlpha = 0.15
192 else 197 else
215 if button.questID and db.QuestsByID[button.questID] then 220 if button.questID and db.QuestsByID[button.questID] then
216 db.QuestsByID[button.questID]:SetShown(false) 221 db.QuestsByID[button.questID]:SetShown(false)
217 end 222 end
218 end 223 end
219 224
220 function Module:UpdateBlizzButtons() 225 db.UsedPOIs = {}
221 226 function Module:GetUsedPOIs()
222 local func = SpellCanTargetQuest() and InternalShowButton or InternalHideButton 227 db.canTargetQuests = SpellCanTargetQuest()
228 local func = db.canTargetQuests and InternalShowButton or InternalHideButton
229 wipe(db.UsedPOIs)
223 for i = 1, NUM_WORLDMAP_TASK_POIS do 230 for i = 1, NUM_WORLDMAP_TASK_POIS do
224 local button = _G['WorldMapFrameTaskPOI'..i] 231 local button = _G['WorldMapFrameTaskPOI'..i]
225 if button and button.worldQuest then 232 if button and button.worldQuest then
226 func(button, i) 233 func(button, i)
227 end 234 db.UsedPOIs[button.questID] = button
228 end 235 end
229 end 236 end
230 237 end
231 function Module:OnUpdateQuestBonusObjectives() 238
232 rprint('|cFFFF4400WorldMap_UpdateQuestBonusObjectives') 239 function Module:OnSecureHook(callbackName, func, ...)
233 self:UpdateBlizzButtons() 240 rprint('|cFFFF4400'..callbackName..'|r', ...)
234 end 241 func(self, ...)
235
236 function Module:OnClickWorldMapActionButton()
237 rprint('|cFFFF4400ClickWorldMapActionButton')
238 self:UpdateBlizzButtons()
239 end 242 end
240 243
241 local defaults = {} 244 local defaults = {}
242 local REWARD_UNKNOWN = 768 245 local REWARD_UNKNOWN = 768
243 function Module:OnLoad() 246 function Module:OnLoad()
253 -- WORLD_MAP_UPDATE and PLAYER_ENTERING_WORLD are passed down from a higher level 256 -- WORLD_MAP_UPDATE and PLAYER_ENTERING_WORLD are passed down from a higher level
254 self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL') 257 self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL')
255 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED') 258 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
256 self:RegisterEvent('SKILL_LINES_CHANGED') 259 self:RegisterEvent('SKILL_LINES_CHANGED')
257 self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED') 260 self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED')
261 self:RegisterEvent('ARTIFACT_UPDATE')
258 end 262 end
259 263
260 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) 264 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen)
261 265
262 print('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap) 266 print('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap)
276 end 280 end
277 local superTrackedQuestID 281 local superTrackedQuestID
278 function Module:OnEvent (event, ...) 282 function Module:OnEvent (event, ...)
279 283
280 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...) 284 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...)
281 if (event == 'QUEST_LOG_UPDATE') or (event == 'SUPER_TRACKED_QUEST_CHANGED') then 285 if (event == 'QUEST_LOG_UPDATE') then
282 local questID, added = ... 286 if self:IsVisible() then
283 if questID and added then 287 self:Refresh()
284 local questPOI = self:AcquirePin(questID) 288 else
285 questPOI:GetQuestInfo()
286 questPOI.isStale = true
287 self.isStale = true 289 self.isStale = true
288 else
289 self:Refresh()
290 end 290 end
291 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale) 291 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale)
292 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then 292 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
293 local questID = ... 293 local questID = ...
294 if questID and db.QuestsByID[questID] then 294 if questID and db.QuestsByID[questID] then
301 local ak = C_ArtifactUI.GetArtifactKnowledgeMultiplier() 301 local ak = C_ArtifactUI.GetArtifactKnowledgeMultiplier()
302 if ak and (ak ~= self.akLevel) then 302 if ak and (ak ~= self.akLevel) then
303 print('push artifact knowledge update', self.akLevel, 'to', ak) 303 print('push artifact knowledge update', self.akLevel, 'to', ak)
304 self.akLevel = ak 304 self.akLevel = ak
305 for index, pin in pairs( db.QuestsByID) do 305 for index, pin in pairs( db.QuestsByID) do
306 pin.dataLoaded = nil 306 if pin.rewardType == REWARD_ARTIFACT_POWER then
307 end 307 pin.dataLoaded = nil
308 self:Refresh() 308 end
309 end
309 end 310 end
310 elseif event == 'SUPER_TRACKED_QUEST_CHANGED' then 311 elseif event == 'SUPER_TRACKED_QUEST_CHANGED' then
311 if superTrackedQuestID and db.QuestsByID[superTrackedQuestID] then 312 if superTrackedQuestID and db.QuestsByID[superTrackedQuestID] then
312 db.QuestsByID[superTrackedQuestID].isStale = true 313 db.QuestsByID[superTrackedQuestID].isStale = true
313 end 314 end
337 if numFree >= 1 then 338 if numFree >= 1 then
338 pin = tremove(db.FreePins, numFree) 339 pin = tremove(db.FreePins, numFree)
339 --print('|cFF00FF00Re-using', pin:GetName()) 340 --print('|cFF00FF00Re-using', pin:GetName())
340 else 341 else
341 totalPins = totalPins + 1 342 totalPins = totalPins + 1
342 local name = 'WorldPlanQuestMarker' .. NumPinFrames 343 local name = 'WorldPlanQuestMarker' .. numOverlays
343 --print('|cFF00FF00Creating', name) 344 --print('|cFF00FF00Creating', name)
344 pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin') 345 pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin')
345 346
346 pin:SetFrameStrata('HIGH') 347 pin:SetFrameStrata('HIGH')
347 pin.GetTypeInfo = function(frame, typeID) 348 pin.GetTypeInfo = function(frame, typeID)
348 return self:GetTypeInfo(typeID) 349 return self:GetTypeInfo(typeID)
349 end 350 end
350 pin:SetID(totalPins) 351 pin:SetID(totalPins)
351 NumPinFrames = NumPinFrames + 1 352 numOverlays = numOverlays + 1
352 --pin.iconBorder:SetVertexColor(0,0,0,1) 353 --pin.iconBorder:SetVertexColor(0,0,0,1)
353 end 354 end
354 pin.questID = questID 355 pin.questID = questID
355 pin.worldQuest = true 356 pin.worldQuest = true
356 pin.throttle = 1 357 pin.throttle = 1
379 380
380 381
381 pin.isActive = TQ_IsActive(questID) 382 pin.isActive = TQ_IsActive(questID)
382 pin:CheckFilterRules() 383 pin:CheckFilterRules()
383 rprint(pin:GetID(), pin.filtered, pin.used) 384 rprint(pin:GetID(), pin.filtered, pin.used)
384 pin:SetShown(pin.used)
385 385
386 return pin 386 return pin
387 end 387 end
388 388
389 -- remove from index and add it to the recycling heap 389 -- remove from index and add it to the recycling heap
518 pin:CheckFilterRules() 518 pin:CheckFilterRules()
519 519
520 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1] 520 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1]
521 print(pin.title, pin.dataLoaded and not pin.filtered, scaleFactor) 521 print(pin.title, pin.dataLoaded and not pin.filtered, scaleFactor)
522 pin:SetAnchor(nil, pin.x, pin.y, self.hostWidth, self.hostHeight, scaleFactor) 522 pin:SetAnchor(nil, pin.x, pin.y, self.hostWidth, self.hostHeight, scaleFactor)
523
524 if pin.isNew then
525 pin:OnShow()
526 end
527
528
523 pin = tremove(db.UpdatedPins) 529 pin = tremove(db.UpdatedPins)
530
524 end 531 end
525 end 532 end
526 533
527 -- create of update quest pins for a map and its underlying zones 534 -- create of update quest pins for a map and its underlying zones
528 function Module:UpdateWorldQuests (mapID) 535 function Module:UpdateWorldQuests (mapID)
605 print(' not visible, flag for later') 612 print(' not visible, flag for later')
606 self.isStale = true 613 self.isStale = true
607 return self:MarkAllPins() 614 return self:MarkAllPins()
608 end 615 end
609 if not db.Config.EnablePins then 616 if not db.Config.EnablePins then
617 numShown = 0
610 return 618 return
611 end 619 end
612 620
613 621
614 wprint(' |cFF00FF88'..self:GetName()..':Refresh()|r') 622 wprint(' |cFF00FF88'..self:GetName()..':Refresh()|r')
616 scaleConstant = db.isContinentMap and 2 or 3 624 scaleConstant = db.isContinentMap and 2 or 3
617 for index, pin in pairs(db.QuestsByID) do 625 for index, pin in pairs(db.QuestsByID) do
618 pin.used = nil 626 pin.used = nil
619 end 627 end
620 628
621 if SpellCanTargetQuest() then 629 canTargetQuests = SpellCanTargetQuest()
622 self:UpdateBlizzButtons() 630 self:UpdateAnchors()
623 else 631
624 self:UpdateAnchors(nil) 632 -- calculate quests shown
625 end
626
627 --local showQuestPOI = db.Config.EnablePins
628 numShown = 0 633 numShown = 0
629 numLoaded = 0 634 numLoaded = 0
630 for questID, pin in pairs(db.QuestsByID) do 635 for questID, pin in pairs(db.QuestsByID) do
631 local oV = pin:IsShown() 636 local oV = pin:IsShown()
632 if pin.used then 637 if pin.used then
642 647
643 else 648 else
644 if oV == true then 649 if oV == true then
645 rprint('|cFFFF4400 -|r', questID, pin.title) 650 rprint('|cFFFF4400 -|r', questID, pin.title)
646 end 651 end
652 pin.hideReason = "Not used in map area " .. (db.currentMapID)
647 pin:HideFrames() 653 pin:HideFrames()
648 end 654 end
649 end 655 end
650 656
651 print(numShown, 'shown', numLoaded, 'loaded') 657 print(numShown, 'shown', numLoaded, 'loaded')
655 661
656 662
657 self.isStale = nil 663 self.isStale = nil
658 self.sizesDirty = nil 664 self.sizesDirty = nil
659 self.isZoomDirty = nil 665 self.isZoomDirty = nil
666 end
667
668 function Module:RefreshIfChanged()
669 local scaleCheck = WorldMapDetailFrame:GetScale()
670 if scaleCheck ~= currentScale then
671 print('|cFF00FF88scale changed from', currentScale, 'to', scaleCheck)
672 self:Refresh()
673 currentScale = scaleCheck
674 elseif self.isStale then
675 print('|cFF00FF88isStale flag was set')
676 self:Refresh()
677 end
660 end 678 end
661 679
662 -- update visibility states of all pins 680 -- update visibility states of all pins
663 function Module:MarkAllPins(pins) 681 function Module:MarkAllPins(pins)
664 print(' |cFFFFFF00'..self:GetName()..':MarkAllPins()|r', pins) 682 print(' |cFFFFFF00'..self:GetName()..':MarkAllPins()|r', pins)
674 local pin = self:AcquirePin(info) 692 local pin = self:AcquirePin(info)
675 if not pin then 693 if not pin then
676 return 694 return
677 end 695 end
678 696
679
680 --print(' |- ', pin.questID, pin.title) 697 --print(' |- ', pin.questID, pin.title)
681 rprint('|cFF00FF00update|r', pin.questID, pin.title) 698 rprint('|cFF00FF00update|r', pin.questID, pin.title)
682
683 if x and y then 699 if x and y then
684 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1] 700 local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1]
685 pin:SetFrameLevel(PinBaseIndex+pin:GetID()) 701 pin:SetFrameLevel(PinBaseIndex+pin:GetID())
686 pin.owningFrame = WorldMapFrame 702 pin.owningFrame = WorldMapFrame
687 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor) 703 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor)
688 --tinsert(self.UsedPositions, pin) 704 --tinsert(self.UsedPositions, pin)
689 end 705 end
690 706
691
692 if self:IsVisible() and (pin.isStale) then 707 if self:IsVisible() and (pin.isStale) then
693 pin:Refresh() 708 pin:Refresh()
694 end 709 end
710
695 if mapID then 711 if mapID then
696 if not db.QuestsByZone[mapID] then 712 if not db.QuestsByZone[mapID] then
697 db.QuestsByZone[mapID] = {} 713 db.QuestsByZone[mapID] = {}
698 end 714 end
699 db.QuestsByZone[mapID][questID] = pin 715 db.QuestsByZone[mapID][questID] = pin
700 end 716 end
701 end 717 end
702 718
703 function Module:UpdateMap(taskInfo, mapID) 719 -- Updates quest markers in taskInfo while associating them with the given map
720 function Module:UpdateQuestsForMap(taskInfo, mapID)
704 rprint('Map', GetMapNameByID(mapID), GetMapNameByID(db.currentMapID)) 721 rprint('Map', GetMapNameByID(mapID), GetMapNameByID(db.currentMapID))
705 for index, info in pairs(taskInfo) do 722 for index, info in pairs(taskInfo) do
706 self:UpdateQuestButton(info, mapID) 723 self:UpdateQuestButton(info, mapID)
707 end 724 end
708 end 725 end
709 726
727 -- Used to refresh the visible quest markers
710 function Module:UpdateAnchors () 728 function Module:UpdateAnchors ()
711
712 wipe(self.UsedPositions) 729 wipe(self.UsedPositions)
713 print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()') 730 print(' |cFF00FF00'..self:GetName()..':UpdateAnchors()')
714 self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize() 731 self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize()
715 self.nudgeThrescholdX = 16/self.hostWidth 732 self.nudgeThrescholdX = 16/self.hostWidth
716 self.nudgeThrescholdY = 16/self.hostHeight 733 self.nudgeThrescholdY = 16/self.hostHeight
718 rprint('|cFF00FF00'..self:GetName()..':UpdateAnchors()') 735 rprint('|cFF00FF00'..self:GetName()..':UpdateAnchors()')
719 local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo() 736 local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo()
720 if isMicroDungeon then 737 if isMicroDungeon then
721 return 738 return
722 end 739 end
723 -- starts as true 740
724 isDataLoaded = true 741 isDataLoaded = true
725
726 numPins = 0
727 local taskInfo = TQ_GetQuestsForPlayerByMapID(db.currentMapID) 742 local taskInfo = TQ_GetQuestsForPlayerByMapID(db.currentMapID)
728 if taskInfo then 743 if taskInfo then
729 self:UpdateMap(taskInfo, db.currentMapID) 744 self:UpdateQuestsForMap(taskInfo, db.currentMapID)
730 end 745 end
731 local numZones = MC_GetNumZones(db.currentMapID) 746 local numZones = MC_GetNumZones(db.currentMapID)
732 if numZones then 747 if numZones then
733 for i = 1, numZones do 748 for i = 1, numZones do
734 local mapAreaID = MC_GetZoneInfo(db.currentMapID, i) 749 local mapAreaID = MC_GetZoneInfo(db.currentMapID, i)
735 local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, db.currentMapID) 750 local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, db.currentMapID)
736 if taskInfo then 751 if taskInfo then
737 self:UpdateMap(taskInfo, mapAreaID) 752 self:UpdateQuestsForMap(taskInfo, mapAreaID)
738 end 753 end
739 end 754 end
740 end 755 end
741 end 756 end
742 757