diff ObjectiveTracker/Frame.lua @ 32:a3afe6c3771e

- organize and display reward icons as a background hint - centralize reward data function
author Nenue
date Fri, 15 Apr 2016 07:01:40 -0400
parents 48b3e3959a0a
children 64f2a9bbea79
line wrap: on
line diff
--- a/ObjectiveTracker/Frame.lua	Thu Apr 14 19:39:05 2016 -0400
+++ b/ObjectiveTracker/Frame.lua	Fri Apr 15 07:01:40 2016 -0400
@@ -79,7 +79,7 @@
 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
-local rewardSize = 32
+local rewardSize = 24
 local oprint = B.print('Objectives')
 local bprint = B.print('Block')
 local tprint = B.print('Tracker')
@@ -248,8 +248,17 @@
       block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
       block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
 
-      block.icon:SetSize(rewardSize, rewardSize)
-      block.icon:SetPoint('TOPRIGHT', block, 'TOPRIGHT', -2, -2)
+      --block.icon:SetSize(rewardSize, rewardSize)
+      --block.icon:SetPoint()
+      local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
+      for i, tile in ipairs(block.rewardTile)  do
+        print(rewardSize)
+        tile:SetSize(rewardSize, rewardSize)
+        tile:ClearAllPoints()
+        tile:SetPoint(anchor, target, point, x, y)
+        block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, -2)
+        anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
+      end
 
 
       --- methods for event handlers
@@ -528,19 +537,29 @@
     --info.itemButton = nil
   end
 
-  local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block, 'TOPRIGHT'
+  local tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
 
-  if info.rewardInfo then
-    print('has immediate reward')
-    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:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
-      tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block.icon, 'TOPLEFT'
-      block.icon:SetTexture(info.rewardInfo[1].texture)
+  local numCurrency = 0
+  for i, rewardTile in ipairs(block.rewardTile) do
+    local reward = info.rewardInfo[i]
+    if reward then
+      --rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
+      rewardTile:SetTexture(reward.texture)
+      rewardTile:Show()
+
+      print('updating reward tile #'.. i, reward.type, reward.count, reward.text, reward.texture)
+      if reward.count and reward.count > 1 then
+        block.rewardLabel[i]:SetText(reward.count)
+        block.rewardLabel[i]:Show()
+      end
+
+      rewardTile:ClearAllPoints()
+      rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, x, y)
+      tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', rewardTile, 'TOPLEFT', -2, 0
+    else
+      rewardTile:Hide()
+      block.rewardLabel[i]:Hide()
     end
-  else
-    block.icon:Hide()
   end
 
   if info.selected then
@@ -578,9 +597,6 @@
 
   block.attachmentHeight = 0
   local text, attachment, template
-  if info.statusKey and (Devian and Devian.InWorkspace()) then
-    handler:AddLine(block, info.statusKey, nil)
-  end
 
 
   if info.description and #info.description >= 1 then
@@ -607,6 +623,10 @@
     end
   end
 
+  if info.statusKey and (Devian and Devian.InWorkspace()) then
+    handler:AddLine(block, info.statusKey, nil)
+  end
+
   for i = block.currentLine + 1, block.numLines do
     print(i, block.numLines)
     print('      - hide |cFFFF0088'..i..'|r', block.lines[i])