diff FilterBar.lua @ 33:be4db60219ca

WorldPlan: - Toggling a reward filter cancels out other types by default. Use right mouse to clear. - Fixed filter bar info falling out of sync after player-triggered world map updates. 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 17:25:07 -0400
parents e8679ecb48d8
children 21bcff08b0f4
line wrap: on
line diff
--- a/FilterBar.lua	Tue Nov 01 10:48:50 2016 -0400
+++ b/FilterBar.lua	Wed Nov 02 17:25:07 2016 -0400
@@ -5,6 +5,7 @@
 --
 
 local print = DEVIAN_WORKSPACE and function(...) _G.print('FilterBar', ...) end or nop
+local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
 local wipe, ipairs, pairs = table.wipe, ipairs, pairs
 
 local REWARD_CASH = WORLD_QUEST_REWARD_TYPE_FLAG_GOLD
@@ -18,7 +19,26 @@
 local LE_QUEST_TAG_TYPE_PET_BATTLE = LE_QUEST_TAG_TYPE_PET_BATTLE
 local LE_QUEST_TAG_TYPE_DUNGEON = LE_QUEST_TAG_TYPE_DUNGEON
 local LE_QUEST_TAG_TYPE_PROFESSION = LE_QUEST_TAG_TYPE_PROFESSION
-local LE_QUEST_TAG_TYPE_NORMAL = LE_QUEST_TAG_TYPE_NORMAL
+
+local familiars = {
+  [42159] = {npc = 106552, name = 'Nightwatcher Merayl'},
+  [40277] = {npc = 97804, name = 'Tiffany Nelson'},
+  [40298] = {npc = 99182, name = 'Sir Galveston'},
+  [40282] = {npc=  99150, name = 'Grixis Tinypop'},
+  [40278] = {npc = 98270, name = 'Robert Craig'},
+  [48195] = {npc = 105250, name = 'Aulier'},
+  [41990] = {npc = 105674, name = 'Varenne'},
+  [41860] = {npc = 104970, name = 'Xorvasc'},
+  [40299] = {npc = 99210, name = 'Bodhi Sunwayver'},
+  [42442] = {npc = 107489, name = 'Amalia'},
+  [40280] = {npc = 99077, name = 'Bredda Tenderhide'},
+  [41687] = {npc = 104553, name = 'Odrogg'},
+  [41944] = {npc = 105455, name = 'Trapper Jarrun'},
+  [40337] = {npc = 97709, name = 'Master Tamer Flummox'},
+  [40279] = {npc = 99035, name = 'Durian Strongfruit'}
+}
+local familiars_id = 9696
+
 local DEFAULT_FILTER_LAYOUT = {
   PinSize = 22,
   Border = 3,
@@ -51,11 +71,7 @@
 WorldPlanFilterPinMixin = {}
 
 function WorldPlanSummaryMixin:OnLoad()
-  self:RegisterEvent('QUEST_LOG_UPDATE')
-  self:RegisterEvent('WORLD_MAP_UPDATE')
-
   WorldPlan:AddHandler(self, defaults)
-
   for index, info in ipairs(DEFAULT_FILTER_LIST) do
     info.zone = DEFAULT_FILTER_LAYOUT
     info.continent = DEFAULT_FILTER_LAYOUT
@@ -68,32 +84,36 @@
 
 
 function WorldPlanSummaryMixin:OnEvent(event)
-  self:Refresh()
+  print('|cFF00FF88'..self:GetName()..':OnEvent()', event)
+  self.isStale = true
 end
 
 local bountyIndex
 local debug_headers = {}
 
 function WorldPlanSummaryMixin:Setup()
+  print('|cFF00FF88'..self:GetName()..':Setup()')
   self:GetFilters()
 end
 
 
-function WorldPlanSummaryMixin:OnEvent(event,...)
-  self.isStale = true
+function WorldPlanSummaryMixin:OnUpdate()
+  if self.isStale then
+    wprint('|cFF00FF00pushing update')
+    self:Refresh()
+  end
 end
-function WorldPlanSummaryMixin:OnUpdate()
+
+function WorldPlanSummaryMixin:OnShow()
+  print('|cFF00FF88'..self:GetName()..':OnShow()')
   if self.isStale then
     self:Refresh()
   end
 end
 
-function WorldPlanSummaryMixin:OnShow()
-  self:Refresh()
-end
-
 function WorldPlanSummaryMixin:GetFilters()
 
+  print('|cFF00FFFF'..self:GetName()..':GetFilters()')
 
   wipe(self.filterList)
 
@@ -127,22 +147,22 @@
   self:GetFilters()
 end
 
-function WorldPlanSummaryMixin:Refresh(forced)
-  self:Update(forced)
+function WorldPlanSummaryMixin:Refresh()
+  self:Update()
 end
 
 local filterFill = "Interface\\BUTTONS\\YELLOWORANGE64"
 local filterMask = "Interface\\Minimap\\UI-Minimap-Background"
 
 local questResults = {{}}
-function WorldPlanSummaryMixin:Update(forced)
+function WorldPlanSummaryMixin:Update()
   local blocks = self.buttons
   local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton
   local numHeaders = 0
-  print('|cFF00FF88'..tostring(self)..':Refresh()|r', 'currentMap=',self.currentMapID)
+  print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',WorldPlan.currentMapID)
 
 
-  local quests = WorldPlanQuests.QuestsByZone[self.currentMapID] or WorldPlanQuests.QuestsByID
+  local quests = WorldPlanQuests.QuestsByZone[WorldPlan.currentMapID] or WorldPlanQuests.QuestsByID
   local foundQuests = questResults[1]
   for index, info in ipairs(self.filterList) do
     local numQuests = 0
@@ -267,7 +287,7 @@
   local desaturated = false
   if self.cVar then
     self.iconBorder:SetVertexColor(1, 1, 1, 1)
-    if GetCVarBool(self.cVar) == true then
+    if GetCVarBool(self.cVar) then
       self.icon:SetVertexColor(1,1,1,1)
       self:SetAlpha(1)
     else
@@ -300,6 +320,7 @@
 function WorldPlanFilterPinMixin:OnUpdate ()
 end
 
+
 function WorldPlanFilterPinMixin:OnLeave ()
   if GameTooltip:IsOwned(self) then
     GameTooltip:Hide()
@@ -320,8 +341,22 @@
 
   if not filterKey then
     wipe(WorldPlan.UsedFilters)
+    for i, info in ipairs(DEFAULT_FILTER_LIST) do
+      if info.cVar then
+        SetCVar(info.cVar, 1)
+      end
+    end
+
   elseif self.cVar then
-    SetCVar(self.cVar, (GetCVarBool(self.cVar) and 0) or 1)
+      for i, info in ipairs(DEFAULT_FILTER_LIST) do
+        if info.cVar then
+          if (info.cVar ~= self.cVar) and (button == 'LeftButton') then
+            SetCVar(info.cVar, 0)
+          else
+            SetCVar(info.cVar, 1)
+          end
+        end
+      end
   else
     local setInclude = (button == 'LeftButton')
     local flushValue
@@ -332,5 +367,5 @@
       WorldPlan.UsedFilters[filterKey] = filterValue
     end
   end
-  WorldPlan:Refresh()
+  WorldPlan:Refresh(true)
 end
\ No newline at end of file