changeset 45:db570c6a0ffb v1.0-rc12

- Fixed filter buttons losing their anchor after FlightMap interactions - Fixed flickering tooltips - Fixed a source of hangs while opening the world map, particularly in non-Broken-Isle continents. - Workaround for World Map Action Button: Temporarily activate blizzard POI buttons while a quest-targeting spell is on the cursor.
author Nenue
date Mon, 26 Dec 2016 10:20:52 -0500
parents 59e9d66195dd
children 0873a1b00bb2
files FilterBar.lua FilterBar.xml QuestPOI.lua WorldPlan.lua WorldQuests.lua
diffstat 5 files changed, 81 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/FilterBar.lua	Sun Dec 25 15:48:24 2016 -0500
+++ b/FilterBar.lua	Mon Dec 26 10:20:52 2016 -0500
@@ -74,7 +74,9 @@
 local Pin = WorldPlanFilterPinMixin
 
 function Module:OnLoad()
-  self:SetParent(WorldMapFrame)
+  self:SetParent(WorldMapFrame.UIElementsFrame)
+  self:ClearAllPoints()
+  self:SetPoint('TOPRIGHT')
   WorldPlan:AddHandler(self)
   for index, info in ipairs(db.DefaultFilters) do
     info.zone = db.DefaultFilterType
@@ -82,7 +84,6 @@
     info.pinMask =  "Interface\\Minimap\\UI-Minimap-Background"
     WorldPlan:AddTypeInfo(self,index, info)
   end
-
 end
 
 
@@ -96,6 +97,7 @@
 
 function Module:Setup()
   print('|cFF00FF88'..self:GetName()..':Setup()')
+  self.isStale = true
 end
 
 
@@ -171,12 +173,7 @@
 function Module:Update()
   local blocks = self.buttons
 
-  local relativeFrame = WorldMapFrame.UIElementsFrame.TrackingOptionsButton
-  if FlightMapFrame and FlightMapFrame:IsVisible() then
-    relativeFrame = FlightMapFrame
-  end
-  self:SetParent(relativeFrame)
-  self:SetPoint('TOPRIGHT')
+  local relativeFrame = self
 
     local numHeaders = 0
   print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',WorldPlan.currentMapID)
@@ -194,9 +191,9 @@
     wipe(info.questList)
 
     for questID, pin in pairs(db.QuestsByID) do
-      print(pin.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION, (db.Config.ShowAllProfessionQuests or pin.isKnownProfession))
+      --print(pin.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION, (db.Config.ShowAllProfessionQuests or pin.isKnownProfession))
       if (pin.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION) or (db.Config.ShowAllProfessionQuests or pin.isKnownProfession) then
-        print(pin.title)
+        --print(pin.title)
         if not info.filterKey then
           if mapQuests[questID] then
               numQuestsHere = numQuestsHere + 1
@@ -303,17 +300,13 @@
 
   self.itemTexture = self.texture
 
+  self:ClearAllPoints()
   if self.isFirst then
-    if FlightMapFrame and FlightMapFrame:IsVisible() then
-      self:SetPoint('TOPRIGHT', FlightMapFrame, 'TOPRIGHT', -4, -25)
-    else
-      self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5)
-    end
-
+    self:SetPoint('TOPRIGHT', self.relativeFrame, 'TOPRIGHT', -5, -42)
   else
-    self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(self.spacing or 0))
+    self:SetPoint('TOPLEFT', self.relativeFrame, 'BOTTOMLEFT', 0, -(self.spacing or 0))
   end
-  print('anchor to', self.relativeFrame:GetName(), info.mask)
+  print('anchor', self.relativeFrame:IsShown(), self:GetPoint(1))
 
   self.icon:SetDesaturated(self.numQuestsHere == 0)
 
--- a/FilterBar.xml	Sun Dec 25 15:48:24 2016 -0500
+++ b/FilterBar.xml	Mon Dec 26 10:20:52 2016 -0500
@@ -8,13 +8,8 @@
       <OnShow method="OnShow" />
     </Scripts>
 
-    <Layers>
-      <Layer level="OVERLAY">
-        <Texture parentKey="CVarsHighlight">
-          <Color a=".5" r="1" g="1" b="1" />
-        </Texture>
-      </Layer>
-    </Layers>
+    <Size x="24" y="24" />
+
   </Frame>
   <Button name="WorldPlanFilterPin" virtual="true" flattenRenderLayers="true" mixin="WorldPlanFilterPinMixin">
     <Scripts>
--- a/QuestPOI.lua	Sun Dec 25 15:48:24 2016 -0500
+++ b/QuestPOI.lua	Mon Dec 26 10:20:52 2016 -0500
@@ -398,20 +398,16 @@
 end
 
 function QuestPOI:OnShow ()
-  -- pop this on principle
-
   if self.isNew or self.isStale then
     self:Refresh()
   end
 
-
-  -- is it a new quest?
   if self.isNew then
     qprint('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
     --qprint('|cFFFFFF00popping new pin handler')
     self:OnNew()
   elseif not self.isAnimating then
-    self:SetAlpha(1)
+    self:SetAlpha(1) -- fix stuck alpha
   end
 
   self.Overlay:SetShown(true)
@@ -556,22 +552,21 @@
   local trackingBorder = self.HighlightBorder
   local icon = self.icon
   local count = self.count
-  --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName))
 
   if self.itemName then
-      --wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
-      if self.itemNumber and self.itemNumber >= 1000 then
-        local numeral = floor(self.itemNumber/1000)
-        local decimal = mod(self.itemNumber, 1000)
-        local numberString = numeral
-        if decimal > 100 then
-          numberString = numberString .. '.' .. tostring(floor(decimal/100))
-        end
-        numberString = numberString .. 'k'
-        self.count:SetText(numberString)
-      else
-        self.count:SetText(self.itemNumber)
+
+    if self.itemNumber and self.itemNumber >= 1000 then
+      local numeral = floor(self.itemNumber/1000)
+      local decimal = mod(self.itemNumber, 1000)
+      local numberString = numeral
+      if decimal > 100 then
+        numberString = numberString .. '.' .. tostring(floor(decimal/100))
       end
+      numberString = numberString .. 'k'
+      self.count:SetText(numberString)
+    else
+      self.count:SetText(self.itemNumber)
+    end
 
 
   end
@@ -674,10 +669,6 @@
   return self.used
 end
 
-function QuestPOI:UpdateTimer (timeLeft, timeType)
-  print('|cFF0088FFUpdatePinTimer()|r')
-end
-
 --- Fixes icons upon size update
 function QuestPOI:UpdateSize ()
 
--- a/WorldPlan.lua	Sun Dec 25 15:48:24 2016 -0500
+++ b/WorldPlan.lua	Mon Dec 26 10:20:52 2016 -0500
@@ -320,7 +320,6 @@
     end
   end)
 
-
   SLASH_WORLDPLAN1 = "/worldplan"
   SLASH_WORLDPLAN2 = "/wp"
 
--- a/WorldQuests.lua	Sun Dec 25 15:48:24 2016 -0500
+++ b/WorldQuests.lua	Mon Dec 26 10:20:52 2016 -0500
@@ -3,7 +3,7 @@
 -- Created: 11/2/2016 3:40 PM
 -- %file-revision%
 local _, db = ...
-local WorldQuests = WorldPlanQuestsMixin
+local Module = WorldPlanQuestsMixin
 
 local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo
 local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented
@@ -14,7 +14,7 @@
 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 mprint = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end
-
+local pairs = pairs
 
 local PinBaseIndex = 1200
 local BROKEN_ISLES_ID, DALARAN_ID, AZSUNA_ID, VALSHARAH_ID, HIGHMOUNTAIN_ID, STORMHEIM_ID, SURAMAR_ID, EOA_ID = 1007, 1014, 1015,1018, 1024, 1017, 1033, 1096
@@ -30,7 +30,7 @@
 
 local numPins = 0
 local NumPinFrames = 1
-WorldQuests.TasksByID = {}
+Module.TasksByID = {}
 
 --%debug%
 local SetTimedCallbackForAllPins = function(seconds, callback)
@@ -41,42 +41,59 @@
   end)
 end
 
-function WorldQuests:OnUpdate(sinceLast)
+function Module:OnUpdate(sinceLast)
   if self.filtersDirty or self.isStale then
     self:Refresh()
   end
 end
 
-function WorldQuests:Setup()
+function Module:Setup()
   print('|cFFFF4400'..self:GetName()..':Setup()')
 
   for mapID, mapName in pairs(WORLD_QUEST_MAPS) do
     db.QuestsByZone[mapID] = {}
   end
 
+  hooksecurefunc("ClickWorldMapActionButton", function () self:OnClickWorldMapActionButton() end)
+  hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", function () self:Refresh() end)
+  hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () self:OnUpdateQuestBonusObjectives() end)
+end
 
-  -- refresh positions any time blizzard does so (i.e. mousewheel zoom)
-  hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", function()
-    print('|cFFFF4400WorldMapScrollFrame_ReanchorQuestPOIs')
-    self:Refresh(true)
-  end)
+local InternalHideButton = function(button, index)
+  button:Hide()
+  if button.questID and db.QuestsByID[button.questID] then
+    if db.QuestsByID[button.questID].used and not db.QuestsByID[button.questID].filtered then
+      db.QuestsByID[button.questID]:SetShown(true)
+    end
+  end
+end
+local InternalShowButton = function(button, index)
+  button:Show()
+  if button.questID and db.QuestsByID[button.questID] then
+    db.QuestsByID[button.questID]:SetShown(false)
+  end
+end
 
+function Module:OnUpdateQuestBonusObjectives()
+  print('|cFFFF4400WorldMap_UpdateQuestBonusObjectives')
+  local func = SpellCanTargetQuest() and InternalShowButton or InternalHideButton
+  print(SpellCanTargetQuest())
+  for i = 1, NUM_WORLDMAP_TASK_POIS do
+    local button = _G['WorldMapFrameTaskPOI'..i]
+    if button and button.worldQuest then
+      func(button, i)
+    end
+  end
+end
 
-  -- hide the original world quest POIs
+function Module:OnClickWorldMapActionButton()
+  self.IsTargeting = SpellCanTargetQuest()
+  self:OnUpdateQuestBonusObjectives()
+end
 
-  hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function()
-    print('|cFFFF4400WorldMap_UpdateQuestBonusObjectives')
-    for i = 1, NUM_WORLDMAP_TASK_POIS do
-      local button = _G['WorldMapFrameTaskPOI'..i]
-      if button and button.worldQuest then
-        button:Hide()
-      end
-    end
-  end)
-end
 local defaults = {}
 local REWARD_UNKNOWN = 768
-function WorldQuests:OnLoad()
+function Module:OnLoad()
   print('|cFFFF4400'..self:GetName()..':OnLoad()')
 
   self:SetParent(WorldMapFrame)
@@ -102,7 +119,7 @@
 
 end
 
-function WorldQuests:OnMapInfo()
+function Module:OnMapInfo()
   if self:IsVisible() then
     self:Refresh()
   else
@@ -110,7 +127,7 @@
   end
 end
 
-function WorldQuests:OnEvent (event, ...)
+function Module:OnEvent (event, ...)
 
   print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...)
   if event == 'QUEST_LOG_UPDATE' then
@@ -137,7 +154,7 @@
 
 local totalPins = 0
 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
-function WorldQuests:AcquirePin (info)
+function Module:AcquirePin (info)
   local questID = info.questId
   if not questID then
     return nil
@@ -194,7 +211,7 @@
 end
 
 -- remove from index and add it to the recycling heap
-function WorldQuests:ReleasePin (pin)
+function Module:ReleasePin (pin)
 
   local id = pin.questID
   if id then
@@ -213,7 +230,7 @@
   print('|cFF00FF00-'.. (pin.mapID and GetMapNameByID(pin.mapID) or '???') ..'|r', id, pin.title)
 end
 
-function WorldQuests:GetBonusObjectives()
+function Module:GetBonusObjectives()
 
 
   local tasksTable = GetTasksTable()
@@ -260,7 +277,7 @@
 
 
 -- use tooltip object to extract item details
-function WorldQuests:GetRewardHeader(questID)
+function Module:GetRewardHeader(questID)
   local name, icon, quantity, quality, _, itemID = GetQuestLogRewardInfo(1, questID)
   local scanner = _G.WorldPlanTooltip
   local print = qprint
@@ -319,7 +336,7 @@
 local GetCurrentMapAreaID, GetMapNameByID= GetCurrentMapAreaID, GetMapNameByID
 local wipe, pairs = wipe, pairs
 -- create of update quest pins for a map and its underlying zones
-function WorldQuests:UpdateWorldQuests (mapID)
+function Module:UpdateWorldQuests (mapID)
 
   mapID = mapID or db.currentMapID
   if not mapID then
@@ -369,7 +386,7 @@
   end
 end
 
-function WorldQuests:Report()
+function Module:Report()
   for i, pin in ipairs(db.UsedPins) do
     db:print(i, pin.questID, pin.title)
   end
@@ -379,7 +396,7 @@
   end
 end
 
-function WorldQuests:Refresh(fromUser)
+function Module:Refresh(fromUser)
   self.currentMapID = GetCurrentMapAreaID()
   print('|cFF00FF88'..self:GetName()..':Refresh()|r', fromUser or '|cFFFFFF00internal')
   if not self:IsVisible() then
@@ -391,7 +408,6 @@
 
   for index, pin in pairs(db.QuestsByID) do
     pin.used = nil
-    pin:SetShown(false)
   end
 
   self:SetFilteredPins(db.QuestsByID)
@@ -401,7 +417,7 @@
 end
 
 -- update visibility states of all pins
-function WorldQuests:SetFilteredPins(pins)
+function Module:SetFilteredPins(pins)
   print('  |cFFFFFF00'..self:GetName()..':SetFilteredPins()|r', pins)
   pins = pins or db.QuestsByID
   for questID, pin in pairs(pins) do
@@ -412,7 +428,7 @@
 end
 
 local abs = math.abs
-function WorldQuests:UpdateQuestButton(info, mapID)
+function Module:UpdateQuestButton(info, mapID)
   local questID, x, y = info.questId, info.x, info.y
   local pin = self:AcquirePin(info)
   if not pin then
@@ -445,14 +461,14 @@
   end
 end
 
-function WorldQuests:UpdateMap(taskInfo, mapID)
+function Module:UpdateMap(taskInfo, mapID)
   print('Map', GetMapNameByID(mapID), GetMapNameByID(self.currentMapID))
   for index, info in pairs(taskInfo) do
     self:UpdateQuestButton(info, mapID)
   end
 end
 
-function WorldQuests:UpdateAnchors (fromUser)
+function Module:UpdateAnchors (fromUser)
 
 
   wipe(self.UsedPositions)
@@ -489,7 +505,7 @@
 end
 
 -- shows, animates, or hides pins based on their current visibility flags
-function WorldQuests:Cleanup (fromUser)
+function Module:Cleanup (fromUser)
 
   print('|cFFFFFF00'..self:GetName()..':Cleanup()|r')
   local print = rprint
@@ -498,7 +514,7 @@
   for questID, pin in pairs(db.QuestsByID) do
     local oV = pin:IsShown()
     if pin.used then
-      pin:SetShown(true)
+
       pin.throttle = 1
       if oV == false then
         print('|cFF00FF00cleanup +|r', questID, pin.title)
@@ -508,6 +524,7 @@
         print('|cFFFF4400 -|r', questID, pin.title)
       end
     end
+    pin:SetShown(pin.used or false)
 
     if pin.worldQuest and (not C_TaskQuest.IsActive(pin.questID)) then
       self:ReleasePin(pin)