changeset 73:25f7dbc20a72

fix WorldMapTooltip getting stranded when flightmap is closed - quests that are not valid spell targets will have their icon go red - auto-complete scrolls will no longer hide pin frames; instead they become click through and blizzard POIs are activated beneath for taint-free interaction
author Nenue
date Fri, 07 Apr 2017 07:20:28 -0400
parents 6db0b9696936
children 2ba11b25aa7f
files FlightMap.lua QuestPOI.lua WorldQuests.lua
diffstat 3 files changed, 72 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/FlightMap.lua	Fri Apr 07 01:07:48 2017 -0400
+++ b/FlightMap.lua	Fri Apr 07 07:20:28 2017 -0400
@@ -163,11 +163,12 @@
 end
 
 function WorldPlanDataPinMixin:OnMouseEnter ()
-
   WorldMap_HijackTooltip(self:GetMap())
 end
 
 function WorldPlanDataPinMixin:OnMouseLeave ()
+  WorldMap_RestoreTooltip()
+  WorldMapTooltip:Hide()
 end
 
 function WorldPlanDataPinMixin:RemoveAllData()
--- a/QuestPOI.lua	Fri Apr 07 01:07:48 2017 -0400
+++ b/QuestPOI.lua	Fri Apr 07 07:20:28 2017 -0400
@@ -40,8 +40,8 @@
 local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or nop
 local QuestPOI = WorldPlanPOIMixin
 
-local pinBaseIndex = 1300
-local overlayBaseIndex = 1350
+local pinBaseIndex = 1500
+local overlayBaseIndex = 1580
 local previousHighlight
 
 local DATA_DEBUG = false
@@ -912,6 +912,18 @@
   self:UpdateStatus()
   self.isStale = nil
 
+
+  if SpellCanTargetQuest() then
+    if IsQuestIDValidSpellTarget(self.questID) then
+      icon:SetVertexColor(1,1,1)
+    else
+      icon:SetVertexColor(1,0,0,1)
+    end
+    self:EnableMouse(false)
+  else
+    self:EnableMouse(true)
+  end
+
   -- signal filter info update
   WorldPlanSummary.isStale = true
 end
@@ -931,16 +943,6 @@
   local filtered
   local canShow = TQ_IsActive(self.questID)
 
-  if db.canTargetQuests then
-    self:EnableMouse(false)
-    if not IsQuestIDValidSpellTarget(self.questID) then
-      self.hideReason = "Not a valid spell target."
-      self:SetShown(false)
-      return
-    end
-  else
-    self:EnableMouse(true)
-  end
 
   if qType == LE_QUEST_TAG_TYPE_PROFESSION then
     if not(self.isKnownProfession or db.Config.ShowAllProfessionQuests) then
--- a/WorldQuests.lua	Fri Apr 07 01:07:48 2017 -0400
+++ b/WorldQuests.lua	Fri Apr 07 07:20:28 2017 -0400
@@ -132,10 +132,10 @@
   self:Show()
 end
 callbacks.ClickWorldMapActionButton = function(WorldQuests)
-  WorldQuests:GetUsedPOIs()
+  WorldQuests:Refresh('CLICK_MAP_ACTION_BUTTON')
 end
 callbacks.WorldMap_UpdateQuestBonusObjectives = function(WorldQuests)
-  WorldQuests:GetUsedPOIs()
+  WorldQuests:UpdateTaskPOIs()
 end
 callbacks.WorldMapFrame_UpdateMap = function(WorldQuests)
   WorldQuests:RefreshIfChanged()
@@ -147,12 +147,12 @@
 callbacks[BountyBoard] = {}
 callbacks[BountyBoard].SetSelectedBountyIndex = function(WorldQuests)
   WorldQuests:UpdateBounties('BOUNTY_SELECTED')
-  WorldQuests:RefreshIfChanged()
+  WorldQuests:Refresh('BOUNTY_SELECTED')
 end
 
 callbacks[ActionButton] = {}
 callbacks[ActionButton].UpdateCastingState = function(WorldQuests)
-  WorldQuests:Refresh(true)
+  WorldQuests:Refresh('CASTING_STATE_CHANGED')
 end
 
 function Module:OnConfigUpdate()
@@ -174,29 +174,19 @@
 
 local InternalHideButton = function(button, index)
   button:Hide()
-  if button.questID and db.QuestsByID[button.questID] then
-    if db.QuestsByID[button.questID].used and not db.QuestsByID[button.questID].filtered then
-      db.QuestsByID[button.questID]:SetShown(true)
-    end
-  end
 end
 local InternalShowButton = function(button, index)
   button:Show()
-  if button.questID and db.QuestsByID[button.questID] then
-    db.QuestsByID[button.questID]:SetShown(false)
-  end
 end
 
 db.UsedPOIs = {}
-function Module:GetUsedPOIs()
-  db.canTargetQuests = SpellCanTargetQuest()
-  local func = db.canTargetQuests and InternalShowButton or InternalHideButton
-  wipe(db.UsedPOIs)
+function Module:UpdateTaskPOIs()
+  canTargetQuests = SpellCanTargetQuest()
+  local func = canTargetQuests and 'Show' or 'Hide'
   for i = 1, NUM_WORLDMAP_TASK_POIS do
     local button = _G['WorldMapFrameTaskPOI'..i]
     if button and button.worldQuest then
-      func(button, i)
-      db.UsedPOIs[button.questID] = button
+      button[func](button)
     end
   end
 end
@@ -224,6 +214,7 @@
   self:RegisterEvent('SKILL_LINES_CHANGED')
   self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED')
   self:RegisterEvent('ARTIFACT_UPDATE')
+  self:RegisterEvent('QUEST_LOG_UPDATE')
 end
 
 local artifactKnowledgeMultiplier
@@ -232,19 +223,16 @@
 
   print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...)
   if (event == 'QUEST_LOG_UPDATE') then
-    if self:IsVisible() then
-      self:Refresh()
-    else
-      self.isStale = true
-    end
-
-    print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale)
+    self:UpdateBounties(event)
+    self:RefreshIfChanged(event)
   elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
     local questID = ...
+    self:UpdateBounties(event)
     if questID and db.QuestsByID[questID] then
       self:ReleasePin(db.QuestsByID[questID])
       rprint('|cFFFF4400release|r', questID)
     end
+    self:Refresh(event)
   elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then
     self:Refresh(event)
   elseif event == 'ARTIFACT_UPDATE' then
@@ -278,44 +266,40 @@
 
 
 
-
+local bountyQuests = {}
 local bountyInfo = {}
 local bountyDisplayLocation, bountyLockedQuestID, selectedBountyIndex, selectedBountyQuestID
 function Module:UpdateBounties(...)
   print('|cFF00FF88BountyInfo()|r', ...)
   wipe(db.BountiesByFactionID)
+  wipe(bountyQuests)
 
-  bountiesDirty = nil
   db.selectedBounty = nil
   selectedBountyIndex = BountyBoard:GetSelectedBountyIndex()
   bountyInfo, bountyDisplayLocation, bountyLockedQuestID = GetQuestBountyInfoForMapID(db.currentMapID, bountyInfo)
   local numBounties = 0
-  for index, data in ipairs(bountyInfo) do
-    if data.factionID then
+  for index, info in ipairs(bountyInfo) do
+    if info.factionID then
       numBounties = numBounties + 1
-      data.index = index
-      data.complete =  IsQuestComplete(data.questID)
-      if not data.complete then
-        db.BountiesByFactionID[data.factionID] = data
+      info.index = index
+      info.complete =  IsQuestComplete(info.questID)
+      if not info.complete then
+        db.BountiesByFactionID[info.factionID] = info
         if index == selectedBountyIndex then
-          db.selectedBounty = data
-          selectedBountyQuestID = data.questID
+          db.selectedBounty = info
+          selectedBountyQuestID = info.questID
         end
-        print(' ', index, data.factionID, GetQuestLogTitle(GetQuestLogIndexByID(data.questID)), data.complete, (index == selectedBountyIndex) and 'SELECTED' or '')
+        print(' ', index, info.factionID, GetQuestLogTitle(GetQuestLogIndexByID(info.questID)), info.complete, (index == selectedBountyIndex) and 'SELECTED' or '')
+        bountyQuests[info.questID] = info
       end
     end
   end
-
-  local numUpdated = 0
-  local numHidden = 0
-  for questID, pin in pairs(db.QuestsByID) do
-  end
-  --print(numUpdated, 'changes from Bounty Board ('..tostring(numHidden)..' hidden)')
+  bountiesDirty = nil
 end
 
 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen)
   if isNewMap then
-    print('|cFF00FF88'..self:GetName()..':OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap)
+    print('|cFF00FF88OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap)
     if isMapOpen then
       self:Refresh(true)
     else
@@ -443,19 +427,21 @@
 function Module:Refresh(...)
 
   rprint(msg, ...)
-  print('|cFF00FF88WorldQuests:Refresh()|r', ...)
   if not self:IsVisible() then
-    print('  not visible, flag for later')
+    rprint('|cFF00FF88WorldQuests:Refresh()|r', ...)
     self.isStale = true
     return self:MarkAllPins()
+  else
+    rprint('|cFF00FF88WorldQuests:Refresh()|r', ...)
+    print('|cFF00FF88WorldQuests:Refresh()|r', ...)
   end
+
   if not db.Config.EnablePins then
     numShown = 0
     return
   end
   wprint('  '..msg)
 
-  layoutDirty = nil
   scaleConstant = db.isContinentMap and 2 or 3
   canTargetQuests = SpellCanTargetQuest()
 
@@ -467,7 +453,6 @@
   if bountiesDirty then
     print('  bounties dirty, pushing that')
     self:UpdateBounties()
-    bountiesDirty = nil
   end
 
 
@@ -498,26 +483,40 @@
 
 
 
-  print(numShown, 'shown,', numLoaded, 'with data')
+  print(' ', numShown, 'shown,', numLoaded, 'with data')
   if numShown > numLoaded then
     self.Status:Show()
   end
 
 
+  layoutDirty = nil
   self.isStale = nil
   self.sizesDirty = nil
   self.isZoomDirty = nil
 end
 
+local refreshReason
 function Module:RefreshIfChanged()
   local scaleCheck = WorldMapDetailFrame:GetScale()
+  refreshReason = nil
   if scaleCheck ~= currentScale then
-    print('|cFF00FF88RefreshIfChanged()|r map scale updated')
+    refreshReason = 'map scale updated'
     self:Refresh('WORLD_MAP_SCALE_CHANGED')
     currentScale = scaleCheck
   elseif self.isStale or layoutDirty then
-    print('|cFF00FF88RefreshIfChanged()|r layout is dirty')
+    refreshReason = 'layout is marked dirty'
+  end
+  if not refreshReason then
+    return
+  end
+
+
+  if self:IsVisible() then
+    print('|cFF00FFFFRefreshIfChanged()|r', refreshReason)
     self:Refresh()
+  else
+    rprint('|cFF00FFFFRefreshIfChanged()|r flagging for later refresh', refreshReason)
+    self.isStale = true
   end
 end
 
@@ -548,7 +547,6 @@
     --tinsert(self.UsedPositions, pin)
   end
 
-
   local isCriteria, isBounty
   if pin.factionID then
     if db.BountiesByFactionID[pin.factionID] then
@@ -559,9 +557,13 @@
     end
   end
 
-  if (pin.isBounty ~= isBounty) or (pin.isCriteria ~= isCriteria) then
-    print(pin.isBounty, '~=', isBounty)
-    print(pin.isCriteria, '~=', isCriteria)
+  local isSpellTarget
+  if canTargetQuests then
+    isSpellTarget = IsQuestIDValidSpellTarget(pin.questID)
+  end
+
+  if (pin.isBounty ~= isBounty) or (pin.isCriteria ~= isCriteria) or (pin.isSpellTarget ~= isSpellTarget) then
+    pin.isSpellTarget = isSpellTarget
     pin.isBounty = isBounty
     pin.isCriteria = isCriteria
     if pin:IsVisible() then
@@ -572,7 +574,6 @@
       --numHidden = numHidden + 1
       pin.isStale = true
     end
-    layoutDirty = true
   end
 
   if self:IsVisible() and (pin.isStale) then