annotate ObjectiveTracker/Achievements.lua @ 29:adcd7c328d07

code collation cleaning
author Nenue
date Wed, 13 Apr 2016 21:53:24 -0400
parents c33c17dd97e7
children 7583684becf4
rev   line source
Nenue@28 1 --- ${PACKAGE_NAME}
Nenue@28 2 -- @file-author@
Nenue@28 3 -- @project-revision@ @project-hash@
Nenue@28 4 -- @file-revision@ @file-hash@
Nenue@28 5 -- Created: 4/13/2016 7:48 PM
Nenue@28 6 local B = select(2,...).frame
Nenue@28 7 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@29 8 local band = bit.band
Nenue@29 9 local ChatEdit_InsertLink, RemoveTrackedAchievement, GetAchievementLink, AchievementFrame, AchievementFrame_LoadUI = ChatEdit_InsertLink, RemoveTrackedAchievement, GetAchievementLink, AchievementFrame, AchievementFrame_LoadUI
Nenue@29 10 local AchievementFrame_ToggleAchievementFrame, AchievementFrame_SelectAchievement = AchievementFrame_ToggleAchievementFrame, AchievementFrame_SelectAchievement
Nenue@29 11 local GetTime, GetAchievementNumCriteria, GetAchievementCriteriaInfo = GetTime, GetAchievementNumCriteria, GetAchievementCriteriaInfo
Nenue@29 12 local GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo = GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo
Nenue@29 13 local Default, Cheevs = T.DefaultHandler, T.Cheevs
Nenue@28 14 local print = B.print('Tracker')
Nenue@28 15 local lprint = B.print('Line')
Nenue@28 16 local iprint = B.print('Info')
Nenue@28 17
Nenue@29 18 --- Data retrieval
Nenue@29 19 Cheevs.GetNumWatched = function(self)
Nenue@29 20 print('|cFF00FF00' .. GetTime())
Nenue@29 21 Cheevs.trackedCheevs = {GetTrackedAchievements()}
Nenue@29 22 return GetNumTrackedAchievements()
Nenue@29 23 end
Nenue@29 24 Cheevs.GetInfo = function(self, index)
Nenue@29 25 local cheevID = Cheevs.trackedCheevs[index]
Nenue@29 26 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
Nenue@28 27
Nenue@29 28 self.Info[cheevID] = {}
Nenue@29 29 local c = self.Info[cheevID]
Nenue@29 30 c.type = 'Cheevs'
Nenue@29 31 c.watchIndex = index
Nenue@29 32 c.cheevID = cheevID
Nenue@29 33 c.title = name
Nenue@29 34 c.points, c.completed, c.month, c.day, c.year, c.description, c.flags, c.icon, c.rewardText, c.isGuildAch, c.wasEarnedByMe, c.earnedBy =
Nenue@29 35 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy
Nenue@29 36 c.numObjectives = GetAchievementNumCriteria(cheevID)
Nenue@29 37 c.objectives = {}
Nenue@29 38 for i = 1, c.numObjectives do
Nenue@29 39 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i)
Nenue@29 40 c.objectives[i] = {
Nenue@29 41 objectiveIndex = i,
Nenue@29 42 cheevID = cheevID,
Nenue@29 43 text = description,
Nenue@29 44 type = type,
Nenue@29 45 finished = completed,
Nenue@29 46 value = quantity,
Nenue@29 47 maxValue = requiredQuantity,
Nenue@29 48 characterName = characterName,
Nenue@29 49 flags = flags,
Nenue@29 50 assetID = assetID,
Nenue@29 51 quantityString = quantityString,
Nenue@29 52 criteriaID = criteriaID,
Nenue@29 53 }
Nenue@29 54 end
Nenue@29 55 print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description)
Nenue@28 56
Nenue@29 57 self.WatchInfo[index] = c
Nenue@29 58 return self.Info[cheevID]
Nenue@29 59 end
Nenue@29 60
Nenue@29 61 --- Content handlers
Nenue@28 62 Cheevs.UpdateLine = function(handler, block, line, data)
Nenue@28 63 local print = B.print('CheevsLine')
Nenue@28 64 line.progress = 0
Nenue@28 65 print(' ', data.objectiveIndex,'|cFF0088FF-|r', data.objectiveType, data.text)
Nenue@28 66 if data.flags then
Nenue@28 67 if band(data.flags, 0x00000001) > 0 then
Nenue@28 68 line.format = "%d/%d"
Nenue@28 69 line.widget = T.SetWidget(line, data, 'ProgressBar', data.criteriaID)
Nenue@28 70 line.height = line.widget.height
Nenue@28 71 elseif band(data.flags, 0x00000002) then
Nenue@28 72 line.widget = nil
Nenue@28 73 else
Nenue@28 74 line.widget = nil
Nenue@28 75 line.displayColor = 'FFFFFF'
Nenue@28 76 line.displayText = line.text
Nenue@28 77
Nenue@28 78 end
Nenue@28 79 else
Nenue@28 80
Nenue@28 81 line.displayText = data.text
Nenue@28 82 end
Nenue@28 83 print('line.type =', data.type)
Nenue@28 84 print(' ** qtyStr:', data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID)
Nenue@28 85 end
Nenue@28 86
Nenue@28 87 Cheevs.Select = function(self)
Nenue@29 88 T:Update(Cheevs.updateReasonModule)
Nenue@28 89 end
Nenue@29 90
Nenue@28 91 Cheevs.Remove = function(self)
Nenue@28 92
Nenue@28 93 RemoveTrackedAchievement(self.info.cheevID)
Nenue@28 94 end
Nenue@28 95 Cheevs.OnMouseUp = function(self, button)
Nenue@28 96
Nenue@28 97 Default.OnMouseUp(self, button)
Nenue@28 98 end
Nenue@28 99 Cheevs.Link = function(self)
Nenue@28 100
Nenue@28 101 local achievementLink = GetAchievementLink(self.info.cheevID);
Nenue@28 102 if ( achievementLink ) then
Nenue@28 103 ChatEdit_InsertLink(achievementLink);
Nenue@28 104 end
Nenue@28 105 end
Nenue@28 106
Nenue@28 107 Cheevs.Open = function(self)
Nenue@28 108
Nenue@28 109 if ( not AchievementFrame ) then
Nenue@28 110 AchievementFrame_LoadUI();
Nenue@28 111 end
Nenue@28 112 if ( not AchievementFrame:IsShown() ) then
Nenue@28 113 AchievementFrame_ToggleAchievementFrame();
Nenue@28 114 end
Nenue@28 115 AchievementFrame_SelectAchievement(self.info.cheevID);
Nenue@28 116 end