diff WorldPlan.lua @ 27:4a7e89bffbcb r27-beta

- Order Hall resource rewards now show numerals in quest pins. - Fixed an occasional lua error that occurs when opening the quest map for the first time. - Fixed another source of textures losing their masks.
author Nenue
date Thu, 27 Oct 2016 06:18:16 -0400
parents 08b03bcdfeac
children c1612c2c1840
line wrap: on
line diff
--- a/WorldPlan.lua	Tue Oct 25 12:32:34 2016 -0400
+++ b/WorldPlan.lua	Thu Oct 27 06:18:16 2016 -0400
@@ -86,7 +86,8 @@
   r = 1, g = 1, b = 1,
   x = 0, y = 0,
   desaturated = true,
-  mask = POI_BORDER_MASK,
+  pinMask = POI_BORDER_MASK,
+  rewardMask = POI_BORDER_MASK,
   texture = POI_BORDER_FILL,
   continent = {
     PinSize = 18,
@@ -94,6 +95,7 @@
     TrackingBorder = 2,
     TagSize = 6,
     TimeleftStage = 3,
+    showNumber = true,
   },
   zone = {
     PinSize = 22,
@@ -101,6 +103,7 @@
     TrackingBorder = 2,
     TagSize = 12,
     TimeleftStage = 3,
+    showNumber = true,
   },
   minimized = {
     PinSize = 4,
@@ -108,6 +111,7 @@
     TrackingBorder = 2,
     NoIcon = true,
     TimeleftStage = 1,
+    showNumber = false,
   }
 }
 local POI_REWARD_TYPE =  setmetatable({}, {
@@ -138,13 +142,16 @@
 }
 POI_REWARD_TYPE[REWARD_ARTIFACT_POWER] = {
   r = 1, g = .25, b = .5,
-  showNumber = true,
+  hasNumeric = true,
+  numberRGB = {1, 1, 1},
 }
 POI_REWARD_TYPE[REWARD_GEAR] = {
   r = .1, g = .2, b = 1,
 }
 POI_REWARD_TYPE[REWARD_CURRENCY] = {
   r = 1, g = 1, b = 0,
+  hasNumeric = true,
+  numberRGB = {1, 1, 1},
 }
 POI_REWARD_TYPE[REWARD_CASH] = {
   r = 0, g = 0, b = 0,
@@ -160,7 +167,7 @@
   defaultPinStyle = POI_DEFAULT_TYPE,
   rewardStyle = POI_REWARD_TYPE,
   filterStyle = POI_FILTER_STYLE,
-  ShowAllProfessionQuests = true,
+  ShowAllProfessionQuests = false,
   DisplayContinentSummary = true,
   DisplayContinentPins = true,
   NotifyWhenNewQuests = true,
@@ -229,6 +236,7 @@
       end
     end)
   end
+  print('inserting task #', #tasksQueue+1, func)
   tinsert(tasksQueue, func)
 end
 
@@ -337,15 +345,24 @@
   self:RegisterEvent("SKILL_LINES_CHANGED")
   self:RegisterEvent("ARTIFACT_XP_UPDATE")
   self:RegisterEvent("ADDON_LOADED")
+  self:SetParent(WorldMapFrame)
 
   WorldPlan.modules = {
     WorldQuests, FilterBar, WorldPlanFlightMapMixin,
   }
 end
 
+function WorldPlan:OnShow()
+  print(self:GetName()..':OnShow()')
+  if self.isStale then
+    self:RefreshAll()
+  end
+
+end
+
 function WorldPlan:OnEvent (event, ...)
   print()
-  print(event, ...)
+  print(event, self.initialized)
   if event == 'ADDON_LOADED' then
     local addon = ...
     if addon == "Blizzard_FlightMap" then
@@ -359,11 +376,12 @@
   elseif event == 'WORLD_MAP_UPDATE' then
     self.currentMapID = GetCurrentMapAreaID()
     self:RefreshAll()
-  end
-  for i, module in ipairs(self.modules) do
-    if module.OnEvent then
-      print('forwarding to', tostring(module))
-      module:OnEvent(event, ...)
+  else
+    for i, module in ipairs(self.modules) do
+      if module.OnEvent then
+        print('forwarding to', tostring(module))
+        module:OnEvent(event, ...)
+      end
     end
   end
 end
@@ -526,7 +544,7 @@
 end
 
 function WorldQuests:OnEvent (event, ...)
-  print('|cFFFFFF00'..tostring(self)..':OnEvent()'..event..'|r', ...)
+  print('|cFFFFFF00'..tostring(self)..':OnEvent()'..event..'|r', GetTime(), ...)
   if event == 'QUEST_LOG_UPDATE' then
     local questID, added = ...
     if questID and added then
@@ -534,6 +552,11 @@
     else
       self:GetPinsForMap()
     end
+      print('WorldMapFrame', WorldMapFrame:IsVisible(), 'doRefresh:', hasNewQuestPins)
+    if WorldMapFrame:IsVisible() and hasNewQuestPins then
+      self:Refresh(true)
+    end
+
   elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
     local questID = ...
     if questID and QuestsByID[questID] then
@@ -645,16 +668,11 @@
       end
     end
   end
-  if hasNewQuestPins and not self.fullSearch then
-    print('|cFF00FF00NEW PINS DO ANCHOR THINGS')
-    self:Refresh (true)
-    hasNewQuestPins = nil
-  end
 end
 
 -- create or update the pin using the given questID and C_TaskQuest results
 function WorldQuests:GetPinByQuestID (questID, taskInfo)
-  if (QuestMapFrame_IsQuestWorldQuest (questID)) then
+
     local questTitle, rewardIcon, rewardName, rewardCount, rewardStyle, rewardType, itemID, quantity, quality, _
     local pin = self:AcquirePin(questID, taskInfo)
 
@@ -701,7 +719,6 @@
         QuestsByFaction[factionID] = QuestsByFaction[factionID] or {}
         QuestsByFaction[factionID][questID] = pin
       end
-      pin.title = questTitle or "|cFFFF0000Retrieving..."
       pin.factionID = factionID
       pin.capped = capped
 
@@ -728,7 +745,6 @@
       pin.tradeskillLineIndex = tradeskillLineIndex
       pin.rarity = rarity
       pin.tagAtlas = tagAtlas
-    end
 
     -- flag unresolved info
     if not (rewardIcon and rewardName) then
@@ -751,6 +767,8 @@
       end
       pin.isPending = nil
     end
+
+    pin.title = questTitle or "|cFFFF0000Retrieving..."
     pin.itemTexture = rewardIcon or pin.itemTexture
     pin.itemName = rewardName or pin.itemName
 
@@ -850,7 +868,6 @@
   for questID, pin in pairs(QuestsByID) do
     -- can we show it?
     if showQuestPOI and (pin.used) then
-      pin:Refresh()
 
       if fadeGrouped then
         pin:SetAlpha(0.25)
@@ -862,9 +879,7 @@
         if not pin.isAnimating then
           pin.isAnimating = true
           OnNext(function()
-            pin.isNew = nil
-            pin:Show()
-            pin.FadeIn:Play()
+            pin:ShowNew()
           end)
           if not notifyPlayed then
             for k,v in pairs(NotificationTypes) do
@@ -883,7 +898,8 @@
       else
         -- hard show existing pin
         print('refresh #', questID, 'filtered:', pin.filtered)
-        pin:Show()
+        pin.hasUpdate = true
+        pin:Show(true)
         tinsert(debug_show,questID)
       end
     else
@@ -996,11 +1012,10 @@
 --- Fixes icons upon size update
 function QuestPOI:UpdateSize (style, subStyle)
   self.style = self.style or POI_DEFAULT_TYPE
-  self.subStyle = self.subStyle or 'continent'
+  style = style or self.style
+  subStyle = subStyle or self.subStyle
 
-  style = style or self.style
-  subStyle = style[subStyle or self.subStyle]
-
+  qprint('|cFF00FF88'..self:GetName()..'|r:UpdateSize()', style, subStyle)
 
   self.currentWidth = subStyle.PinSize
   self.borderSize = subStyle.Border
@@ -1009,17 +1024,26 @@
   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 style = self.style or POI_DEFAULT_TYPE
-  local mask = style.mask or POI_BORDER_FILL
+  local pinMask = style.pinMask
+  local rewardMask = style.rewardMask
 
-  self.icon:SetMask(nil)
-  self.iconBorder:SetMask(nil)
-  self.supertrackBorder:SetMask(nil)
+  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
@@ -1042,16 +1066,9 @@
   end
 
   --qprint('using mask:', mask, self.name )
-  self.icon:SetMask(mask)
-  self.icon:SetTexture(self.icon:GetTexture())
-  self.iconBorder:SetMask(mask)
-  self.supertrackBorder:SetMask(mask)
+  iconBorder:SetMask(pinMask)
+  trackingBorder:SetMask(pinMask)
 
-  if self.NoIcon then
-    self.icon:Hide()
-  else
-    self.icon:Show()
-  end
 
 end
 
@@ -1236,6 +1253,8 @@
   self:SetFrameStrata('HIGH')
   self:SetFrameLevel(151)
   self:SetScript('OnUpdate', nil)
+  self.style = db.filterStyle
+  self.subStyle = db.defaultPinStyle.continent
 end
 
 function FilterPin:OnUpdate ()