diff ObjectiveFrame.lua @ 5:e9b61fd5f607

- use IsQuestWatched as the determinant for setting action button updates - check for block match-up in deferred action button updates
author Nenue
date Thu, 31 Mar 2016 15:58:08 -0400
parents 18eee961038e
children 589de8ea05b9
line wrap: on
line diff
--- a/ObjectiveFrame.lua	Thu Mar 31 14:28:40 2016 -0400
+++ b/ObjectiveFrame.lua	Thu Mar 31 15:58:08 2016 -0400
@@ -356,6 +356,7 @@
 
   t.info = info
 
+  if info.questID then handler.QuestBlock[info.questID] = t end
   if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end
   if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end
 
@@ -407,8 +408,8 @@
     style = 'Super'
   end
 
-  if info.specialItem then
-    print('  - |cFF00FFFFupdate item button')
+  if info.specialItem and not info.itemButton then
+    print('  - |cFF00FFFFgenerating item button for info set')
     info.itemButton = mod.SetItemButton(t, info)
   else
     --info.itemButton = nil
@@ -613,38 +614,40 @@
   local previousItem
   for questID, itemButton in pairs(usedButtons) do
     local questIndex = mod.Quest.Info[questID].questLogIndex
-    print('|cFF00FFFF', questID, itemButton:GetName())
-    local block = mod.Quest.LogBlock[questIndex]
+    print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
+    local block = mod.Quest.QuestBlock[questID]
     if block then
-      print(block:GetTop())
+        -- Dispatch the probe
       if IsQuestWatched(questIndex) then
-        -- Dispatch the probe
+
+        print('  |cFFFFFF00probing', block:GetName())
         block:SetScript('OnUpdate', function()
-          print('|cFFFFFF00probing', block:GetName())
-            if block:GetBottom() and not InCombatLockdown() then
-              print('|cFF00FF00ding ding ding!')
-              mod.UpdateBlockAction(block, itemButton, previousItem)
-              block:SetScript('OnUpdate', nil)
-            end
-          end)
-        return
+          if block:GetBottom() and not InCombatLockdown() then
+            print('  '..block:GetName()..' |cFF00FF00probe hit!')
+            mod.UpdateBlockAction(block, itemButton, previousItem)
+            block:SetScript('OnUpdate', nil)
+          end
+        end)
       else
-        mod.FreeItemButtons(block)
+        print('hidden block or unwatched quest')
+        itemButton:Hide()
       end
+    else
+      print('  |cFFFF0088missing block data', itemButton:GetName())
     end
   end
 end
 
 mod.UpdateBlockAction = function (block, itemButton, previousItem)
-  if block.itemButton ~= itemButton then
-    block.itemButton = itemButton
-  end
-  if itemButton.block ~= block then
-    itemButton.block = block
+  print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
+  if itemButton.questID ~= block.info.questID then
+    print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
+
+    return mod.UpdateActionButtons()
   end
 
   if block:GetBottom() < Scroller:GetBottom() then
-    print('|cFFFFFF00bottom not fully visible')
+    print('** ',block:GetName() ,'|cFFFFFF00bottom not fully visible')
     if previousItem then
       previousItem:ClearAllPoints()
       previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, 4)
@@ -653,7 +656,7 @@
     itemButton:SetPoint('BOTTOMRIGHT', UIParent, 'BOTTOMLEFT', Wrapper:GetLeft(), Wrapper:GetBottom())
     itemButton:Show()
   else
-    print('|cFF00FF00visible positions')
+    print('** ',block:GetName() ,'|cFF00FF00visible positions')
     itemButton:ClearAllPoints()
     itemButton:SetPoint('TOPRIGHT', UIParent, 'BOTTOMLEFT', block:GetLeft(), block:GetTop())
     itemButton:Show()