diff WorldQuests.lua @ 65:02f1d3bce558

Update for Legion Patch 7.2 - Massively improved performance footprint via 7.2 API changes and some major optimization of POI update triggers - Removed AP token caching until reliable mechanisms for detecting AK shifts can be resolved.
author Nenue
date Wed, 29 Mar 2017 13:45:41 -0400
parents 876c3f0bfd0e
children e43e10c5576b
line wrap: on
line diff
--- a/WorldQuests.lua	Thu Mar 23 05:26:51 2017 -0400
+++ b/WorldQuests.lua	Wed Mar 29 13:45:41 2017 -0400
@@ -35,7 +35,9 @@
 local REWARD_CURRENCY = WORLD_QUEST_REWARD_TYPE_FLAG_ORDER_RESOURCES
 local REWARD_REAGENT = WORLD_QUEST_REWARD_TYPE_FLAG_MATERIALS
 
-
+local numShown = 0
+local numLoaded = 0
+local isDataLoaded
 local numPins = 0
 local NumPinFrames = 1
 Module.TasksByID = {}
@@ -72,6 +74,31 @@
   hooksecurefunc("WorldMapFrame_UpdateMap", InternalDoRefresh)
   WorldMapFrame.UIElementsFrame.BountyBoard:SetSelectedBountyChangedCallback(InternalDoRefresh);
   WorldMapFrame.UIElementsFrame.ActionButton:SetOnCastChangedCallback(InternalDoRefresh);
+
+  self.Status = CreateFrame('Frame', nil, self)
+  self.Status:SetPoint('TOPLEFT', WorldMapPOIFrame, 'TOPLEFT', 0, 0)
+  self.Status:SetPoint('BOTTOMRIGHT', WorldMapPOIFrame, 'TOPRIGHT', 0, -4)
+  self.Status.t = self.Status:CreateTexture(nil, 'OVERLAY')
+  self.Status.b = self.Status:CreateTexture(nil, 'BACKGROUND')
+  self.Status.b:SetColorTexture(0,0,0,.25)
+  self.Status.b:SetAllPoints(self.Status)
+  self.Status.t:SetColorTexture(1,1,1,.5)
+  self.Status.t:SetPoint('TOP')
+  self.Status.t:SetPoint('BOTTOM')
+  self.Status.t:SetPoint('LEFT')
+  local translationEnd, translationStart
+  self.Status:SetScript('OnUpdate', function(status)
+    local translateTo
+    if numLoaded < numShown then
+      translateTo = numLoaded/numShown * status:GetWidth()
+      status.t:SetWidth(translateTo)
+    else
+      translateTo = numShown * status:GetWidth()
+      status.t:SetWidth(translateTo)
+    end
+
+
+  end)
 end
 
 function Module:OnConfigUpdate()
@@ -160,7 +187,7 @@
     self.isStale = true
   end
 end
-
+local superTrackedQuestID
 function Module:OnEvent (event, ...)
 
   print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...)
@@ -181,10 +208,7 @@
       self:ReleasePin(db.QuestsByID[questID])
       rprint('|cFFFF4400release|r', questID)
     end
-  elseif event == 'SKILL_LINES_CHANGED' then
-    self:Refresh()
-  elseif event == 'CURRENT_SPELL_CAST_CHANGED' then
-
+  elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then
     self:Refresh()
   elseif event == 'ARTIFACT_UPDATE' then
     local ak = C_ArtifactUI.GetArtifactKnowledgeMultiplier()
@@ -196,6 +220,14 @@
       end
       self:Refresh()
     end
+  elseif event == 'SUPER_TRACKED_QUEST_CHANGED' then
+    if superTrackedQuestID and db.QuestsByID[superTrackedQuestID] then
+      db.QuestsByID[superTrackedQuestID].isStale = true
+    end
+    local newID = GetSuperTrackedQuestID()
+    if newID and db.QuestsByID[newID] then
+      db.QuestsByID[newID].isStale = true
+    end
   end
 end
 
@@ -253,14 +285,14 @@
   end
 
   if (not pin.dataLoaded) then
-    pin:GetData()
+    local dataLoaded = pin:GetData()
+    isDataLoaded = (isDataLoaded and dataLoaded)
     WorldPlan.dataFlush = true
   end
 
   pin.isActive = TQ_IsActive(questID)
 
   pin:CheckFilterRules()
-  pin.isStale = true
   rprint(pin:GetID(), pin.filtered, pin.used)
 
   return pin
@@ -475,6 +507,8 @@
   print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
   rprint('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
   --local showQuestPOI = db.Config.EnablePins
+  numShown = 0
+  numLoaded = 0
   for questID, pin in pairs(db.QuestsByID) do
     local oV = pin:IsShown()
     if pin.used then
@@ -483,6 +517,11 @@
         print('|cFF00FF00cleanup +|r', questID, pin.title)
       end
       pin:SetShown(true)
+      numShown = numShown + 1
+      if pin.dataLoaded then
+        numLoaded = numLoaded + 1
+      end
+
     else
       if oV == true then
         print('|cFFFF4400 -|r', questID, pin.title)
@@ -491,6 +530,11 @@
     end
   end
 
+  if numShown > numLoaded then
+    self.Status:Show()
+  end
+
+
   self.isStale = nil
   self.sizesDirty = nil
 end
@@ -517,17 +561,13 @@
   rprint('|cFF00FF00update|r', pin.questID, pin.title)
 
   if x and y then
-    pin.x = x
-    pin.y = y
     pin:SetFrameLevel(PinBaseIndex+pin:GetID())
     pin.owningFrame = WorldMapFrame
-    pin:SetAnchor(WorldMapPOIFrame, pin.x, pin.y, self.hostWidth, self.hostHeight)
+    pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight)
     --tinsert(self.UsedPositions, pin)
   end
-  if self:IsVisible() then
+  if self:IsVisible() and pin.isStale then
     pin:Refresh()
-  else
-    pin.isStale = true
   end
   if mapID then
     if not db.QuestsByZone[mapID] then
@@ -545,6 +585,7 @@
 end
 
 function Module:UpdateAnchors ()
+
   wipe(self.UsedPositions)
   print('  |cFF00FF00'..self:GetName()..':UpdateAnchors()')
   self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize()
@@ -556,7 +597,8 @@
   if isMicroDungeon then
     return
   end
-
+  -- starts as true
+  isDataLoaded = true
 
   numPins = 0
   local taskInfo = TQ_GetQuestsForPlayerByMapID(self.currentMapID)
@@ -575,4 +617,3 @@
   end
 end
 
-