Mercurial > wow > buffalo2
diff ObjectiveTracker/Achievements.lua @ 40:03ed70f846de
- move block accessors into a new file
- define a tMove function for reconciling the free/used tables as needed
- when retrieving an old block frame, confirm ID still matches; resolves multiple watch items on one block
- stop any animations when a block is freed; resolves stuck flare graphics
author | Nenue |
---|---|
date | Sun, 24 Apr 2016 14:15:25 -0400 |
parents | 1f8f9cc3d956 |
children |
line wrap: on
line diff
--- a/ObjectiveTracker/Achievements.lua Thu Apr 21 16:43:37 2016 -0400 +++ b/ObjectiveTracker/Achievements.lua Sun Apr 24 14:15:25 2016 -0400 @@ -14,7 +14,78 @@ local wipe = table.wipe local print, bprint, lprint, iprint = B.print('Tracker'), B.print('Block'), B.print('Line'), B.print('iprint') ---- Data retrieval +--- Frame data +Cheevs.UpdateObjectives = function(handler, block, block_schema) + -- if completed on another character, only show the heading for CHATLINK + if block.info.completed then + return 0, block_schema + end + + if block.info.description then + handler:AddLine(block, block.info.description, nil, 'defalut') + end + local attachments = Default.UpdateObjectives(handler, block, block_schema) + + return attachments, block_schema +end + +Cheevs.UpdateLine = function(handler, block, data) + local print = lprint + local attachment + local text + local lineSchema = 'default' + print(' ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text) + if data.type == CRITERIA_TYPE_ACHIEVEMENT then + if data.value == 1 then + return nil, nil + end + + text = data.text + lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement' + elseif band(data.flags, 0x00000001) > 0 then + attachment = T.GetWidget(data, 'StatusBar', data.criteriaID) + attachment.format = "%d/%d" + attachment.value = data.value + attachment.maxValue = data.maxValue + attachment:SetParent(block) + + print(attachment:GetNumPoints()) + for i = 1, attachment:GetNumPoints() do + print(' ',attachment:GetPoint(i)) + end + attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue) + attachment:SetPoint('TOP', line, 'TOP') + lineSchema = 'progressbar' + else + + text = format("%d/%d %s", data.value, data.maxValue, data.text) + lineSchema = 'default' + end + print(' |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) + return text, attachment, lineSchema +end + +Cheevs.Select = function(self, block) + Cheevs.Link(self, block) + T:Update(self.updateReasonModule, block.info.cheevID) +end + +Cheevs.Remove = function(self, block) + + RemoveTrackedAchievement(block.info.cheevID) +end +Cheevs.OnMouseUp = function(self, button) + + Default.OnMouseUp(self, button) +end +Cheevs.Link = function(self, block) + local achievementLink = GetAchievementLink(block.info.cheevID); + if ( achievementLink ) then + _G.ChatEdit_InsertLink(achievementLink); + end +end + +--- Data accessors Cheevs.GetNumWatched = function(self, targetID, isNew) local trackedList = {GetTrackedAchievements() } local numWatched, numAll = #trackedList, #self.WatchList @@ -122,66 +193,6 @@ end end -Cheevs.UpdateObjectives = function(handler, block, block_schema) - Default.UpdateObjectives(handler, block, block_schema) - return block_schema -end - ---- assemble line info -Cheevs.UpdateLine = function(handler, block, data) - local print = lprint - local attachment - local text - local lineSchema = 'default' - print(' ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text) - if data.type == CRITERIA_TYPE_ACHIEVEMENT then - if data.value == 1 then - return nil, nil - end - - text = data.text - lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement' - elseif band(data.flags, 0x00000001) > 0 then - attachment = T.GetWidget(data, 'StatusBar', data.criteriaID) - attachment.format = "%d/%d" - attachment.value = data.value - attachment.maxValue = data.maxValue - attachment:SetParent(block) - - print(attachment:GetNumPoints()) - for i = 1, attachment:GetNumPoints() do - print(' ',attachment:GetPoint(i)) - end - attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue) - attachment:SetPoint('TOP', line, 'TOP') - lineSchema = 'progressbar' - else - text = data.quantityString .. ' ' .. data.text - lineSchema = 'default' - end - print(' |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) - return text, attachment, lineSchema -end - -Cheevs.Select = function(self, block) - Cheevs.Link(self, block) - T:Update(self.updateReasonModule, block.info.cheevID) -end - -Cheevs.Remove = function(self, block) - - RemoveTrackedAchievement(block.info.cheevID) -end -Cheevs.OnMouseUp = function(self, button) - - Default.OnMouseUp(self, button) -end -Cheevs.Link = function(self, block) - local achievementLink = GetAchievementLink(block.info.cheevID); - if ( achievementLink ) then - _G.ChatEdit_InsertLink(achievementLink); - end -end Cheevs.Open = function(self, block)