Mercurial > wow > buffalo2
comparison 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 |
comparison
equal
deleted
inserted
replaced
39:92534dc793f2 | 40:03ed70f846de |
---|---|
12 local GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo = GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo | 12 local GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo = GetNumTrackedAchievements, GetTrackedAchievements, GetAchievementInfo |
13 local Default, Cheevs = T.DefaultHandler, T.Cheevs | 13 local Default, Cheevs = T.DefaultHandler, T.Cheevs |
14 local wipe = table.wipe | 14 local wipe = table.wipe |
15 local print, bprint, lprint, iprint = B.print('Tracker'), B.print('Block'), B.print('Line'), B.print('iprint') | 15 local print, bprint, lprint, iprint = B.print('Tracker'), B.print('Block'), B.print('Line'), B.print('iprint') |
16 | 16 |
17 --- Data retrieval | 17 --- Frame data |
18 Cheevs.UpdateObjectives = function(handler, block, block_schema) | |
19 -- if completed on another character, only show the heading for CHATLINK | |
20 if block.info.completed then | |
21 return 0, block_schema | |
22 end | |
23 | |
24 if block.info.description then | |
25 handler:AddLine(block, block.info.description, nil, 'defalut') | |
26 end | |
27 local attachments = Default.UpdateObjectives(handler, block, block_schema) | |
28 | |
29 return attachments, block_schema | |
30 end | |
31 | |
32 Cheevs.UpdateLine = function(handler, block, data) | |
33 local print = lprint | |
34 local attachment | |
35 local text | |
36 local lineSchema = 'default' | |
37 print(' ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text) | |
38 if data.type == CRITERIA_TYPE_ACHIEVEMENT then | |
39 if data.value == 1 then | |
40 return nil, nil | |
41 end | |
42 | |
43 text = data.text | |
44 lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement' | |
45 elseif band(data.flags, 0x00000001) > 0 then | |
46 attachment = T.GetWidget(data, 'StatusBar', data.criteriaID) | |
47 attachment.format = "%d/%d" | |
48 attachment.value = data.value | |
49 attachment.maxValue = data.maxValue | |
50 attachment:SetParent(block) | |
51 | |
52 print(attachment:GetNumPoints()) | |
53 for i = 1, attachment:GetNumPoints() do | |
54 print(' ',attachment:GetPoint(i)) | |
55 end | |
56 attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue) | |
57 attachment:SetPoint('TOP', line, 'TOP') | |
58 lineSchema = 'progressbar' | |
59 else | |
60 | |
61 text = format("%d/%d %s", data.value, data.maxValue, data.text) | |
62 lineSchema = 'default' | |
63 end | |
64 print(' |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) | |
65 return text, attachment, lineSchema | |
66 end | |
67 | |
68 Cheevs.Select = function(self, block) | |
69 Cheevs.Link(self, block) | |
70 T:Update(self.updateReasonModule, block.info.cheevID) | |
71 end | |
72 | |
73 Cheevs.Remove = function(self, block) | |
74 | |
75 RemoveTrackedAchievement(block.info.cheevID) | |
76 end | |
77 Cheevs.OnMouseUp = function(self, button) | |
78 | |
79 Default.OnMouseUp(self, button) | |
80 end | |
81 Cheevs.Link = function(self, block) | |
82 local achievementLink = GetAchievementLink(block.info.cheevID); | |
83 if ( achievementLink ) then | |
84 _G.ChatEdit_InsertLink(achievementLink); | |
85 end | |
86 end | |
87 | |
88 --- Data accessors | |
18 Cheevs.GetNumWatched = function(self, targetID, isNew) | 89 Cheevs.GetNumWatched = function(self, targetID, isNew) |
19 local trackedList = {GetTrackedAchievements() } | 90 local trackedList = {GetTrackedAchievements() } |
20 local numWatched, numAll = #trackedList, #self.WatchList | 91 local numWatched, numAll = #trackedList, #self.WatchList |
21 print(' |cFF'..self.internalColor..'GetNumWatched:|r',self.name, numWatched, ' ('..numAll..' recorded)') | 92 print(' |cFF'..self.internalColor..'GetNumWatched:|r',self.name, numWatched, ' ('..numAll..' recorded)') |
22 local start = 1 | 93 local start = 1 |
120 | 191 |
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"') | 192 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 | 193 end |
123 end | 194 end |
124 | 195 |
125 Cheevs.UpdateObjectives = function(handler, block, block_schema) | |
126 Default.UpdateObjectives(handler, block, block_schema) | |
127 return block_schema | |
128 end | |
129 | |
130 --- assemble line info | |
131 Cheevs.UpdateLine = function(handler, block, data) | |
132 local print = lprint | |
133 local attachment | |
134 local text | |
135 local lineSchema = 'default' | |
136 print(' ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text) | |
137 if data.type == CRITERIA_TYPE_ACHIEVEMENT then | |
138 if data.value == 1 then | |
139 return nil, nil | |
140 end | |
141 | |
142 text = data.text | |
143 lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement' | |
144 elseif band(data.flags, 0x00000001) > 0 then | |
145 attachment = T.GetWidget(data, 'StatusBar', data.criteriaID) | |
146 attachment.format = "%d/%d" | |
147 attachment.value = data.value | |
148 attachment.maxValue = data.maxValue | |
149 attachment:SetParent(block) | |
150 | |
151 print(attachment:GetNumPoints()) | |
152 for i = 1, attachment:GetNumPoints() do | |
153 print(' ',attachment:GetPoint(i)) | |
154 end | |
155 attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue) | |
156 attachment:SetPoint('TOP', line, 'TOP') | |
157 lineSchema = 'progressbar' | |
158 else | |
159 text = data.quantityString .. ' ' .. data.text | |
160 lineSchema = 'default' | |
161 end | |
162 print(' |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) | |
163 return text, attachment, lineSchema | |
164 end | |
165 | |
166 Cheevs.Select = function(self, block) | |
167 Cheevs.Link(self, block) | |
168 T:Update(self.updateReasonModule, block.info.cheevID) | |
169 end | |
170 | |
171 Cheevs.Remove = function(self, block) | |
172 | |
173 RemoveTrackedAchievement(block.info.cheevID) | |
174 end | |
175 Cheevs.OnMouseUp = function(self, button) | |
176 | |
177 Default.OnMouseUp(self, button) | |
178 end | |
179 Cheevs.Link = function(self, block) | |
180 local achievementLink = GetAchievementLink(block.info.cheevID); | |
181 if ( achievementLink ) then | |
182 _G.ChatEdit_InsertLink(achievementLink); | |
183 end | |
184 end | |
185 | 196 |
186 Cheevs.Open = function(self, block) | 197 Cheevs.Open = function(self, block) |
187 | 198 |
188 if ( not _G.AchievementFrame ) then | 199 if ( not _G.AchievementFrame ) then |
189 _G.AchievementFrame_LoadUI(); | 200 _G.AchievementFrame_LoadUI(); |