diff ObjectiveTracker/QuestData.lua @ 44:756e8aeb040b

- Default.lua - simplified the response to SuperTrackedQuestID changes - tag icons work again
author Nenue
date Mon, 25 Apr 2016 19:37:13 -0400
parents 9480bd904f4c
children dd1ae565f559
line wrap: on
line diff
--- a/ObjectiveTracker/QuestData.lua	Mon Apr 25 13:51:58 2016 -0400
+++ b/ObjectiveTracker/QuestData.lua	Mon Apr 25 19:37:13 2016 -0400
@@ -54,20 +54,14 @@
   end
   local completionText
   if info.isComplete then
-    if info.isAutoComplete then
-      local questID, popupType = GetAutoQuestPopUp(info.logIndex)
-      if popupType == 'COMPLETE' then
-        print('    :: auto-complete quest :: set the message')
-        self:AddLine(block, T.strings.CLICK_TO_COMPLETE, nil, 'complete')
-      end
-    else
-      if not completionText or info.completionText then
-        info.completionText = GetQuestLogCompletionText(info.logIndex)
-      end
+    if T.Conf.ShowCompletionText then
+      self:AddLine(block, info.completionText, nil, 'complete')
     end
-    self:AddLine(block, info.completionText, nil, 'complete')
-    displayObjectives = false
+    if not T.Conf.ShowObjectivesWhenComplete then
+      displayObjectives = false
+    end
     print('|cFF'..self.internalColor..'    :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"')
+    block_schema = 'complete'
   end
 
   Default.UpdateObjectives(self, block, block_schema, displayObjectives)
@@ -115,7 +109,6 @@
   local numAll = GetNumQuestLogEntries()
   local numWatched = GetNumQuestWatches()
   local bottomIndex = 1
-  print('GetNumWatched', self.name, numWatched, 'of', numAll)
   local start, limit = 1, numAll
 
   if id and not added then
@@ -126,6 +119,7 @@
   end
 
   numAnimating = 0
+  local numEntries = 0
   for logIndex = start, limit do
     local reason1, reason2 = '', ''
     local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex)
@@ -161,28 +155,34 @@
 
     -- add to watch index if: the questID is non-zero
     if questID ~= 0 then
-      self.Info[questID] = self:GetInfo(logIndex, watchIndex)
-      print('GetQuests', format('request info |cFF00FF00%2d|r |cFFFFFF00%6d|r |cFFFF4400%3s|r', logIndex, questID, tostring(watchIndex or '')))
+      self:GetInfo(logIndex, watchIndex)
+      print('GetQuests', format('request info |cFF00FF00%2d|r |cFFFFFF00%6d|r |cFFFF4400%3s|r |cFF00FFFF%3s|r', logIndex, questID, tostring(watchIndex or ''), numEntries))
     end
   end
 
+
+
   --- After GetInfo pass, look for any non-conformant blocks and deal with them
-  for _, block in pairs(blocksChecked) do
+  for index, block in ipairs(self.usedBlocks) do
+
     local logIndex = GetQuestLogIndexByID(block.info.questID, 'player')
+    print('GetNumWatched', '|cFFFF4400'.. index, (block and block:GetName() or '|cFFFF0000-|r'), logIndex or '|cFF444444-|r')
     -- animating blocks have been evaluated
     if not block.isAnimating then
       if not logIndex then
         self:ClearBlock(block)
+        print('GetNumWatched', 'trim dropped quest', block:GetName())
       elseif not IsQuestWatched(block.info.logIndex) then
         self:ClearBlock(block)
+        print('GetNumWatched', 'trim untracked quest', block:GetName())
       end
     end
-    blocksChecked[block] = nil
   end
 
   self.numWatched = numWatched
   self.numAll = numAll
 
+  print('GetNumWatched', 'RESULT', numWatched, 'of', numAll)
   return numWatched, numAll, self.WatchList
 end
 
@@ -192,13 +192,15 @@
 -- Manifest of line data to be displayed in relation to the tracked object
 Quest.GetInfo = function (self, logIndex, watchIndex)
   local print = iprint
+  print('')
   local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex)
   if ( not questID ) then
     tprint('GetNumWatched', logIndex, watchIndex, '|cFFFF2299no data|r')
-    return
+    return 0
   end
 
   Quest.Info[questID] = Quest.Info[questID] or {}
+  local numEntries = 0
   local q = Quest.Info[questID]
   q.questID = questID
   q.id = questID
@@ -208,22 +210,13 @@
   local numObjectives, requiredMoney, isAutoComplete, failureTime, timeElapsed, questType
    = 0, 0, nil, false, false, 0
   if watchIndex then
+    self.print('WatchIndex', watchIndex)
     local _
-    _,_,_, numObjectives, requiredMoney, _, _, isAutoComplete,
+    _, _, _, numObjectives, requiredMoney, _, _, isAutoComplete,
     failureTime, timeElapsed, questType = GetQuestWatchInfo(watchIndex)
-
-    -- ensure that the entry being populated isn't animating
-    if self.WatchBlock[watchIndex] then
-      local checkIndex = watchIndex
-      while self.WatchBlock[checkIndex + numAnimating] and self.WatchBlock[checkIndex + numAnimating].isAnimating do
-        print(self.WatchBlock[checkIndex + numAnimating]:GetName(), 'is in an animation sequence')
-        numAnimating = numAnimating + 1
-      end
-    end
-
-    self.WatchList[watchIndex + numAnimating] = q
+    self.WatchList[watchIndex] = q
     --tprint('      |cFF88FF00GetInfo:|r set watch entry', watchIndex)
-    print('GetInfo:', logIndex, watchIndex, '|cFFFF2299'..title..'|r')
+    self.print('WatchIndex', logIndex, watchIndex + numAnimating, '|cFFFF2299'..title..'|r')
   end
   self.LogInfo[logIndex] = q
 
@@ -265,21 +258,22 @@
       isBreadcrumb = true;
     end
   end
-  print('QuestFlags', (isComplete and 'isComplete' or ''), (questFailed and 'questFailed' or ''), (isBreadcrumb and 'isBreadcrumb' or ''))
+  print('QuestFlags', (isComplete and 'isComplete' or ''), (questFailed and 'questFailed' or ''), (isBreadcrumb and 'isBreadcrumb' or ''), numObjectives)
 
   -- completion message?
   local isSequenced = IsQuestSequenced(questID)
   local temp_status = ''
   if ( isComplete ) then
     temp_status = 'COMPLETED_OBJECTIVES'
-    objectives = Quest.GetObjectives(questLogIndex, numObjectives, true, isSequenced, isStory)
+    --objectives = Quest.GetObjectives(logIndex, numObjectives, true, isSequenced, isStory)
+    q.objectives = objectives
     if ( isAutoComplete ) then
       temp_status = 'AUTOCOMPLETE_OBJECTIVES'
       completionText = _G.QUEST_WATCH_CLICK_TO_COMPLETE
     else
       if ( isBreadcrumb ) then
         temp_status = 'COMPLETE_BREADCRUMB'
-        completionText = GetQuestLogCompletionText(questLogIndex)
+        completionText = GetQuestLogCompletionText(logIndex)
       else
         temp_status = 'COMPLETE_READY_FOR_TURN_IN'
         completionText = _G.QUEST_WATCH_QUEST_READY
@@ -331,7 +325,6 @@
       end
     end
   end
-  q.objectives = objectives
   q.moneyInfo = moneyInfo
   q.timerInfo = timerInfo
   q.completionText = completionText
@@ -386,28 +379,24 @@
       tagID = QUEST_TAG_ACCOUNT
       isAccount = true
     end
-    tagInfo['typeTag'] = tagID
-    tagCoords['typeTag'] = QUEST_TAG_TCOORDS[tagID]
+    tagInfo['type'] = QUEST_TAG_TCOORDS[tagID]
   elseif ( factionGroup) then
     tagID = "ALLIANCE"
     if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
       tagID = "HORDE"
     end
     isFaction = true
-    tagInfo['typeTag'] = tagID
-    tagCoords['typeTag'] = QUEST_TAG_TCOORDS[tagID]
+    tagInfo['type'] = QUEST_TAG_TCOORDS[tagID]
   end
 
   if( frequency == LE_QUEST_FREQUENCY_DAILY and (not isComplete or isComplete == 0) ) then
     tagID = 'DAILY'
-    tagInfo['frequencyTag'] = tagID
-    tagCoords['frequencyTag'] = QUEST_TAG_TCOORDS[tagID]
+    tagInfo['frequency'] = QUEST_TAG_TCOORDS[tagID]
     isDaily = true
     schema = 'daily'
   elseif( frequency == LE_QUEST_FREQUENCY_WEEKLY and (not isComplete or isComplete == 0) )then
     tagID = 'WEEKLY'
-    tagInfo['frequencyTag'] = tagID
-    tagCoords['frequencyTag'] = QUEST_TAG_TCOORDS[tagID]
+    tagInfo['frequency'] = QUEST_TAG_TCOORDS[tagID]
     isWeekly = true
     schema = 'weekly'
   elseif( questTagID ) then
@@ -415,16 +404,13 @@
   end
 
   if( isComplete ) then
-    tagInfo['completionTag'] = 'COMPLETED'
+    tagInfo['completion'] = QUEST_TAG_TCOORDS['COMPLETED']
   elseif ( questFailed ) then
-    tagInfo['completionTag'] = 'FAILED'
+    tagInfo['completion'] = QUEST_TAG_TCOORDS['FAILED']
   end
-  tagCoords['completionTag'] = QUEST_TAG_TCOORDS[tagInfo['completionTag']]
 
   q.tagInfo = tagInfo
-  q.tagCoords = tagCoords
-  -- establishes the primary block tag for view compacting
-  q.tagID = tagID
+  q.tagID = tagID -- defining primary tags for compact view
   q.tagName = tagName
 
   -- action button information
@@ -492,7 +478,7 @@
     end
   end
 
-  return q
+  return numEntries
 end
 
 Quest.GetObjectives = function(logIndex, numObjectives, isComplete, isSequenced, isStory)