changeset 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
files ObjectiveTracker/BonusObjectives.lua ObjectiveTracker/Frame.lua ObjectiveTracker/ObjectiveTracker.lua ObjectiveTracker/ObjectiveTracker.xml ObjectiveTracker/Quests.lua
diffstat 5 files changed, 133 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/ObjectiveTracker/BonusObjectives.lua	Thu Apr 14 19:39:05 2016 -0400
+++ b/ObjectiveTracker/BonusObjectives.lua	Fri Apr 15 07:01:40 2016 -0400
@@ -18,49 +18,6 @@
 local GetQuestLogRewardMoney, GetMoneyString = GetQuestLogRewardMoney, GetMoneyString
 local GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime = GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime
 
-local DoQuestRewards = function(t, questID)
-  local rewards = {}
-  t.numCurrencies = GetNumQuestLogRewardCurrencies(questID)
-  for i = 1, t.numCurrencies do
-    local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID)
-    tinsert(rewards,{
-      type = 'currency',
-      index = i,
-      name = name,
-      texture = texture,
-      count = count
-    });
-  end
-  -- items
-  t.numItems = GetNumQuestLogRewards(questID)
-  for i = 1, t.numItems do
-    local name, texture, count, quality, isUsable = GetQuestLogRewardInfo(i, questID)
-    tinsert(rewards, {
-      type = 'item',
-      index = i ,
-      name = name,
-      texture = texture,
-      count = count,
-      quality = quality,
-      isUsable = isUsable
-    });
-  end
-  -- money
-
-  local money = GetQuestLogRewardMoney(questID)
-  if ( money > 0 ) then
-    tinsert(rewards, {
-      type = 'money',
-      name = GetMoneyString(money),
-      texture = "Interface\\Icons\\inv_misc_coin_01",
-      count = 0,
-    });
-  end
-
-  if #rewards >= 1 then
-    t.rewardInfo = rewards
-  end
-end
 
 --- Returns a tasks table modified to include recently completed objectives
 local InternalGetTasksTable = function()
@@ -159,7 +116,7 @@
       t.taskIndex = i
 
 
-      DoQuestRewards(t, questID)
+      T.SetRewards(t, questID)
 
       local taskTitle
       local taskFinished = true;
--- 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])
--- a/ObjectiveTracker/ObjectiveTracker.lua	Thu Apr 14 19:39:05 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.lua	Fri Apr 15 07:01:40 2016 -0400
@@ -409,6 +409,67 @@
   end
 end
 
+local iprint = B.print('Info')
+T.SetRewards = function(t, questID)
+
+  SelectQuestLogEntry(GetQuestLogIndexByID(questID))
+  local numQuestChoices = GetNumQuestLogChoices();
+  local skillName, skillIcon, skillPoints = GetQuestLogRewardSkillPoints();
+  local xp = GetQuestLogRewardXP();
+  local playerTitle = GetQuestLogRewardTitle();
+  ProcessQuestLogRewardFactions();
+  local rewards = {}
+  local texture, name, isTradeskillSpell, isSpellLearned, hideSpellLearnText, isBoostSpell, garrFollowerID = GetQuestLogRewardSpell(questID)
+  if name  then
+    tinsert(rewards,{
+      type = 'spell',
+      name = name,
+      texture = texture,
+    })
+  end
+
+  t.numCurrencies = GetNumQuestLogRewardCurrencies(questID)
+  for i = 1, t.numCurrencies do
+    local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID)
+    tinsert(rewards,{
+      type = 'currency',
+      index = i,
+      name = name,
+      texture = texture,
+      count = count
+    });
+  end
+  -- items
+  t.numItems = GetNumQuestLogRewards(questID)
+  for i = 1, t.numItems do
+    local name, texture, count, quality, isUsable = GetQuestLogRewardInfo(i, questID)
+    tinsert(rewards, {
+      type = 'item',
+      index = i ,
+      name = name,
+      texture = texture,
+      count = count,
+      quality = quality,
+      isUsable = isUsable
+    });
+  end
+  -- money
+
+  local money = GetQuestLogRewardMoney(questID)
+  if ( money > 0 ) then
+    tinsert(rewards, {
+      type = 'money',
+      name = GetMoneyString(money),
+      texture = "Interface\\Icons\\inv_misc_coin_01",
+      count = 0,
+    });
+  end
+
+  if #rewards >= 1 then
+    t.rewardInfo = rewards
+  end
+end
+
 local Play = function(file) if Devian and Devian.InWorkspace() then PlaySoundFile(file) end end
 
 function T:OnEvent (event, ...)
--- a/ObjectiveTracker/ObjectiveTracker.xml	Thu Apr 14 19:39:05 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.xml	Fri Apr 15 07:01:40 2016 -0400
@@ -329,18 +329,17 @@
             </Anchors>
           </Texture>
 
-        <Texture name="$parentItemTile" parentKey="icon" alphaMode="BLEND" hidden="true">
-          <Anchors>
-            <Anchor point="TOPRIGHT" x="0" y="0" />
-          </Anchors>
-        </Texture>
+        <Texture alpha="0.75" parentArray="rewardTile" hidden="true" />
+        <Texture alpha="0.66" parentArray="rewardTile" hidden="true" />
+        <Texture alpha="0.57" parentArray="rewardTile" hidden="true" />
+
         <Texture parentKey="typeTag" file="Interface\QuestFrame\QuestTypeIcons" alphaMode="ADD" hidden="true">
           <Size x="18" y="18"/>
           <Anchors>
             <Anchor point="TOPRIGHT" relativePoint="TOPLEFT" relativeKey="$parent.FrequencyTag" x="-3" y="-3"/>
-
           </Anchors>
         </Texture>
+
         <Texture parentKey="frequencyTag" file="Interface\QuestFrame\QuestTypeIcons" alphaMode="ADD" hidden="true">
           <Size x="18" y="18"/>
           <Anchors>
@@ -355,7 +354,11 @@
 
           </Anchors>
         </Texture>
-        <Texture name="$parentMoneyTile" parentKey="money" hidden="true" />
+        <Texture name="$parentMoneyTile" parentKey="money" hidden="true">
+          <Size x="16" y="16" />
+
+        </Texture>
+
 
         <Texture parentKey="SelectionOverlay" alphaMode="ADD" hidden="true">
           <Anchors>
@@ -389,11 +392,9 @@
             <Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" />
           </Anchors>
         </FontString>
-        <FontString name="$parentItemTileText" parentKey="iconLabel" inherits="VeneerNumberFont">
-          <Anchors>
-            <Anchor point="TOPRIGHT" x="-1" y="-4" relativeKey="$parent.icon" />
-          </Anchors>
-        </FontString>
+        <FontString parentArray="rewardLabel" inherits="VeneerNumberFont" />
+        <FontString parentArray="rewardLabel" inherits="VeneerNumberFont" />
+        <FontString parentArray="rewardLabel" inherits="VeneerNumberFont" />
 
 
         <Texture alphaMode="BLEND" parentArray="config" hidden="true">
--- a/ObjectiveTracker/Quests.lua	Thu Apr 14 19:39:05 2016 -0400
+++ b/ObjectiveTracker/Quests.lua	Fri Apr 15 07:01:40 2016 -0400
@@ -115,13 +115,21 @@
 
   Quest.Info[questID] = Quest.Info[questID] or {}
 
-  local showQuest = true
-  if isTask then
-    showQuest = false
-  end
 
   local q = Quest.Info[questID]
+  q.watchIndex = watchIndex
+  q.type = 'Quest'
+  q.id = questID
+  q.questID = questID
+  q.title = title
+  q.level = level
+  q.displayQuestID = displayQuestID
+  q.suggestedGroup = suggestedGroup
+  q.questLogIndex = questLogIndex
+
   -- re-use Blizzard logic for consistency
+  local showQuest = true
+  if isTask then showQuest = false end
   local watchMoney = false;
   local tagID, typeTag, frequencyTag, completionTag, completionText
   local isAccount, isFaction, isWeekly, isDaily = false, false, false, false
@@ -211,8 +219,11 @@
   end
   q.numObjectives = numObjectives
   q.objectives = objectives
+  q.requiredMoney = requiredMoney
   q.moneyInfo = moneyInfo
   q.timerInfo = timerInfo
+  q.failureTime = failureTime
+  q.timeElapsed = timeElapsed
   q.completionText = completionText
 
   -- POI data
@@ -316,25 +327,14 @@
     }
   end
 
-  -- resolved data
+  if moneyInfo or timerInfo then
+    numObjectives = #objectives
+  end
 
   -- raw data
-  q.watchIndex = watchIndex
-  q.type = 'Quest'
-  q.id = questID
-  q.questID = questID
-  q.title = title
-  q.level = level
-  q.displayQuestID = displayQuestID
-  q.suggestedGroup = suggestedGroup
-  q.questLogIndex = questLogIndex
-  q.numObjectives = numObjectives
-  q.requiredMoney = requiredMoney
   q.isComplete = isComplete
   q.startEvent = startEvent
   q.isAutoComplete = isAutoComplete
-  q.failureTime = failureTime
-  q.timeElapsed = timeElapsed
   q.questType = questType
   q.isTask = isTask
   q.isStory = isStory
@@ -345,8 +345,10 @@
   q.isStory = isStory
   q.isTask = isTask
   q.statusKey = temp_status
+  q.selected =  (questID == superTrackQuestID)
 
-  q.selected =  (questID == superTrackQuestID) -- call directly so artifact data doesn't become an issue
+  T.SetRewards(q, questID)
+
   self.WatchInfo[watchIndex] = q
   self.LogInfo[questLogIndex] = q