changeset 100:fbd4ead2a19f v1.4.11

- More attempts to fix quest markers re-appearing when completed via the order hall spells. Hard to test due to cooldown.
author Nenue
date Thu, 18 May 2017 16:43:14 -0400
parents cffecc347e90
children b68af1e44bdc
files QuestPOI.lua WorldPlan.lua WorldQuests.lua
diffstat 3 files changed, 109 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/QuestPOI.lua	Mon May 15 00:15:44 2017 -0400
+++ b/QuestPOI.lua	Thu May 18 16:43:14 2017 -0400
@@ -33,7 +33,6 @@
 local GetItemIcon = GetItemIcon
 
 local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop
-local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or nop
 local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or nop
 local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or nop
 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or nop
@@ -41,8 +40,8 @@
 local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or nop
 local QuestPOI = WorldPlanPOIMixin
 
-local pinBaseIndex = 1320
-local overlayBaseIndex = 1380
+local pinBaseIndex = 1520
+local overlayBaseIndex = 1580
 local previousHighlight
 
 local FADE_TIMING_MULTIPLIER = 3
@@ -288,7 +287,7 @@
 end
 
 function QuestPOI:OnLoad()
-  --qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
+  --print('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
   self.debugTimer = 4
   self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
   self.count = self.Overlay.count
@@ -296,7 +295,11 @@
   self.Description = self.Overlay.Description
   self.updateRate = PIN_REQUEST_DELAY
   self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
-
+  self.checkFilters = true
+  self.checkCriteria = true
+  self.checkCursor = true
+  self.worldQuest = true
+  self.isNew = true
 
   self.IconBackdrop:SetVertexColor(0,0,0,1)
   self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4)
@@ -415,8 +418,21 @@
 end
 
 function QuestPOI:OnMouseDown(button)
+
   if button == 'RightButton' then
-    SetSuperTrackedQuestID(nil)
+
+    local timers = db.IgnoreTimers
+    if timers[self.questID] then
+      timers[self.questID] = nil
+    else
+      local tl = TQ_GetQuestTimeLeftMinutes(self.questID)
+      if tl and (tl ~= 0) then
+        timers[self.questID] = time() + (tl * 60)
+      else
+        timers[self.questID] = 0
+      end
+    end
+    self:Refresh()
   else
     TaskPOI_OnClick(self, button)
   end
@@ -565,7 +581,7 @@
       local id = self.tradeskillLineIndex and select(7, GetProfessionInfo(self.tradeskillLineIndex))
       if id then
         self.isKnownProfession = true
-        --qprint('profession' , self.title, id)
+        --print('profession' , self.title, id)
         tagAtlas = WORLD_QUEST_ICONS_BY_PROFESSION[id]
       end
     elseif worldQuestType == LE_QUEST_TAG_TYPE_DUNGEON then
@@ -828,10 +844,11 @@
 end
 
 -- Non-hieriarchical display states, checked separately from used/filtered states
-function QuestPOI:GetCriteriaState()
+function QuestPOI:OnCriteria()
+  self.checkCriteria = nil
   local isCriteria, isBounty, isSpellTarget
 
-
+  print('  ' ..self:GetID() .. ':|cFFFFFF00OnCriteria()' )
 
   for index, bounty in pairs(db.Bounties) do
     if (not IsQuestComplete(bounty.questID)) and IsQuestCriteriaForBounty(self.questID, bounty.questID) then
@@ -842,18 +859,20 @@
       --dprint('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty)
     end
   end
-  isSpellTarget = IsQuestIDValidSpellTarget(self.questID)
 
-  if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) or (self.isSpellTarget ~= isSpellTarget) then
+  if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) then
     --wqprint('|cFF00FF00criteria state changed')
     self.isBounty = isBounty
     self.isCriteria = isCriteria
     self.isSpellTarget = isSpellTarget
-    self.isStale = true
-    return true
   end
 end
 
+function QuestPOI:OnCursor()
+  self.checkCursor = nil
+  self.isSpellTarget = IsQuestIDValidSpellTarget(self.questID)
+end
+
 local cvar_check = {
   [REWARD_CASH] = 'worldQuestFilterGold',
   [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower',
@@ -863,11 +882,11 @@
 }
 
 
-function QuestPOI:CheckFilterRules ()
-  local print = qprint
+function QuestPOI:OnFilters ()
   local qType = self.worldQuestType
 
   self.canShow = false
+  self.checkFilters = nil
 
   if not TQ_IsActive(self.questID) then
     self.hideReason = 'Filter check ended because quest is inactive.'
@@ -900,7 +919,7 @@
     end
   end
 
-  print('  '..self.questID..':|cFFFFFF00CheckFilterRules()|r', filtered, self.title)
+  print('  '..self.questID..':|cFFFFFF00OnFilters()|r', filtered, self.title)
   if self.filtered ~= filtered then
     wqprint('|cFF00FF00filter changed')
     self.isStale = true
@@ -913,9 +932,24 @@
 function QuestPOI:Refresh (event)
   print('|cFF00FF88Refresh(|r'..self:GetID()..'|cFF00FF88)|r', event, self.title)
 
+  if not self:IsShown() then
+    print('queued for Refresh')
+    self.isStale = true
+    return nil
+  end
+
+  if self.checkCriteria then
+    self:OnCriteria()
+  end
+  if self.checkFilters then
+    self:OnFilters()
+  end
+  if self.checkCursor then
+    self:OnCursor()
+  end
 
   local style = DEFAULT_STYLE
-  if self.filtered then
+  if self.filtered or db.IgnoreTimers[self.questID] then
     print('choose minimized')
     style = MINIMIZED_STYLE
   elseif self.dataLoaded then
@@ -926,9 +960,6 @@
   end
 
   local currentWidth = style.iconWidth or DEFAULT_STYLE.iconWidth
-
-
-
   local borderWidth = style.borderWidth or DEFAULT_STYLE.borderWidth
   local highlightWidth = style.highlightWidth or DEFAULT_STYLE.highlightWidth
   local tagSize = style.TagSize or DEFAULT_STYLE.TagSize
@@ -1057,19 +1088,23 @@
   end
 
   if SpellCanTargetQuest() then
-    if IsQuestIDValidSpellTarget(self.questID) then
+    if self.isSpellTarget then
       icon:SetVertexColor(1,1,1)
+      self:EnableMouse(false)
     else
-      icon:SetVertexColor(1,0,0,1)
+      icon:SetVertexColor(0.5,0.5,0.5,1)
+      self:EnableMouse(true)
     end
-    self:EnableMouse(false)
   else
+    icon:SetVertexColor(1,1,1)
     self:EnableMouse(true)
   end
+
   self.isStale = nil
 
   -- signal filter info update
   WorldPlanSummary.isStale = true
+  return true
 end
 
 -- Called at static intervals and with Refresh
@@ -1080,6 +1115,7 @@
   local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder
 
   if self.isActive then
+
     local tl = self.alertLevel
     local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID)
     if timeLeft > 0 then
@@ -1144,6 +1180,10 @@
   self:UnregisterEvent('QUEST_TURNED_IN')
   self:UnregisterEvent('QUEST_LOG_UPDATE')
 
+  self.checkCursor = true
+  self.checkFilters = true
+  self.checkCriteria = true
+
   for i, pin in ipairs(db.UsedPins) do
     if pin == self then
       print('|cFFFF4400cleared from UsedPins|r')
--- a/WorldPlan.lua	Mon May 15 00:15:44 2017 -0400
+++ b/WorldPlan.lua	Thu May 18 16:43:14 2017 -0400
@@ -35,8 +35,9 @@
 db.Bounties = {}
 db.BountiesByQuestID = {}
 db.BountiesByFactionID = {}
+db.IgnoreTimers = {}
 
--- default color templates
+  -- default color templates
 db.DefaultType = {
   a = 1,
   r = 1, g = 1, b = 1,
@@ -96,6 +97,7 @@
   --RewardColorReagent = {},
   --RewardColorArtifactPower = {},
   --RewardColorCurrency = {},
+  IgnoreTimers = {},
 }
 
 
@@ -440,12 +442,17 @@
   -- debug info
   WorldPlanData.key = (WorldPlanData.key or 0) + 1
   WorldPlanData.Debug = WorldPlanData.Debug or {}
+  local guid = UnitGUID('player')
+  WorldPlanData.IgnoreTimers = WorldPlanData.IgnoreTimers or {}
+  WorldPlanData.IgnoreTimers[guid] = WorldPlanData.IgnoreTimers[guid] or {}
+
   for _, msg in ipairs(WorldPlanData.Debug) do
     tinsert(DEBUG_HISTORY, msg)
   end
   tinsert(DEBUG_HISTORY, '--SESSION BREAK--')
   wipe(WorldPlanData.Debug)
 
+  db.IgnoreTimers = WorldPlanData.IgnoreTimers
   db.Config = WorldPlanData
   for k,v in pairs(db.DefaultConfig) do
     --[===[@non-debug@
--- a/WorldQuests.lua	Mon May 15 00:15:44 2017 -0400
+++ b/WorldQuests.lua	Thu May 18 16:43:14 2017 -0400
@@ -68,8 +68,8 @@
 local numLoaded = 0
 local numOverlays = 1
 local scaleConstant = 1
-local pinBaseIndex = 1500
-local overlayBaseIndex = 1580
+local pinBaseIndex = 1550
+local overlayBaseIndex = 1600
 
 local artifactKnowldegeSpells = {
   [207856] = true,
@@ -205,19 +205,26 @@
 callbacks[BountyBoard] = {}
 callbacks[BountyBoard].SetSelectedBountyIndex = function(WorldQuests)
   WorldQuests:UpdateBounties('BOUNTY_SELECTED')
-  WorldQuests:Refresh('BOUNTY_SELECTED')
+  for questID, pin in pairs(db.QuestsByID) do
+    pin.checkCriteria = true
+    pin:Refresh()
+  end
 end
 
 callbacks[ActionButton] = {}
 callbacks[ActionButton].UpdateCastingState = function(WorldQuests)
-  WorldQuests:Refresh('CASTING_STATE_CHANGED')
+  for questID, pin in pairs(db.QuestsByID) do
+    pin.checkCursor = true
+    pin:Refresh()
+  end
 end
 
 callbacks.UseWorldMapActionButtonSpellOnQuest = function(questID)
   local pin = db.QuestsByID[questID]
   -- calling this implies that the pin is used in some way
   if pin then
-    pin:CheckFilterRules()
+    db.log(pin.title ..  ' completed by spell?', IsQuestComplete(pin.questID))
+    pin:OnFilters()
     pin.isStale = true
   end
 end
@@ -309,7 +316,7 @@
 function Module:UpdateNext()
   --print('|cFF00FF88UpdateNext()')
   local pin = tremove(db.UpdatedPins)
-  pin:CheckFilterRules()
+  pin:OnFilters()
 
   local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1]
   --print(pin.title, pin.dataLoaded  and not pin.filtered, scaleFactor)
@@ -437,6 +444,10 @@
         numLoaded = numLoaded + 1
       end
 
+      pin.checkCriteria = true
+      pin.checkFilters = true
+      pin:Refresh('WORLDMAP_REFRESH ' .. GetTime())
+
     else
       if pin:IsShown() then
         print('|cFFFF4400need to remove', pin.title)
@@ -540,23 +551,22 @@
   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('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.canShow then
-      pin.used = true
-      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
+        if db.QuestsByZone[mapID] then
+          db.QuestsByZone[mapID][questID] = pin
+        end
+      else
+        print('|cFFFF4400discarding|r', pin.title)
       end
-      if db.QuestsByZone[mapID] then
-        db.QuestsByZone[mapID][questID] = pin
-      end
-    else
-      print('|cFFFF4400discarding|r', pin.title)
     end
   end
 end
@@ -567,17 +577,21 @@
   if not (questID and QuestUtils_IsQuestWorldQuest(questID)) then
     return nil
   end
+  if IsQuestComplete(questID) then
+    return nil
+  end
+
 
   local pin = db.QuestsByID[questID]
   if not pin then
     local numFree = #db.FreePins
     if numFree >= 1 then
       pin = tremove(db.FreePins, numFree)
-      print('|cFF00FF00Re-using', pin:GetName())
+      print('|cFF00FF00Acquire()|r Re-using', pin:GetName())
     else
       totalPins = totalPins + 1
       local name = 'WorldPlanQuestMarker' .. numOverlays
-      print('|cFF00FF00Creating', name)
+      print('|cFF00FF00Acquire()|r Creating', name)
       pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin')
 
       pin:SetID(totalPins)
@@ -585,10 +599,9 @@
       --pin.iconBorder:SetVertexColor(0,0,0,1)
     end
     pin.questID = questID
-    pin.worldQuest = true
     pin.throttle = pin.updateRate
-    pin.isNew = true
     pin.currentWidth = nil
+
     db.QuestsByID[questID] = pin
     tinsert(db.UsedPins, pin)
   end
@@ -624,9 +637,8 @@
     end
   end
 
+  pin:OnFilters()
   pin.isActive = TQ_IsActive(questID)
-  pin:GetCriteriaState()
-  pin:CheckFilterRules()
   --rprint(pin:GetID(), pin.filtered, pin.used)
   return pin
 end