diff QuestPOI.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 d0114b51cdea
children 0100d923d8c3
line wrap: on
line diff
--- a/QuestPOI.lua	Tue Nov 01 10:48:50 2016 -0400
+++ b/QuestPOI.lua	Wed Nov 02 17:25:07 2016 -0400
@@ -4,15 +4,21 @@
 -- %file-revision%
 --
 
+WorldPlanPOIMixin = {}
 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID
 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
 local TQ_IsActive = C_TaskQuest.IsActive
 local TQ_RequestPreloadRewardData = C_TaskQuest.RequestPreloadRewardData
 local QuestPOIGetIconInfo, WorldMapPOIFrame =  QuestPOIGetIconInfo, WorldMapPOIFrame
+local WorldMap_DoesWorldQuestInfoPassFilters = WorldMap_DoesWorldQuestInfoPassFilters
+local QuestMapFrame_IsQuestWorldQuest = QuestMapFrame_IsQuestWorldQuest
+local GameTooltip = GameTooltip
+local GetItemIcon = GetItemIcon
 
-local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
+local print = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
 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 wqprint = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end
 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
 local QuestPOI = WorldPlanPOIMixin
@@ -77,29 +83,32 @@
 
 -- Pin color/display variables
 
-  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 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
+
+
+-- update a masked texture without messing up its blending mask
 
 
 -- update a masked texture without messing up its blending mask
 local SetMaskedTexture = function(region, file, mask)
-  mask = mask or POI_BORDER_MASK
+  mask = mask or "Interface\\Minimap\\UI-Minimap-Background"
   region:SetMask(nil)
   region:SetTexture(file)
   region:SetMask(mask)
@@ -242,7 +251,7 @@
 
   local questID = self:GetID()
   local questTitle, rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality, _
-  local hasUpdate, isPending = (self.hasUpdate or self.isNew), self.isPending
+  local hasUpdate, isPending = (self.isStale or self.isNew), self.isPending
 
 
   if not HaveQuestData(questID) then
@@ -317,7 +326,7 @@
     self.title = questTitle or "|cFFFF0000Retrieving..."
     self.itemTexture = rewardIcon or self.itemTexture
     self.itemName = rewardName or self.itemName
-    self.hasUpdate = hasUpdate
+    self.isStale = hasUpdate
     self.isPending = isPending
 
 
@@ -338,14 +347,14 @@
 function WorldPlanPOIMixin:ShowNew()
   self:SetShown(true)
   self.isNew = nil
-  self.hasUpdate = true
+  self.isStale = true
   self.FadeIn:Play()
 end
 
 function WorldPlanPOIMixin:OnShow ()
-  qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow() update:', self.hasUpdate, 'new:', self.isNew, 'animation:', self.isAnimating)
+  qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow() update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
   -- pop this on principle
-  if self.hasUpdate then
+  if self.isStale then
     self:Refresh()
   end
 
@@ -355,7 +364,7 @@
 end
 
 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight)
-  qprint('  |cFF00FF00'..self:GetName()..':SetAnchor()|r', self.questID, mapID, mapWidth)
+  --qprint('  |cFF00FF00'..self:GetName()..':SetAnchor()|r', self.questID, mapID, mapWidth)
   self:ClearAllPoints()
   local dX, dY = TQ_GetQuestLocation(self.questID)
   if not dX or dX == 0 then
@@ -388,7 +397,7 @@
 
 function WorldPlanPOIMixin:OnEvent(event, ...)
   if event == 'SUPER_TRACKED_QUEST_CHANGED' then
-    self.hasUpdate = true
+    self.isStale = true
   end
 end
 
@@ -397,8 +406,8 @@
 local TOP_PIN_ID
 function WorldPlanPOIMixin:OnUpdate (sinceLast)
 
-  if self.hasUpdate then
-    wqprint('|cFFFFFF00push poi update')
+  if self.isStale then
+    print('|cFFFFFF00push poi update')
     self:Refresh()
     return
   end
@@ -457,7 +466,6 @@
 
 function WorldPlanPOIMixin:Refresh ()
   local db = WorldPlan.db
-  local print = wqprint
   print('|cFF00FF88'..self:GetName()..'|r:Refresh()')
 
 
@@ -492,10 +500,10 @@
 
     if self.hasNumeric then
       if subStyle.numberFontObject then
-        wqprint('change font', _G[subStyle.numberFontObject]:GetName())
+        --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
         self.count:SetFontObject(_G[subStyle.numberFontObject])
       end
-      wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
+      --wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
 
       self.count:SetShown(self.showNumber)
       self.count:SetText(self.itemNumber)
@@ -540,36 +548,103 @@
 
 
   self:UpdateSize()
-  self.hasUpdate = nil
+  self.isStale = nil
 end
 
-function WorldPlanFilterPinMixin:OnEnter ()
-  local filter = WorldPlan.FilterOptions[self:GetID()]
-  local mapID = GetCurrentMapAreaID()
-  local quests = (mapID == WorldPlan.BrokenIsleID) and WorldPlan.QuestsByID or WorldPlan.QuestsByZone[mapID]
-  if quests then
-    GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
-    GameTooltip:AddLine(filter.label)
-    local filterKey = self.filterKey
-    local filterValue = self.filterValue
-    if filterKey then
-      for questID, pin in pairs(quests) do
-        if pin.used and not pin.filtered then
-          if  pin[filterKey] == filterValue then
-            local style = pin.style or WorldPlan.FilterStyle
 
-            if familiars[questID] then
-              GameTooltip:AddLine(pin.title,0,1,0)
-            else
-              GameTooltip:AddLine(pin.title,1,1,1)
-            end
 
-          end
-        end
-      end
-    else
-      GameTooltip:AddLine('Reset all filters')
+
+function QuestPOI:IsShowable ()
+  local print = wqprint
+  local db = WorldPlan.db
+  local qType = self.worldQuestType
+  local rType = self.rewardType
+  self.filtered = nil
+  self.used = true
+
+
+  self.questId  = self:GetID()
+  if not (WorldMap_DoesWorldQuestInfoPassFilters(self, false, true)) then
+    self.filtered = true
+  end
+
+  for filterKey, value in pairs(WorldPlan.UsedFilters) do
+    if self[filterKey] ~= value then
+      self.filtered = true
     end
-    GameTooltip:Show()
   end
+
+  if not TQ_IsActive(self.questID) then
+    self.used = nil
+  elseif qType == LE_QUEST_TAG_TYPE_PROFESSION then
+    if not (db.ShowAllProfessionQuests or (self.tradeskillLineIndex and GetProfessionInfo(self.tradeskillLineIndex))) then
+      self.used = nil
+    end
+  end
+  print('  |cFFFF4400IsShowable()|r', self.used, self.filtered, self.title)
+  return self.used, self.filtered
+end
+
+function QuestPOI:UpdateTimer (timeLeft, timeType)
+  print('|cFF0088FFUpdatePinTimer()|r')
+end
+
+--- Fixes icons upon size update
+function QuestPOI:UpdateSize (style, subStyle)
+  style = style or self.style
+  subStyle = subStyle or self.subStyle
+
+  --qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle)
+
+  self.currentWidth = subStyle.PinSize
+  self.borderSize = subStyle.Border
+  self.trackingBorderSize = subStyle.TrackingBorder
+  self.tagSize = subStyle.TagSize
+  self.TimeleftStage = subStyle.TimeleftStage
+  self.NoIcon = subStyle.NoIcon
+
+
+  self:SetSize(self.currentWidth, self.currentWidth)
+
+  local icon = self.icon
+  local iconBorder = self.iconBorder
+  local trackingBorder = self.supertrackBorder
+  local tag = self.tagIcon
+  local pinMask = style.pinMask
+  local rewardMask = style.rewardMask
+
+  if self.NoIcon then
+    self.icon:Hide()
+  else
+    self.icon:Show()
+    icon:SetMask(nil)
+    icon:SetMask(rewardMask)
+    icon:SetTexture(self.icon:GetTexture())
+  end
+  iconBorder:SetMask(nil)
+  trackingBorder:SetMask(nil)
+
+
+  local borderWidth = self.borderSize
+  local trackingWidth = self.trackingBorderSize
+
+  iconBorder:ClearAllPoints()
+  iconBorder:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', -borderWidth + (style.x or 0), -borderWidth + (style.y or 0))
+  iconBorder:SetPoint('TOPRIGHT', self, 'TOPRIGHT', borderWidth + (style.x or 0), borderWidth + (style.y or 0))
+
+  trackingBorder:ClearAllPoints()
+  trackingBorder:SetPoint('BOTTOMLEFT', iconBorder, 'BOTTOMLEFT', -trackingWidth, -trackingWidth)
+  trackingBorder:SetPoint('TOPRIGHT', iconBorder, 'TOPRIGHT', trackingWidth, trackingWidth)
+
+  if self.tagSize then
+    tag:Show()
+    tag:ClearAllPoints()
+    tag:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', borderWidth, -borderWidth)
+  else
+    tag:Hide()
+  end
+
+  --qprint('using mask:', mask, self.name )
+  iconBorder:SetMask(pinMask)
+  trackingBorder:SetMask(pinMask)
 end
\ No newline at end of file