Mercurial > wow > buffalo2
comparison ObjectiveTracker/Achievements.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 | 7583684becf4 |
| children | 69d03f8e293e |
comparison
equal
deleted
inserted
replaced
| 33:64f2a9bbea79 | 34:9856ebc63fa4 |
|---|---|
| 19 Cheevs.GetNumWatched = function(self) | 19 Cheevs.GetNumWatched = function(self) |
| 20 print('|cFF00FF00' .. GetTime()) | 20 print('|cFF00FF00' .. GetTime()) |
| 21 Cheevs.trackedCheevs = {GetTrackedAchievements()} | 21 Cheevs.trackedCheevs = {GetTrackedAchievements()} |
| 22 return GetNumTrackedAchievements() | 22 return GetNumTrackedAchievements() |
| 23 end | 23 end |
| 24 Cheevs.GetInfo = function(self, index) | 24 Cheevs.GetInfo = function(self, watchIndex) |
| 25 local cheevID = Cheevs.trackedCheevs[index] | 25 --- step 1: confirm primary data and begin an entry if needed |
| 26 local cheevID = Cheevs.trackedCheevs[watchIndex] | |
| 26 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) | 27 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) |
| 28 if not id then return false end | |
| 27 | 29 |
| 28 self.Info[cheevID] = {} | 30 if not self.Info[cheevID] then self.Info[cheevID] = {} end |
| 29 local c = self.Info[cheevID] | 31 local c = self.Info[cheevID] |
| 32 local numObjectives = GetAchievementNumCriteria(cheevID) | |
| 33 | |
| 34 local tagInfo = {} | |
| 35 local objectives = c.objectives or {} | |
| 36 for i = 1, numObjectives do | |
| 37 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i) | |
| 38 local line = objectives[i] or {} | |
| 39 line.objectiveIndex = i | |
| 40 line.cheevID = cheevID | |
| 41 line.text = description | |
| 42 line.type = type | |
| 43 line.finished = completed | |
| 44 line.value = quantity | |
| 45 line.maxValue = requiredQuantity | |
| 46 line.characterName = characterName | |
| 47 line.flags = flags | |
| 48 line.assetID = assetID | |
| 49 line.quantityString = quantityString | |
| 50 line.criteriaID = criteriaID | |
| 51 objectives[i] = line | |
| 52 end | |
| 53 | |
| 54 | |
| 55 local rewards = {} | |
| 56 print('Cheevs.|cFF0088FFGetInfo|r('..watchIndex..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description) | |
| 57 | |
| 58 c.rewardInfo = rewards | |
| 59 c.numObjectives = numObjectives | |
| 60 c.objectives = objectives | |
| 30 c.type = 'Cheevs' | 61 c.type = 'Cheevs' |
| 31 c.watchIndex = index | 62 c.title = name |
| 63 c.points = points | |
| 64 c.completed = completed | |
| 65 c.month = month | |
| 66 c.day = day | |
| 67 c.year = year | |
| 68 c.description = description | |
| 69 c.flags = flags | |
| 70 c.icon = icon | |
| 71 c.rewardText = rewardText | |
| 72 c.isGuildAch = isGuildAch | |
| 73 c.wasEarnedByMe = wasEarnedByMe | |
| 74 c.earnedBy = earnedBy | |
| 75 | |
| 76 c.tagInfo = tagInfo | |
| 77 c.watchIndex = watchIndex | |
| 32 c.id = cheevID | 78 c.id = cheevID |
| 33 c.cheevID = cheevID | 79 c.cheevID = cheevID |
| 34 c.title = name | 80 self.WatchInfo[watchIndex] = c |
| 35 c.points, c.completed, c.month, c.day, c.year, c.description, c.flags, c.icon, c.rewardText, c.isGuildAch, c.wasEarnedByMe, c.earnedBy = | |
| 36 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy | |
| 37 c.numObjectives = GetAchievementNumCriteria(cheevID) | |
| 38 | |
| 39 local tagInfo = {} | |
| 40 | |
| 41 | |
| 42 c.objectives = {} | |
| 43 for i = 1, c.numObjectives do | |
| 44 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i) | |
| 45 c.objectives[i] = { | |
| 46 objectiveIndex = i, | |
| 47 cheevID = cheevID, | |
| 48 text = description, | |
| 49 type = type, | |
| 50 finished = completed, | |
| 51 value = quantity, | |
| 52 maxValue = requiredQuantity, | |
| 53 characterName = characterName, | |
| 54 flags = flags, | |
| 55 assetID = assetID, | |
| 56 quantityString = quantityString, | |
| 57 criteriaID = criteriaID, | |
| 58 } | |
| 59 end | |
| 60 print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description) | |
| 61 | |
| 62 c.tagInfo = tagInfo | |
| 63 self.WatchInfo[index] = c | |
| 64 return self.Info[cheevID] | 81 return self.Info[cheevID] |
| 65 end | 82 end |
| 66 | 83 |
| 67 --- Content handlers | 84 --- Content handlers |
| 68 Cheevs.UpdateLine = function(handler, block, line, data) | 85 Cheevs.UpdateLine = function(handler, block, line, data) |
