diff WorldQuests.lua @ 96:8591401ec278

- Fixed quest markers for other maps becoming visible due to ambiguous interpretations of pin.used. - Removed some redundant filter checking calls on pins obtained through Acquire()
author Nenue
date Sun, 14 May 2017 23:45:08 -0400
parents b29b35cb8539
children 5d90d09cb7b7
line wrap: on
line diff
--- a/WorldQuests.lua	Mon May 08 22:38:52 2017 -0400
+++ b/WorldQuests.lua	Sun May 14 23:45:08 2017 -0400
@@ -28,6 +28,7 @@
 local GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestComplete = GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestComplete
 local HaveQuestRewardData = HaveQuestRewardData
 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
+local InCombatLockdown, hooksecurefunc = InCombatLockdown, hooksecurefunc
 
 local ToggleButton = {}
 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
@@ -49,6 +50,7 @@
 local layoutDirty = true
 local bountiesDirty = true
 local artifactPowerDirty = true
+local hooksDirty = true
 local currentScale = WorldMapDetailFrame:GetScale()
 local canTargetQuests
 local isDataLoaded = true
@@ -211,11 +213,17 @@
   WorldQuests:Refresh('CASTING_STATE_CHANGED')
 end
 
-function Module:Setup()
-  --print('|cFFFF4400'..self:GetName()..':Setup()')
-  for mapID, mapName in pairs(WORLD_QUEST_MAPS) do
-    db.QuestsByZone[mapID] = {}
+callbacks.UseWorldMapActionButtonSpellOnQuest = function(questID)
+  if db.QuestsByID[questID] then
+    db.QuestsByID[questID].isStale = true
   end
+end
+
+function Module:SetupCallbacks()
+  if InCombatLockdown() then
+    return nil
+  end
+  print('SetupCallbacks()')
   for target, arg in pairs(callbacks) do
     --print(type(target))
     if type(target) == 'table' then
@@ -234,6 +242,16 @@
   end
 
 
+end
+
+function Module:Setup()
+  --print('|cFFFF4400'..self:GetName()..':Setup()')
+  for mapID, mapName in pairs(WORLD_QUEST_MAPS) do
+    db.QuestsByZone[mapID] = {}
+  end
+
+  hooksDirty = self:SetupCallbacks()
+
   self:SetAllPoints(WorldMapFrame.UIElementsFrame)
   self:UpdateArtifactPower()
   self:UpdateBounties('SETUP')
@@ -290,18 +308,17 @@
 function Module:UpdateNext()
   --print('|cFF00FF88UpdateNext()')
   local pin = tremove(db.UpdatedPins)
+  pin:CheckFilterRules()
 
-  -- criteria state is asserted independently
-  pin:CheckFilterRules()
   local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1]
   --print(pin.title, pin.dataLoaded  and not pin.filtered, scaleFactor)
   if pin.used then
+    pin:SetShown(true)
     pin:SetAnchor(nil, pin.x, pin.y, self.hostWidth, self.hostHeight, scaleFactor)
-    if pin:IsVisible() then
-      pin:Refresh()
-    else
-      pin.isStale = true
-    end
+    pin:Refresh()
+  else
+    print('|cFFFF4400flagging queued pin that got hidden:', pin.title)
+    pin.isStale = true
   end
 end
 
@@ -368,17 +385,20 @@
 
 local msg = '|cFF00FF88WorldQuests:Refresh()|r|cFF00FFFF'
 function Module:Refresh(...)
+
+  if hooksDirty then
+    hooksDirty = self:SetupCallbacks()
+  end
+
+
   if not self:IsVisible() then
     print('|cFFFF4400Refresh()|r', ...)
-    --layoutDirty = true
     return
   else
-    --
     if lastRefresh == GetTime() then
       print('|cFFFF4400multiple refreshes tried')
     end
     lastRefresh = GetTime()
-    --rprint(msg, ...)
     print(msg, lastRefresh, ...)
   end
 
@@ -389,7 +409,6 @@
     print('starting bench', self.refreshBenchMark)
     return
   end
-  --wprint('  '..msg)
 
   scaleConstant = db.isContinentMap and 2 or 3
   canTargetQuests = SpellCanTargetQuest()
@@ -399,12 +418,6 @@
   end
 
   self:UpdateAnchors(...)
---[[
-  if bountiesDirty then
-    --print('  bounties dirty, pushing that')
-    self:UpdateBounties()
-  end
-  --]]
 
   if artifactPowerDirty and not InCombatLockdown() then
     self:UpdateArtifactPower()
@@ -415,12 +428,8 @@
   for questID, pin in pairs(db.QuestsByID) do
     local oV = pin:IsShown()
     if pin.used then
+      print('show', pin.title)
       pin.throttle = 1
-      --[[
-      if oV == false then
-        --rprint('|cFF00FF00cleanup +|r', questID, pin.title)
-      end
-      --]]
       pin:SetShown(true)
       numShown = numShown + 1
       if pin.dataLoaded then
@@ -428,18 +437,16 @@
       end
 
     else
-      --[[
-      if oV == true then
-        rprint('|cFFFF4400 -|r', questID, pin.title)
+      if pin:IsShown() then
+        print('|cFFFF4400need to remove', pin.title)
+
       end
-      --]]
+
       pin.hideReason = "Not used in map area " .. (db.currentMapID)
       pin:SetShown(false)
     end
 
   end
-  --print('flags ', layoutDirty, self.isStale)
-  --print(' ', numShown, 'shown,', numLoaded, 'with data')
 
 
 --
@@ -483,16 +490,6 @@
   end
 end
 
--- marks a pin set for passive update
-function Module:MarkAllPins(pins)
-  --print('  |cFFFFFF00'..self:GetName()..':MarkAllPins()|r', pins)
-  pins = pins or db.QuestsByID
-  for questID, pin in pairs(pins) do
-    pin.isStale =  true
-    --rprint('|cFF00FF00filter', pin.questID, pin.filtered, 'used:', pin.used)
-  end
-end
-
 -- Walks the current map tree and fires updates as needed
 function Module:UpdateAnchors (event)
   wipe(self.UsedPositions)
@@ -529,7 +526,7 @@
   end
 end
 
--- Applies map association to the pins corresponding with each TaskInfo item
+-- Attempt to display the pins for quests in taskInfo
 function Module:UpdateQuestsForMap(taskInfo, mapID)
   print('|cFF00FF00UpdateQuestsForMap()|r', GetMapNameByID(mapID), GetMapNameByID(db.currentMapID), layoutDirty)
   if db.QuestsByZone[mapID] then
@@ -537,30 +534,28 @@
   elseif db.isBrokenIsle then
     continentScanned = true
   end
+  print('layoutDirty =',layoutDirty)
 
   for index, info in pairs(taskInfo) do
     local questID, x, y = info.questId, info.x, info.y
     local pin = self:AcquirePin(info)
 
-    if pin then
+    if pin.canShow then
       pin.used = true
-      print(pin.title, pin.isStale, layoutDirty, (pin.owningFrame ~= WorldMapFrame))
-      if pin:IsShown() and (layoutDirty or pin.isStale or (pin.owningFrame ~= WorldMapFrame)) then
+      print('using', pin.title, (pin.owningFrame ~= WorldMapFrame))
+      if layoutDirty or (pin.owningFrame ~= WorldMapFrame) then
         local scaleFactor = SCALE_FACTORS[(not pin.filtered and scaleConstant) or 1]
         pin.owningFrame = WorldMapFrame
         pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor)
         if pin.isStale then
           pin:Refresh('WORLDMAP_REFRESH ' .. GetTime())
         end
-      else
-        if layoutDirty then
-          pin.isStale = true
-        end
       end
-
-      if db.QuestsByZone[mapID] and pin.used then
+      if db.QuestsByZone[mapID] then
         db.QuestsByZone[mapID][questID] = pin
       end
+    else
+      print('|cFFFF4400not using|r', pin.title)
     end
   end
 end