Mercurial > wow > buffalo2
view ObjectiveTracker/Achievements.lua @ 33:64f2a9bbea79
- implementing structural revisions in bonus objectives
- prevent instances of nil arithmetic
- decide on where to keep style values
- start widgets with dummy values for operability
author | Nenue |
---|---|
date | Fri, 15 Apr 2016 17:01:06 -0400 |
parents | 7583684becf4 |
children | 9856ebc63fa4 |
line wrap: on
line source
--- ${PACKAGE_NAME} -- @file-author@ -- @project-revision@ @project-hash@ -- @file-revision@ @file-hash@ -- Created: 4/13/2016 7:48 PM local B = select(2,...).frame local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') local band = bit.band local RemoveTrackedAchievement, GetAchievementLink = RemoveTrackedAchievement, GetAchievementLink local AchievementFrame_ToggleAchievementFrame, AchievementFrame_SelectAchievement = AchievementFrame_ToggleAchievementFrame, AchievementFrame_SelectAchievement local GetTime, GetAchievementNumCriteria, GetAchievementCriteriaInfo = GetTime, GetAchievementNumCriteria, GetAchievementCriteriaInfo local GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo = GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo local Default, Cheevs = T.DefaultHandler, T.Cheevs local print = B.print('Tracker') local lprint = B.print('Line') local iprint = B.print('Info') --- Data retrieval Cheevs.GetNumWatched = function(self) print('|cFF00FF00' .. GetTime()) Cheevs.trackedCheevs = {GetTrackedAchievements()} return GetNumTrackedAchievements() end Cheevs.GetInfo = function(self, index) local cheevID = Cheevs.trackedCheevs[index] local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) self.Info[cheevID] = {} local c = self.Info[cheevID] c.type = 'Cheevs' c.watchIndex = index c.id = cheevID c.cheevID = cheevID c.title = name c.points, c.completed, c.month, c.day, c.year, c.description, c.flags, c.icon, c.rewardText, c.isGuildAch, c.wasEarnedByMe, c.earnedBy = points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy c.numObjectives = GetAchievementNumCriteria(cheevID) local tagInfo = {} c.objectives = {} for i = 1, c.numObjectives do local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i) c.objectives[i] = { objectiveIndex = i, cheevID = cheevID, text = description, type = type, finished = completed, value = quantity, maxValue = requiredQuantity, characterName = characterName, flags = flags, assetID = assetID, quantityString = quantityString, criteriaID = criteriaID, } end print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description) c.tagInfo = tagInfo self.WatchInfo[index] = c return self.Info[cheevID] end --- Content handlers Cheevs.UpdateLine = function(handler, block, line, data) local print = B.print('CheevsLine') local attachment line.progress = 0 print(' ', data.objectiveIndex,'|cFF0088FF-|r', data.objectiveType, data.text) if data.flags then if band(data.flags, 0x00000001) > 0 then line.format = "%d/%d" line.widget = T.SetWidget(line, data, 'ProgressBar', data.criteriaID) line.height = line.widget.height elseif band(data.flags, 0x00000002) then line.widget = nil else line.widget = nil line.displayColor = 'FFFFFF' line.displayText = line.text end else line.displayText = data.text end print('line.type =', data.type) print(' ** qtyStr:', data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) return line.displayText, line.widget end Cheevs.Select = function(self, block) Cheevs.Link(self, block) 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) if ( not _G.AchievementFrame ) then _G.AchievementFrame_LoadUI(); end if ( not _G.AchievementFrame:IsShown() ) then _G.AchievementFrame_ToggleAchievementFrame(); end _G.AchievementFrame_SelectAchievement(block.info.cheevID); end