diff ObjectiveTracker/DefaultTracker.lua @ 40:03ed70f846de

- move block accessors into a new file - define a tMove function for reconciling the free/used tables as needed - when retrieving an old block frame, confirm ID still matches; resolves multiple watch items on one block - stop any animations when a block is freed; resolves stuck flare graphics
author Nenue
date Sun, 24 Apr 2016 14:15:25 -0400
parents 92534dc793f2
children
line wrap: on
line diff
--- a/ObjectiveTracker/DefaultTracker.lua	Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/DefaultTracker.lua	Sun Apr 24 14:15:25 2016 -0400
@@ -70,12 +70,12 @@
       hasStuff = true
       currentPosition = currentPosition + 1
       Default.AddTracker(handler, frame, currentPosition)
-
+      frame.wasEmpty = nil
     else
-      frame:ClearAllPoints()
-      frame:SetPoint('BOTTOM', Scroll, 'BOTTOM', 0, 0)
       frame.destinationOffset = 0
-      frame:Hide()
+      if not frame.wasEmpty and  not frame.fadeOut:IsPlaying() then
+        frame.fadeOut:Play()
+      end
       frame.wasEmpty = true
     end
   end
@@ -92,7 +92,7 @@
   local print = handler.print
   local frame = handler.frame
   local blockIndex = 0
-  print('UpdateTracker', handler.name, reason)
+  print('MODULE:'..handler.name, 'message:', reason, 'id:', id, (isNew and '|cFF88FF88' or '|cFF555555')..'isNew|r')
   handler.updateReason = reason
   local numWatched, numAll, watchTable = handler:GetNumWatched(id, isNew)
 
@@ -120,7 +120,6 @@
     end
   end
 
-
   local numBlocks = handler.numBlocks
   local used = handler.usedBlocks
   local free = handler.freeBlocks
@@ -146,23 +145,25 @@
   block.info = info
 
   info.blockIndex = index
+  local keyInfo
   if info.id then
-    print('  storing id', info.id, 'for', block:GetName())
+    keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'InfoBlock[' .. info.id .. '] = *' .. block:GetName():gsub('%D', '')
     handler.InfoBlock[info.id] = block
   end
   if info.logIndex then
-    print('  storing logIndex', info.logIndex, 'for', block:GetName())
+    keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'LogBlock[' .. info.logIndex .. '] = ' .. block:GetName():gsub('%D', '')
     handler.LogBlock[info.logIndex] = block
   end
   if info.watchIndex then
-    print('  storing watchIndex', info.watchIndex, 'for', block:GetName())
+    keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'WatchBlock[' .. info.watchIndex .. '] = ' .. block:GetName():gsub('%D', '')
     handler.WatchBlock[info.watchIndex] = block
   end
+  if keyInfo then print('    assigned', keyInfo) end
   handler.BlockInfo[index] = info
   block.endPoint = block.titlebg
   block.attachmentHeight = 0
   block.currentLine = 0
-  handler:UpdateObjectives(block, block.schema)
+  local attachments, override_schema = handler:UpdateObjectives(block, block.schema)
 
   block.title:SetText(info.title)
 
@@ -175,28 +176,6 @@
 
   local tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
 
-  local numCurrency = 0
-  for i, rewardTile in ipairs(block.rewardTile) do
-    if info.rewardInfo and info.rewardInfo[i] then
-      local reward = info.rewardInfo[i]
-      --rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
-      rewardTile:SetTexture(reward.texture)
-      rewardTile:Show()
-
-      print('updating reward tile #'.. i, reward.type, reward.count, reward.text, reward.texture)
-      if reward.count and reward.count > 1 then
-        block.rewardLabel[i]:SetText(reward.count)
-        block.rewardLabel[i]:Show()
-      end
-
-      rewardTile:ClearAllPoints()
-      rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, x, y)
-      tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', rewardTile, 'TOPLEFT', -2, 0
-    else
-      rewardTile:Hide()
-      block.rewardLabel[i]:Hide()
-    end
-  end
 
   if info.selected then
     block.SelectionOverlay:Show()
@@ -224,7 +203,7 @@
   print('  |cFF00FF00default.objectives', block:GetName())
   -- reset the starting positions
   local text, attachment, template
-
+  local numAttachments = 0
 
   if info.objectives and displayObjectives then
     for i, data in ipairs(info.objectives) do
@@ -235,6 +214,9 @@
         print('  |cFF88FF00#', i, data.type, text, attachment)
         handler:AddLine(block, text, attachment, template)
       end
+      if attachment then
+        numAttachments = numAttachments + 1
+      end
     end
   end
 
@@ -251,7 +233,7 @@
     block.attachmentHeight = block.attachmentHeight
     print('   |cFF00FF00attachment:', block.attachmentHeight)
   end
-  return block_schema
+  return numAttachments, block_schema
 end
 
 Default.UpdateLine = function(handler, block, data)