changeset 34:0100d923d8c3

WorldPlan: - Reward filter toggle changed to clear out other reward filters. The assumption being that one is most often looking only for that particular type of quest when they go to use it. - Fixed filter bar info falling out of sync after player-triggered world map updates. - Code stuff: -- Quest pin shown-state management makes better use of OnShow OnHide handlers, SetShown is toggled and it all goes from there -- WorldQuests module re-factored outside of the top level frame script. ClassPlan: - Available missions are now recorded; the mission list can be toggled between in-progress and available by clicking the heading.
author Nenue
date Wed, 02 Nov 2016 19:04:47 -0400
parents be4db60219ca
children 26dfa661daa7
files QuestPOI.lua WorldPlan.lua WorldPlan.xml WorldQuests.lua
diffstat 4 files changed, 75 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/QuestPOI.lua	Wed Nov 02 17:25:07 2016 -0400
+++ b/QuestPOI.lua	Wed Nov 02 19:04:47 2016 -0400
@@ -344,23 +344,57 @@
   print('cheevos')
 end
 
-function WorldPlanPOIMixin:ShowNew()
-  self:SetShown(true)
-  self.isNew = nil
-  self.isStale = true
-  self.FadeIn:Play()
+-- run from OnShow if .isNew is set
+function WorldPlanPOIMixin:OnNew()
+  self:SetAlpha(0)
+
+  if WorldPlan.db.FadeWhileGrouped then
+    self.FadeIn.FadeIn:SetToAlpha(0.15)
+    self.PendingFade.FadeIn:SetToAlpha(0.15)
+    self.PendingFade.FadeIn:SetFromAlpha(0.15)
+  else
+    self.FadeIn.FadeIn:SetToAlpha(1)
+    self.PendingFade.FadeIn:SetToAlpha(1)
+    self.PendingFade.FadeIn:SetFromAlpha(1)
+  end
+  if not self.isAnimating then
+    self.isAnimating = true
+    WorldPlan:OnNext(function()
+      self.isNew = nil
+      self.FadeIn:Play()
+    end)
+  end
 end
 
 function WorldPlanPOIMixin:OnShow ()
   qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow() update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
   -- pop this on principle
-  if self.isStale then
+
+  if self.isNew or self.isStale then
     self:Refresh()
   end
 
+
+  -- is it a new quest?
+  if self.isNew then
+    WorldPlan:print('|cFF0088FF', self.title, '|r', self.isNew and 'new', self.isStale and 'stale', self.isAnimating and 'animating')
+    self:OnNew()
+    -- trap new but animating pins here
+  else
+    -- hard show existing self
+    --print('refresh #', questID, 'filtered:', self.filtered, 'hasUpdate', self.hasUpdate)
+    self:Show()
+  end
+
+
 end
 function WorldPlanPOIMixin:OnHide()
   qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
+  if not self:IsShown() then
+    self.isAnimating = nil
+    self:SetAlpha(0)
+  end
+
 end
 
 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight)
@@ -581,7 +615,7 @@
       self.used = nil
     end
   end
-  print('  |cFFFF4400IsShowable()|r', self.used, self.filtered, self.title)
+  print('  |cFFFF4400IsShowable()|r', self.isNew, self.isAnimating, self.used, self.filtered, self.title)
   return self.used, self.filtered
 end
 
--- a/WorldPlan.lua	Wed Nov 02 17:25:07 2016 -0400
+++ b/WorldPlan.lua	Wed Nov 02 19:04:47 2016 -0400
@@ -66,7 +66,7 @@
   DisplayContinentPins = true,
   NotifyWhenNewQuests = true,
   EnablePins = true,
-  FadeWhileGrouped = true,
+  FadeWhileGrouped = false,
 }
 
 -- operating flags
@@ -158,6 +158,8 @@
   if self.isStale then
     self:Refresh()
   end
+
+  hooksecurefunc(self, 'SetScript', function(...) self:print('|cFFFFFF00'..self:GetName()..':SetScript()|r', ...) end)
 end
 
 function WorldPlan:OnEvent (event, ...)
@@ -177,7 +179,7 @@
     if event == 'WORLD_MAP_UPDATE' then
       self.currentMapID = GetCurrentMapAreaID()
       self.isContinentMap = (self.currentMapID == BROKEN_ISLES_ID)
-      print('|cFFFF4400currentMapID =', self.currentMapID)
+      self:print('|cFFFF4400currentMapID =', self.currentMapID)
       --self.isStale = true
     end
 
@@ -191,18 +193,19 @@
 end
 
 function WorldPlanCore:OnNext(func)
+
+
   tinsert(self.TaskQueue, func)
+  self:print('|cFF00FF00adding scheduled task #', #self.TaskQueue)
 end
 
 function WorldPlanCore:OnUpdate()
   if #self.TaskQueue >= 1 then
-  local func = tremove(self.TaskQueue, 1)
-  if func then
+    local func = tremove(self.TaskQueue, 1)
+    --self:print('|cFF00FF00running scheduled task #', #self.TaskQueue)
     func()
   end
 
-  end
-
   if self.isStale then
     print('|cFF00FF00pushing global update')
     self.isStale = nil
@@ -401,7 +404,7 @@
   info.value = "FadeWhileGrouped"
   info.tooltipTitle = "Group Fade"
   info.tooltipText = "Reduce pin alpha when grouped, so player dots are easier to see."
-  info.checked = db.DisplayContinentSummary
+  info.checked = db.FadeWhileGrouped
   info.func = DropDown_OnClick
   UIDropDownMenu_AddButton(info)
 end
--- a/WorldPlan.xml	Wed Nov 02 17:25:07 2016 -0400
+++ b/WorldPlan.xml	Wed Nov 02 19:04:47 2016 -0400
@@ -39,7 +39,7 @@
   <Button name="WorldPlanQuestPin" virtual="true" hidden="true" frameStrata="TOOLTIP" mixin="WorldPlanPOIMixin">
     <Animations>
       <AnimationGroup parentKey="FadeIn" setToFinalAlpha="true" looping="NONE">
-        <Alpha duration="0.15" fromAlpha="0" toAlpha="1" order="1" />
+        <Alpha parentKey="FadeIn" duration="0.15" fromAlpha="0" toAlpha="1" order="1" />
         <Scripts>
           <OnPlay>
             self:GetParent().highlight:Show()
@@ -55,8 +55,8 @@
         </Scripts>
       </AnimationGroup>
       <AnimationGroup parentKey="PendingFade" setToFinalAlpha="true" looping="REPEAT">
-        <Alpha duration="0.72" fromAlpha="1" toAlpha="0" order="1" />
-        <Alpha duration="0.72" fromAlpha="0" toAlpha="1" order="2" />
+        <Alpha parentKey="FadeOut" duration="0.72" fromAlpha="1" toAlpha="0" order="1" />
+        <Alpha parentKey="FadeIn" duration="0.72" fromAlpha="0" toAlpha="1" order="2" />
       </AnimationGroup>
     </Animations>
     <Layers>
--- a/WorldQuests.lua	Wed Nov 02 17:25:07 2016 -0400
+++ b/WorldQuests.lua	Wed Nov 02 19:04:47 2016 -0400
@@ -106,7 +106,7 @@
       self:RefreshData()
     end
     print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale)
-  elseif event == 'WORLD_MAP_UPDATE' then
+  elseif event == 'WORLD_MAP_UPDATE' or event == 'PLAYER_ENTERING_WORLD' then
     self.isStale = true
   elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
     local questID = ...
@@ -185,7 +185,14 @@
     return
   end
 
-  print('|cFF00FF88'..self:GetName()..':RefreshData()|r', 'map:', mapID, 'realMap:', GetCurrentMapAreaID())
+  if not self:IsVisible() then
+    self.isStale = true
+    print('frame closed, do it later')
+    return
+  end
+
+
+    print('|cFF00FF88'..self:GetName()..':RefreshData()|r', 'map:', mapID, 'realMap:', GetCurrentMapAreaID())
 
   if mapID == BROKEN_ISLES_ID then
     self.isStale = false
@@ -209,6 +216,7 @@
         info.mapID = mapID
         local questPOI = self:AcquirePin(questID, mapID)
         local hasUpdate, isPending = questPOI:RefreshData(info)
+        --  WorldPlan:print('|cFF0088FF'..questPOI.title..'|r', hasUpdate)
         self.isStale = (self.isStale or hasUpdate)
         self.isPending = (self.isPending or isPending)
         numQuests = numQuests + 1
@@ -227,6 +235,12 @@
 function WorldQuests:Refresh()
   local print = wqprint
   print('|cFF00FF88'..self:GetName()..':Refresh()|r')
+  if not self:IsVisible() then
+    self.isStale = true
+    print('frame closed, do it later')
+    return
+  end
+
   self:Reset()
   self:UpdateAnchors()
   self:Cleanup ()
@@ -277,7 +291,7 @@
         pin.hasUpdate = true
         pin:SetFrameLevel(PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins)
         print('level', PinBaseIndex+ (pin.whiteListed and 200 or 0) +numPins)
-        pin:SetAnchor(WorldMapPOIFrame, currentMap, mapWidth, mapHeight)
+        pin:SetAnchor(_G.WorldMapPOIFrame, currentMap, mapWidth, mapHeight)
         numPins = numPins + 1
       end
     end
@@ -290,61 +304,19 @@
 local debug_hide = {}
 function WorldQuests:Cleanup ()
   local print = wqprint
-  local showQuestPOI = db.EnablePins
-  print('|cFFFFFF00'..tostring(self)..':Cleanup()|r')
-  local mapID = GetCurrentMapAreaID()
-  isContinentMap = (mapID == BROKEN_ISLES_ID)
+  local showQuestPOI = WorldPlan.db.EnablePins
+  WorldPlan:print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
+  -- continent or zone sizing
 
-  wipe(debug_show)
-  wipe(debug_animate)
-  wipe(debug_hide)
-  -- continent or zone sizing
-  local fadeGrouped = (db.FadeWhileGrouped and IsInGroup())
 
   numPins = 0
   for questID, pin in pairs(self.QuestsByID) do
     -- can we show it?
-    if showQuestPOI and (pin.used) then
-
-      pin.isStale = true
-      if fadeGrouped then
-        pin:SetAlpha(0.25)
-      else
-        pin:SetAlpha(1)
-      end
-      -- is it a new quest?
-      if pin.isNew then
-        if not pin.isAnimating then
-          pin.isAnimating = true
-          WorldPlan:OnNext(function()
-            pin:ShowNew()
-          end)
-          tinsert(debug_animate,questID)
-        else
-
-          print('animating? ', questID, 'filtered:', pin.filtered)
-        end
-        -- trap new but animating pins here
-      else
-        -- hard show existing pin
-        --print('refresh #', questID, 'filtered:', pin.filtered, 'hasUpdate', pin.hasUpdate)
-        pin:Show()
-        tinsert(debug_show,questID)
-      end
-    else
-      if pin:IsShown() then
-        tinsert(debug_hide,questID)
-      end
-      pin.isAnimating = nil
-      pin.FadeIn:Stop()
-      pin:Hide()
-    end
+    pin:SetShown((showQuestPOI and pin.used))
   end
   print('   adding:', table.concat(debug_animate, ',' ))
   print('  refresh:', table.concat(debug_show, ',' ))
   print('  hiding:', table.concat(debug_hide, ',' ))
-  hasNewQuestPins = nil
-  notifyPlayed = nil
   self.isStale = nil
 end