changeset 45:dd1ae565f559

Hooks and Handlers: - correct argument mix-ups for AcceptQuest/QUEST_ACCEPTED handlers; fixes auto-watch - respond to AcknowledgeAutoAcceptQuest; fixes lingering popups - include Popup and Quest trackers in the response code for CompleteQuest; fixes content artifacts following the rollover of repeating popups seen in Ashran - clean up wacky OnEvent header Layout - add alpha blend options QuestData - reset objectives data when a quest is in a completed state; keeps old data from ever reaching the Default.x code
author Nenue
date Tue, 26 Apr 2016 14:57:18 -0400
parents 756e8aeb040b
children aa693607b813
files ObjectiveTracker/APIHooks.lua ObjectiveTracker/AutoQuestPopupData.lua ObjectiveTracker/Block.lua ObjectiveTracker/Default.lua ObjectiveTracker/Layout.lua ObjectiveTracker/ObjectiveTracker.lua ObjectiveTracker/ObjectiveTracker.xml ObjectiveTracker/QuestData.lua ObjectiveTracker/Schema.lua
diffstat 9 files changed, 87 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/ObjectiveTracker/APIHooks.lua	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/APIHooks.lua	Tue Apr 26 14:57:18 2016 -0400
@@ -12,6 +12,9 @@
 local QuestPOIUpdateIcons = QuestPOIUpdateIcons
 
 --- Module updates triggered by user events
+T.AcknowledgeAutoAcceptQuest = function(...)
+  return OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST + OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP
+end
 
 T.AddQuestWatch = function(questID)
   return OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST
@@ -28,6 +31,7 @@
   return OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP
 end
 T.RemoveAutoQuestPopUp = function(questID)
+  AddQuestWatch(GetQuestLogIndexByID(questID))
   return OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP
 end
 --- SUPER_TRACKED_QUEST_CHANGED will fires
@@ -43,10 +47,10 @@
       end
     end
   end
-  T.SuperTrackedQuestID = questID
 end
 
 
+
 local previousSelection
 --@debug@
 local tprint = B.print('Tracker') -- @debug@
--- a/ObjectiveTracker/AutoQuestPopupData.lua	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/AutoQuestPopupData.lua	Tue Apr 26 14:57:18 2016 -0400
@@ -12,32 +12,42 @@
 local GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetQuestLogIndexByID, GetQuestLogTitle = GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetQuestLogIndexByID, GetQuestLogTitle
 --- Data retrieval
 function AutoQuest:GetNumWatched ()
-  if true then return 0, 0, nil end
-  print(self.name, self)
-  --Quest:GetNumWatched()
-  self.numWatched = GetNumAutoQuestPopUps()
+  local numWatched = GetNumAutoQuestPopUps()
+  local numAll = numWatched
 
-  return self.numWatched
+  self.print('GetNumWatched', numWatched, 'popups detected')
+  for i = 1, numWatched do
+      self:GetInfo(i)
+  end
+
+  for i, block in ipairs(self.usedBlocks) do
+    if not GetAutoQuestPopUp(block.info.id) then
+      self:FreeBlock(block)
+    end
+  end
+
+  self.numWatched = numWatched
+  self.WatchList = self.Info
+  return numWatched
 end
-AutoQuest.GetInfo = function(self, popupIndex)
+AutoQuest.GetInfo = function(self, index)
 
 
-  local questID, type = GetAutoQuestPopUp(popupIndex)
+  local questID, type = GetAutoQuestPopUp(index)
   local questLogIndex = GetQuestLogIndexByID(questID)
   local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questLogIndex)
 
-  self.Info[questID] = self.Info[questID] or {}
-  local popup = self.Info[questID]
+  self.Info[index] = self.Info[index] or {}
+  local popup = self.Info[index]
   popup.questID = questID
-  popup.id = questID
+  popup.id = index
   popup.title = title
   popup.description = type
   popup.popupType = type
   popup.logIndex = questLogIndex
-  popup.popupIndex = popupIndex
 
   self.Info[questID] = popup
-  self.WatchInfo[popupIndex] = popup
+  self.WatchInfo[index] = popup
 
 
   return self.Info[questID]
--- a/ObjectiveTracker/Block.lua	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/Block.lua	Tue Apr 26 14:57:18 2016 -0400
@@ -187,6 +187,4 @@
     bprint('  animGroup', i,  animGroup:GetName())
     animGroup:Stop()
   end
-
-  T:Update(self.updateReasonsModule)
 end
--- a/ObjectiveTracker/Default.lua	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/Default.lua	Tue Apr 26 14:57:18 2016 -0400
@@ -54,7 +54,7 @@
   elseif not reason then
     reason = OBJECTIVE_TRACKER_UPDATE_ALL
   end
-  print(format('|cFFBB0066Update:|r |cFFFF%04X%d|r  ', tick, lshift(reason, 4)), reason, ...)
+  print(format('|cFFBB0066Update:|r %d |cFFFF%04X%d|r  ', tick, lshift(reason, 4)), reason, ...)
   currentPosition = 0
 
   for id, handler in pairs(T.orderedHandlers) do
--- a/ObjectiveTracker/Layout.lua	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/Layout.lua	Tue Apr 26 14:57:18 2016 -0400
@@ -65,11 +65,13 @@
 
 local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2}
 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
-local titleColor = {0,.7,1,1}
+local titleColor = {0,.7,1,1 }
+local titleBlend = 'BLEND'
 
 local textbg =  {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
 local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'
 local textColor = {1,1,1,1 }
+local textBlend = 'BLEND'
 
 local widgetTextFont, widgetTextSize, widgetTextOutline = [[Interface\Addons\SharedMedia_MyMedia\font\XOIREQE.TTF]], 11, 'OUTLINE'
 local widgetTextColor = {1,1,1,1 }
@@ -122,6 +124,8 @@
     titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing
     titleIndent, textIndent,selectionIndent = c.titleIndex, c.textIndex, c.selectionIndent
     titleColor = c.titleColor
+    titleBlend = c.titlebg[10] or 'BLEND'
+    textBlend = c.textbg[10] or 'BLEND'
     print(unpack(c.titleColor))
     rewardSize = 24
     textFont, textSize, textOutline = unpack(c.textFont)
@@ -255,6 +259,7 @@
   block.titlebg:SetGradientAlpha(unpack(titlebg))
   block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
   block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
+  block.titlebg:SetBlendMode(titleBlend)
   block.status:SetSpacing(textSpacing)
   block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
   block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
@@ -262,6 +267,7 @@
   block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
   block.statusbg:SetTexture(1,1,1,1)
   block.statusbg:SetGradientAlpha(unpack(textbg))
+  block.statusbg:SetBlendMode(textBlend)
   block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
   block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
   block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
--- a/ObjectiveTracker/ObjectiveTracker.lua	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.lua	Tue Apr 26 14:57:18 2016 -0400
@@ -23,6 +23,7 @@
 local BlizzHooks = {
   'AcceptQuest',
   'AddQuestWatch',
+  'CompleteQuest',
   'RemoveQuestWatch',
   'AbandonQuest',
   'AcknowledgeAutoAcceptQuest',
@@ -270,12 +271,14 @@
 end
 local GetNumQuestWatches, AddQuestWatch, SetSuperTrackedQuestID = GetNumQuestWatches, AddQuestWatch, SetSuperTrackedQuestID
 Event.QUEST_ACCEPTED = function(questLogIndex, questID, added)
+
+  --todo: stall non-confirmed autoquests
+  AddQuestWatch(questLogIndex)
   if ( IsQuestTask(questID) ) then
     return OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED + OBJECTIVE_TRACKER_UPDATE_TASK_ADDED, questID, added
   else
     return OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID, added
   end
-  AddQuestWatch(questID)
 end
 
 Event.QUEST_WATCH_LIST_CHANGED = function(questID, added)
@@ -446,12 +449,17 @@
 local Play = function(file) if Devian and Devian.InWorkspace() then PlaySoundFile(file) end end
 
 local tprint = B.print('Tracker')
+local ignoredNames = {
+  ['SelectQuestLogEntry'] = true
+}
 T.OnHookedFunc = function(name, ...)
-  print('|cFFFF8800securehook:|r', name, '|cFF00FFFFargs:|r', ...)
+  --tprint('|cFFFF8800securehook:|r', name, '|cFF00FFFFargs:|r', ...)
   local updateReason, arg1, arg2, arg3 = T[name](...)
   if updateReason then
-    print('|cFF00FFFFupdate reason:|r', updateReason, arg1, arg2, arg3)
+    tprint('OnHookedFunc(|cFF00FFFF'..name..'|r):', ...)
     T:Update(updateReason, arg1, arg2, arg3)
+  elseif not ignoredNames[name] then
+    tprint('OnHookedFunc(|cFFFF4400'..name..'|r):', ...)
   end
 end
 
@@ -468,21 +476,22 @@
     end
   else
     print('no event handler set for', event)
+    tprint('no event handler set for', event)
     Play([[Interface\Addons\SharedMedia_MyMedia\sound\IM.ogg]])
   end
   if reason then
-    tprint('OnEvent(|cFF00FF00'.. event ..'|r):', ...)
+    local args = (reason or '0')
+    if arg1 then args = args .. ', ' .. tostring(arg1) end
+    if arg2 then args = args .. ', ' .. tostring(arg2) end
+    if arg3 then args = args .. ', ' .. tostring(arg3) end
+    print('OnEvent(|cFF00FF00'.. event ..'|r):', ..., '|cFFFFFF00=> Update (|r', args,'|cFFFFFF00)|r')
+    tprint('OnEvent(|cFF00FF00'.. event ..'|r):', ..., '|cFFFFFF00=> Update (|r', args,'|cFFFFFF00)|r')
     T:Update(reason, arg1, arg2, arg3)
   else
-    print('OnEvent(|cFFFF4400'.. event ..'|r):', ...)
+    tprint('OnEvent(|cFFFF4400'.. event ..'|r):', ...)
     print('no detected reason')
     --Play([[Interface\Addons\SharedMedia_MyMedia\sound\Quack.ogg]])
   end
-  local args = (reason or '0')
-  if arg1 then args = args .. ', ' .. tostring(arg1) end
-  if arg2 then args = args .. ', ' .. tostring(arg2) end
-  if arg3 then args = args .. ', ' .. tostring(arg3) end
-  tprint('OnEvent(|cFF00FF00'.. event ..'|r):', ..., '|cFFFFFF00=> Update (|r', args,'|cFFFFFF00)|r')
 
 end
 
@@ -506,6 +515,12 @@
   end
 
 
+  local weekDays = {'Su', 'M', 'T', 'W', 'R' ,'F', 'Sa'}
+  Wrapper.Clock:SetScript('OnUpdate', function(self)
+    local weekday, month, day, year = CalendarGetDate()
+    local hour, min = GetGameTime()
+    self.time:SetFormattedText("%s.%s.%s %d:%02d", weekDays[weekday], month, day, hour, min)
+  end)
 
   ObjectiveTrackerFrame:UnregisterAllEvents()
   ObjectiveTrackerFrame:Hide()
--- a/ObjectiveTracker/ObjectiveTracker.xml	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.xml	Tue Apr 26 14:57:18 2016 -0400
@@ -162,16 +162,16 @@
         <Anchors>
           <Anchor point="TOPRIGHT" relativePoint="TOPLEFT" relativeKey="$parent.QuestMapButton" />
         </Anchors>
-        <Size x="160" y="16" />
+        <Size x="280" y="16" />
         <Layers>
           <Layer level="OVERLAY">
-            <FontString font="Interface\Addons\SharedMedia_MyMedia\font\XOIREQE.TTF" parentKey="time" text="GAME_TIME">
+            <FontString font="Interface\Addons\SharedMedia_MyMedia\font\XOIREQE.TTF" parentKey="time" text="GAME_TIME" outline="NORMAL">
               <FontHeight>
-                <AbsValue val="16" />
+                <AbsValue val="14" />
               </FontHeight>
 
               <Anchors>
-                <Anchor point="CENTER" />
+                <Anchor point="RIGHT" />
               </Anchors>
               <Color r="1" g="1" b="1" a="1" />
             </FontString>
@@ -179,9 +179,6 @@
         </Layers>
         <Scripts>
           <OnUpdate>
-            local hour, min = GetGameTime()
-            self.time:SetFormattedText("%d:%02d", hour, min)
-            --self:SetWidth(self.time:GetWidth()+4)
           </OnUpdate>
         </Scripts>
       </Frame>
@@ -373,7 +370,7 @@
       </AnimationGroup>
       <AnimationGroup name="$parent_BlockFade" parentKey="blockFadeOut" ignoreFramerateThrottle="true" looping="NONE">
         <Alpha duration="0.25" order="1" fromAlpha="1" toAlpha="0" />
-        <!--<Translation duration="0.25" order="1" offsetX="260" offsetY="0" smoothing="OUT" />-->
+        <Translation duration="0.25" order="1" offsetX="-260" offsetY="0" smoothing="OUT" />
         <Scale order="1" duration="0.25" scaleX="0.1" scaleY="0.1">
           <Origin point="CENTER">
             <Offset x="0" y="0" />
@@ -383,14 +380,14 @@
     </Animations>
     <Layers>
       <Layer level="BACKGROUND">
-        <Texture name="$parentTitleBackground" parentKey="titlebg">
+        <Texture name="$parentTitleBackground" parentKey="titlebg" alphaMode="MOD">
           <Color r="1" g="1" b="1" a="1" />
           <Anchors>
             <Anchor point="TOPLEFT" x="0" y="0" />
             <Anchor point="RIGHT" />
           </Anchors>
         </Texture>
-        <Texture name="$parentStatusBackground" parentKey="statusbg">
+        <Texture name="$parentStatusBackground" parentKey="statusbg" alphaMode="MOD">
           <Anchors>
             <Anchor point="LEFT" />
             <Anchor point="RIGHT" />
--- a/ObjectiveTracker/QuestData.lua	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/QuestData.lua	Tue Apr 26 14:57:18 2016 -0400
@@ -53,9 +53,15 @@
     block_schema = 'weekly'
   end
   local completionText
-  if info.isComplete then
+
+  if info.isAutoComplete and info.isComplete then
+    displayObjectives = false
+    info.numObjectives = 1
+    self:AddLine(block, info.completionText, nil, 'complete')
+  elseif info.isComplete then
     if T.Conf.ShowCompletionText then
       self:AddLine(block, info.completionText, nil, 'complete')
+      displayObjectives = false
     end
     if not T.Conf.ShowObjectivesWhenComplete then
       displayObjectives = false
@@ -64,6 +70,7 @@
     block_schema = 'complete'
   end
 
+
   Default.UpdateObjectives(self, block, block_schema, displayObjectives)
   return 0, block_schema
 end
@@ -166,16 +173,20 @@
   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())
+        print('GetNumWatched', '|cFF44FF00'.. index, (block and block:GetName() or '|cFFFF0000-|r'), '(trim not active)')
       elseif not IsQuestWatched(block.info.logIndex) then
         self:ClearBlock(block)
-        print('GetNumWatched', 'trim untracked quest', block:GetName())
+        print('GetNumWatched', '|cFFFF4400'.. index, (block and block:GetName() or '|cFFFF0000-|r'), '(trim non-watched)')
+      else
+        print('GetNumWatched', '|cFF0088FF'.. index, (block and block:GetName() or '|cFFFF0000-|r'), logIndex or '|cFF444444-|r')
       end
+    else
+
+      print('GetNumWatched', '|cFF00FFFF'.. index, (block and block:GetName() or '|cFFFF0000-|r'), ' (animating)')
     end
   end
 
@@ -266,7 +277,6 @@
   if ( isComplete ) then
     temp_status = 'COMPLETED_OBJECTIVES'
     --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
@@ -279,6 +289,9 @@
         completionText = _G.QUEST_WATCH_QUEST_READY
       end
     end
+    if not T.Conf.ShowObjectivesWhenComplete then
+      q.objectives = {}
+    end
   elseif ( questFailed ) then
     temp_status = 'FAILED'
     -- Case 2: failed quest
--- a/ObjectiveTracker/Schema.lua	Mon Apr 25 19:37:13 2016 -0400
+++ b/ObjectiveTracker/Schema.lua	Tue Apr 26 14:57:18 2016 -0400
@@ -61,8 +61,8 @@
 T.defaults.Schema.block = {
   default = {
     titleColor = {1, 1, 1, 1},
-    titlebg = {'HORIZONTAL', 1, 0, .7, 0,    1, 0, .7, .125},
-    textbg = {'HORIZONTAL', 0, 0, 0, 0,      0, 0, 0, 0.4 },
+    titlebg = {'HORIZONTAL', 1, 1, 1, 0,   1, 1, 1, 1, 'MOD'},
+    textbg = {'HORIZONTAL', 1, 1, 1, 1,      .7, .7, .7, 1, 'MOD'},
     selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225},
     titleFont = {[[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'},
     textFont = {[[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'},