changeset 74:2ba11b25aa7f

flight map data handler adjustments
author Nenue
date Sat, 08 Apr 2017 17:07:58 -0400
parents 25f7dbc20a72
children 78d78dc77822
files FlightMap.lua FlightMap.xml QuestPOI.lua WorldQuests.lua
diffstat 4 files changed, 115 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/FlightMap.lua	Fri Apr 07 07:20:28 2017 -0400
+++ b/FlightMap.lua	Sat Apr 08 17:07:58 2017 -0400
@@ -52,6 +52,7 @@
   self.ticker = nil;
 end
 
+
 function WorldPlanDataProvider:OnAdded(mapCanvas)
   self.activePins = {};
   self.owningMap = mapCanvas
@@ -102,8 +103,6 @@
                 local frame = self.activePins[info.questId]
                 if not frame then
                   frame = self:GetMap():AcquirePin("WorldPlanFlightPin")
-                  print(alpha1, alpha2, alpha3)
-                  print(scale1, scale2, scale3)
                   frame:SetAlphaLimits(alpha1, alpha2, alpha3)
                   frame:SetScalingLimits(scale1, scale2, scale3);
                   frame:SetFrameLevel(1000 + self:GetMap():GetNumActivePinsByTemplate("WorldPlanFlightPin"));
@@ -113,13 +112,10 @@
                 frame:SetPosition(info.x, info.y)
                 frame.pin = pin
 
-                -- sticking it onto the MapCanvas pin
-                pin:SetAnchor(frame, nil, nil, nil, nil, pin.filtered and 0.5 or 1)
+                -- fix the scale
+                pin:SetAnchor(frame, nil, nil, nil, nil, 1)
                 pin.owningFrame = frame:GetMap()
                 pin.throttle = 1
-                pin.isStale = true
-
-                pin:CheckFilterRules()
                 pin:ClearAllPoints()
                 pin:SetPoint('CENTER', frame, 'CENTER')
                 --print(pin.Overlay:IsShown(), pin.Overlay:GetPoint(1))
@@ -159,6 +155,18 @@
   self:SetNudgeZoomedInFactor(0.25);
 end
 
+function WorldPlanDataPinMixin:OnUpdate()
+  local pin = self.pin
+  if pin and pin.isStale then
+    print(pin.questID, 'is stale')
+    pin:SetAnchor(nil, nil, nil, nil, nil, pin.filtered and 0.5 or 1)
+    if pin.isNew then
+      pin:OnShow()
+    end
+  end
+end
+
+
 function WorldPlanDataPinMixin:OnShow()
 end
 
--- a/FlightMap.xml	Fri Apr 07 07:20:28 2017 -0400
+++ b/FlightMap.xml	Sat Apr 08 17:07:58 2017 -0400
@@ -13,6 +13,9 @@
   </Frame>
 
   <Frame name="WorldPlanFlightPin" mixin="WorldPlanDataPinMixin" hidden="true" flattenRenderLayers="true" frameStrata="MEDIUM" enableMouse="false" enableMouseMotion="true" virtual="true">
+    <Scripts>
+      <OnUpdate method="OnUpdate" />
+    </Scripts>
     <Size x="50" y="50"/>
   </Frame>
 </Ui>
\ No newline at end of file
--- 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
--- a/WorldQuests.lua	Fri Apr 07 07:20:28 2017 -0400
+++ b/WorldQuests.lua	Sat Apr 08 17:07:58 2017 -0400
@@ -229,8 +229,7 @@
     local questID = ...
     self:UpdateBounties(event)
     if questID and db.QuestsByID[questID] then
-      self:ReleasePin(db.QuestsByID[questID])
-      rprint('|cFFFF4400release|r', questID)
+      db.QuestsByID[questID].complete = true
     end
     self:Refresh(event)
   elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then
@@ -361,7 +360,7 @@
     if info.x and info.y then
       pin.x = info.x or pin.x
       pin.y = info.y or pin.y
-      rprint('|cFFFF4400coords|r', info.x, info.y)
+      --rprint('|cFFFF4400coords|r', info.x, info.y)
     end
   end
 
@@ -513,7 +512,7 @@
 
   if self:IsVisible() then
     print('|cFF00FFFFRefreshIfChanged()|r', refreshReason)
-    self:Refresh()
+    self:Refresh('WORLDMAP_QUEUED')
   else
     rprint('|cFF00FFFFRefreshIfChanged()|r flagging for later refresh', refreshReason)
     self.isStale = true
@@ -537,49 +536,33 @@
     return
   end
 
+
+  local doUpdate = pin:GetCriteriaState() or pin.isStale
   --print('  |- ', pin.questID, pin.title)
   rprint('|cFF00FF00update|r', pin.questID, pin.title)
+
+  print(doUpdate)
+
   if x and y then
     local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1]
     pin:SetFrameLevel(PinBaseIndex+pin:GetID())
     pin.owningFrame = WorldMapFrame
     pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor)
+    doUpdate = true
     --tinsert(self.UsedPositions, pin)
   end
 
-  local isCriteria, isBounty
-  if pin.factionID then
-    if db.BountiesByFactionID[pin.factionID] then
-      isCriteria = true
-    end
-    if selectedBountyQuestID then
-      isBounty = IsQuestCriteriaForBounty(pin.questID, selectedBountyQuestID) and true or nil
-    end
-  end
-
-  local isSpellTarget
-  if canTargetQuests then
-    isSpellTarget = IsQuestIDValidSpellTarget(pin.questID)
-  end
-
-  if (pin.isBounty ~= isBounty) or (pin.isCriteria ~= isCriteria) or (pin.isSpellTarget ~= isSpellTarget) then
-    pin.isSpellTarget = isSpellTarget
-    pin.isBounty = isBounty
-    pin.isCriteria = isCriteria
+  if doUpdate then
+    print(' changed', pin.title, pin.isCriteria, pin.isBounty, pin.scaleFactor)
     if pin:IsVisible() then
-      --print(' changed', pin.title)
       --numUpdated = numUpdated + 1
-      pin:Refresh('BOUNTY_UPDATE')
+      pin:Refresh('WORLDMAP_REFRESH')
     else
       --numHidden = numHidden + 1
       pin.isStale = true
     end
   end
 
-  if self:IsVisible() and (pin.isStale) then
-    pin:Refresh()
-  end
-
   if mapID then
     if not db.QuestsByZone[mapID] then
       db.QuestsByZone[mapID] = {}
@@ -600,9 +583,13 @@
 function Module:UpdateAnchors ()
   wipe(self.UsedPositions)
   print('  |cFF00FF00'..self:GetName()..':UpdateAnchors()')
-  self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize()
-  self.nudgeThrescholdX = 16/self.hostWidth
-  self.nudgeThrescholdY = 16/self.hostHeight
+  local hostWidth, hostHeight = WorldMapPOIFrame:GetSize()
+
+  if (hostWidth ~= self.hostWidth) or (hostHeight ~= self.hostHeight) then
+    self.hostWidth, self.hostHeight = hostWidth, hostHeight
+    layoutDirty = true
+  end
+
 
   rprint('|cFF00FF00'..self:GetName()..':UpdateAnchors()')
   local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo()