diff QuestPOI.lua @ 74:2ba11b25aa7f

flight map data handler adjustments
author Nenue
date Sat, 08 Apr 2017 17:07:58 -0400
parents 25f7dbc20a72
children 78d78dc77822
line wrap: on
line diff
--- a/QuestPOI.lua	Fri Apr 07 07:20:28 2017 -0400
+++ b/QuestPOI.lua	Sat Apr 08 17:07:58 2017 -0400
@@ -103,12 +103,10 @@
 }
 local REWARD_TYPE_STYLES = {
   [REWARD_CASH] = {
-    border = {1,1,0},
     hideNumber = true,
   },
   [REWARD_ARTIFACT_POWER] = {},
   [REWARD_GEAR] = {
-
     hideNumber = true,
   },
   [REWARD_CURRENCY] = {
@@ -119,6 +117,8 @@
     hideNumber = true,
   },
 }
+local BORDER_SELECTED_BOUNTY = {1, 1, 0, 1 }
+local BORDER_CRITERIA = {.25, .5, 1, 1}
 
 local LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS = LE_ITEM_CLASS_WEAPON, LE_ITEM_CLASS_ARMOR, LE_ITEM_CLASS_GEM, LE_ITEM_GEM_ARTIFACTRELIC, LE_ITEM_CLASS_TRADEGOODS
 
@@ -491,7 +491,7 @@
               for i = 1, WorldPlanTooltip:NumLines() do
                 local line = _G['WorldPlanTooltipTextLeft' .. i]
                 local text = line and line:GetText()
-                local ap = text and text:gsub(',', ''):match('(%d+) '..ARTIFACT_POWER)
+                local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('(%d+) '..ARTIFACT_POWER)
                 if ap then
                   rewardCount = tonumber(ap)
                   print(ap)
@@ -576,7 +576,7 @@
     qprint('|cFFFFFF00clearing new status')
     self:SetAlpha(0)
     if self.dataLoaded then
-      self:Refresh()
+      self:Refresh('POI_ISNEW')
       self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha)
       self.PendingFade.FadeIn:SetToAlpha(db.PinAlpha)
       self.PendingFade.FadeOut:SetFromAlpha(db.PinAlpha)
@@ -605,7 +605,7 @@
     end
     if self.isStale then
       print('|cFF00FF00refresh on show')
-      self:Refresh()
+      self:Refresh('POI_SCRIPT')
     end
   end
   self:ShowFrames()
@@ -633,41 +633,38 @@
   end
 
   if owner then
-    local prevOwner = self:GetParent()
-    if prevOwner ~= owner then
-      self.isStale = true
-    end
     self:SetParent(owner)
     self.Overlay:SetParent(owner)
+    self.isStale = true
   else
     owner = self:GetParent()
   end
 
-  self:ClearAllPoints()
   self:SetFrameLevel(pinBaseIndex + self:GetID())
   self.Overlay:SetFrameLevel(overlayBaseIndex + self:GetID())
 
-  local scaleChanged
-  if scaleFactor and (self.scaleFactor ~= scaleFactor) then
+
+  if scaleFactor then
     --print('scaleFactor')
     self:SetScale(scaleFactor)
     self.Overlay:SetScale(scaleFactor)
     self.scaleFactor = scaleFactor
-    scaleChanged = true
   end
 
-  if (dX and dY) then
-    if not (mapHeight and mapWidth) then
-      mapWidth, mapHeight = owner:GetSize()
-    end
+  mapWidth = mapWidth or owner:GetWidth()
+  mapHeight = mapHeight or owner:GetHeight()
+  dX = dX or self.x
+  dY = dY or self.y
+  --print(owner:GetName() or tostring(owner), self:GetName(), owner:GetScale(), scaleFactor)
+  if (self.x ~= dX) or (self.y ~= dY) or scaleFactor then
 
-    if (self.x ~= dY) or (self.y ~= dY) or scaleChanged then
-      self.x = dX
-      self.y = dY
-      local pX = (dX * mapWidth) * (1 / scaleFactor)
-      local pY = (-dY * mapHeight) * (1 / scaleFactor)
-      self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY)
-    end
+    self.x = dX
+    self.y = dY
+    local pX = (dX * mapWidth) * (1 / scaleFactor)
+    local pY = (-dY * mapHeight) * (1 / scaleFactor)
+    --print('to', pX, pY, self:GetScale())
+    self:ClearAllPoints()
+    self:SetPoint('CENTER', owner, 'TOPLEFT', pX, pY)
   end
 
 end
@@ -748,9 +745,8 @@
 
     local dataLoaded = self:GetData()
     if dataLoaded and not tContains(db.UpdatedPins, self) then
-
-      print('|cFF00FF88'..self:GetID()..':|r delayed reward info, queueing for update')
       self.PendingFade:Stop()
+      -- scale info from the parent module is needed, so deal with it there
       tinsert(db.UpdatedPins, self)
     end
     return
@@ -762,6 +758,40 @@
 
 end
 
+function QuestPOI:GetCriteriaState()
+  local isCriteria, isBounty, isSpellTarget
+  if self.factionID then
+
+    local bounties = db.BountiesByFactionID
+    if bounties then
+      for factionID, bounty in pairs(bounties) do
+
+        if IsQuestCriteriaForBounty(self.questID, bounty.questID) then
+          isCriteria = true
+          if db.selectedBounty == bounty then
+            isBounty = true
+          end
+          print('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty)
+        end
+      end
+
+
+      print('|cFFFF4400Criteria:|r', self.questID, self.isCriteria, self.isBounty)
+
+    end
+  end
+  isSpellTarget = IsQuestIDValidSpellTarget(self.questID)
+
+  if (self.isBounty ~= isBounty) or (self.isCriteria ~= isCriteria) or (self.isSpellTarget ~= isSpellTarget) then
+
+    self.isBounty = isBounty
+    self.isCriteria = isCriteria
+    self.isSpellTarget = isSpellTarget
+    return true
+  end
+
+end
+
 -- Called at static intervals and with Refresh
 function QuestPOI:UpdateStatus()
   -- update time elements
@@ -779,14 +809,12 @@
       end
     end
 
+    local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder
+
     if tl and (timeLeft < 120) then
-      self.HighlightBorder:SetVertexColor(1,0,0,0.7)
-    elseif self.isBounty then
-      self.HighlightBorder:SetVertexColor(1,1,0,1)
-    elseif self.isCriteria then
-      self.HighlightBorder:SetVertexColor(.25,.5,1,1)
+      border:SetVertexColor(1,0,0,0.7)
     else
-      self.HighlightBorder:SetVertexColor(0,0,0,0.7)
+      border:SetVertexColor(0,0,0,0.7)
     end
     self.alertLevel = tl
     self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1))
@@ -798,9 +826,9 @@
 end
 
 
-function QuestPOI:Refresh ()
+function QuestPOI:Refresh (event)
 
-  rprint('|cFF00FF88'..self:GetID()..'|r:Refresh() type =', self.rewardType, 'title =', self.title)
+  print('|cFF00FF88'..self:GetID()..'|r:Refresh()', event)
 
   local style = DEFAULT_STYLE
   if self.dataLoaded and not self.filtered then
@@ -829,6 +857,7 @@
   local tagIcon = self.tagIcon
   self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel
 
+
   if self.itemName then
     if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then
       local numberString = self.itemNumber
@@ -883,13 +912,13 @@
     icon:SetVertexColor(unpack(borderColor))
   end
   local borderMask = style.borderMask or DEFAULT_STYLE.borderMask
-  local borderSize = currentWidth + (borderWidth * 2)
+  local borderSize = currentWidth + (borderWidth * 2) + (self.isCriteria and 2 or 0)
 
 
   iconBorder:SetSize(borderSize, borderSize)
   iconBorder:SetMask(borderMask)
   iconBorder:SetTexture(PENDING_BORDER)
-  iconBorder:SetVertexColor(unpack(borderColor))
+
   iconBorder:SetDesaturated(true)
 
   local highlightSize = borderSize + (highlightWidth * 2)
@@ -912,6 +941,19 @@
   self:UpdateStatus()
   self.isStale = nil
 
+  if self.isBounty then
+    print('is bounty')
+    iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
+    trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY))
+  elseif self.isCriteria then
+    print('is criteria of a bounty')
+    iconBorder:SetVertexColor(trackingBorder:GetVertexColor())
+    trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA))
+  else
+
+    iconBorder:SetVertexColor(unpack(borderColor))
+    trackingBorder:SetVertexColor(1,1,1,1)
+  end
 
   if SpellCanTargetQuest() then
     if IsQuestIDValidSpellTarget(self.questID) then