Nenue@35
|
1 --- ${PACKAGE_NAME}
|
Nenue@35
|
2 -- @file-author@
|
Nenue@35
|
3 -- @project-revision@ @project-hash@
|
Nenue@35
|
4 -- @file-revision@ @file-hash@
|
Nenue@35
|
5 -- Created: 4/17/2016 7:33 AM
|
Nenue@44
|
6 --- These are the first layer of methods invoked by event handlers
|
Nenue@44
|
7
|
Nenue@35
|
8 local B = select(2,...).frame
|
Nenue@35
|
9 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
|
Nenue@38
|
10 local Devian = Devian
|
Nenue@35
|
11 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
|
Nenue@35
|
12 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove
|
Nenue@35
|
13 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
|
Nenue@35
|
14 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
|
Nenue@35
|
15 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
|
Nenue@35
|
16 local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs
|
Nenue@35
|
17 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
|
Nenue@35
|
18 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow
|
Nenue@35
|
19 local print = B.print('Tracker')
|
Nenue@35
|
20 local oprint = B.print('Objectives')
|
Nenue@35
|
21 local bprint = B.print('Block')
|
Nenue@35
|
22 local tprint = B.print('Tracker')
|
Nenue@35
|
23 local lprint = B.print('Line')
|
Nenue@35
|
24 local unitLevel = 1
|
Nenue@35
|
25 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON
|
Nenue@35
|
26 local debug = false
|
Nenue@35
|
27
|
Nenue@35
|
28 --- FRAMES
|
Nenue@35
|
29 local Wrapper = _G.VeneerObjectiveWrapper
|
Nenue@35
|
30 local Scroller = Wrapper.scrollArea
|
Nenue@35
|
31 local Scroll = _G.VeneerObjectiveScroll
|
Nenue@35
|
32 local orderedHandlers = T.orderedHandlers
|
Nenue@35
|
33 local orderedNames = T.orderedNames
|
Nenue@35
|
34
|
Nenue@35
|
35
|
Nenue@35
|
36 --- Placing the Update functions here since they shouldn't be messing with schema stuff
|
Nenue@35
|
37 local currentPosition, anchorFrame, anchorPoint
|
Nenue@35
|
38 --- Positioning and stuff
|
Nenue@35
|
39 local tick = 0
|
Nenue@38
|
40 local initReason = OBJECTIVE_TRACKER_UPDATE_ALL
|
Nenue@38
|
41 local requiresInit
|
Nenue@35
|
42 function T:Update (reason, ...)
|
Nenue@35
|
43 if not B.Conf.VeneerObjectiveWrapper.enabled then
|
Nenue@35
|
44 return
|
Nenue@35
|
45 end
|
Nenue@35
|
46 tick = tick + 1
|
Nenue@35
|
47 local print = tprint
|
Nenue@35
|
48 local hasStuff = false
|
Nenue@35
|
49 local insertingStuff = false
|
Nenue@35
|
50
|
Nenue@38
|
51 if initReason then
|
Nenue@38
|
52 reason = initReason
|
Nenue@38
|
53 initReason = nil
|
Nenue@38
|
54 elseif not reason then
|
Nenue@38
|
55 reason = OBJECTIVE_TRACKER_UPDATE_ALL
|
Nenue@38
|
56 end
|
Nenue@35
|
57 print(format('|cFFBB0066Update:|r |cFFFF%04X%d|r ', tick, lshift(reason, 4)), reason, ...)
|
Nenue@35
|
58 currentPosition = 0
|
Nenue@35
|
59
|
Nenue@35
|
60 for id, handler in pairs(T.orderedHandlers) do
|
Nenue@35
|
61 local frame = handler.frame
|
Nenue@35
|
62
|
Nenue@38
|
63 print('')
|
Nenue@35
|
64 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then
|
Nenue@35
|
65 insertingStuff = handler:UpdateTracker(reason, ...)
|
Nenue@35
|
66 else
|
Nenue@35
|
67 print(' |cFFFF4400Update:|r skipping',handler.name)
|
Nenue@35
|
68 end
|
Nenue@35
|
69
|
Nenue@35
|
70 if handler.numWatched >= 1 then
|
Nenue@35
|
71 hasStuff = true
|
Nenue@35
|
72 currentPosition = currentPosition + 1
|
Nenue@35
|
73 Default.AddTracker(handler, frame, currentPosition)
|
Nenue@40
|
74 frame.wasEmpty = nil
|
Nenue@35
|
75 else
|
Nenue@35
|
76 frame.destinationOffset = 0
|
Nenue@40
|
77 if not frame.wasEmpty and not frame.fadeOut:IsPlaying() then
|
Nenue@40
|
78 frame.fadeOut:Play()
|
Nenue@40
|
79 end
|
Nenue@35
|
80 frame.wasEmpty = true
|
Nenue@35
|
81 end
|
Nenue@35
|
82 end
|
Nenue@35
|
83
|
Nenue@35
|
84 -- do these whenever there is content or content is being added
|
Nenue@35
|
85 if hasStuff or insertingStuff then
|
Nenue@35
|
86 T:FinishWrapper()
|
Nenue@35
|
87 end
|
Nenue@35
|
88 Quest.GetClosest()
|
Nenue@43
|
89 T.UpdateActionButtons(reason)
|
Nenue@35
|
90 end
|
Nenue@35
|
91
|
Nenue@35
|
92 Default.UpdateTracker = function (handler, reason, id, isNew)
|
Nenue@38
|
93 local print = handler.print
|
Nenue@37
|
94 local frame = handler.frame
|
Nenue@35
|
95 local blockIndex = 0
|
Nenue@40
|
96 print('MODULE:'..handler.name, 'message:', reason, 'id:', id, (isNew and '|cFF88FF88' or '|cFF555555')..'isNew|r')
|
Nenue@35
|
97 handler.updateReason = reason
|
Nenue@37
|
98 local numWatched, numAll, watchTable = handler:GetNumWatched(id, isNew)
|
Nenue@35
|
99
|
Nenue@37
|
100 if numWatched >= 1 then
|
Nenue@37
|
101 if watchTable then
|
Nenue@38
|
102 print(' WatchList', ' n ID Obj wID Log Blk')
|
Nenue@37
|
103 for i, w in ipairs(watchTable) do
|
Nenue@38
|
104 print(' WatchList', format('%2d => %6d %3d %3d %3s %s', i, w.id, w.numObjectives, w.watchIndex, (w.logIndex or ''), (handler.InfoBlock[w.id] and handler.InfoBlock[w.id]:GetName() or '')))
|
Nenue@37
|
105 end
|
Nenue@37
|
106 end
|
Nenue@35
|
107 end
|
Nenue@35
|
108
|
Nenue@37
|
109 handler.numWatched = numWatched
|
Nenue@37
|
110 handler.numAll = numAll
|
Nenue@35
|
111 handler.numBlocks = 0
|
Nenue@35
|
112 handler.currentBlock = 0
|
Nenue@37
|
113 handler.currentAnchor = frame.titlebg
|
Nenue@37
|
114 for blockIndex = 1, numWatched do
|
Nenue@35
|
115 local currentBlock = handler:UpdateBlock(blockIndex, id, isNew)
|
Nenue@35
|
116 if currentBlock then
|
Nenue@35
|
117 handler:AddBlock(currentBlock)
|
Nenue@35
|
118 else
|
Nenue@38
|
119 print(' |cFF'..handler.internalColor..'finished|r @', blockIndex)
|
Nenue@35
|
120 break -- done with quest stuff
|
Nenue@35
|
121 end
|
Nenue@35
|
122 end
|
Nenue@35
|
123
|
Nenue@35
|
124 local numBlocks = handler.numBlocks
|
Nenue@35
|
125 local used = handler.usedBlocks
|
Nenue@35
|
126 local free = handler.freeBlocks
|
Nenue@38
|
127 print(format('#### %s ## |cFFFF8800%04X|r --- blocks |cFFFF8800%d|r, (used/free: |cFFFF8800%d|r/|cFFFF8800%d|r)', handler.name, band(reason, handler.updateReasonModule + handler.updateReasonEvents, reason), numBlocks, #used, #free))
|
Nenue@38
|
128
|
Nenue@37
|
129 return numWatched, numAll
|
Nenue@35
|
130 end
|
Nenue@35
|
131
|
Nenue@37
|
132 Default.UpdateBlock = function (handler, index)
|
Nenue@43
|
133 --@debug@
|
Nenue@43
|
134 local print = bprint -- @end-debug@
|
Nenue@37
|
135 if not index then
|
Nenue@35
|
136 return
|
Nenue@35
|
137 end
|
Nenue@37
|
138 local info = handler.WatchList[index] -- should match up with whatever the internal watch list has
|
Nenue@35
|
139 if not info then
|
Nenue@35
|
140 return
|
Nenue@35
|
141 end
|
Nenue@35
|
142 local frame = handler.frame
|
Nenue@35
|
143 local block = handler:GetBlock(info.id)
|
Nenue@35
|
144
|
Nenue@44
|
145 --@debug@
|
Nenue@44
|
146 handler.print('UpdateBlock', '|cFF00FFFF'..index..'|r|cFF0099FF', info.id ,'|r', (block.isAnimating and 'animating' or 'static'))--@end-debug@
|
Nenue@43
|
147 if block.isAnimating then
|
Nenue@43
|
148 -- Nothing to do, leave it as is
|
Nenue@43
|
149 return block
|
Nenue@43
|
150 end
|
Nenue@43
|
151
|
Nenue@35
|
152 block.handler = handler
|
Nenue@35
|
153 block.info = info
|
Nenue@37
|
154 info.blockIndex = index
|
Nenue@43
|
155 --@debug@
|
Nenue@43
|
156 local keyInfo--@end-debug@
|
Nenue@37
|
157 if info.id then
|
Nenue@37
|
158 handler.InfoBlock[info.id] = block
|
Nenue@43
|
159 --@debug@
|
Nenue@43
|
160 keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'InfoBlock[' .. info.id .. '] = *' .. block:GetName():gsub('%D', '') --@end-debug@
|
Nenue@35
|
161 end
|
Nenue@37
|
162 if info.logIndex then
|
Nenue@37
|
163 handler.LogBlock[info.logIndex] = block
|
Nenue@43
|
164 --@debug@
|
Nenue@43
|
165 keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'LogBlock[' .. info.logIndex .. '] = ' .. block:GetName():gsub('%D', '')--@end-debug@
|
Nenue@37
|
166 end
|
Nenue@37
|
167 if info.watchIndex then
|
Nenue@37
|
168 handler.WatchBlock[info.watchIndex] = block
|
Nenue@43
|
169 --@debug@
|
Nenue@43
|
170 keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'WatchBlock[' .. info.watchIndex .. '] = ' .. block:GetName():gsub('%D', '')--@end-debug@
|
Nenue@37
|
171 end
|
Nenue@43
|
172 --@debug@
|
Nenue@43
|
173 if keyInfo then print(' assigned', keyInfo) end--@end-debug@
|
Nenue@37
|
174 handler.BlockInfo[index] = info
|
Nenue@38
|
175 block.endPoint = block.titlebg
|
Nenue@38
|
176 block.attachmentHeight = 0
|
Nenue@38
|
177 block.currentLine = 0
|
Nenue@40
|
178 local attachments, override_schema = handler:UpdateObjectives(block, block.schema)
|
Nenue@35
|
179
|
Nenue@44
|
180
|
Nenue@35
|
181 block.title:SetText(info.title)
|
Nenue@35
|
182
|
Nenue@35
|
183 if info.specialItem and not info.itemButton then
|
Nenue@43
|
184 --@debug@
|
Nenue@43
|
185 print(' - |cFF00FFFFgenerating item button for info set')--@end-debug@
|
Nenue@35
|
186 info.itemButton = T.SetItemButton(block, info)
|
Nenue@35
|
187 end
|
Nenue@35
|
188
|
Nenue@35
|
189
|
Nenue@35
|
190 if info.selected then
|
Nenue@35
|
191 block.SelectionOverlay:Show()
|
Nenue@35
|
192 else
|
Nenue@35
|
193 block.SelectionOverlay:Hide()
|
Nenue@35
|
194 end
|
Nenue@35
|
195
|
Nenue@35
|
196 if info.tagInfo then
|
Nenue@44
|
197 handler:AddTags(block, info.tagInfo, info.tagCoords)
|
Nenue@35
|
198 end
|
Nenue@35
|
199
|
Nenue@44
|
200 if override_schema then
|
Nenue@44
|
201 block.schema = override_schema
|
Nenue@44
|
202 elseif info.schema then
|
Nenue@37
|
203 block.schema = info.schema
|
Nenue@37
|
204 end
|
Nenue@35
|
205 return block
|
Nenue@35
|
206 end
|
Nenue@35
|
207
|
Nenue@38
|
208 Default.UpdateObjectives = function(handler, block, block_schema, displayObjectives)
|
Nenue@35
|
209 local print = lprint
|
Nenue@38
|
210 displayObjectives = displayObjectives or true
|
Nenue@38
|
211 block_schema = block_schema or block.schema
|
Nenue@35
|
212 local info = block.info
|
Nenue@35
|
213 print(' |cFF00FF00default.objectives', block:GetName())
|
Nenue@35
|
214 -- reset the starting positions
|
Nenue@35
|
215 local text, attachment, template
|
Nenue@40
|
216 local numAttachments = 0
|
Nenue@35
|
217
|
Nenue@38
|
218 if info.objectives and displayObjectives then
|
Nenue@38
|
219 for i, data in ipairs(info.objectives) do
|
Nenue@38
|
220 text, attachment, template = handler:UpdateLine(block, data)
|
Nenue@38
|
221 if text or attachment then
|
Nenue@35
|
222 local line = handler:GetLine(block)
|
Nenue@35
|
223 line.height = 0
|
Nenue@35
|
224 print(' |cFF88FF00#', i, data.type, text, attachment)
|
Nenue@35
|
225 handler:AddLine(block, text, attachment, template)
|
Nenue@35
|
226 end
|
Nenue@40
|
227 if attachment then
|
Nenue@40
|
228 numAttachments = numAttachments + 1
|
Nenue@40
|
229 end
|
Nenue@35
|
230 end
|
Nenue@35
|
231 end
|
Nenue@35
|
232
|
Nenue@35
|
233 if block.currentLine < block.numLines then
|
Nenue@35
|
234 print(' - cull', block.currentLine, block.numLines)
|
Nenue@35
|
235 for i = block.currentLine + 1, block.numLines do
|
Nenue@35
|
236 print(' - hide |cFFFF0088'..i..'|r', block.lines[i])
|
Nenue@35
|
237 block.lines[i]:ClearAllPoints()
|
Nenue@35
|
238 block.lines[i]:Hide()
|
Nenue@35
|
239 end
|
Nenue@35
|
240 end
|
Nenue@35
|
241
|
Nenue@35
|
242 if block.currentLine > 0 then
|
Nenue@35
|
243 block.attachmentHeight = block.attachmentHeight
|
Nenue@35
|
244 print(' |cFF00FF00attachment:', block.attachmentHeight)
|
Nenue@35
|
245 end
|
Nenue@40
|
246 return numAttachments, block_schema
|
Nenue@35
|
247 end
|
Nenue@35
|
248
|
Nenue@38
|
249 Default.UpdateLine = function(handler, block, data)
|
Nenue@38
|
250 return block.info.description, nil, 'default'
|
Nenue@35
|
251 end
|
Nenue@35
|
252
|
Nenue@35
|
253 Default.Select = function(handler, block)
|
Nenue@35
|
254 T:Update()
|
Nenue@35
|
255 end
|
Nenue@35
|
256 Default.Open = function(handler, block)
|
Nenue@37
|
257 T:Update(handler.updateReasonModule)
|
Nenue@35
|
258 end
|
Nenue@35
|
259 Default.Remove = function(handler, block)
|
Nenue@37
|
260 T:Update(handler.updateReasonModule)
|
Nenue@35
|
261 end
|
Nenue@35
|
262 Default.Report = function(handler, block)
|
Nenue@35
|
263 print('Stats:', handler.numWatched,'items tracked,', handler.numBlocks,'blocks assigned.')
|
Nenue@35
|
264 end
|
Nenue@35
|
265
|
Nenue@43
|
266 function Default:OnMouseUp (button)
|
Nenue@44
|
267 print(self.handler.name, button, IsModifiedClick('CHATLINK'), IsModifiedClick("QUESTWATCHTOGGLE"))
|
Nenue@35
|
268 if button == 'LeftButton' then
|
Nenue@35
|
269 if IsModifiedClick("CHATLINK") and ChatEdit_GetActiveWindow() then
|
Nenue@35
|
270 self.Link(self.handler, self)
|
Nenue@35
|
271 elseif IsModifiedClick("QUESTWATCHTOGGLE") then
|
Nenue@35
|
272 self.Remove(self.handler, self)
|
Nenue@35
|
273 else
|
Nenue@35
|
274 self.Select(self.handler, self)
|
Nenue@35
|
275 end
|
Nenue@35
|
276 elseif button == 'RightButton' then
|
Nenue@35
|
277 self.Open(self.handler, self)
|
Nenue@35
|
278 end
|
Nenue@35
|
279 self.initialButton = nil
|
Nenue@35
|
280 self.modChatLink = nil
|
Nenue@35
|
281 self.modQuestWatch = nil
|
Nenue@37
|
282 --T:Update(self.handler.updateReasonModule)
|
Nenue@35
|
283 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r')
|
Nenue@35
|
284 end
|
Nenue@43
|
285 function Default:OnMouseDown (button)
|
Nenue@44
|
286 --print(self.info.title)
|
Nenue@35
|
287 end
|