diff ObjectiveTracker/Frame.lua @ 31:48b3e3959a0a

- clean up method arguments
author Nenue
date Thu, 14 Apr 2016 19:39:05 -0400
parents 7583684becf4
children a3afe6c3771e
line wrap: on
line diff
--- a/ObjectiveTracker/Frame.lua	Thu Apr 14 17:11:13 2016 -0400
+++ b/ObjectiveTracker/Frame.lua	Thu Apr 14 19:39:05 2016 -0400
@@ -37,9 +37,9 @@
 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}
 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'
 
-local titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125}
-local titlebg_daily = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125 }
-local titlebg_account = {'HORIZONTAL', 0, .45, 1, .25, 0,  .45, 1, .125}
+local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2}
+local titlebg_daily = {'HORIZONTAL', 0, .7, 1, 0, 0, 1, .7, .2 }
+local titlebg_account = {'HORIZONTAL', 0, .45, 1, 0, 0,  .45, 1, .2}
 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
 
 local textbg =  {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
@@ -53,7 +53,27 @@
 local titleIndent, textIndent,selectionIndent = 2, 5, 50
 
 local lineColors = {
-  text = {.5,.75,1},
+  normal = {
+    text = {.5,.75,1},
+  },
+  completed = {
+    text = {1,0,.1}
+  },
+  failed = {
+    text = {1,0,0 }
+  },
+  autocomplete = {
+    text = {0,1,0 }
+  },
+  object = {
+    text = {0,1,1}
+  },
+  monster = {
+    text = {1,1,0}
+  },
+  item = {
+    text = {1,.25,.5}
+  }
 }
 
 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
@@ -106,43 +126,45 @@
   local print = lprint
   local lineIndex = block.currentLine + 1
   local line = handler:GetLine(block)
+  line.index = lineIndex
   line:ClearAllPoints()
   line:SetPoint('LEFT', block, 'LEFT', 0, 0)
-  line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
+  line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, 0)
   line:SetPoint('RIGHT', block, 'RIGHT', 0, 0)
   line:Show()
 
-  local r, g, b, a = 1, 1, 1, 1
-  if lineColors[template] then
-    r, g, b = unpack(lineColors[template])
-  end
-
+  print('     |cFF0088FFAddLine >>|r', block, '::',  block.endPoint:GetName(),'"'.. text .. '"', attachment, template)
   line.status:SetText(text)
   line.height = floor(line.status:GetStringHeight()+.5) + textSpacing
   line:SetHeight(line.height)
+
+  local r, g, b, a = 1, 1, 1, 1
+  if lineColors[template] then
+    r, g, b = unpack(lineColors[template].text)
+  end
   line.status:SetTextColor(r, g, b, a)
 
   -- For progressbar and timer lines, status text may be used as the title heading
   if attachment then
-    local widgetPosition = 0
-    attachment:SetPoint('TOP', line, 'TOP', 0, -block.attachmentHeight)
+    local widgetOffset = 0
+    if text and #text >= 1 then
+      widgetOffset = line.status:GetHeight() + textSpacing
+      line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + attachment.height
+      print('     |cFFFF0088doing things with captioned widget')
+    else
+      print('     |cFFFF0088doing things with a widget')
+    end
+    attachment:SetPoint('TOP', line, 'TOP', 0, -widgetOffset)
     attachment:Show()
-    if text and #text >= 1 then
-      widgetPosition = line.status:GetHeight() + textSpacing
-      line.status:SetText(text)
-      line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + attachment.height
-      print('      - progressbar has text, adjust')
-    end
-  else
-    print('     |cFFFF0088no attachments')
   end
 
-  block.endIndex = line.index
-  block.attachmentHeight = block.attachmentHeight + (line.height + textSpacing)
+  block.attachmentHeight = block.attachmentHeight + line.height
   print('     |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n            |cFF0088FFsize:|r", line.height,
     "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
   block.currentLine = lineIndex
-  block.endPoint = line
+  block.endPoint = line.statusbg -- edge used for the next block
+
+  return lineIndex
 end
 
 --- Creates or retrieves a complete line data object
@@ -152,13 +174,13 @@
   local lines = block.lines
   if not lineIndex then
     lineIndex = block.currentLine + 1
-    print('fetching the "next" line:', lineIndex)
+    print('        fetching the "next" line:', lineIndex)
   else
-    print('fetching explicit offset:', lineIndex)
+    print('        fetching explicit offset:', lineIndex)
   end
 
   block.numLines = max(block.numLines, lineIndex)
-  print('|cFF00FFFFnumLines:|r', block.numLines, '|cFF00FFFFcurrentLine:|r', block.currentLine)
+  print('        |cFF00FFFFposition|r', block.currentLine, '|cFF00FFFFof|r|cFFFFFF00' , block.numLines)
 
   if not lines[lineIndex] then
     print('     |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex)
@@ -209,7 +231,7 @@
       block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
 
       block.titlebg:SetTexture(1,1,1,1)
-      block.titlebg:SetGradientAlpha(unpack(Module.colors.default.titlebg))
+      block.titlebg:SetGradientAlpha(unpack(titlebg))
       block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
       block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
 
@@ -220,7 +242,7 @@
       block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
       block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
       block.statusbg:SetTexture(1,1,1,1)
-      block.statusbg:SetGradientAlpha(unpack(Module.colors.default.textbg))
+      block.statusbg:SetGradientAlpha(unpack(textbg))
 
       block.SelectionOverlay:SetGradientAlpha(unpack(Module.colors.default.selectionbg))
       block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
@@ -530,10 +552,11 @@
   --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1)
   --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1)
 
-  tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative)
-  tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative)
-  tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative)
-
+  if info.tagInfo then
+    tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative)
+    tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative)
+    tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative)
+  end
   return block
 end
 
@@ -545,24 +568,21 @@
 Default.UpdateObjectives = function(handler, block)
   local print = lprint
   local info = block.info
-  print('   |cFF00FF00default objectives routine', block:GetName())
+  print('|cFF00FF00default.objectives', block:GetName())
+  -- reset the starting positions
   block.endPoint = block.titlebg
   block.attachmentHeight = 0
   block.currentLine = 0
 
-  -- reset the starting positions
-  block.attachmentHeight = 0
-  block.endPoint = block.titlebg
-  local completionScore, completionMax = 0, 0
   local displayObjectiveHeader = false
 
+  block.attachmentHeight = 0
+  local text, attachment, template
+  if info.statusKey and (Devian and Devian.InWorkspace()) then
+    handler:AddLine(block, info.statusKey, nil)
+  end
 
-  --- The first line is going to be used no matter what, so it is hard-pulled.
-  -- It also ensures that we're in the right position for cleaning up the leftover lines.
 
-  block.attachmentHeight = 0
-
-  local text, attachment
   if info.description and #info.description >= 1 then
     print('   |cFF00FFFF  header line:|r', info.description)
     text = info.description
@@ -572,16 +592,16 @@
   if (info.isComplete or info.numObjectives == 0) and info.completionText then
     print('     overriding line #1 for completion text:', info.completionText)
     text = info.completionText
-    Module.AddLine(block, text, nil)
+    handler:AddLine(block, text, nil)
   else
     if info.objectives then
       for i, data in ipairs(info.objectives) do
         local line = handler:GetLine(block)
         displayObjectiveHeader = true
         line.height = 0
-        text, attachment = handler:UpdateLine(block, line, data)
+        text, attachment, template = handler:UpdateLine(block, line, data)
         print('     |cFF88FF00#', i, data.type, text)
-        handler:AddLine(block, text, attachment)
+        handler:AddLine(block, text, attachment, template)
 
       end
     end
@@ -595,25 +615,9 @@
   end
 
   if block.currentLine > 0 then
-    block.attachmentHeight = block.attachmentHeight + textSpacing * 2
+    block.attachmentHeight = block.attachmentHeight + textSpacing
     print('     |cFF00FF00attachment:', block.attachmentHeight)
   end
-
-
-  if debug then
-    for i, region in ipairs(block.debug) do
-      for j = 1, region:GetNumPoints() do
-        local _, target = region:GetPoint(j)
-        if target:IsVisible() then
-          region:Hide()
-        else
-          region:Show()
-        end
-      end
-    end
-  end
-
-  block.completionScore = completionScore / completionMax
 end
 
 
@@ -623,7 +627,7 @@
 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively
 
 
-Default.UpdateLine = function(block, line)
+Default.UpdateLine = function(handler, block, line, data)
   if line.finished then
     line.progress = 2
   elseif line.quantity > 0 then
@@ -631,7 +635,7 @@
   else
     line.progress = 0
   end
-  return line.displayText, line.widget
+  return data.text, line.widget, 'normal'
 end
 ----------
 --- Top level methods