changeset 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
files ObjectiveFrame.lua ObjectiveInfo.lua ObjectiveUI.lua
diffstat 3 files changed, 51 insertions(+), 38 deletions(-) [+]
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()
--- a/ObjectiveInfo.lua	Thu Mar 31 14:28:40 2016 -0400
+++ b/ObjectiveInfo.lua	Thu Mar 31 15:58:08 2016 -0400
@@ -12,6 +12,7 @@
 Quest.itemButtons = {}
 Quest.freeButtons = {}
 Quest.POI = {}
+Quest.QuestBlock = {}
 Quest.GetNumWatched = function()
   return GetNumQuestWatches ()
 end
--- a/ObjectiveUI.lua	Thu Mar 31 14:28:40 2016 -0400
+++ b/ObjectiveUI.lua	Thu Mar 31 15:58:08 2016 -0400
@@ -60,8 +60,13 @@
 end
 
 Quest.Remove = function(self)
-  RemoveQuestWatch(self.info.questIndex)
+  print('removing', self.info.questLogIndex, 'from watcher')
+  RemoveQuestWatch(self.info.questLogIndex)
+
+  mod.Quest.LogBlock[self.info.questLogIndex] = nil
+  mod.Quest.QuestBlock[self.info.questID] = nil
   QuestPOIUpdateIcons()
+  mod.UpdateWrapper()
 end
 
 
@@ -105,29 +110,28 @@
         itemButton.block = nil
       end
     else
-      print('    |cFFFF4400starting new button')
       local buttonIndex = mod.Quest.numButtons + #freeButtons + 1
       itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate')
       itemButton.buttonIndex = buttonIndex
       itemButton:SetSize(48, 48)
       itemButton:GetNormalTexture():SetSize(80,80)
+      print('    |cFFFF4400starting new button', itemButton:GetName())
     end
     mod.Quest.numButtons = mod.Quest.numButtons + 1
   else
-    print('    |cFF00FF00found assigned button')
     itemButton = info.itemButton
-    if itemButton.block then
-      print('  - moving from old block')
-      itemButton.block.itemButton = nil
-    end
+    print('    |cFF00FF00found assigned button', itemButton:GetName())
 
   end
   -- set values
 
+  info.itemButton = itemButton
+  usedButtons[info.questID] = itemButton
+  print('      |cFF8800FFassigning|r', itemButton:GetName(), 'to quest|cFF00FF00', info.questID, '|rat|cFFFFFF00', block:GetName(),'|r')
 
-  info.itemButton = itemButton
-  block.itemButton = itemButton
-  usedButtons[info.questID] = itemButton
+  for k,v in pairs(usedButtons) do
+    print('|cFFFF44DD'..k..'|r', v:GetName())
+    end
 
   itemButton:SetAttribute("type", "item")
   itemButton:SetAttribute("item", itemInfo.link)
@@ -149,13 +153,18 @@
 
   if block.itemButton then
     local itemButton = block.itemButton
-    itemButton.block = nil
-    itemButton:Hide()
+    if itemButton.questID ~= block.info.questID then
+      block.itemButton = nil
+      itemButton.block = mod.Quest.InfoBlock[itemButton.questID]
+    else
+      itemButton.block = nil
+      itemButton:Hide()
 
-    usedButtons[itemButton.questID] = nil
-    freeButtons[#freeButtons + 1] = itemButton
-    mod.Quest.numButtons = mod.Quest.numButtons - 1
-    print('|cFFFF0088released', itemButton:GetName(),'and', block:GetName())
+      usedButtons[itemButton.questID] = nil
+      freeButtons[#freeButtons + 1] = itemButton
+      mod.Quest.numButtons = mod.Quest.numButtons - 1
+      print('|cFFFF0088released', itemButton:GetName(),'and', block:GetName())
+    end
   end
 end