comparison ObjectiveTracker/DefaultTracker.lua @ 38:1f8f9cc3d956

- module integration brought up to speed with current frame management structure
author Nenue
date Thu, 21 Apr 2016 11:36:41 -0400
parents e84d645c8ab8
children 92534dc793f2
comparison
equal deleted inserted replaced
37:e84d645c8ab8 38:1f8f9cc3d956
3 -- @project-revision@ @project-hash@ 3 -- @project-revision@ @project-hash@
4 -- @file-revision@ @file-hash@ 4 -- @file-revision@ @file-hash@
5 -- Created: 4/17/2016 7:33 AM 5 -- Created: 4/17/2016 7:33 AM
6 local B = select(2,...).frame 6 local B = select(2,...).frame
7 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') 7 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
8 local Devian = Devian
8 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band 9 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove 10 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove
10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent 11 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText 12 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
12 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent 13 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
32 33
33 --- Placing the Update functions here since they shouldn't be messing with schema stuff 34 --- Placing the Update functions here since they shouldn't be messing with schema stuff
34 local currentPosition, anchorFrame, anchorPoint 35 local currentPosition, anchorFrame, anchorPoint
35 --- Positioning and stuff 36 --- Positioning and stuff
36 local tick = 0 37 local tick = 0
37 local firstUpdate = true 38 local initReason = OBJECTIVE_TRACKER_UPDATE_ALL
39 local requiresInit
38 function T:Update (reason, ...) 40 function T:Update (reason, ...)
39 if not B.Conf.VeneerObjectiveWrapper.enabled then 41 if not B.Conf.VeneerObjectiveWrapper.enabled then
40 return 42 return
41 end 43 end
42
43 tick = tick + 1 44 tick = tick + 1
44 if firstUpdate or not reason then
45 reason = _G.OBJECTIVE_TRACKER_UPDATE_ALL
46 end
47
48 local print = tprint 45 local print = tprint
49 local hasStuff = false 46 local hasStuff = false
50 local insertingStuff = false 47 local insertingStuff = false
51 48
49 if initReason then
50 reason = initReason
51 initReason = nil
52 elseif not reason then
53 reason = OBJECTIVE_TRACKER_UPDATE_ALL
54 end
52 print(format('|cFFBB0066Update:|r |cFFFF%04X%d|r ', tick, lshift(reason, 4)), reason, ...) 55 print(format('|cFFBB0066Update:|r |cFFFF%04X%d|r ', tick, lshift(reason, 4)), reason, ...)
53 currentPosition = 0 56 currentPosition = 0
54 57
55 for id, handler in pairs(T.orderedHandlers) do 58 for id, handler in pairs(T.orderedHandlers) do
56 local frame = handler.frame 59 local frame = handler.frame
57 60
58 61 print('')
59 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then 62 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then
60 insertingStuff = handler:UpdateTracker(reason, ...) 63 insertingStuff = handler:UpdateTracker(reason, ...)
61 else 64 else
62 print(' |cFFFF4400Update:|r skipping',handler.name) 65 print(' |cFFFF4400Update:|r skipping',handler.name)
63 end 66 end
80 if hasStuff or insertingStuff then 83 if hasStuff or insertingStuff then
81 T:FinishWrapper() 84 T:FinishWrapper()
82 end 85 end
83 Quest.GetClosest() 86 Quest.GetClosest()
84 --T.UpdateActionButtons(reason) 87 --T.UpdateActionButtons(reason)
85 if firstUpdate then
86 firstUpdate = nil
87 end
88 end 88 end
89 89
90 Default.UpdateTracker = function (handler, reason, id, isNew) 90 Default.UpdateTracker = function (handler, reason, id, isNew)
91 local print = tprint 91 local print = handler.print
92 local frame = handler.frame 92 local frame = handler.frame
93 local blockIndex = 0 93 local blockIndex = 0
94 94 print('UpdateTracker', handler.name, reason)
95 print(format(' |cFFFF8800UpdateTracker|r(%s): %s', handler.name, reason))
96 handler.updateReason = reason 95 handler.updateReason = reason
97 local numWatched, numAll, watchTable = handler:GetNumWatched(id, isNew) 96 local numWatched, numAll, watchTable = handler:GetNumWatched(id, isNew)
98 97
99 if numWatched >= 1 then 98 if numWatched >= 1 then
100 if watchTable then 99 if watchTable then
101 print('|cFF00FF00 n ID Obj wID Log Blk') 100 print(' WatchList', ' n ID Obj wID Log Blk')
102 for i, w in ipairs(watchTable) do 101 for i, w in ipairs(watchTable) do
103 print(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 ''))) 102 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 '')))
104 end 103 end
105 end 104 end
106 end 105 end
107 106
108 handler.numWatched = numWatched 107 handler.numWatched = numWatched
113 for blockIndex = 1, numWatched do 112 for blockIndex = 1, numWatched do
114 local currentBlock = handler:UpdateBlock(blockIndex, id, isNew) 113 local currentBlock = handler:UpdateBlock(blockIndex, id, isNew)
115 if currentBlock then 114 if currentBlock then
116 handler:AddBlock(currentBlock) 115 handler:AddBlock(currentBlock)
117 else 116 else
118 print(' |cFFFF9900finished|r @', blockIndex) 117 print(' |cFF'..handler.internalColor..'finished|r @', blockIndex)
119 break -- done with quest stuff 118 break -- done with quest stuff
120 end 119 end
121 end 120 end
122 121
123 122
124 local numBlocks = handler.numBlocks 123 local numBlocks = handler.numBlocks
125 local used = handler.usedBlocks 124 local used = handler.usedBlocks
126 local free = handler.freeBlocks 125 local free = handler.freeBlocks
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)) 126 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))
127
128 return numWatched, numAll 128 return numWatched, numAll
129 end 129 end
130 130
131 Default.UpdateBlock = function (handler, index) 131 Default.UpdateBlock = function (handler, index)
132 local print = bprint 132 local print = bprint
156 if info.watchIndex then 156 if info.watchIndex then
157 print(' storing watchIndex', info.watchIndex, 'for', block:GetName()) 157 print(' storing watchIndex', info.watchIndex, 'for', block:GetName())
158 handler.WatchBlock[info.watchIndex] = block 158 handler.WatchBlock[info.watchIndex] = block
159 end 159 end
160 handler.BlockInfo[index] = info 160 handler.BlockInfo[index] = info
161 handler:UpdateObjectives(block) 161 block.endPoint = block.titlebg
162 block.attachmentHeight = 0
163 block.currentLine = 0
164 handler:UpdateObjectives(block, block.schema)
162 165
163 block.title:SetText(info.title) 166 block.title:SetText(info.title)
164
165 print(' |cFFFFFF00height|r:', block.height)
166 print(' |cFF00FFFF)|r -> ', block, block:GetHeight())
167
168 block:Show()
169 167
170 if info.specialItem and not info.itemButton then 168 if info.specialItem and not info.itemButton then
171 print(' - |cFF00FFFFgenerating item button for info set') 169 print(' - |cFF00FFFFgenerating item button for info set')
172 info.itemButton = T.SetItemButton(block, info) 170 info.itemButton = T.SetItemButton(block, info)
173 else 171 else
212 end 210 end
213 211
214 if info.schema then 212 if info.schema then
215 block.schema = info.schema 213 block.schema = info.schema
216 end 214 end
217
218 if info.statusKey and (Devian and Devian.InWorkspace()) then
219 block.debugText:SetText(tostring(info.statusKey) .. ' ' .. tostring(block.posIndex) .. ' '.. tostring(info.logIndex))
220 block.debugText:Show()
221 end
222 return block 215 return block
223 end 216 end
224 217
225 Default.UpdateObjectives = function(handler, block) 218 Default.UpdateObjectives = function(handler, block, block_schema, displayObjectives)
226 local print = lprint 219 local print = lprint
227 local block_schema = block.schema 220 displayObjectives = displayObjectives or true
221 block_schema = block_schema or block.schema
228 local info = block.info 222 local info = block.info
229 print(' |cFF00FF00default.objectives', block:GetName()) 223 print(' |cFF00FF00default.objectives', block:GetName())
230 -- reset the starting positions 224 -- reset the starting positions
231 block.endPoint = block.titlebg
232 block.attachmentHeight = 0
233 block.currentLine = 0
234
235 local displayObjectiveHeader = false
236
237 block.attachmentHeight = 0
238 local text, attachment, template 225 local text, attachment, template
239 226
240 227
241 if info.description and #info.description >= 1 then 228 if info.objectives and displayObjectives then
242 print(' |cFF00FFFF header line:|r', info.description) 229 for i, data in ipairs(info.objectives) do
243 text = info.description 230 text, attachment, template = handler:UpdateLine(block, data)
244 handler:AddLine(block, text, nil) 231 if text or attachment then
245 end
246
247 if (info.isComplete or info.numObjectives == 0) and info.completionText then
248 print(' overriding line #1 for completion text:', info.completionText)
249 text = info.completionText
250 handler:AddLine(block, text, nil, 'completed')
251 else
252 if info.objectives then
253 for i, data in ipairs(info.objectives) do
254 local line = handler:GetLine(block) 232 local line = handler:GetLine(block)
255 displayObjectiveHeader = true
256 line.height = 0 233 line.height = 0
257 text, attachment, template = handler:UpdateLine(block, line, data)
258 print(' |cFF88FF00#', i, data.type, text, attachment) 234 print(' |cFF88FF00#', i, data.type, text, attachment)
259 handler:AddLine(block, text, attachment, template) 235 handler:AddLine(block, text, attachment, template)
260
261 end 236 end
262 end 237 end
263 end 238 end
264 239
265 if block.currentLine < block.numLines then 240 if block.currentLine < block.numLines then
276 print(' |cFF00FF00attachment:', block.attachmentHeight) 251 print(' |cFF00FF00attachment:', block.attachmentHeight)
277 end 252 end
278 return block_schema 253 return block_schema
279 end 254 end
280 255
281 Default.UpdateLine = function(handler, block, line, data) 256 Default.UpdateLine = function(handler, block, data)
282 return data.text, line.widget, 'normal' 257 return block.info.description, nil, 'default'
283 end 258 end
284 259
285 Default.Select = function(handler, block) 260 Default.Select = function(handler, block)
286 T:Update() 261 T:Update()
287 end 262 end