Mercurial > wow > buffalo2
comparison ObjectiveTracker/Achievements.lua @ 38:1f8f9cc3d956
- module integration brought up to speed with current frame management structure
| author | Nenue |
|---|---|
| date | Thu, 21 Apr 2016 11:36:41 -0400 |
| parents | e84d645c8ab8 |
| children | 03ed70f846de |
comparison
equal
deleted
inserted
replaced
| 37:e84d645c8ab8 | 38:1f8f9cc3d956 |
|---|---|
| 16 | 16 |
| 17 --- Data retrieval | 17 --- Data retrieval |
| 18 Cheevs.GetNumWatched = function(self, targetID, isNew) | 18 Cheevs.GetNumWatched = function(self, targetID, isNew) |
| 19 local trackedList = {GetTrackedAchievements() } | 19 local trackedList = {GetTrackedAchievements() } |
| 20 local numWatched, numAll = #trackedList, #self.WatchList | 20 local numWatched, numAll = #trackedList, #self.WatchList |
| 21 print(' |cFF00FF88GetNumWatched:|r',self.name, numWatched, ' ('..numAll..' recorded)') | 21 print(' |cFF'..self.internalColor..'GetNumWatched:|r',self.name, numWatched, ' ('..numAll..' recorded)') |
| 22 local start = 1 | 22 local start = 1 |
| 23 local limit = max(numAll, #trackedList) | 23 local limit = max(numAll, #trackedList) |
| 24 if targetID then | 24 if targetID then |
| 25 if not isNew and self.Info[targetID] then | 25 if not isNew and self.Info[targetID] then |
| 26 -- if it's only an update, we can limit the scope | 26 -- if it's only an update, we can limit the scope |
| 27 start = self.Info[targetID].watchIndex | 27 start = self.Info[targetID].watchIndex |
| 28 print(' |cFF0088FFGetNumWatched: limit selection to['..start..'-'..limit..']') | 28 print(' |cFF'..self.internalColor..'GetNumWatched: limit selection to['..start..'-'..limit..']') |
| 29 if self.InfoBlock[targetID] then | 29 if self.InfoBlock[targetID] then |
| 30 self.InfoBlock[targetID]:Hide() | 30 self.InfoBlock[targetID]:Hide() |
| 31 end | 31 end |
| 32 | 32 |
| 33 end | 33 end |
| 40 else | 40 else |
| 41 local cheevID = trackedList[index] | 41 local cheevID = trackedList[index] |
| 42 if not self.Info[cheevID] then | 42 if not self.Info[cheevID] then |
| 43 self.Info[cheevID] = self:GetInfo(cheevID, index) | 43 self.Info[cheevID] = self:GetInfo(cheevID, index) |
| 44 else | 44 else |
| 45 print(' |cFF00FFBBGetInfo:', cheevID, 'already pulled') | 45 print(' |cFF'..self.internalColor..'GetInfo:', cheevID, 'already pulled') |
| 46 end | 46 end |
| 47 self:GetObjectives(cheevID) | 47 self:GetObjectives(cheevID) |
| 48 | 48 |
| 49 local info = self.Info[cheevID] | 49 local info = self.Info[cheevID] |
| 50 local watchBlock = self.WatchBlock[cheevID] | 50 local watchBlock = self.WatchBlock[cheevID] |
| 60 Cheevs.GetInfo = function(self, cheevID, watchIndex) | 60 Cheevs.GetInfo = function(self, cheevID, watchIndex) |
| 61 --- step 1: confirm primary data and begin an entry if needed | 61 --- step 1: confirm primary data and begin an entry if needed |
| 62 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) | 62 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) |
| 63 if not id then return nil end | 63 if not id then return nil end |
| 64 | 64 |
| 65 print(' |cFF44AAFFGetInfo: pulling', id..',', name, earnedBy) | 65 print(' |cFF'..self.internalColor..'GetInfo: pulling', id..',', name, earnedBy) |
| 66 | 66 |
| 67 | 67 |
| 68 self.Info[cheevID] = self.Info[cheevID] or {} | 68 self.Info[cheevID] = self.Info[cheevID] or {} |
| 69 local c = self.Info[cheevID] | 69 local c = self.Info[cheevID] |
| 70 local rewards = {} | 70 local rewards = {} |
| 116 line.assetID = assetID | 116 line.assetID = assetID |
| 117 line.quantityString = quantityString | 117 line.quantityString = quantityString |
| 118 line.criteriaID = criteriaID | 118 line.criteriaID = criteriaID |
| 119 c.objectives[i] = line | 119 c.objectives[i] = line |
| 120 | 120 |
| 121 print(' |cFF44FFDDGetObjectives:|r', i, type, description, quantityString) | 121 print(' |cFF'..self.internalColor..'GetObjectives:|r', i, format('|cFF0088FF%02X|r(%d)', type, type), format('|cFF88FF00%01X|r', flags or 0), '|cFF00FF00'..tostring(quantity)..'|r/|cFF00FF00'.. tostring(requiredQuantity)..'|r', '"|cFF88FF00'..tostring(description)..'|r"') |
| 122 end | 122 end |
| 123 end | 123 end |
| 124 | 124 |
| 125 --- Content handlers | 125 Cheevs.UpdateObjectives = function(handler, block, block_schema) |
| 126 Cheevs.UpdateLine = function(handler, block, line, data) | 126 Default.UpdateObjectives(handler, block, block_schema) |
| 127 local print = B.print('CheevsLine') | 127 return block_schema |
| 128 end | |
| 129 | |
| 130 --- assemble line info | |
| 131 Cheevs.UpdateLine = function(handler, block, data) | |
| 132 local print = lprint | |
| 128 local attachment | 133 local attachment |
| 129 local text | 134 local text |
| 130 line.progress = 0 | 135 local lineSchema = 'default' |
| 131 print(' ', data.objectiveIndex,'|cFF0088FF-|r', data.objectiveType, data.text) | 136 print(' ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text) |
| 132 if data.flags then | 137 if data.type == CRITERIA_TYPE_ACHIEVEMENT then |
| 133 if band(data.flags, 0x00000001) > 0 then | 138 if data.value == 1 then |
| 134 line.format = "%d/%d" | 139 return nil, nil |
| 135 attachment = T.SetWidget(line, data, 'ProgressBar', data.criteriaID) | 140 end |
| 136 attachment.value = data.value | |
| 137 attachment.maxValue = data.maxValue | |
| 138 attachment:SetParent(handler.frame) | |
| 139 | 141 |
| 140 print(attachment:GetNumPoints()) | 142 text = data.text |
| 141 for i = 1, attachment:GetNumPoints() do | 143 lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement' |
| 142 print(' ',attachment:GetPoint(i)) | 144 elseif band(data.flags, 0x00000001) > 0 then |
| 143 end | 145 attachment = T.GetWidget(data, 'StatusBar', data.criteriaID) |
| 144 attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue) | 146 attachment.format = "%d/%d" |
| 145 attachment:SetPoint('TOP', line, 'TOP') | 147 attachment.value = data.value |
| 146 line.height = attachment.height | 148 attachment.maxValue = data.maxValue |
| 147 elseif band(data.flags, 0x00000002) then | 149 attachment:SetParent(block) |
| 148 line.widget = nil | |
| 149 text = line.text | |
| 150 else | |
| 151 line.widget = nil | |
| 152 line.displayColor = 'FFFFFF' | |
| 153 text = line.text | |
| 154 | 150 |
| 151 print(attachment:GetNumPoints()) | |
| 152 for i = 1, attachment:GetNumPoints() do | |
| 153 print(' ',attachment:GetPoint(i)) | |
| 155 end | 154 end |
| 155 attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue) | |
| 156 attachment:SetPoint('TOP', line, 'TOP') | |
| 157 lineSchema = 'progressbar' | |
| 156 else | 158 else |
| 157 | 159 text = data.quantityString .. ' ' .. data.text |
| 158 line.displayText = data.text | 160 lineSchema = 'default' |
| 159 end | 161 end |
| 160 print(' |cFF00DD22UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) | 162 print(' |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) |
| 161 return text, attachment, 'default' | 163 return text, attachment, lineSchema |
| 162 end | 164 end |
| 163 | 165 |
| 164 Cheevs.Select = function(self, block) | 166 Cheevs.Select = function(self, block) |
| 165 Cheevs.Link(self, block) | 167 Cheevs.Link(self, block) |
| 166 T:Update(self.updateReasonModule, block.info.cheevID) | 168 T:Update(self.updateReasonModule, block.info.cheevID) |
