comparison ObjectiveTracker/BonusObjectives.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
comparison
equal deleted inserted replaced
31:48b3e3959a0a 32:a3afe6c3771e
16 local GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo = GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo 16 local GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo = GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo
17 local GetNumQuestLogRewards, GetQuestLogRewardInfo = GetNumQuestLogRewards, GetQuestLogRewardInfo 17 local GetNumQuestLogRewards, GetQuestLogRewardInfo = GetNumQuestLogRewards, GetQuestLogRewardInfo
18 local GetQuestLogRewardMoney, GetMoneyString = GetQuestLogRewardMoney, GetMoneyString 18 local GetQuestLogRewardMoney, GetMoneyString = GetQuestLogRewardMoney, GetMoneyString
19 local GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime = GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime 19 local GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime = GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime
20 20
21 local DoQuestRewards = function(t, questID)
22 local rewards = {}
23 t.numCurrencies = GetNumQuestLogRewardCurrencies(questID)
24 for i = 1, t.numCurrencies do
25 local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID)
26 tinsert(rewards,{
27 type = 'currency',
28 index = i,
29 name = name,
30 texture = texture,
31 count = count
32 });
33 end
34 -- items
35 t.numItems = GetNumQuestLogRewards(questID)
36 for i = 1, t.numItems do
37 local name, texture, count, quality, isUsable = GetQuestLogRewardInfo(i, questID)
38 tinsert(rewards, {
39 type = 'item',
40 index = i ,
41 name = name,
42 texture = texture,
43 count = count,
44 quality = quality,
45 isUsable = isUsable
46 });
47 end
48 -- money
49
50 local money = GetQuestLogRewardMoney(questID)
51 if ( money > 0 ) then
52 tinsert(rewards, {
53 type = 'money',
54 name = GetMoneyString(money),
55 texture = "Interface\\Icons\\inv_misc_coin_01",
56 count = 0,
57 });
58 end
59
60 if #rewards >= 1 then
61 t.rewardInfo = rewards
62 end
63 end
64 21
65 --- Returns a tasks table modified to include recently completed objectives 22 --- Returns a tasks table modified to include recently completed objectives
66 local InternalGetTasksTable = function() 23 local InternalGetTasksTable = function()
67 local savedTasks = T.Conf.TasksLog 24 local savedTasks = T.Conf.TasksLog
68 local char = UnitName("player") 25 local char = UnitName("player")
157 t.id = questID 114 t.id = questID
158 t.objectives = {} 115 t.objectives = {}
159 t.taskIndex = i 116 t.taskIndex = i
160 117
161 118
162 DoQuestRewards(t, questID) 119 T.SetRewards(t, questID)
163 120
164 local taskTitle 121 local taskTitle
165 local taskFinished = true; 122 local taskFinished = true;
166 for objectiveIndex = 1, numObjectives do 123 for objectiveIndex = 1, numObjectives do
167 local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false); 124 local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false);