Nenue@28: --- ${PACKAGE_NAME} Nenue@28: -- @file-author@ Nenue@28: -- @project-revision@ @project-hash@ Nenue@28: -- @file-revision@ @file-hash@ Nenue@28: -- Created: 4/13/2016 7:48 PM Nenue@28: local B = select(2,...).frame Nenue@28: local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') Nenue@29: local band = bit.band Nenue@30: local RemoveTrackedAchievement, GetAchievementLink = RemoveTrackedAchievement, GetAchievementLink Nenue@29: local AchievementFrame_ToggleAchievementFrame, AchievementFrame_SelectAchievement = AchievementFrame_ToggleAchievementFrame, AchievementFrame_SelectAchievement Nenue@29: local GetTime, GetAchievementNumCriteria, GetAchievementCriteriaInfo = GetTime, GetAchievementNumCriteria, GetAchievementCriteriaInfo Nenue@29: local GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo = GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo Nenue@29: local Default, Cheevs = T.DefaultHandler, T.Cheevs Nenue@28: local print = B.print('Tracker') Nenue@28: local lprint = B.print('Line') Nenue@28: local iprint = B.print('Info') Nenue@28: Nenue@29: --- Data retrieval Nenue@29: Cheevs.GetNumWatched = function(self) Nenue@29: print('|cFF00FF00' .. GetTime()) Nenue@29: Cheevs.trackedCheevs = {GetTrackedAchievements()} Nenue@29: return GetNumTrackedAchievements() Nenue@29: end Nenue@34: Cheevs.GetInfo = function(self, watchIndex) Nenue@34: --- step 1: confirm primary data and begin an entry if needed Nenue@34: local cheevID = Cheevs.trackedCheevs[watchIndex] Nenue@29: local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) Nenue@34: if not id then return false end Nenue@28: Nenue@34: if not self.Info[cheevID] then self.Info[cheevID] = {} end Nenue@29: local c = self.Info[cheevID] Nenue@34: local numObjectives = GetAchievementNumCriteria(cheevID) Nenue@34: Nenue@34: local tagInfo = {} Nenue@34: local objectives = c.objectives or {} Nenue@34: for i = 1, numObjectives do Nenue@34: local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i) Nenue@34: local line = objectives[i] or {} Nenue@34: line.objectiveIndex = i Nenue@34: line.cheevID = cheevID Nenue@34: line.text = description Nenue@34: line.type = type Nenue@34: line.finished = completed Nenue@34: line.value = quantity Nenue@34: line.maxValue = requiredQuantity Nenue@34: line.characterName = characterName Nenue@34: line.flags = flags Nenue@34: line.assetID = assetID Nenue@34: line.quantityString = quantityString Nenue@34: line.criteriaID = criteriaID Nenue@34: objectives[i] = line Nenue@34: end Nenue@34: Nenue@34: Nenue@34: local rewards = {} Nenue@35: print(' |cFF0088FFGetInfo|r:', watchIndex, '|cFF00FFFF', name) Nenue@34: Nenue@34: c.rewardInfo = rewards Nenue@34: c.numObjectives = numObjectives Nenue@34: c.objectives = objectives Nenue@29: c.type = 'Cheevs' Nenue@34: c.title = name Nenue@34: c.points = points Nenue@34: c.completed = completed Nenue@34: c.month = month Nenue@34: c.day = day Nenue@34: c.year = year Nenue@34: c.description = description Nenue@34: c.flags = flags Nenue@34: c.icon = icon Nenue@34: c.rewardText = rewardText Nenue@34: c.isGuildAch = isGuildAch Nenue@34: c.wasEarnedByMe = wasEarnedByMe Nenue@34: c.earnedBy = earnedBy Nenue@34: Nenue@34: c.tagInfo = tagInfo Nenue@34: c.watchIndex = watchIndex Nenue@30: c.id = cheevID Nenue@29: c.cheevID = cheevID Nenue@34: self.WatchInfo[watchIndex] = c Nenue@29: return self.Info[cheevID] Nenue@29: end Nenue@29: Nenue@29: --- Content handlers Nenue@28: Cheevs.UpdateLine = function(handler, block, line, data) Nenue@28: local print = B.print('CheevsLine') Nenue@30: local attachment Nenue@28: line.progress = 0 Nenue@28: print(' ', data.objectiveIndex,'|cFF0088FF-|r', data.objectiveType, data.text) Nenue@28: if data.flags then Nenue@28: if band(data.flags, 0x00000001) > 0 then Nenue@28: line.format = "%d/%d" Nenue@28: line.widget = T.SetWidget(line, data, 'ProgressBar', data.criteriaID) Nenue@28: line.height = line.widget.height Nenue@28: elseif band(data.flags, 0x00000002) then Nenue@28: line.widget = nil Nenue@28: else Nenue@28: line.widget = nil Nenue@28: line.displayColor = 'FFFFFF' Nenue@28: line.displayText = line.text Nenue@28: Nenue@28: end Nenue@28: else Nenue@28: Nenue@28: line.displayText = data.text Nenue@28: end Nenue@28: print('line.type =', data.type) Nenue@28: print(' ** qtyStr:', data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) Nenue@30: return line.displayText, line.widget Nenue@28: end Nenue@28: Nenue@30: Cheevs.Select = function(self, block) Nenue@30: Cheevs.Link(self, block) Nenue@28: end Nenue@29: Nenue@30: Cheevs.Remove = function(self, block) Nenue@28: Nenue@30: RemoveTrackedAchievement(block.info.cheevID) Nenue@28: end Nenue@28: Cheevs.OnMouseUp = function(self, button) Nenue@28: Nenue@28: Default.OnMouseUp(self, button) Nenue@28: end Nenue@30: Cheevs.Link = function(self, block) Nenue@30: local achievementLink = GetAchievementLink(block.info.cheevID); Nenue@28: if ( achievementLink ) then Nenue@30: _G.ChatEdit_InsertLink(achievementLink); Nenue@28: end Nenue@28: end Nenue@28: Nenue@30: Cheevs.Open = function(self, block) Nenue@28: Nenue@30: if ( not _G.AchievementFrame ) then Nenue@30: _G.AchievementFrame_LoadUI(); Nenue@28: end Nenue@30: if ( not _G.AchievementFrame:IsShown() ) then Nenue@30: _G.AchievementFrame_ToggleAchievementFrame(); Nenue@28: end Nenue@30: _G.AchievementFrame_SelectAchievement(block.info.cheevID); Nenue@28: end