diff ObjectiveTracker/DefaultTracker.lua @ 38:1f8f9cc3d956

- module integration brought up to speed with current frame management structure
author Nenue
date Thu, 21 Apr 2016 11:36:41 -0400
parents e84d645c8ab8
children 92534dc793f2
line wrap: on
line diff
--- a/ObjectiveTracker/DefaultTracker.lua	Mon Apr 18 07:56:23 2016 -0400
+++ b/ObjectiveTracker/DefaultTracker.lua	Thu Apr 21 11:36:41 2016 -0400
@@ -5,6 +5,7 @@
 -- Created: 4/17/2016 7:33 AM
 local B = select(2,...).frame
 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
+local Devian = Devian
 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove
 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
@@ -34,28 +35,30 @@
 local currentPosition, anchorFrame, anchorPoint
 --- Positioning and stuff
 local tick = 0
-local firstUpdate = true
+local initReason = OBJECTIVE_TRACKER_UPDATE_ALL
+local requiresInit
 function T:Update (reason, ...)
   if not B.Conf.VeneerObjectiveWrapper.enabled then
     return
   end
-
   tick = tick + 1
-  if firstUpdate or not reason then
-    reason = _G.OBJECTIVE_TRACKER_UPDATE_ALL
-  end
-
   local print = tprint
   local hasStuff = false
   local insertingStuff = false
 
+  if initReason then
+    reason = initReason
+    initReason = nil
+  elseif not reason then
+    reason = OBJECTIVE_TRACKER_UPDATE_ALL
+  end
   print(format('|cFFBB0066Update:|r |cFFFF%04X%d|r  ', tick, lshift(reason, 4)), reason, ...)
   currentPosition = 0
 
   for id, handler in pairs(T.orderedHandlers) do
     local frame = handler.frame
 
-
+    print('')
     if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then
       insertingStuff = handler:UpdateTracker(reason, ...)
     else
@@ -82,25 +85,21 @@
   end
   Quest.GetClosest()
   --T.UpdateActionButtons(reason)
-  if firstUpdate then
-    firstUpdate = nil
-  end
 end
 
 Default.UpdateTracker = function (handler, reason, id, isNew)
-  local print = tprint
+  local print = handler.print
   local frame = handler.frame
   local blockIndex = 0
-
-  print(format('  |cFFFF8800UpdateTracker|r(%s): %s', handler.name, reason))
+  print('UpdateTracker', handler.name, reason)
   handler.updateReason = reason
   local numWatched, numAll, watchTable = handler:GetNumWatched(id, isNew)
 
   if numWatched >= 1 then
     if watchTable then
-      print('|cFF00FF00      n     ID    Obj wID Log Blk')
+      print('    WatchList', ' n     ID    Obj wID Log Blk')
       for i, w in ipairs(watchTable) do
-        print(format('     %2d => %6d %3d %3d %3s %s', i, w.id, w.numObjectives, w.watchIndex, (w.logIndex or ''), (handler.InfoBlock[w.id] and handler.InfoBlock[w.id]:GetName() or '')))
+        print('    WatchList', format('%2d => %6d %3d %3d %3s %s', i, w.id, w.numObjectives, w.watchIndex, (w.logIndex or ''), (handler.InfoBlock[w.id] and handler.InfoBlock[w.id]:GetName() or '')))
       end
     end
   end
@@ -115,7 +114,7 @@
     if currentBlock then
       handler:AddBlock(currentBlock)
     else
-      print('    |cFFFF9900finished|r @', blockIndex)
+      print('    |cFF'..handler.internalColor..'finished|r @', blockIndex)
       break -- done with quest stuff
     end
   end
@@ -124,7 +123,8 @@
   local numBlocks = handler.numBlocks
   local used = handler.usedBlocks
   local free = handler.freeBlocks
-  print(format('    (%s): |cFFFF8800%04X|r --- blocks |cFFFF8800%d|r, (used/free: |cFFFF8800%d|r/|cFFFF8800%d|r)', handler.name, band(reason, handler.updateReasonModule + handler.updateReasonEvents, reason), numBlocks, #used, #free))
+  print(format('#### %s ## |cFFFF8800%04X|r --- blocks |cFFFF8800%d|r, (used/free: |cFFFF8800%d|r/|cFFFF8800%d|r)', handler.name, band(reason, handler.updateReasonModule + handler.updateReasonEvents, reason), numBlocks, #used, #free))
+
   return numWatched, numAll
 end
 
@@ -158,15 +158,13 @@
     handler.WatchBlock[info.watchIndex] = block
   end
   handler.BlockInfo[index] = info
-  handler:UpdateObjectives(block)
+  block.endPoint = block.titlebg
+  block.attachmentHeight = 0
+  block.currentLine = 0
+  handler:UpdateObjectives(block, block.schema)
 
   block.title:SetText(info.title)
 
-  print('           |cFFFFFF00height|r:', block.height)
-  print('  |cFF00FFFF)|r -> ', block, block:GetHeight())
-
-  block:Show()
-
   if info.specialItem and not info.itemButton then
     print('    - |cFF00FFFFgenerating item button for info set')
     info.itemButton = T.SetItemButton(block, info)
@@ -214,50 +212,27 @@
   if info.schema then
     block.schema = info.schema
   end
-
-  if info.statusKey and (Devian and Devian.InWorkspace()) then
-    block.debugText:SetText(tostring(info.statusKey) .. ' ' .. tostring(block.posIndex) .. ' '.. tostring(info.logIndex))
-    block.debugText:Show()
-  end
   return block
 end
 
-Default.UpdateObjectives = function(handler, block)
+Default.UpdateObjectives = function(handler, block, block_schema, displayObjectives)
   local print = lprint
-  local block_schema = block.schema
+  displayObjectives = displayObjectives or true
+  block_schema = block_schema or block.schema
   local info = block.info
   print('  |cFF00FF00default.objectives', block:GetName())
   -- reset the starting positions
-  block.endPoint = block.titlebg
-  block.attachmentHeight = 0
-  block.currentLine = 0
-
-  local displayObjectiveHeader = false
-
-  block.attachmentHeight = 0
   local text, attachment, template
 
 
-  if info.description and #info.description >= 1 then
-    print('   |cFF00FFFF  header line:|r', info.description)
-    text = info.description
-    handler:AddLine(block, text, nil)
-  end
-
-  if (info.isComplete or info.numObjectives == 0) and info.completionText then
-    print('     overriding line #1 for completion text:', info.completionText)
-    text = info.completionText
-    handler:AddLine(block, text, nil, 'completed')
-  else
-    if info.objectives then
-      for i, data in ipairs(info.objectives) do
+  if info.objectives and displayObjectives then
+    for i, data in ipairs(info.objectives) do
+      text, attachment, template = handler:UpdateLine(block, data)
+      if text or attachment then
         local line = handler:GetLine(block)
-        displayObjectiveHeader = true
         line.height = 0
-        text, attachment, template = handler:UpdateLine(block, line, data)
         print('  |cFF88FF00#', i, data.type, text, attachment)
         handler:AddLine(block, text, attachment, template)
-
       end
     end
   end
@@ -278,8 +253,8 @@
   return block_schema
 end
 
-Default.UpdateLine = function(handler, block, line, data)
-  return data.text, line.widget, 'normal'
+Default.UpdateLine = function(handler, block, data)
+  return block.info.description, nil, 'default'
 end
 
 Default.Select = function(handler, block)