diff ObjectiveFrame.lua @ 4:18eee961038e

- more action button debug
author Nenue
date Thu, 31 Mar 2016 14:28:40 -0400
parents 3397aae1f44d
children e9b61fd5f607
line wrap: on
line diff
--- a/ObjectiveFrame.lua	Thu Mar 31 07:32:05 2016 -0400
+++ b/ObjectiveFrame.lua	Thu Mar 31 14:28:40 2016 -0400
@@ -387,52 +387,12 @@
       -- * height of whatever display widget is involved in conveying the task
       -- * number of non-wrapped text lines to account for line space; may be discarded depending on things
       -- * boolean that determines listening for money events or not
-    t.attachmentHeight = 0
-    for o, obj in ipairs(t.info.objectives) do
-      --- achievement criteria
-      if obj.flags then
+    t.attachmentHeight, text = mod.UpdateObjectives(t, info, text)
 
-        if bit.band(obj.flags, 0x00000001) > 0 then
-          obj.type = 'ProgressBar'
-          obj.widget = mod.SetWidget(obj, info)
-        elseif bit.band(obj.flags, 0x00000002) then
-          obj.type = 'Hidden'
-          obj.widget = nil
-        else
-          obj.type = 'Text'
-          obj.widget = nil
-          text = text .. ((text == '') and "" or "\n") .. obj.text
-        end
-
-        print(obj.type, obj.text, obj.quantityString)
-      --- none of the above (most quests)
-      else
-        local line = obj.text
-        if obj.type == 'monster' then
-          line = '|cFFFFFF00' .. line .. '|r'
-        elseif obj.type == 'item' then
-          line = '|cFF44BBFF' .. line .. '|r'
-        elseif obj.type == 'object' then
-          line = '|cFFFFFFFF' .. line .. '|r'
-        end
-        text = text .. ((text == '') and "" or "\n") .. line
-      end
-
-      if obj.widget then
-        t.attachmentHeight = t.attachmentHeight + obj.widget.height
-      end
-
-    end
     t.objectives:SetText(text)
     t.objectives:SetWordWrap(true)
 
 
-    -- todo: set up a SecureActionButton template
-    if info.specialItem and not info.itemButton then
-      print('  - |cFF00FFFFupdate item button')
-      mod.SetItemButton(t, info)
-    end
-
 
   elseif info.description then
     t.objectives:SetText(info.description)
@@ -447,6 +407,13 @@
     style = 'Super'
   end
 
+  if info.specialItem then
+    print('  - |cFF00FFFFupdate item button')
+    info.itemButton = mod.SetItemButton(t, info)
+  else
+    --info.itemButton = nil
+  end
+
   --- metrics are calculated in SetStyle
   t:SetStyle(style)
   t:Show()
@@ -455,6 +422,50 @@
   return t
 end
 
+mod.UpdateObjectives = function(block, info, text)
+  local attachmentHeight = 0
+  for o, obj in ipairs(info.objectives) do
+    --- achievement criteria
+    if obj.flags then
+
+
+      if bit.band(obj.flags, 0x00000001) > 0 then
+        obj.type = 'ProgressBar'
+        obj.widget = mod.SetWidget(obj, info)
+      elseif bit.band(obj.flags, 0x00000002) then
+        obj.type = 'Hidden'
+        obj.widget = nil
+      else
+        obj.type = 'Text'
+        obj.widget = nil
+        text = text .. ((text == '') and "" or "\n") .. obj.text
+      end
+
+      print(obj.type, obj.text, obj.quantityString)
+      --- none of the above (most quests)
+    else
+      local line = obj.text
+      local color = '00FFFF'
+      if obj.finished then
+        color = 'FFFFFF'
+      elseif obj.type == 'monster' then
+        color = 'FFFF00'
+      elseif obj.type == 'item' then
+        color = '44DDFF'
+      elseif obj.type == 'object' then
+        color = 'FF44DD'
+      end
+      text = text .. ((text == '') and "" or "\n") .. '|cFF'..color.. line .. '|r'
+    end
+
+    if obj.widget then
+      attachmentHeight = attachmentHeight + obj.widget.height
+    end
+
+  end
+  return attachmentHeight, text
+end
+
 mod.UpdateTracker = function(handler)
   print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r')
   local tracker = handler.Tracker
@@ -603,14 +614,14 @@
   for questID, itemButton in pairs(usedButtons) do
     local questIndex = mod.Quest.Info[questID].questLogIndex
     print('|cFF00FFFF', questID, itemButton:GetName())
-    local block = mod.Quest.LogBlock[questID]
-    print(block:GetTop())
+    local block = mod.Quest.LogBlock[questIndex]
     if block then
+      print(block:GetTop())
       if IsQuestWatched(questIndex) then
         -- Dispatch the probe
         block:SetScript('OnUpdate', function()
           print('|cFFFFFF00probing', block:GetName())
-            if block:GetBottom() then
+            if block:GetBottom() and not InCombatLockdown() then
               print('|cFF00FF00ding ding ding!')
               mod.UpdateBlockAction(block, itemButton, previousItem)
               block:SetScript('OnUpdate', nil)