Mercurial > wow > buffalo2
comparison ObjectiveInfo.lua @ 22:9b3fa734abff
ObjectiveFrame
- polish quest rewards display
- implement money objectives
- set line metrics in UpdateLine
- set block metrics in UpdateBlock (sum of line metrics)
author | Nenue |
---|---|
date | Sat, 09 Apr 2016 07:32:45 -0400 |
parents | d5ee940de273 |
children |
comparison
equal
deleted
inserted
replaced
21:d5ee940de273 | 22:9b3fa734abff |
---|---|
1 local B = select(2,...).frame | 1 local B = select(2,...).frame |
2 local wipe, pairs, ipairs, min, max, unpack, format = table.wipe, pairs, ipairs, min, max, unpack, format | 2 local wipe, pairs, ipairs, min, max, unpack, format, mod = table.wipe, pairs, ipairs, min, max, unpack, format, mod |
3 local tinsert, tostring = tinsert, tostring | 3 local tinsert, tostring = tinsert, tostring |
4 local GetQuestTagInfo, GetQuestLogTitle = GetQuestTagInfo, GetQuestLogTitle | 4 local GetQuestTagInfo, GetQuestLogTitle = GetQuestTagInfo, GetQuestLogTitle |
5 local GetNumQuestLogEntries, GetNumQuestWatches, GetQuestLogCompletionText, IsQuestWatched, IsQuestHardWatched, GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown = GetNumQuestLogEntries, GetNumQuestWatches, GetQuestLogCompletionText, IsQuestWatched, IsQuestHardWatched, GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown | 5 local GetNumQuestLogEntries, GetNumQuestWatches, GetQuestLogCompletionText, IsQuestWatched, IsQuestHardWatched, GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown = GetNumQuestLogEntries, GetNumQuestWatches, GetQuestLogCompletionText, IsQuestWatched, IsQuestHardWatched, GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown |
6 local GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetTasksTable, GetNumQuestLogTasks, GetTaskInfo, GetQuestObjectiveInfo = GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetTasksTable, GetNumQuestLogTasks, GetTaskInfo, GetQuestObjectiveInfo | 6 local GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetTasksTable, GetNumQuestLogTasks, GetTaskInfo, GetQuestObjectiveInfo = GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetTasksTable, GetNumQuestLogTasks, GetTaskInfo, GetQuestObjectiveInfo |
7 local GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo, GetNumQuestLogRewards, GetQuestLogRewardInfo, GetQuestLogRewardMoney, GetMoneyString = GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo, GetNumQuestLogRewards, GetQuestLogRewardInfo, GetQuestLogRewardMoney, GetMoneyString | 7 local GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo, GetNumQuestLogRewards, GetQuestLogRewardInfo, GetQuestLogRewardMoney, GetMoneyString = GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo, GetNumQuestLogRewards, GetQuestLogRewardInfo, GetQuestLogRewardMoney, GetMoneyString |
8 local GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo = GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo | 8 local GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo = GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo |
9 local GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo = GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo | 9 local GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo = GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo |
10 local QuestHasPOIInfo, GetDistanceSqToQuest, GetQuestFactionGroup = QuestHasPOIInfo, GetDistanceSqToQuest, GetQuestFactionGroup | 10 local QuestHasPOIInfo, GetDistanceSqToQuest, GetQuestFactionGroup = QuestHasPOIInfo, GetDistanceSqToQuest, GetQuestFactionGroup |
11 local GetTrackedAchievements, GetNumTrackedAchievements, GetAchievementInfo = GetTrackedAchievements, GetNumTrackedAchievements, GetAchievementInfo | 11 local GetTrackedAchievements, GetNumTrackedAchievements, GetAchievementInfo = GetTrackedAchievements, GetNumTrackedAchievements, GetAchievementInfo |
12 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | 12 local GetMoney, floor = GetMoney, floor |
13 local print = B.print('TrackerInfo') | 13 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') |
14 local print = B.print('Info') | |
14 local QUEST_TAG_DUNGEON = QUEST_TAG_DUNGEON | 15 local QUEST_TAG_DUNGEON = QUEST_TAG_DUNGEON |
15 local QUEST_TAG_GROUP = QUEST_TAG_GROUP | 16 local QUEST_TAG_GROUP = QUEST_TAG_GROUP |
16 local QUEST_TAG_ACCOUNT = QUEST_TAG_ACCOUNT | 17 local QUEST_TAG_ACCOUNT = QUEST_TAG_ACCOUNT |
17 local QUEST_TAG_TCOORDS = QUEST_TAG_TCOORDS | 18 local QUEST_TAG_TCOORDS = QUEST_TAG_TCOORDS |
18 local LE_QUEST_FREQUENCY_DAILY = LE_QUEST_FREQUENCY_DAILY | 19 local LE_QUEST_FREQUENCY_DAILY = LE_QUEST_FREQUENCY_DAILY |
19 local LE_QUEST_FREQUENCY_WEEKLY = LE_QUEST_FREQUENCY_WEEKLY | 20 local LE_QUEST_FREQUENCY_WEEKLY = LE_QUEST_FREQUENCY_WEEKLY |
20 local FACTION_ALLIANCE, LE_QUEST_FACTION_HORDE, FACTION_HORDE, LE_QUEST_FACTION_HORDE = FACTION_ALLIANCE, LE_QUEST_FACTION_HORDE, FACTION_HORDE, LE_QUEST_FACTION_HORDE | 21 local FACTION_ALLIANCE, LE_QUEST_FACTION_HORDE, FACTION_HORDE, LE_QUEST_FACTION_HORDE = FACTION_ALLIANCE, LE_QUEST_FACTION_HORDE, FACTION_HORDE, LE_QUEST_FACTION_HORDE |
21 | 22 |
22 local Tracker, Bonus, AutoQuest, Quest, Cheevs = mod.DefaultTracker, mod.Bonus, mod.AutoQuest, mod.Quest, mod.Cheevs | 23 local Tracker, Bonus, AutoQuest, Quest, Cheevs = T.DefaultTracker, T.Bonus, T.AutoQuest, T.Quest, T.Cheevs |
23 -------------------------------------------------------------------- | 24 -------------------------------------------------------------------- |
24 --- Tracker-specific data retrieval functions | 25 --- Tracker-specific data retrieval functions |
25 -------------------------------------------------------------------- | 26 -------------------------------------------------------------------- |
26 | 27 |
27 | 28 |
28 ----------------------------- | 29 local DoQuestRewards= function(t, questID) |
29 --- AUTO_QUEST | |
30 AutoQuest.LogInfo = {} | |
31 AutoQuest.LogBlock = {} | |
32 AutoQuest.QuestBlock = {} | |
33 AutoQuest.WatchBlock = {} | |
34 function AutoQuest:GetNumWatched () | |
35 print(self.name, self) | |
36 Quest:GetNumWatched() | |
37 self.numWatched = GetNumAutoQuestPopUps() | |
38 | |
39 return self.numWatched | |
40 end | |
41 AutoQuest.GetInfo = function(self, popupIndex) | |
42 | |
43 local questID, type = GetAutoQuestPopUp(popupIndex) | |
44 local questIndex = GetQuestLogIndexByID(questID) | |
45 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex) | |
46 | |
47 self.Info[questID] = { | |
48 title = title, | |
49 description = type, | |
50 popupType = type, | |
51 questID = questID, | |
52 questIndex = questIndex, | |
53 popupIndex = popupIndex, | |
54 } | |
55 self.WatchInfo[popupIndex] = self.Info[questID] | |
56 | |
57 | |
58 return self.Info[questID] | |
59 end | |
60 | |
61 ----------------------------- | |
62 --- BONUS OBJECTIVE | |
63 -- The default UI pops them up as you enter their relevant areas, but the data is actually available at all times. | |
64 -- The only requirement is that you've been to said area and progressed any of the objectives. | |
65 -- Blizzard deal with this fact by caching any task data collected during session and masking out whatever gets completed. | |
66 -- For the addon's module structure to work, GetNumWatched method also invokes a tasks table scan. | |
67 -- That composes the table searched by GetInfo(). | |
68 | |
69 ------------------------------------------------------------------------------------------ | |
70 --- These functions are copied from Blizzard_BonusObjectiveTracker.lua; | |
71 -- It's kind of dumb, but this avoids the risk of code taint. | |
72 | |
73 --- Returns a tasks table modified to include recently completed objectives | |
74 local completedTasks = {} | |
75 local InternalGetTasksTable = function() | |
76 local tasks = GetTasksTable() | |
77 for questID, data in pairs(completedTasks) do | |
78 if questID > 0 then | |
79 local found = false | |
80 for i = 1, #tasks do | |
81 if tasks[i] == questID then | |
82 found = true | |
83 break | |
84 end | |
85 end | |
86 -- if it's not part of the current table, then try to insert it where it was last found | |
87 if not found then | |
88 if data.watchIndex < #tasks then | |
89 tinsert(tasks, data.watchIndex, data) | |
90 else | |
91 tinsert(tasks, data) | |
92 end | |
93 end | |
94 end | |
95 end | |
96 return tasks | |
97 end | |
98 | |
99 --- Returns an entry from the composed tasks table if possible, otherwise makes an API pull | |
100 local InternalGetTaskInfo = function(questID) | |
101 if completedTasks[questID] then | |
102 return true, true, #completedTasks[questID].objectives | |
103 else | |
104 return GetTaskInfo(questID) | |
105 end | |
106 end | |
107 | |
108 --- Same as above but for the objective entries | |
109 local InternalGetQuestObjectiveInfo = function(questID, objectiveIndex) | |
110 if ( completedTasks[questID] ) then | |
111 return completedTasks[questID].objectives[objectiveIndex], completedTasks[questID].objectiveType, true; | |
112 else | |
113 return GetQuestObjectiveInfo(questID, objectiveIndex, false); | |
114 end | |
115 end | |
116 | |
117 --- end redundant copy of silliness | |
118 ------------------------------------------------------------------------------------------ | |
119 | |
120 Bonus.Completed = {} | |
121 Bonus.POI = {} | |
122 Bonus.Scenario = {} | |
123 Bonus.QuestBlock = {} | |
124 function Bonus:GetNumWatched () | |
125 print(self.name, self) | |
126 local tasks = InternalGetTasksTable() | |
127 local numWatched = 0 | |
128 local numAll = 0 | |
129 self.WatchInfo = {} | |
130 print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks) | |
131 for i, questID in ipairs(tasks) do | |
132 local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID) | |
133 local existingTask = self.QuestBlock[questID] | |
134 local displayObjectiveHeader = false; | |
135 print (' |cFF00FF00taskIndex', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N')) | |
136 if isInArea or isOnMap then | |
137 self.Info[questID] = self.Info[questID] or {} | |
138 | |
139 local t = self.Info[questID] | |
140 local title = GetQuestLogTitle(questID) | |
141 self.WatchInfo[i] = t | |
142 t.title = title | |
143 t.isInArea = isInArea | |
144 t.isOnMap = isOnMap | |
145 t.existingTask = existingTask | |
146 t.questID = questID | |
147 t.objectives = {} | |
148 t.taskIndex = i | |
149 | |
150 local taskFinished = true; | |
151 for objectiveIndex = 1, numObjectives do | |
152 local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false); | |
153 displayObjectiveHeader = displayObjectiveHeader or displayAsObjective; | |
154 print(' --', text, objectiveType, finished, displayAsObjective) | |
155 t.objectives[objectiveIndex] = t.objectives[objectiveIndex] or {} | |
156 local o = t.objectives[objectiveIndex] | |
157 | |
158 o.objectiveIndex = objectiveIndex | |
159 o.text = text | |
160 o.objectiveType = objectiveType | |
161 o.finished = finished | |
162 o.displayAsObjective = displayAsObjective | |
163 print(' |cFF00FF88*', objectiveIndex, text) | |
164 end | |
165 end | |
166 end | |
167 | |
168 | |
169 self.numAll = #tasks | |
170 self.numWatched = #self.WatchInfo | |
171 print(' stats:', self.numAll, 'active tasks,', self.numWatched, 'nearby or animating') | |
172 --return #tasks | |
173 return GetNumQuestLogTasks() | |
174 end | |
175 | |
176 Bonus.GetInfo = function(self, taskIndex) | |
177 print(self.name, self) | |
178 return self.WatchInfo[taskIndex] | |
179 end | |
180 | |
181 Bonus.Store = function(questID) | |
182 | |
183 if not questID then | |
184 print('|cFFFF4400invalid quest ID', questID) | |
185 return | |
186 end | |
187 | |
188 Bonus.Info[questID] = Bonus.Info[questID] or {} | |
189 local t = Bonus.Info[questID] | |
190 local isInArea, isOnMap, numObjectives = GetTaskInfo(questID) | |
191 t.questID = questID | |
192 t.numObjectives = numObjectives | |
193 t.isInArea = isInArea | |
194 t.isOnMap = isOnMap | |
195 | |
196 print(' isInArea', isInArea, 'isOnMap', isOnMap, 'numObj', numObjectives) | |
197 local displayObjectives = false | |
198 local isComplete = true | |
199 if numObjectives >= 1 then | |
200 print(' ', numObjectives,'objective rows') | |
201 t.objectives = {} | |
202 for i = 1, t.numObjectives do | |
203 t.objectives[i] = {} | |
204 local o = t.objectives[i] | |
205 o.index = i | |
206 --local text, objectiveType, finished, displayAsObjective = | |
207 o.text, o.objectiveType, o.finished, o.displayAsObjective = GetQuestObjectiveInfo(questID, i, false) | |
208 | |
209 print(i, '==>', o.text, o.objectiveType, o.finished, o.displayAsObjective) | |
210 t.displayObjectives = t.displayObjectives or o.displayAsObjective | |
211 t.isComplete = t.isComplete and o.finished | |
212 | |
213 end | |
214 end | |
215 | |
216 t.displayObjectives = displayObjectives | |
217 | |
218 | |
219 local rewards = {} | 30 local rewards = {} |
220 t.numCurrencies = GetNumQuestLogRewardCurrencies(questID) | 31 t.numCurrencies = GetNumQuestLogRewardCurrencies(questID) |
221 for i = 1, t.numCurrencies do | 32 for i = 1, t.numCurrencies do |
222 local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID) | 33 local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID) |
223 tinsert(rewards,{ | 34 tinsert(rewards,{ |
255 end | 66 end |
256 | 67 |
257 if #rewards >= 1 then | 68 if #rewards >= 1 then |
258 t.rewardInfo = rewards | 69 t.rewardInfo = rewards |
259 end | 70 end |
71 end | |
72 | |
73 | |
74 ----------------------------- | |
75 --- AUTO_QUEST | |
76 AutoQuest.LogInfo = {} | |
77 AutoQuest.LogBlock = {} | |
78 AutoQuest.QuestBlock = {} | |
79 AutoQuest.WatchBlock = {} | |
80 function AutoQuest:GetNumWatched () | |
81 print(self.name, self) | |
82 Quest:GetNumWatched() | |
83 self.numWatched = GetNumAutoQuestPopUps() | |
84 | |
85 return self.numWatched | |
86 end | |
87 AutoQuest.GetInfo = function(self, popupIndex) | |
88 | |
89 | |
90 local questID, type = GetAutoQuestPopUp(popupIndex) | |
91 local questIndex = GetQuestLogIndexByID(questID) | |
92 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex) | |
93 | |
94 self.Info[questID] = self.Info[questID] or {} | |
95 local popup = self.Info[questID] | |
96 popup.title = title | |
97 popup.description = type | |
98 popup.popupType = type | |
99 popup.questID = questID | |
100 popup.questIndex = questIndex | |
101 popup.popupIndex = popupIndex | |
102 | |
103 self.Info[questID] = popup | |
104 self.WatchInfo[popupIndex] = popup | |
105 | |
106 | |
107 return self.Info[questID] | |
108 end | |
109 | |
110 ----------------------------- | |
111 --- BONUS OBJECTIVE | |
112 -- The default UI pops them up as you enter their relevant areas, but the data is actually available at all times. | |
113 -- The only requirement is that you've been to said area and progressed any of the objectives. | |
114 -- Blizzard deal with this fact by caching any task data collected during session and masking out whatever gets completed. | |
115 -- For the addon's module structure to work, GetNumWatched method also invokes a tasks table scan. | |
116 -- That composes the table searched by GetInfo(). | |
117 | |
118 ------------------------------------------------------------------------------------------ | |
119 --- These functions are copied from Blizzard_BonusObjectiveTracker.lua; | |
120 -- It's kind of dumb, but this avoids the risk of code taint. | |
121 | |
122 --- Returns a tasks table modified to include recently completed objectives | |
123 local UnitName, GetRealmName = UnitName, GetRealmName | |
124 local InternalGetTasksTable = function() | |
125 local completedTasks = T.Conf.TasksLog | |
126 local char = UnitName("player") | |
127 local realm = GetRealmName() | |
128 local tasks = GetTasksTable() | |
129 | |
130 for questID, data in pairs(Bonus.Info) do | |
131 | |
132 print(' -- questID:', questID, #data.objectives) | |
133 for i, o in ipairs(data.objectives) do | |
134 print(' --', i, o.text) | |
135 end | |
136 | |
137 end | |
138 | |
139 | |
140 for questID, data in pairs(completedTasks) do | |
141 if questID > 0 then | |
142 local found = false | |
143 for i = 1, #tasks do | |
144 if tasks[i] == questID then | |
145 found = true | |
146 break | |
147 end | |
148 end | |
149 -- if it's not part of the current table, then try to insert it where it was last found | |
150 if not found then | |
151 if data.watchIndex < #tasks then | |
152 tinsert(tasks, data.watchIndex, data) | |
153 else | |
154 tinsert(tasks, data) | |
155 end | |
156 end | |
157 end | |
158 end | |
159 return tasks | |
160 end | |
161 | |
162 --- Returns an entry from the composed tasks table if possible, otherwise makes an API pull | |
163 local InternalGetTaskInfo = function(questID) | |
164 local completedTasks = T.Conf.TasksLog | |
165 if completedTasks[questID] then | |
166 return true, true, #completedTasks[questID].objectives | |
167 else | |
168 return GetTaskInfo(questID) | |
169 end | |
170 end | |
171 | |
172 --- Same as above but for the objective entries | |
173 local InternalGetQuestObjectiveInfo = function(questID, objectiveIndex) | |
174 local completedTasks = T.Conf.TasksLog | |
175 if ( completedTasks[questID] ) then | |
176 print('using internal data') | |
177 return completedTasks[questID].objectives[objectiveIndex], completedTasks[questID].objectiveType, true; | |
178 else | |
179 return GetQuestObjectiveInfo(questID, objectiveIndex, false); | |
180 end | |
181 end | |
182 | |
183 --- end redundant copy of silliness | |
184 ------------------------------------------------------------------------------------------ | |
185 | |
186 Bonus.Completed = {} | |
187 Bonus.POI = {} | |
188 Bonus.Scenario = {} | |
189 Bonus.QuestBlock = {} | |
190 Bonus.WatchInfo = {} | |
191 function Bonus:GetNumWatched () | |
192 print(self.name, self) | |
193 | |
194 local tasks = InternalGetTasksTable() | |
195 local numWatched = 0 | |
196 local numAll = 0 | |
197 self.WatchInfo = {} | |
198 print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks) | |
199 print(' TasksTable pull:') | |
200 for i, questID in ipairs(tasks) do | |
201 local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID) | |
202 local existingTask = self.QuestBlock[questID] | |
203 local displayObjectiveHeader = false; | |
204 local test = (isInArea or (isOnMap and existingTask)) | |
205 --local test = true | |
206 if test then | |
207 self.Info[questID] = self.Info[questID] or {} | |
208 | |
209 local t = self.Info[questID] | |
210 self.WatchInfo[i] = t | |
211 t.isInArea = isInArea | |
212 t.isOnMap = isOnMap | |
213 t.existingTask = existingTask | |
214 t.questID = questID | |
215 t.objectives = {} | |
216 t.taskIndex = i | |
217 | |
218 | |
219 DoQuestRewards(t, questID) | |
220 | |
221 local taskTitle | |
222 local taskFinished = true; | |
223 for objectiveIndex = 1, numObjectives do | |
224 local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false); | |
225 displayObjectiveHeader = displayObjectiveHeader or displayAsObjective; | |
226 if not taskTitle then | |
227 if objectiveType == 'progressbar' and not text:match('^%d%+\\%d+') then | |
228 taskTitle = text | |
229 text = '' | |
230 end | |
231 end | |
232 | |
233 | |
234 print(' --', text, objectiveType, finished, displayAsObjective) | |
235 t.objectives[objectiveIndex] = t.objectives[objectiveIndex] or {} | |
236 local o = t.objectives[objectiveIndex] | |
237 | |
238 o.objectiveIndex = objectiveIndex | |
239 o.text = text | |
240 o.objectiveType = objectiveType | |
241 o.finished = finished | |
242 o.displayAsObjective = displayAsObjective | |
243 print(' |cFF00FF88*', objectiveIndex, text) | |
244 end | |
245 | |
246 -- didn't get a name from progress bar? what about area name | |
247 if not taskTitle then | |
248 if isInArea then | |
249 taskTitle = GetMapNameByID(GetCurrentMapAreaID()) | |
250 end | |
251 end | |
252 t.title = taskTitle | |
253 end | |
254 | |
255 print (' |cFF00FF88#', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N'), (test and '|cFF00FF00show|r' or '|cFFFF0088hide|r')) | |
256 end | |
257 | |
258 | |
259 self.numAll = #tasks | |
260 self.numWatched = #self.WatchInfo | |
261 print(' stats:', self.numAll, 'active tasks,', self.numWatched, 'nearby or animating') | |
262 --return #tasks | |
263 return #self.WatchInfo | |
264 end | |
265 | |
266 --- info cleanup done when turn-ins are detected | |
267 Bonus.OnTurnIn = function(self, questID, xp, money) | |
268 print('|cFFFF8800'..self.name..':OnTurnIn call', questID, xp, money) | |
269 | |
270 | |
271 | |
272 end | |
273 | |
274 Bonus.GetInfo = function(self, taskIndex) | |
275 print(self.name, self) | |
276 return self.WatchInfo[taskIndex] | |
277 end | |
278 | |
279 Bonus.Store = function(questID) | |
280 | |
281 if not questID then | |
282 print('|cFFFF4400invalid quest ID', questID) | |
283 return | |
284 end | |
285 | |
286 Bonus.Info[questID] = Bonus.Info[questID] or {} | |
287 local t = Bonus.Info[questID] | |
288 local isInArea, isOnMap, numObjectives = GetTaskInfo(questID) | |
289 t.questID = questID | |
290 t.numObjectives = numObjectives | |
291 t.isInArea = isInArea | |
292 t.isOnMap = isOnMap | |
293 | |
294 print(' isInArea', isInArea, 'isOnMap', isOnMap, 'numObj', numObjectives) | |
295 local displayObjectives = false | |
296 local isComplete = true | |
297 if numObjectives >= 1 then | |
298 print(' ', numObjectives,'objective rows') | |
299 t.objectives = {} | |
300 for i = 1, t.numObjectives do | |
301 t.objectives[i] = {} | |
302 local o = t.objectives[i] | |
303 o.index = i | |
304 --local text, objectiveType, finished, displayAsObjective = | |
305 o.text, o.objectiveType, o.finished, o.displayAsObjective = GetQuestObjectiveInfo(questID, i, false) | |
306 | |
307 print(i, '==>', o.text, o.objectiveType, o.finished, o.displayAsObjective) | |
308 t.displayObjectives = t.displayObjectives or o.displayAsObjective | |
309 t.isComplete = t.isComplete and o.finished | |
310 | |
311 end | |
312 end | |
313 | |
314 t.displayObjectives = displayObjectives | |
315 | |
316 DoQuestRewards(t, questID) | |
260 | 317 |
261 Bonus.TasksTable[questID] = t | 318 Bonus.TasksTable[questID] = t |
262 | 319 |
263 return t | 320 return t |
264 end | 321 end |
369 q.completionText= GetQuestLogCompletionText(questIndex) | 426 q.completionText= GetQuestLogCompletionText(questIndex) |
370 q.numObjectives = GetNumQuestLeaderBoards(questIndex) | 427 q.numObjectives = GetNumQuestLeaderBoards(questIndex) |
371 q.objectives = {} | 428 q.objectives = {} |
372 for i = 1, q.numObjectives do | 429 for i = 1, q.numObjectives do |
373 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex) | 430 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex) |
431 print(format(' #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished))) | |
374 q.objectives[i] = { | 432 q.objectives[i] = { |
375 index = i, | 433 index = i, |
376 type = type, | 434 type = type, |
377 text = text, | 435 text = text, |
378 finished = finished | 436 finished = finished |
382 elseif type == 'object' then | 440 elseif type == 'object' then |
383 elseif type == 'reputation' then | 441 elseif type == 'reputation' then |
384 elseif type == 'item' then | 442 elseif type == 'item' then |
385 end | 443 end |
386 end | 444 end |
445 | |
446 if requiredMoney >= 1 then | |
447 local money = GetMoney() | |
448 local moneyText = money | |
449 local requiredSilver, requiredCopper | |
450 local requiredGold = (requiredMoney > 10000) and (floor(requiredMoney/10000)) or nil | |
451 if mod(requiredMoney, 10000) ~= 0 then | |
452 requiredSilver = (requiredMoney > 100) and (mod(requiredMoney, 10000) / 100) or nil | |
453 if mod(requiredMoney, 100) ~= 0 then | |
454 requiredCopper = mod(requiredMoney, 100) | |
455 end | |
456 end | |
457 | |
458 -- round the money value down | |
459 if requiredMoney > 9999 and not (requiredSilver or requiredCopper) then | |
460 moneyText = floor(money/10000) | |
461 elseif requiredMoney < 10000 and mod(requiredMoney,100) == 0 then | |
462 moneyText = floor(money/100) | |
463 end | |
464 | |
465 local text = moneyText | |
466 local index = #q.objectives + 1 | |
467 local finished = (GetMoney() >= requiredMoney) | |
468 | |
469 if not finished then | |
470 text = text .. ' / ' .. GetCoinTextureString(requiredMoney, 15) | |
471 else | |
472 text = '' .. GetCoinTextureString(requiredMoney, 15) | |
473 end | |
474 q.objectives[index] = { | |
475 index = index, | |
476 type = 'progressbar', | |
477 quantity = money, | |
478 requiredQuantity = requiredMoney, | |
479 text = text, | |
480 finished = finished | |
481 } | |
482 print(format(' #%d %s %s %s', index, 'money', text, tostring(finished))) | |
483 end | |
484 | |
387 | 485 |
388 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex) | 486 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex) |
389 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex) | 487 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex) |
390 if link or icon or charges then | 488 if link or icon or charges then |
391 q.specialItem = { | 489 q.specialItem = { |