diff ObjectiveFrame.lua @ 3:3397aae1f44d

- use the correct key value when searching for action buttons - handle pre-built frames from XML
author Nenue
date Thu, 31 Mar 2016 07:32:05 -0400
parents a2396b03ce63
children 18eee961038e
line wrap: on
line diff
--- a/ObjectiveFrame.lua	Thu Mar 31 01:38:47 2016 -0400
+++ b/ObjectiveFrame.lua	Thu Mar 31 07:32:05 2016 -0400
@@ -54,7 +54,7 @@
   },
   ObjectiveHeaderStyle = {
     Normal = {
-      Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,1}},
+      Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,.25}},
       Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing,
     }
   },
@@ -109,6 +109,13 @@
   }
 }
 
+local FontBank = {
+  ['Normal'] = VeneerCriteriaFontNormal,
+  ['Progress'] = VeneerCriteriaFontProgress,
+  ['Complete'] = VeneerCriteriaFontComplete,
+  ['Failed'] = VeneerCriteriaFontFailed,
+}
+
 local Scroller_OnShow = function()
   Wrapper.watchMoneyReasons = 0;
   mod.UpdateWrapper()
@@ -227,16 +234,17 @@
   if rest then
     XPBar.rested:ClearAllPoints()
     if xp == 0 then
-      XPBar.rested:SetPoint('LEFT', XPBar, 'LEFT', 0, 0)
+      XPBar.rested:SetPoint('TOPLEFT', XPBar, 'TOPLEFT', 0, 0)
     else
-      XPBar.rested:SetPoint('LEFT', XPBar.fg, 'RIGHT', 0, 0)
+      XPBar.rested:SetPoint('TOPLEFT', XPBar.fg, 'TOPRIGHT', 0, 0)
     end
 
     if (xp + rest) > xpmax then
-      XPBar.rested:SetPoint('RIGHT', XPBar, 'RIGHT', 0, 0)
+      XPBar.rested:SetPoint('BOTTOMRIGHT', XPBar, 'BOTTOMRIGHT', 0, 0)
     else
-      XPBar.rested:SetWidth((xp/xpmax) * XPBar:GetWidth())
+      XPBar.rested:SetWidth((rest/xpmax) * XPBar:GetWidth())
     end
+    XPBar.rested:SetPoint('BOTTOM', XPBar, 'BOTTOM')
     XPBar.rested:Show()
   else
     XPBar.rested:Hide()
@@ -367,19 +375,56 @@
   elseif info.numObjectives >= 1 then
     t.objectives:Show()
     print('  - objective lines:', info.numObjectives, 'can wrap:', t.objectives:CanWordWrap())
+
     local text = ''
+    if info.description then
+      print('  -- has description text:', select('#', info.description), info.description)
+      text = info.description
+    end
+
+    --- todo: implement objective displays
+     -- in an accumulator loop, call upon handler for the appropriate display frame, each defining:
+      -- * 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
-      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'
+      --- 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
+        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
-      text = text .. ((text == '') and "" or "\n") .. line
+
+      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
@@ -402,12 +447,11 @@
     style = 'Super'
   end
 
+  --- metrics are calculated in SetStyle
   t:SetStyle(style)
+  t:Show()
 
-
-  local fullheight = t:GetHeight()
-  t:Show()
-  print('  |cFF00FFFF)|r -> ', t, t:GetHeight(), fullheight)
+  print('  |cFF00FFFF)|r -> ', t, t:GetHeight())
   return t
 end
 
@@ -558,8 +602,8 @@
   local previousItem
   for questID, itemButton in pairs(usedButtons) do
     local questIndex = mod.Quest.Info[questID].questLogIndex
-    print('|cFF00FFFF', questIndex, itemButton:GetName())
-    local block = mod.Quest.LogBlock[questIndex]
+    print('|cFF00FFFF', questID, itemButton:GetName())
+    local block = mod.Quest.LogBlock[questID]
     print(block:GetTop())
     if block then
       if IsQuestWatched(questIndex) then