diff QuestPOI.lua @ 67:96183f981acb

Update for Legion Patch 7.2 - Pins for quests detected from the flight map should properly update as needed. - Fixed dropdown menu configurations not getting applied. - Added a toggle button to the world map display that performs the same function as the 'Enable' option in the dropdown menu. - Rewrote the majority of display update handlers for a significant performance improvements while interacting with the world map. - AP token info should now reflect artifact knowledge changes.
author Nenue
date Sat, 01 Apr 2017 08:17:30 -0400
parents e43e10c5576b
children 31de7e9e7849
line wrap: on
line diff
--- a/QuestPOI.lua	Thu Mar 30 02:32:44 2017 -0400
+++ b/QuestPOI.lua	Sat Apr 01 08:17:30 2017 -0400
@@ -31,19 +31,20 @@
 local GameTooltip = GameTooltip
 local GetItemIcon = GetItemIcon
 
-local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
-local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
-local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
-local wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end
-local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
-local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end
-local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or function() end
+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
+local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or nop
+local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or nop
 local QuestPOI = WorldPlanPOIMixin
 
 local pinBaseIndex = 1300
 local overlayBaseIndex = 1350
 local previousHighlight
 
+local DATA_DEBUG = false
 local PIN_REFRESH_DELAY = .5
 local PIN_REQUEST_DELAY = .1
 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark"
@@ -90,6 +91,7 @@
 local MINIMIZED_STYLE = {
   hideNumber = true,
   hideIcon = true,
+  iconWidth = 3,
 }
 local REWARD_TYPE_STYLES = {
   [REWARD_CASH] = {
@@ -376,7 +378,6 @@
     end
   end
 
-  self.isCriteria = WorldMapFrame.UIElementsFrame.BountyBoard:IsWorldQuestCriteriaForSelectedBounty(questID)
 
   return self.dataLoaded
 end
@@ -511,7 +512,12 @@
       qprint('  ', tostring(self.title), " |T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
 
       if (self.itemNumber ~= rewardCount) or (self.rewardType ~= rewardType) or (self.itemName ~= rewardName) or (self.itemTexture ~= rewardIcon) then
+        if DATA_DEBUG and (self.debugTimer <= 0) then
+          return false
+        end
+
         return true, rewardType, rewardName, rewardIcon, rewardCount, quality
+
       else
         return false
       end
@@ -565,8 +571,8 @@
     self:Refresh()
   end
 
-  if self.isNew or (not self.Overlay:IsShown()) then
-    --qprint('|cFFFFFF00popping new pin handler')
+  if self.isNew then
+    qprint('|cFFFFFF00popping new pin handler')
     self:StartFade()
   end
 
@@ -585,42 +591,52 @@
   self.isAnimating = nil
 end
 
--- Places the pin and triggers display
+-- Applies position and sizing parameters to the pin data
 function QuestPOI:SetAnchor(owner, dX, dY, mapWidth, mapHeight, scaleFactor)
-  wqprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used)
+  dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used)
   if not self.used then
     self:HideFrames()
     return
   end
 
-  self:SetScale(scaleFactor)
-  self:SetParent(owner)
+  if owner then
+    local prevOwner = self:GetParent()
+    if prevOwner ~= owner then
+      self.isStale = true
+    end
+    self:SetParent(owner)
+    self.Overlay:SetParent(owner)
+  else
+    owner = self:GetParent()
+  end
+
   self:ClearAllPoints()
   self:SetFrameLevel(pinBaseIndex + self:GetID())
-  self.Overlay:SetParent(owner)
-  self.Overlay:SetScale(scaleFactor)
   self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID())
+
+  local scaleChanged
+  if scaleFactor and (self.scaleFactor ~= scaleFactor) then
+    print('scaleFactor')
+    self:SetScale(scaleFactor)
+    self.Overlay:SetScale(scaleFactor)
+    self.scaleFactor = scaleFactor
+    scaleChanged = true
+  end
+
   if (dX and dY) then
     if not (mapHeight and mapWidth) then
       mapWidth, mapHeight = owner:GetSize()
-      end
-    if (self.x ~= dY) or (self.y ~= dY) or (self.scaleFactor ~= scaleFactor) then
+    end
+
+    if (self.x ~= dY) or (self.y ~= dY) or scaleChanged then
       self.x = dX
       self.y = dY
-      self.scaleFactor = scaleFactor
       local pX = (dX * mapWidth) * (1 / scaleFactor)
       local pY = (-dY * mapHeight) * (1 / scaleFactor)
       self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY)
     end
-  else
-    if self.x or self.y then
-      self.x = nil
-      self.y = nil
-      self:SetPoint('CENTER')
-    end
   end
 
-  self:ShowFrames()
 end
 
 -- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked
@@ -650,7 +666,7 @@
 
 function QuestPOI:OnLoad()
   qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config)
-
+  self.debugTimer = 4
   self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r'
   self.isPending = true
   self.count = self.Overlay.count
@@ -674,6 +690,8 @@
 
 function QuestPOI:OnUpdate (sinceLast)
   -- control update check intervals
+
+
   self.throttle = (self.throttle or self.updateRate) + sinceLast
   if self.throttle >= self.updateRate then
     -- factor overtime into the throttle timer
@@ -681,31 +699,42 @@
   else
     return
   end
-  if self.isNew then
-    --print('|cFFFFFF00push new poi stuff')
-    self:OnNew()
-  elseif self.isStale then
-    --wprint('|cFFFFFF00push poi update')
-    self:Refresh()
-    return
+  --@debug@
+  if DATA_DEBUG then
+    self.debugTimer = self.debugTimer - sinceLast
+    if self.debugTimer >= 0 then
+      print(self.debugTimer)
+    end
   end
+  --@end-debug@
 
   -- query for reward data if it wasn't found in the original scan
   local questID = self.questID
   if not self.dataLoaded then
-    --print('|cFFFF4400'..self:GetID()..':|r polling reward info')
+    print('|cFFFF4400'..self:GetID()..':|r polling reward info')
     if not (self.isAnimating) then
       self.PendingFade:Play()
     end
     local dataLoaded = self:GetData()
-    if dataLoaded then
-      WorldPlanQuests.isZoomDirty = true
+    if dataLoaded and not tContains(db.UpdatedPins, self) then
+
+      print('|cFF00FF88'..self:GetID()..':|r reward info loaded! queue it up')
+
+      tinsert(db.UpdatedPins, self)
     end
     return
   else
     if self.PendingFade:IsPlaying() then
+      print('|cFFFF4400'..self:GetID()..':|r cancel fader')
       self.PendingFade:Stop()
     end
+
+    if self.isStale then
+      print(self.questID, '|cFFFFFF00flagged for update')
+      self:CheckFilterRules()
+      self:Refresh()
+      return
+    end
   end
 
   self:UpdateStatus()