Mercurial > wow > buffalo2
comparison ObjectiveTracker/BonusObjectives.lua @ 34:9856ebc63fa4
- half solution to Update being fired multiple times during load
- change securefunc handlers to dispense a reason code; catch that reason code in the enclosure passed to hooksecurefunc, and decide whether to update or not from there.
author | Nenue |
---|---|
date | Sun, 17 Apr 2016 00:21:45 -0400 |
parents | 64f2a9bbea79 |
children | a487841050be |
comparison
equal
deleted
inserted
replaced
33:64f2a9bbea79 | 34:9856ebc63fa4 |
---|---|
93 local numWatched = 0 | 93 local numWatched = 0 |
94 local numAll = 0 | 94 local numAll = 0 |
95 local existingTasks = {} | 95 local existingTasks = {} |
96 self.WatchInfo = {} | 96 self.WatchInfo = {} |
97 print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks) | 97 print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks) |
98 print(' TasksTable pull:') | 98 print(' |cFF00FFFFInternalGetTaskInfo|r:') |
99 for i, questID in ipairs(tasks) do | 99 for i, questID in ipairs(tasks) do |
100 local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID) | 100 local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID) |
101 local existingTask = self.QuestBlock[questID] | 101 local existingTask = self.QuestBlock[questID] |
102 local displayObjectiveHeader = false; | 102 local displayObjectiveHeader = false; |
103 local test = (isInArea or (isOnMap and existingTask)) | 103 local test = (isInArea or (isOnMap and existingTask)) |
129 | 129 |
130 print(' --', text, objectiveType, finished, displayAsObjective) | 130 print(' --', text, objectiveType, finished, displayAsObjective) |
131 t.objectives[objectiveIndex] = t.objectives[objectiveIndex] or {} | 131 t.objectives[objectiveIndex] = t.objectives[objectiveIndex] or {} |
132 local o = t.objectives[objectiveIndex] | 132 local o = t.objectives[objectiveIndex] |
133 | 133 |
134 o.objectiveIndex = objectiveIndex | 134 o.index = objectiveIndex |
135 o.text = text | 135 o.text = text |
136 o.objectiveType = objectiveType | 136 o.type = objectiveType |
137 o.finished = finished | 137 o.finished = finished |
138 o.displayAsObjective = displayAsObjective | 138 o.displayAsObjective = displayAsObjective |
139 print(' |cFF00FF88*', objectiveIndex, text) | |
140 end | 139 end |
141 | 140 |
142 T.SetRewards(t, questID) | 141 T.SetRewards(t, questID) |
143 | 142 |
144 -- didn't get a name from progress bar? what about area name | 143 -- didn't get a name from progress bar? what about area name |
145 if not taskTitle then | 144 if not taskTitle then |
146 if isInArea then | 145 if isInArea then |
147 taskTitle = GetMapNameByID(GetCurrentMapAreaID()) | 146 taskTitle = GetMapNameByID(GetCurrentMapAreaID()) |
148 end | 147 end |
149 end | 148 end |
150 | 149 t.numObjectives = numObjectives |
151 t.isInArea = isInArea | 150 t.isInArea = isInArea |
152 t.isOnMap = isOnMap | 151 t.isOnMap = isOnMap |
153 t.existingTask = existingTask | 152 t.existingTask = existingTask |
154 t.questID = questID | 153 t.questID = questID |
155 t.id = questID | 154 t.id = questID |
186 print(' reward ', i, ' ', reward.type, reward.name, reward.count) | 185 print(' reward ', i, ' ', reward.type, reward.name, reward.count) |
187 | 186 |
188 end | 187 end |
189 end | 188 end |
190 | 189 |
191 print('|cFFFF8800'..block.name..':OnTurnIn call', questID, xp, money) | 190 print('|cFFFF8800'..block:GetName()..':OnTurnIn call', questID, xp, money) |
192 local savedTasks = B.Conf.TasksLog | 191 local savedTasks = B.Conf.TasksLog or {} |
193 | 192 |
194 info.completedTime = GetTime() | 193 info.completedTime = GetTime() |
195 info.animate = true | 194 info.animate = true |
196 T.SetAnimate(handler.watchReasonModule) | 195 T.SetAnimate(self.updateReasonModule) |
197 savedTasks[questID] = info | 196 savedTasks[questID] = { |
197 id = questID, | |
198 title = info.title, | |
199 finished = true, | |
200 numObjectives = info.numObjectives, | |
201 objectives = info.objectives, | |
202 rewardInfo = info.rewardInfo, | |
203 } | |
204 B.Conf.TasksLog = savedTasks | |
205 | |
206 print(' ## CONF TASKLOG ##') | |
207 for i, t in pairs(savedTasks[questID]) do | |
208 print(' |cFFFFFF00'.. tostring(i)..'|r', t) | |
209 | |
210 end | |
211 for o, j in ipairs(savedTasks[questID].objectives) do | |
212 print(' |cFF00FFFF#'.. o ..'|r', j.type, j.finished) | |
213 end | |
198 | 214 |
199 print('adding', info.title, 'to cache') | 215 print('adding', info.title, 'to cache') |
200 end | 216 end |
201 | 217 |
202 Bonus.GetInfo = function(self, taskIndex) | 218 Bonus.GetInfo = function(self, taskIndex) |
207 | 223 |
208 | 224 |
209 --- Update hooks | 225 --- Update hooks |
210 Bonus.UpdateObjectives = function(handler, block) | 226 Bonus.UpdateObjectives = function(handler, block) |
211 Default.UpdateObjectives(handler, block) | 227 Default.UpdateObjectives(handler, block) |
228 return 'default' | |
212 end | 229 end |
213 | 230 |
214 Bonus.UpdateLine = function(handler, block, line, data) | 231 Bonus.UpdateLine = function(handler, block, line, data) |
215 local info = block.info | 232 local info = block.info |
216 local print = lprint | 233 local print = lprint |
217 local text, attachment = '', nil | 234 local text, attachment = '', nil |
218 line.displayColor = 'FFFFFF' | 235 line.displayColor = 'FFFFFF' |
219 print(' ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text) | 236 if data.type == 'progressbar' then |
220 if data.objectiveType == 'progressbar' then | |
221 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) | 237 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) |
222 local percent = 100 | 238 local percent = 100 |
223 attachment = T.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex) | 239 attachment = T.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.index) |
224 if not data.finished then | 240 if not data.finished then |
225 percent = GetQuestProgressBarPercent(info.questID) | 241 percent = GetQuestProgressBarPercent(info.questID) |
226 end | 242 end |
243 data.value = percent | |
244 data.maxValue = 100 | |
245 | |
246 print(attachment:GetNumPoints()) | |
247 for i = 1, attachment:GetNumPoints() do | |
248 print(' ',attachment:GetPoint(i)) | |
249 end | |
250 | |
251 | |
227 attachment.value = percent | 252 attachment.value = percent |
228 attachment.maxValue = 100 | 253 attachment.maxValue = 100 |
229 attachment:SetPoint('TOP', line, 'TOP', 0, 0) | 254 attachment:SetPoint('TOP', line, 'TOP', 0, 0) |
230 attachment.status:SetFormattedText(PERCENTAGE_STRING, (percent / 100)) | 255 attachment.status:SetFormattedText(PERCENTAGE_STRING, percent) |
256 print(attachment.status:GetText()) | |
231 print(' |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue) | 257 print(' |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue) |
232 else | 258 end |
233 text = data.text | 259 text = data.text |
234 end | |
235 return text, attachment | 260 return text, attachment |
236 end | 261 end |
237 | 262 |
238 Bonus.Select = function(handler, block) | 263 Bonus.Select = function(handler, block) |
239 print(handler, block) | 264 print(handler, block) |