diff ObjectiveFrame.lua @ 22:9b3fa734abff

ObjectiveFrame - polish quest rewards display - implement money objectives - set line metrics in UpdateLine - set block metrics in UpdateBlock (sum of line metrics)
author Nenue
date Sat, 09 Apr 2016 07:32:45 -0400
parents d5ee940de273
children
line wrap: on
line diff
--- a/ObjectiveFrame.lua	Fri Apr 08 06:12:05 2016 -0400
+++ b/ObjectiveFrame.lua	Sat Apr 09 07:32:45 2016 -0400
@@ -43,7 +43,8 @@
 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24
 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2
-local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0}
+local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
+local rewardSize = 32
 local oprint = B.print('Objectives')
 local bprint = B.print('Block')
 local tprint = B.print('Tracker')
@@ -122,6 +123,8 @@
       block.SelectionOverlay:SetPoint('TOPLEFT')
       block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
 
+      block.icon:SetSize(rewardSize, rewardSize)
+      block.icon:SetPoint('TOPRIGHT', block, 'TOPRIGHT', -2, -2)
 
 
       --- methods for event handlers
@@ -181,6 +184,7 @@
 
   local attachmentHeight = 0
   if info.objectives then
+    attachmentHeight = textSpacing * 2
     for i, data in ipairs(info.objectives) do
       print('     |cFF88FF00#', i, data.type, data.text)
       displayObjectiveHeader = true
@@ -189,16 +193,24 @@
       block:UpdateLine(line, data)
 
       line:ClearAllPoints()
-      if line.displayText then
+      if line.widget then
+        local widgetPosition = 0
+        line.widget:SetPoint('TOP', line, 'TOP', 0, -widgetPosition)
+        line.widget:Show()
+        line.height = line.widget:GetHeight() + textSpacing
+
+        if line.displayText and #line.displayText >= 1 then
+          widgetPosition = line.status:GetHeight() + textSpacing
+          line.status:SetText(line.displayText)
+          line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + line.widget.height
+          print('      - progressbar has text, adjust')
+        end
+      elseif line.displayText then
         line.status:SetText(line.displayText)
-        line.height = floor(line.status:GetStringHeight()+.5)
+        line.height = floor(line.status:GetStringHeight()+.5) + textSpacing
+
       end
-
-      if line.widget then
-        line.widget:SetPoint('TOP', line, 'TOP', 0, 0)
-        line.widget:Show()
-      end
-
+      attachmentHeight = attachmentHeight + line.height
 
       line:Show()
 
@@ -207,7 +219,7 @@
       line:SetPoint('RIGHT', block, 'RIGHT', 0, 0)
       line:SetHeight(line.height)
 
-      attachmentHeight = attachmentHeight + line.height
+
       print('      sz', line:GetSize())
       print('      pt', line:GetPoint(1))
       print('     |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg)
@@ -216,14 +228,14 @@
     end
 
     if attachmentHeight > 0 then
-      block.attachmentHeight = attachmentHeight + textSpacing * 2
+      block.attachmentHeight = attachmentHeight
       print('     |cFF00FF00attachment:', block.attachmentHeight)
     end
 
     local lines = handler.lines[block.blockIndex]
-    local numObjectives = info.numObjectives
+    local numObjectives = #info.objectives
     local numLines = #lines
-    if numLines > numObjectives then
+    if lines and numLines > numObjectives then
       print('   has extra lines, need to clean up;', numLines, numObjectives)
       for  i = numObjectives+1, numLines do
         print('    hide', i, lines[i]:GetName())
@@ -270,7 +282,6 @@
 Quest.UpdateObjectives = function(handler, block)
   local print = lprint
   print('|cFF00FFFFUpdateObjectives()')
-  Default.UpdateObjectives(handler, block)
   local info = block.info
   local completionText
   if info.isAutoComplete then
@@ -279,11 +290,13 @@
       completionText = CLICK_TO_COMPLETE
     end
   end
-  if not completionText then
-    completionText = GetQuestLogCompletionText(info.questLogIndex)
+  if info.isComplete then
+    if not completionText then
+      completionText = GetQuestLogCompletionText(info.questLogIndex)
+    end
+  else
+    Default.UpdateObjectives(handler, block)
   end
-
-  block.status:SetText()
 end
 
 --- Module-specific display variables
@@ -313,6 +326,7 @@
   line.displayColor = {r, g, b, a}
   line.status:SetTextColor(r, g, b, a)
   line.displayText = data.text
+
   return line
 end
 
@@ -322,13 +336,7 @@
 
 
   line.displayColor = 'FFFFFF'
-  if data.text and not info.title then
-    print('using first text item as title')
-    info.title = data.text
-  else
-    line.displayText = data.text
-  end
-
+  line.displayText = data.text
   line.progress = 0
   print('  ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text)
   if data.objectiveType == 'progressbar' then
@@ -344,7 +352,7 @@
     line.format = PERCENTAGE_STRING
     local widget = mod.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex)
     print('    |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue)
-    widget:SetPoint('CENTER', line, 'CENTER', 0, 0)
+    widget:SetPoint('TOP', line, 'TOP', 0, 0)
 
     line.widget = widget
     line.height = widget.height
@@ -480,7 +488,6 @@
 Default.Update = function (self, reason, ...)
   local print = tprint
   local tracker = self.frame
-  print('|cFFFF4400'..tracker:GetName().. '|r:Update()', reason, ...)
   local blockIndex = 0
   local trackerHeight = floor(tracker.titlebg:GetHeight()+.5)
 
@@ -494,10 +501,10 @@
       local info = self:GetInfo(watchIndex)
       if info then
         local currentBlock = self:UpdateBlock(blockIndex, info)
-        currentBlock:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, -1)
+        currentBlock:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, 0)
         currentBlock:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
         self.currentAnchor = currentBlock
-        print('    |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height)
+        print('    |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height, trackerHeight)
         trackerHeight = trackerHeight + currentBlock.height
         numBlocks = max(numBlocks, watchIndex)
         actualBlocks = actualBlocks + 1
@@ -528,7 +535,7 @@
   if numBlocks >= 1 then
     previousBlock = nil
 
-    tracker.height = trackerHeight + tracker.titlebg:GetHeight()
+    tracker.height = trackerHeight
     tracker:SetHeight(tracker.height)
     tracker:Show()
 
@@ -613,8 +620,7 @@
     if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then
       block.icon:Show()
       block.iconLabel:SetText(info.rewardInfo[1].count)
-      block.icon:SetSize(block.height, block.height)
-      block.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
+      block.icon:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
       tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block.icon, 'TOPLEFT'
       block.icon:SetTexture(info.rewardInfo[1].texture)
     end
@@ -659,7 +665,7 @@
   for id, handler in pairs(mod.orderedHandlers) do
     local frame = handler.frame
 
-    print(format(' |cFF00FFFFbitcheck (%04X vs %04x+%04x):|r', reason, handler.updateReasonModule, handler.updateReasonEvents), band(reason, handler.updateReasonModule + handler.updateReasonEvents))
+    print(format('|cFF00FFFF%s and(%04X vs %04x+%04x) = %04X|r', handler.name, reason, handler.updateReasonModule, handler.updateReasonEvents, band(reason, handler.updateReasonModule + handler.updateReasonEvents)))
     if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then
       handler:Update(reason, ...)
       print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched)
@@ -737,6 +743,7 @@
             print('  '..block:GetName()..' |cFF00FF00probe hit!')
             mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
             block:SetScript('OnUpdate', nil)
+
           end
         end)
         previousItem = itemButton