diff ObjectiveTracker/Quests.lua @ 34:9856ebc63fa4

- half solution to Update being fired multiple times during load - change securefunc handlers to dispense a reason code; catch that reason code in the enclosure passed to hooksecurefunc, and decide whether to update or not from there.
author Nenue
date Sun, 17 Apr 2016 00:21:45 -0400
parents a3afe6c3771e
children 69d03f8e293e
line wrap: on
line diff
--- a/ObjectiveTracker/Quests.lua	Fri Apr 15 17:01:06 2016 -0400
+++ b/ObjectiveTracker/Quests.lua	Sun Apr 17 00:21:45 2016 -0400
@@ -33,45 +33,42 @@
   print('|cFF00FFFFUpdateObjectives()')
   local info = block.info
 
-  local titlebg, textbg = colors.default.titlebg, colors.default.textbg
   print((info.isAccount and 'isAccount' or ''), (info.isFaction and 'isFaction' or ''), (info.isDaily and 'isDaily' or ''), (info.isWeekly and 'isWeekly' or ''), info.tagID, info.tagName)
 
+  local block_schema = 'default'
   if info.isAccount then
     if info.isFaction then
       print('     faction', info.tagID)
-      titlebg, textbg = colors['faction_'..info.tagID].titlebg, colors.default.textbg
+      block_schema = 'faction_'..info.tagID
     else
       print('     account', info.isAccount, info.isFaction)
-      titlebg, textbg = colors.account.titlebg, colors.account.textbg
+      block_schema = 'account'
     end
   elseif info.isDaily then
     print('     daily', info.frequency)
-    titlebg, textbg = colors.daily.titlebg, colors.daily.textbg
+    block_schema = 'daily'
   elseif info.isWeekly then
     print('     weekly', info.frequency)
-    titlebg, textbg = colors.weekly.titlebg, colors.weekly.textbg
+    block_schema = 'weekly'
   end
-
-  block.titlebg:SetGradientAlpha(unpack(titlebg))
-  block.statusbg:SetGradientAlpha(unpack(textbg))
-
   local completionText
   if info.isComplete then
     if info.isAutoComplete then
-      local questID, popupType = GetAutoQuestPopUp(info.questLogIndex)
+      local questID, popupType = GetAutoQuestPopUp(info.logIndex)
       if popupType == 'COMPLETE' then
         print('    :: auto-complete quest :: set the message')
         info.completionText = T.strings.CLICK_TO_COMPLETE
       end
     else
       if not completionText or info.completionText then
-        info.completionText = GetQuestLogCompletionText(info.questLogIndex)
+        info.completionText = GetQuestLogCompletionText(info.logIndex)
       end
     end
     print('    :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"')
   end
 
-  Default.UpdateObjectives(handler, block)
+  Default.UpdateObjectives(handler, block, block_schema)
+  return block_schema
 end
 
 Quest.UpdateLine = function(handler, block, line, data)
@@ -87,7 +84,6 @@
 Quest.LogInfo = {}
 
 function Quest:GetNumWatched ()
-  print(self.name, self)
   superTrackQuestID = GetSuperTrackedQuestID()
   playerMoney = GetMoney();
   inScenario = C_Scenario.IsInScenario();
@@ -102,8 +98,6 @@
 -- Manifest of line data to be displayed in relation to the tracked object
 Quest.GetInfo = function (self, watchIndex)
   local print = iprint
-  print('')
-  print('|cFF00DDFFindex: |r'.. tostring(watchIndex))
 
   local questID, title, questLogIndex, numObjectives, requiredMoney, isComplete, startEvent, isAutoComplete,
     failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
@@ -111,21 +105,18 @@
     return
   end
 
+  tprint('    |cFFFFBB00GetInfo:|r', watchIndex, '|cFFFF2299'..title..'|r')
   local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questLogIndex)
 
   Quest.Info[questID] = Quest.Info[questID] or {}
 
 
   local q = Quest.Info[questID]
-  q.watchIndex = watchIndex
   q.type = 'Quest'
-  q.id = questID
-  q.questID = questID
   q.title = title
   q.level = level
   q.displayQuestID = displayQuestID
   q.suggestedGroup = suggestedGroup
-  q.questLogIndex = questLogIndex
 
   -- re-use Blizzard logic for consistency
   local showQuest = true
@@ -349,11 +340,15 @@
 
   T.SetRewards(q, questID)
 
+  q.questID = questID
+  q.logIndex = questLogIndex
+  q.watchIndex = watchIndex
+  q.id = questID
   self.WatchInfo[watchIndex] = q
   self.LogInfo[questLogIndex] = q
 
   if Devian and Devian.InWorkspace() then
-    print('|cFF00DDFFstatus:|r', temp_status, '|cFF00FF00questLogIndex|r:', title)
+    print('|cFF00DDFFstatus:|r', temp_status, '|cFF00FF00questLogIndex|r:', questLogIndex, title)
     local temp  ={}
     local data_txt = '|cFFFF4400values:|r'
     for k,v in pairs(q) do
@@ -380,7 +375,7 @@
   local objectives = {}
   for i = 1, numObjectives do
     local text, type, finished = GetQuestLogLeaderBoard(i, questLogIndex)
-    print(format('   #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished)))
+    print(format('      |cFFFF4400GetObjectives:|r #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished)))
     objectives[i] = {
       index = i,
       type = type,
@@ -417,7 +412,7 @@
 
 Quest.Select = function (handler, block)
   if block.info.isAutoComplete and block.info.isComplete then
-    ShowQuestComplete(block.info.questLogIndex)
+    ShowQuestComplete(block.info.logIndex)
   else
     SetSuperTrackedQuestID(block.info.questID)
   end
@@ -425,7 +420,7 @@
 
 Quest.Link = function(handler, block)
 
-  local questLink = GetQuestLink(block.info.questLogIndex);
+  local questLink = GetQuestLink(block.info.logIndex);
   if ( questLink ) then
     ChatEdit_InsertLink(questLink);
   end
@@ -438,6 +433,6 @@
 
 Quest.Remove = function(handler, block)
 
-  print('removing', block.info.questLogIndex, 'from watcher')
-  RemoveQuestWatch(block.info.questLogIndex)
+  print('removing', block.info.logIndex, 'from watcher')
+  RemoveQuestWatch(block.info.logIndex)
 end