diff QuestPOI.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 26dfa661daa7
children 78cf1f19856a
line wrap: on
line diff
--- a/QuestPOI.lua	Thu Nov 03 17:29:15 2016 -0400
+++ b/QuestPOI.lua	Fri Nov 04 01:40:39 2016 -0400
@@ -53,29 +53,29 @@
 
 local subStyles = {
   continent = {
-    PinSize = 14,
-    Border = 2,
-    TrackingBorder = 1,
+    iconWidth = 14,
+    borderWidth = 2,
+    highlightWidth = 1,
     TagSize = 6,
-    TimeleftStage = 0,
+    maxAlertLevel = 0,
     showNumber = false,
     numberFontObject = 'WorldPlanFont'
   },
   zone = {
-    PinSize = 22,
-    Border = 3,
-    TrackingBorder = 2,
+    iconWidth = 22,
+    borderWidth = 3,
+    highlightWidth = 2,
     TagSize = 12,
-    TimeleftStage = 3,
+    maxAlertLevel = 3,
     showNumber = true,
     numberFontObject = 'WorldPlanNumberFontThin'
   },
   minimized = {
-    PinSize = 4,
-    Border = 0,
-    TrackingBorder = 1,
+    iconWidth = 4,
+    borderWidth = 0,
+    highlightWidth = 1,
     NoIcon = true,
-    TimeleftStage = 1,
+    maxAlertLevel = 1,
     showNumber = false,
   }
 }
@@ -167,7 +167,10 @@
 end
 
 function WorldPlanPOIMixin:OnEnter()
-  WorldMap_HijackTooltip(self)
+  if not WorldMapFrame:IsVisible() then
+    WorldMap_HijackTooltip(self)
+  end
+
   local completed = select(4,GetAchievementInfo(familiars_id))
   if not completed then
     if self.worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE and familiars[self.questID] then
@@ -367,7 +370,6 @@
 end
 
 function WorldPlanPOIMixin:OnShow ()
-  qprint('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r update:', self.isStale, 'new:', self.isNew, 'animation:', self.isAnimating)
   -- pop this on principle
 
   if self.isNew or self.isStale then
@@ -377,12 +379,14 @@
 
   -- is it a new quest?
   if self.isNew then
-    print('|cFFFFFF00popping new pin handler')
+    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)
   end
 
+  self.Overlay:SetShown(true)
   --WorldPlan:print(self:GetAlpha())
 
 end
@@ -393,6 +397,7 @@
     self:SetAlpha(1)
   end
 
+  self.Overlay:SetShown(false)
 end
 
 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight)
@@ -423,8 +428,9 @@
 function WorldPlanPOIMixin:OnLoad()
   qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',WorldPlan.db)
   self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
-  self.style = WorldPlan.db.defaultPinStyle
-  self.subStyle = WorldPlan.db.defaultPinStyle.continent
+
+  self.count = self.Overlay.count
+  self.timeLabel = self.Overlay.timeLabel
 end
 
 function WorldPlanPOIMixin:OnEvent(event, ...)
@@ -450,7 +456,7 @@
     return
   end
   if self.isStale and not self.isAnimating then
-    print('|cFFFFFF00push poi update')
+    wprint('|cFFFFFF00push poi update')
     self:Refresh()
     return
   end
@@ -471,10 +477,10 @@
 
 
   -- update time elements
-  local tl = self.timeThreschold
+  local tl = self.alertLevel
   local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
   if timeLeft > 0 then
-    local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.TimeleftStage)
+    local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel)
     if tl ~= timeState then
       tl = timeState
       self.timeLabel:SetText(text)
@@ -488,7 +494,7 @@
       end
     end
   end
-  self.timeThreschold = tl
+  self.alertLevel = tl
 
   if self:IsMouseOver() then
     self.MouseGlow:Show()
@@ -506,81 +512,50 @@
 
 
   local questID = self:GetID()
-  local style,subStyle =  WorldPlanQuests:GetTypeInfo(self.rewardType)
-  if self.filtered then
-    subStyle = style.minimized
-  end
-  self.style = style
-  self.subStyle = subStyle
-
-
-  local borderMask = style.mask
-  local borderFill = style.texture
-  local iconBorder = self.iconBorder
+  local iconBorder = self.RewardBorder
+  local trackingBorder = self.HighlightBorder
   local icon = self.icon
   local count = self.count
 
-  self.hasNumeric = style.hasNumeric
-  self.numberRGB = style.numberRGB
-  self.showNumber = subStyle.showNumber
 
 
 
   --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName))
-  SetMaskedTexture(icon, self.itemTexture or ICON_UNKNOWN, borderMask)
-  icon:SetAllPoints(self)
+
+
 
   if self.itemName then
-
-
-    if self.hasNumeric then
-      if subStyle.numberFontObject then
-        --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
-        self.count:SetFontObject(_G[subStyle.numberFontObject])
-      end
       --wqprint('filtered:', self.filtered, 'showNumber:', self.showNumber)
 
-      self.count:SetShown(self.showNumber)
       self.count:SetText(self.itemNumber)
-      self.count:SetTextColor(unpack(self.numberRGB))
-    else
-      self.count:SetShown(false)
-      self.count:SetText(nil)
-    end
-
+  end
+  if self.itemTexture then
+    icon:SetTexture(self.itemTexture)
+    icon:SetMask("Interface\\Minimap\\UI-Minimap-Background")
   end
 
-  SetMaskedTexture(iconBorder, borderFill, borderMask)
   local border = self:GetTypeInfo(self.rewardType)
   iconBorder:SetVertexColor(border.r, border.g, border.b, border.a)
   iconBorder:SetDesaturated(true)
 
-  local trackingBorder = self.supertrackBorder
 
-  self.highlight:SetMask(nil)
   if questID == GetSuperTrackedQuestID() then
     trackingBorder:SetVertexColor(0,0,0,1)
   else
     trackingBorder:SetVertexColor(0,0,0,0.5)
   end
-  self.highlight:SetAllPoints(trackingBorder)
 
-  SetMaskedTexture(trackingBorder, borderFill, borderMask)
-  self.highlight:SetMask(borderMask)
-
-  local qType = self.worldQuestType
   self.tagIcon:SetAtlas(self.tagAtlas)
   self.tagIcon:SetTexCoord(0,1,0,1)
-
-
-  if self.isElite then
-    self.EliteBorder:Show()
-  else
-    self.EliteBorder:Hide()
-  end
+  self.EliteBorder:SetShown(self.isElite and not self.filtered)
   --qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '')
   --print('  - subStyle:', (self.filtered == true), self.subStyle)
 
+  self.Overlay:SetShown(self:IsShown())
+  self.Overlay:SetParent(self:GetParent())
+  self.Overlay:SetFrameLevel(self:GetFrameLevel()+200)
+  self.Overlay:SetAllPoints(self)
+
 
   self:UpdateSize()
 
@@ -598,24 +573,31 @@
 
 
 function QuestPOI:IsShowable ()
-  local print = wqprint
+  local print = qprint
   local db = WorldPlan.db
   local qType = self.worldQuestType
   local rType = self.rewardType
   self.filtered = nil
   self.used = true
 
+  for filterKey, value in pairs(WorldPlan.UsedFilters) do
+    print('|cFFFF4400', filterKey, self[filterKey])
+    if self[filterKey] ~= value then
+      self.filtered = true
+    end
+  end
 
   self.questId  = self:GetID()
   if self.rewardType then
-    if cvar_check[self.rewardType] and not GetCVarBool(cvar_check[self.rewardType]) then
-      self.filtered = true
-    end
-  else
-    for filterKey, value in pairs(WorldPlan.UsedFilters) do
-      if self[filterKey] ~= value then
+    if cvar_check[self.rewardType] then
+      if self.rewardType == REWARD_CASH then
+        print('##', cvar_check[self.rewardType], GetCVarBool(cvar_check[self.rewardType]))
+      end
+      if not GetCVarBool(cvar_check[self.rewardType]) then
         self.filtered = true
+
       end
+
     end
   end
 
@@ -626,7 +608,7 @@
       self.used = nil
     end
   end
-  print('  |cFFFF4400IsShowable()|r', self.isNew, self.isAnimating, self.used, self.filtered, self.title)
+  print('  |cFF'.. (((self.rewardType == REWARD_CASH) and 'FFFF00') or '0088FF') ..'IsShowable()|r ', cvar_check[self.rewardType], 'used:', self.used, 'filtered:', self.filtered, self.title)
   return self.used, self.filtered
 end
 
@@ -635,52 +617,46 @@
 end
 
 --- Fixes icons upon size update
-function QuestPOI:UpdateSize (style, subStyle)
-  style = style or self.style
-  subStyle = subStyle or self.subStyle
+function QuestPOI:UpdateSize ()
 
+  local style,subStyle =  self:GetTypeInfo(self.rewardType)
+  if self.filtered then
+    subStyle = style.minimized
+  end
   --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
+  local icon = self.icon
+  local iconBorder = self.RewardBorder
+  local trackingBorder = self.HighlightBorder
+  local tag = self.tagIcon
 
+  local iconWidth = subStyle.iconWidth
+  local borderWidth = iconWidth + (subStyle.borderWidth * 2)
+  local highlightWidth = borderWidth + (subStyle.highlightWidth * 2)
 
-  self:SetSize(self.currentWidth, self.currentWidth)
+  local iconTexture = self.itemTexture
 
-  local icon = self.icon
-  local iconBorder = self.iconBorder
-  local trackingBorder = self.supertrackBorder
-  local tag = self.tagIcon
-  local pinMask = style.pinMask
-  local rewardMask = style.rewardMask
+  self:SetSize(iconWidth, iconWidth)
+  icon:SetSize(iconWidth, iconWidth)
+  iconBorder:SetSize(borderWidth, borderWidth)
+  trackingBorder:SetSize(highlightWidth, highlightWidth)
 
-  if self.NoIcon then
-    self.icon:Hide()
-  else
-    self.icon:Show()
-    icon:SetMask(nil)
-    icon:SetMask(rewardMask)
-    icon:SetTexture(self.icon:GetTexture())
+
+  iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
+  trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0))
+
+
+  if style.hasNumeric then
+    self.count:SetTextColor(unpack(style.numberRGB))
+    if subStyle.numberFontObject then
+      --wqprint('change font', _G[subStyle.numberFontObject]:GetName())
+      self.count:SetFontObject(_G[subStyle.numberFontObject])
+    end
   end
-  iconBorder:SetMask(nil)
-  trackingBorder:SetMask(nil)
 
+  self.count:SetShown((subStyle.showNumber and self.itemNumber) and style.hasNumeric)
 
-  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()
@@ -689,9 +665,41 @@
     tag:Hide()
   end
 
-  qprint('using mask:', pinMask, self.name )
-  iconBorder:SetMask(pinMask)
-  trackingBorder:SetMask(pinMask)
+  if self.NoIcon then
+    self.icon:Hide()
+  else
+    self.icon:Show()
+    if style.rewardMask then
+      icon:SetMask(rewardMask)
+    else
+      icon:SetMask(iconTexture)
+    end
+    if style.pinMask then
+      iconBorder:Show()
+      trackingBorder:Show()
+      iconBorder:SetMask(pinMask)
+      trackingBorder:SetMask(pinMask)
+    else
+      iconBorder:Hide()
+      trackingBorder:Hide()
+    end
+  end
+
+
+  icon:SetTexture(iconTexture)
   iconBorder:SetTexture(iconBorder:GetTexture())
   trackingBorder:SetTexture(trackingBorder:GetTexture())
+  --]]
+  self.currentWidth = subStyle.iconWidth
+  self.borderWidth = subStyle.borderWidth
+  self.highlightWidth = subStyle.highlightWidth
+  self.tagSize = subStyle.TagSize
+  self.maxAlertLevel = subStyle.maxAlertLevel
+  self.NoIcon = subStyle.NoIcon
+  self.style = style
+  self.subStyle = subStyle
+  if self.rewardType == REWARD_CASH then
+  qprint('using mask:', pinMask or iconTexture, rewardMask or iconTexture, self.used, self.filtered)
+  end
+
 end
\ No newline at end of file