diff ObjectiveTracker/Achievements.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 03ed70f846de
line wrap: on
line diff
--- a/ObjectiveTracker/Achievements.lua	Mon Apr 18 07:56:23 2016 -0400
+++ b/ObjectiveTracker/Achievements.lua	Thu Apr 21 11:36:41 2016 -0400
@@ -18,14 +18,14 @@
 Cheevs.GetNumWatched = function(self, targetID, isNew)
   local trackedList = {GetTrackedAchievements() }
   local numWatched, numAll = #trackedList, #self.WatchList
-  print('    |cFF00FF88GetNumWatched:|r',self.name, numWatched, ' ('..numAll..' recorded)')
+  print('    |cFF'..self.internalColor..'GetNumWatched:|r',self.name, numWatched, ' ('..numAll..' recorded)')
   local start = 1
   local limit = max(numAll, #trackedList)
   if targetID then
     if not isNew and self.Info[targetID] then
       -- if it's only an update, we can limit the scope
       start = self.Info[targetID].watchIndex
-      print('    |cFF0088FFGetNumWatched: limit selection to['..start..'-'..limit..']')
+      print('    |cFF'..self.internalColor..'GetNumWatched: limit selection to['..start..'-'..limit..']')
       if self.InfoBlock[targetID] then
         self.InfoBlock[targetID]:Hide()
       end
@@ -42,7 +42,7 @@
       if not self.Info[cheevID] then
         self.Info[cheevID] = self:GetInfo(cheevID, index)
       else
-        print('    |cFF00FFBBGetInfo:', cheevID, 'already pulled')
+        print('    |cFF'..self.internalColor..'GetInfo:', cheevID, 'already pulled')
       end
       self:GetObjectives(cheevID)
 
@@ -62,7 +62,7 @@
   local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
   if not id then return nil end
 
-  print('      |cFF44AAFFGetInfo: pulling', id..',', name, earnedBy)
+  print('      |cFF'..self.internalColor..'GetInfo: pulling', id..',', name, earnedBy)
 
 
   self.Info[cheevID] = self.Info[cheevID] or {}
@@ -118,47 +118,49 @@
     line.criteriaID = criteriaID
     c.objectives[i] = line
 
-    print('        |cFF44FFDDGetObjectives:|r', i, type, description, quantityString)
+    print('        |cFF'..self.internalColor..'GetObjectives:|r', i, format('|cFF0088FF%02X|r(%d)', type, type), format('|cFF88FF00%01X|r', flags or 0), '|cFF00FF00'..tostring(quantity)..'|r/|cFF00FF00'.. tostring(requiredQuantity)..'|r', '"|cFF88FF00'..tostring(description)..'|r"')
   end
 end
 
---- Content handlers
-Cheevs.UpdateLine = function(handler, block, line, data)
-  local print = B.print('CheevsLine')
+Cheevs.UpdateObjectives = function(handler, block, block_schema)
+  Default.UpdateObjectives(handler, block, block_schema)
+  return block_schema
+end
+
+--- assemble line info
+Cheevs.UpdateLine = function(handler, block, data)
+  local print = lprint
   local attachment
   local text
-  line.progress = 0
-  print('  ', data.objectiveIndex,'|cFF0088FF-|r', data.objectiveType, data.text)
-  if data.flags then
-    if band(data.flags, 0x00000001) > 0 then
-      line.format = "%d/%d"
-      attachment = T.SetWidget(line, data, 'ProgressBar', data.criteriaID)
-      attachment.value = data.value
-      attachment.maxValue = data.maxValue
-      attachment:SetParent(handler.frame)
+  local lineSchema = 'default'
+  print('  ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text)
+  if data.type == CRITERIA_TYPE_ACHIEVEMENT then
+    if data.value == 1 then
+      return nil, nil
+    end
 
-      print(attachment:GetNumPoints())
-      for i = 1, attachment:GetNumPoints() do
-        print('  ',attachment:GetPoint(i))
-      end
-      attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue)
-      attachment:SetPoint('TOP', line, 'TOP')
-      line.height = attachment.height
-    elseif band(data.flags, 0x00000002) then
-      line.widget = nil
-      text = line.text
-    else
-      line.widget = nil
-      line.displayColor = 'FFFFFF'
-      text = line.text
+    text = data.text
+    lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement'
+  elseif band(data.flags, 0x00000001) > 0 then
+    attachment = T.GetWidget(data, 'StatusBar', data.criteriaID)
+    attachment.format = "%d/%d"
+    attachment.value = data.value
+    attachment.maxValue = data.maxValue
+    attachment:SetParent(block)
 
+    print(attachment:GetNumPoints())
+    for i = 1, attachment:GetNumPoints() do
+      print('  ',attachment:GetPoint(i))
     end
+    attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue)
+    attachment:SetPoint('TOP', line, 'TOP')
+    lineSchema = 'progressbar'
   else
-
-    line.displayText = data.text
+    text = data.quantityString .. ' ' .. data.text
+    lineSchema = 'default'
   end
-  print('  |cFF00DD22UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID)
-  return text, attachment, 'default'
+  print('  |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID)
+  return text, attachment, lineSchema
 end
 
 Cheevs.Select = function(self, block)