diff ObjectiveFrame.lua @ 18:d1812fb10ae6

ObjectiveStyle - move tag/template logic into the corresponding GetInfo
author Nenue
date Tue, 05 Apr 2016 02:38:01 -0400
parents 880828018bf4
children 605e8f0e46db
line wrap: on
line diff
--- a/ObjectiveFrame.lua	Tue Apr 05 00:44:25 2016 -0400
+++ b/ObjectiveFrame.lua	Tue Apr 05 02:38:01 2016 -0400
@@ -41,7 +41,6 @@
 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2
 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0}
 
-
 mod.InitializeWrapper = function()
 
   mod.SetBlockStyle(Scroller, 'Scroller', 'Normal')
@@ -159,7 +158,7 @@
   local tracker = handler.Tracker
   print('|cFFFF4400'..tracker:GetName().. '|r:Update()')
   local blockIndex = 0
-  local trackerHeight = headerHeight
+  local trackerHeight = tracker.titleHeight
 
 
   previousBlock = tracker.title
@@ -226,8 +225,8 @@
   local t = handler:GetBlock(blockIndex)
   t.handler = handler
   t.info = info
-  t.mainStyle = 'Normal'
-  t.subStyle = nil
+  t.mainStyle = info.mainStyle or 'Normal'
+  t.subStyle = info.subStyle
 
   info.blockIndex = blockIndex
   if info.questID then handler.QuestBlock[info.questID] = t end
@@ -237,16 +236,23 @@
 
 
   t.attachmentHeight = 0
-  --if info.isComplete then
-    --t.status:Show()
-    --t.status:SetText(info.completionText)
-  --end
 
-  if info.numObjectives >= 1 then
+
+
+
+
+  if info.isComplete == 1 then
+    if info.popupInfo then
+      t.status:SetText('(Click to Complete)')
+    else
+      t.status:SetText('Ready to turn in')
+    end
+  elseif info.completed then
+    t.status:SetText(nil)
+  elseif info.numObjectives >= 1 then
     t.attachmentHeight = 0
     t.status:Show()
     print('    lines to build:', info.numObjectives)
-
     local text = ''
 
     mod.UpdateObjectives(t, info, text)
@@ -266,8 +272,6 @@
     --info.itemButton = nil
   end
 
-  handler.SetBlockTags(t, info)
-
   if previousBlock then
     t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0)
     t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
@@ -281,23 +285,56 @@
 
   print('  |cFF00FFFF)|r -> ', t, t:GetHeight())
 
+  local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t, 'TOPRIGHT'
   if info.rewardInfo then
     print('has immediate reward')
     if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then
       t.icon:Show()
       t.iconLabel:SetText(info.rewardInfo[1].count)
       t.icon:SetSize(t.height, t.height)
+      t.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
+      tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.icon, 'TOPLEFT'
       t.icon:SetTexture(info.rewardInfo[1].texture)
     end
-
   else
     t.icon:Hide()
   end
 
-  if Devian and Devian.InWorkspace() then
+  if info.selected then
+    t.SelectionOverlay:Show()
+  else
+    t.SelectionOverlay:Hide()
+  end
+
+  if info.frequencyTag then
+    t.FrequencyTag:SetTexCoord(unpack(info.frequencyTag))
+    t.FrequencyTag:Show()
+    t.FrequencyTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
+    tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.FrequencyTag, 'TOPLEFT'
+  else
+    t.FrequencyTag:Hide()
+  end
+  if info.typeTag then
+    t.TypeTag:SetTexCoord(unpack(info.typeTag))
+    t.TypeTag:Show()
+    t.TypeTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
+    tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.TypeTag, 'TOPLEFT'
+  else
+    t.TypeTag:Hide()
+  end
+  if info.completionTag then
+    t.CompletionTag:SetTexCoord(unpack(info.completionTag))
+    t.CompletionTag:Show()
+    t.CompletionTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
+    tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.CompletionTag, 'TOPLEFT'
+  else
+    t.CompletionTag:Hide()
+  end
+
+  --[[if Devian and Devian.InWorkspace() then
     t.debugText:Show()
     t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle)))
-  end
+  end]]
   return t
 end
 
@@ -306,7 +343,7 @@
   print('   |cFF00FF00objective updates for', block:GetName())
 
   local attachmentHeight = block.attachmentHeight
-  if info.description then
+  if info.description and not(info.earnedBy or info.isComplete) then
     print('  -- has description text:', select('#', info.description), info.description)
     text = info.description
   end
@@ -321,12 +358,10 @@
       line.title = nil
     end
 
-
     if line.widget then
       if attachmentHeight == 0 then
         attachmentHeight = block.status.spacing
       end
-
       line.widget:Show()
       line.widget:SetParent(block)
       line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight )
@@ -340,14 +375,19 @@
       print('   has text')
       text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r'
     end
-
   end
 
   block.completionScore = completionScore / completionMax
   block.attachmentHeight = attachmentHeight
 
-  block.status:SetText(text)
-  block.status:SetWordWrap(true)
+  if #text >= 1 then
+    block.status:SetText(text)
+    block.status:SetWordWrap(true)
+  else
+    block.status:SetText(nil)
+    block.status:Hide()
+  end
+
 end
 
 --- Objective parsers
@@ -517,8 +557,8 @@
     '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(),
     '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5)
   )
+  --]]
   mod.UpdateActionButtons()
-  --]]
 
 end
 
@@ -622,3 +662,7 @@
 mod.UpdateItemButtonCooldown = function(button)
 
 end
+
+local unitLevel = UnitLevel('player')
+
+