diff FilterBar.lua @ 36:21bcff08b0f4

WorldPlan: - Quest pins are now placed on the flight map. Their visibility rules will mirror the filter options from the world map. - Filter controls polish: - First click negates other reward type filters. Subsequent clicks will then toggle individual reward types until the filters are reset via Right-click. - Adheres to the Blizzard CVars added in patch 7.1 - Numerous optimizations to how data and visual updates are handled; should see an even better load time, and snappier world map interaction. ClassPlan: - The 'Available Missions' list is now recorded. It can be reviewed by clicking on the mission list heading. - Information filtering by character and realm.
author Nenue
date Fri, 04 Nov 2016 01:40:39 -0400
parents be4db60219ca
children 589c444d4837
line wrap: on
line diff
--- a/FilterBar.lua	Thu Nov 03 17:29:15 2016 -0400
+++ b/FilterBar.lua	Fri Nov 04 01:40:39 2016 -0400
@@ -40,9 +40,9 @@
 local familiars_id = 9696
 
 local DEFAULT_FILTER_LAYOUT = {
-  PinSize = 22,
-  Border = 3,
-  TrackingBorder = 2,
+  iconWidth = 24,
+  borderWidth = 3,
+  highlightWidth = 2,
   TagSize = 12,
   TimeleftStage = 3,
   showNumber = true,
@@ -161,7 +161,9 @@
   local numHeaders = 0
   print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',WorldPlan.currentMapID)
 
-
+  local layout = DEFAULT_FILTER_LAYOUT
+  local borderWidth = layout.iconWidth + (layout.borderWidth * 2)
+  local highlightWidth = borderWidth + (layout.highlightWidth * 2)
   local quests = WorldPlanQuests.QuestsByZone[WorldPlan.currentMapID] or WorldPlanQuests.QuestsByID
   local foundQuests = questResults[1]
   for index, info in ipairs(self.filterList) do
@@ -186,25 +188,22 @@
       local button = blocks[numHeaders]
       if not blocks[numHeaders] then
         button = CreateFrame('Button', 'WorldPlanFilterButton'..numHeaders, WorldMapScrollFrame, 'WorldPlanFilterPin')
+        button:SetSize(borderWidth, borderWidth)
 
-        button:SetSize(24,24)
-        button.icon:ClearAllPoints()
-        button.icon:SetAllPoints(button)
+        button.icon:SetSize(layout.iconWidth, layout.iconWidth)
+        button.RewardBorder:SetSize(borderWidth, borderWidth)
+        button.HighlightBorder:SetSize(highlightWidth, highlightWidth)
+        button.RewardBorder:SetMask(filterMask)
+        button.RewardBorder:SetDesaturated(true)
 
-        button.iconBorder:SetPoint('TOPLEFT', button, 'TOPLEFT', -2, 2)
-        button.iconBorder:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', 2, -2)
-        button.iconBorder:SetMask(filterMask)
-        button.iconBorder:SetTexture(filterFill)
-        button.iconBorder:SetDesaturated(true)
-
-        button.supertrackBorder:Hide()
+        button.HighlightBorder:Hide()
         blocks[numHeaders] = button
       end
 
       button.info = info
       button.questList = questResults[resultIndex]
       button:SetID(index)
-      button.spacing = ((info.filterKey ~=  relativeFrame.filterKey) and 10) or 0
+      button.spacing = ((relativeFrame.cVar and (not info.cVar)) or (relativeFrame.filterKey ~= info.filterKey)) and 5 or 0
       button.relativeFrame = relativeFrame
       button:Refresh((numHeaders == 1), numQuests)
       button:Show()
@@ -233,21 +232,12 @@
 function WorldPlanFilterPinMixin:OnEnter()
   if self.questList and #self.questList >= 1 then
     GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
-    GameTooltip_ClearInsertedFrames(GameTooltip)
     GameTooltip:AddLine(self.info.label)
     for index, pin in ipairs(self.questList) do
       local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite
-      GameTooltip:AddLine(pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b)
-      GameTooltip:AddTexture(pin.itemTexture)
-      local cLine = GameTooltip:NumLines() - 1
-      --print(cLine, _G['GameTooltipTexture'..cLine]:GetTexture())
-      if type(pin.itemTexture) == 'number' then
-        --- voodoo workaround for IDs getting coerced to string
-        _G['GameTooltipTexture'..cLine]:Show()
-        _G['GameTooltipTexture'..cLine]:SetTexture(pin.itemTexture)
-      end
-      GameTooltip:Show()
+      GameTooltip:AddLine('|T'.. tostring(pin.itemTexture)..':16:16|t ' .. pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b)
     end
+    GameTooltip:Show()
   end
 end
 
@@ -279,14 +269,14 @@
   if isFirst then
     self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5)
   else
-    self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(3 + (self.spacing or 0)))
+    self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(self.spacing or 0))
   end
   print('anchor to', self.relativeFrame:GetName(), info.mask)
 
   local r, g, b, a = 1,1,1,1
   local desaturated = false
   if self.cVar then
-    self.iconBorder:SetVertexColor(1, 1, 1, 1)
+    self.RewardBorder:SetVertexColor(1, 1, 1, 1)
     if GetCVarBool(self.cVar) then
       self.icon:SetVertexColor(1,1,1,1)
       self:SetAlpha(1)
@@ -298,12 +288,20 @@
     self:SetAlpha(1)
     if WorldPlan.UsedFilters[self.filterKey] then
       if WorldPlan.UsedFilters[self.filterKey] == self.filterValue then
-        self.iconBorder:SetVertexColor(0, 1, 0)
+        self.RewardBorder:SetVertexColor(0, 1, 0)
       else
-        self.iconBorder:SetVertexColor(1, 0, 0)
+        self.RewardBorder:SetVertexColor(1, 0, 0)
       end
     else
-      self.iconBorder:SetVertexColor(1, 1, 1, 1)
+      if self.filterKey == 'worldQuestType' then
+        self.RewardBorder:SetVertexColor(0, 1, 1)
+      elseif self.filterKey == 'factionID' then
+        self.RewardBorder:SetVertexColor(1, 1, 0)
+      else
+
+        self.RewardBorder:SetVertexColor(0.5, 0.5, 0.5)
+      end
+
     end
   end
 
@@ -315,6 +313,7 @@
   self:SetFrameStrata('HIGH')
   self:SetFrameLevel(151)
   self:SetScript('OnUpdate', nil)
+  WorldPlanPOIMixin.OnLoad(self)
 end
 
 function WorldPlanFilterPinMixin:OnUpdate ()
@@ -329,43 +328,69 @@
 
 -- shift-click: reset filter
 -- click: rotate through include(1), exclude(-1), ignore(nil)
+local filtered_report = {}
 function WorldPlanFilterPinMixin:OnClick (button)
 
   print('|cFF00FF88'..self:GetName()..':OnClick()|r', filterKey, filterValue, operation)
   local filterKey = self.filterKey
   local filterValue = self.filterValue
+  local cVar = self.cVar
+  local parent = self:GetParent()
+  local operation = opPrefix
+  local setDirty = false
 
-
-  local operation = opPrefix
-
-
-  if not filterKey then
+  local resetMode = (button == 'RightButton')
+  wipe(filtered_report)
+  if not (filterKey or cVar) then
     wipe(WorldPlan.UsedFilters)
     for i, info in ipairs(DEFAULT_FILTER_LIST) do
       if info.cVar then
+        if GetCVar(info.cVar) ~= 1 then
+          tinsert(filtered_report, '|cFF888888'.. tostring(info.label) ..'|r')
+        end
         SetCVar(info.cVar, 1)
       end
     end
 
-  elseif self.cVar then
+  elseif cVar then
+    WorldPlan:print('Toggling cvar filter:', cVar)
+    if (not parent.isDirty) or resetMode then
       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)
+          local value = GetCVar(info.cVar)
+          if resetMode then
+            value = 1
+            parent.isDirty = nil
           else
-            SetCVar(info.cVar, 1)
+
+              if (cVar ~= info.cVar) then
+                value = 0
+              else
+                value = 1
+              end
+              setDirty = true
+
           end
+          SetCVar(info.cVar, value)
         end
       end
+      if setDirty then
+        parent.isDirty = true
+      end
+    else
+      SetCVar(cVar, (GetCVarBool(cVar) and 0) or 1)
+    end
   else
-    local setInclude = (button == 'LeftButton')
     local flushValue
     print('')
     if WorldPlan.UsedFilters[filterKey] == filterValue then
       WorldPlan.UsedFilters[filterKey] = nil
+      tinsert(filtered_report,  '|cFFFF0000'.. tostring(filterKey) ..'|r')
     else
       WorldPlan.UsedFilters[filterKey] = filterValue
+      tinsert(filtered_report,  '|cFF00FF00'.. tostring(filterKey) ..'|r')
     end
   end
+  WorldPlan:print('Changed:', table.concat(filtered_report, ', '))
   WorldPlan:Refresh(true)
 end
\ No newline at end of file