Mercurial > wow > buffalo2
comparison ObjectiveFrame.lua @ 14:ed642234f017
ObjectiveFrame
- implement proper tracker name text
- expanded tracker prototypes to cover "objective lines" formatting and accommodation of widget variables
- implement the progress bars for bonus objectives
ObjectiveStyle
- moved `UpdateWrapperStyle` over and renamed it to fit semantics
- change the formula for block.`height` to measure non-widget content only
- allows widgets to position relative to text
- size FontString `status` to match block.`height`
- full block height is acquired by adding block.`height` and block.`attachmentHeight` which is calculated during objective parsing
ObjectiveWidgets
- use string keys for generated widgets to deal with multiple objectives under the same questID, and maybe dungeon objectives
- wrapper buttons use a common code path
- specialized handlers for wheel scrolling moved over to fit semantics
author | Nenue |
---|---|
date | Mon, 04 Apr 2016 03:16:22 -0400 |
parents | 9455693fc290 |
children | f660f1c1e0aa |
comparison
equal
deleted
inserted
replaced
13:9455693fc290 | 14:ed642234f017 |
---|---|
3 -- @project-revision@ @project-hash@ | 3 -- @project-revision@ @project-hash@ |
4 -- @file-revision@ @file-hash@ | 4 -- @file-revision@ @file-hash@ |
5 -- Created: 3/30/2016 12:49 AM | 5 -- Created: 3/30/2016 12:49 AM |
6 local B = select(2,...).frame | 6 local B = select(2,...).frame |
7 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | 7 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') |
8 local ipairs, max, min, unpack, floor, pairs, tostring, type = ipairs, max, min, unpack, floor, pairs, tostring, type | 8 local ipairs, max, min, unpack, floor, pairs, tostring, type, band = ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band |
9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion | 9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion |
10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent | 10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent |
11 local Quest, Bonus, Cheevs = mod.Quest, mod.Bonus, mod.Cheevs | |
11 local CreateFrame = CreateFrame | 12 local CreateFrame = CreateFrame |
12 local print = B.print('Objectives') | 13 local print = B.print('Objectives') |
13 local unitLevel = 1 | 14 local unitLevel = 1 |
14 -------------------------------------------------------------------- | 15 -------------------------------------------------------------------- |
15 --- Global frame layout | 16 --- Global frame layout |
38 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' | 39 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' |
39 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 | 40 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 |
40 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 | 41 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 |
41 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} | 42 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} |
42 | 43 |
43 --- These are mostly aesthetic choices so it lives here | 44 |
44 | 45 mod.InitializeWrapper = function() |
45 | 46 |
46 local Scroller_OnShow = function() | 47 mod.SetBlockStyle(Scroller, 'Scroller', 'Normal') |
47 Wrapper.watchMoneyReasons = 0; | 48 mod.SetBlockStyle(Scroller, 'Scroll', 'Normal') |
48 mod.UpdateWrapper() | 49 mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal') |
49 mod.SetEvents() | |
50 for i, region in ipairs(Wrapper.headerComplex) do | |
51 region:Show() | |
52 end | |
53 end | |
54 | |
55 local Scroller_OnHide = function() | |
56 local self = Wrapper | |
57 Wrapper:UnregisterAllEvents() | |
58 Wrapper:SetScript('OnEvent', nil) | |
59 for i, region in ipairs(Wrapper.headerComplex) do | |
60 region:Hide() | |
61 end | |
62 end | |
63 | |
64 local Scroller_OnMouseWheel = function(self, delta) | |
65 local r = Scroll:GetHeight() - Scroller:GetHeight() | |
66 local s = B.Conf.ObjectiveScroll - delta * floor(r/5+.5) | |
67 local from = self:GetVerticalScroll() | |
68 if s >= r then | |
69 s = r | |
70 elseif s < 1 then | |
71 s = 0 | |
72 end | |
73 self:SetVerticalScroll(s) | |
74 B.Conf.ObjectiveScroll = s | |
75 print('|cFF00FF00OnMouseWheel', 'from = ', from, 'scroll =', s, ' range =', r, 'current =', self:GetVerticalScroll()) | |
76 | |
77 mod.UpdateActionButtons('SCROLLING') | |
78 end | |
79 | |
80 local WrapperCloseButton_OnClick = function(self) | |
81 Wrapper:Minimize() | |
82 if B.Conf.FrameState[Wrapper:GetName()] == 1 then | |
83 self:GetNormalTexture():SetTexture([[Interface\PaperDollInfoFrame\UI-Character-SkillsPageDown-Up]]) | |
84 self:GetPushedTexture():SetTexture([[Interface\PaperDollInfoFrame\UI-Character-SkillsPageDown-Down]]) | |
85 else | |
86 self:GetNormalTexture():SetTexture([[Interface\PaperDollInfoFrame\UI-Character-SkillsPageUp-Up]]) | |
87 self:GetPushedTexture():SetTexture([[Interface\PaperDollInfoFrame\UI-Character-SkillsPageUp-Down]]) | |
88 end | |
89 end | |
90 local WrapperCloseButton_OnMouseWheel = function(self, delta) | |
91 end | |
92 | |
93 mod.InitializeTrackers = function() | |
94 | |
95 | 50 |
96 for i, name in ipairs(orderedNames) do | 51 for i, name in ipairs(orderedNames) do |
97 if not mod.orderedHandlers[i] then | 52 if not mod.orderedHandlers[i] then |
98 if mod.Tracker(name, i) then | 53 if mod.Tracker(name, i) then |
99 local handler = mod[name] | 54 local handler = mod[name] |
100 | |
101 local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate') | 55 local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate') |
102 tracker.title:SetText(name) | 56 tracker.title:SetText(handler.displayName) |
103 mod.SetBlockStyle(tracker, 'Tracker', 'Normal') | 57 mod.SetBlockStyle(tracker, 'Tracker', 'Normal') |
104 | |
105 handler.Tracker = tracker | 58 handler.Tracker = tracker |
106 mod.orderedTrackers[i] = tracker | 59 mod.orderedTrackers[i] = tracker |
107 mod.namedTrackers[name] = tracker | 60 mod.namedTrackers[name] = tracker |
108 mod.indexedTrackers[handler] = tracker | 61 mod.indexedTrackers[handler] = tracker |
109 print('created new tracker frames for new handler') | 62 print('created new tracker frames for new handler') |
110 | |
111 | |
112 end | 63 end |
113 end | 64 end |
114 end | 65 end |
115 | 66 |
116 Scroller:SetScrollChild(Scroll) | 67 Scroller:SetScrollChild(Scroll) |
117 Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel) | 68 |
118 Scroller:SetScript('OnShow', Scroller_OnShow) | 69 mod.InitializeWrapperWidgets() |
119 Scroller:SetScript('OnHide', Scroller_OnHide) | |
120 Wrapper.close:SetScript('OnClick', WrapperCloseButton_OnClick) | |
121 Wrapper.close:SetScript('OnMouseWheel', WrapperCloseButton_OnMouseWheel) | |
122 Wrapper:SetPoint(unpack(wrapperPosition)) | |
123 if B.Conf.ObjectiveTrackerMinimized then | 70 if B.Conf.ObjectiveTrackerMinimized then |
124 Scroller_OnShow(Scroller) | 71 Scroller_OnShow(Scroller) |
125 end | 72 end |
126 mod.UpdateWrapperStyle() | 73 mod.UpdateWrapperStyle() |
127 end | 74 end |
206 end | 153 end |
207 end | 154 end |
208 | 155 |
209 | 156 |
210 | 157 |
211 local segments = {'Left', 'Right', 'Tile'} | 158 mod.UpdateTracker = function(handler) |
212 mod.UpdateWrapperStyle = function() | |
213 --[[for _, segment in ipairs(segments) do | |
214 local texture, a1, a2, a3, a4, width = unpack(mod.defaults.Style.Wrapper.BackgroundComplex[segment]) | |
215 Wrapper['Background'..segment]:SetAtlas(texture) | |
216 Wrapper['Background'..segment]:SetTexCoord(a1, a2, a3, a4) | |
217 if width then | |
218 Wrapper['Background'..segment]:SetWidth(width) | |
219 end | |
220 end]] | |
221 end | |
222 | |
223 --- Updates the selected block frame to display the given info batch | |
224 -- If `previousBlock` is set, it will attempt to anchor to that | |
225 -- @param blockNum the ordered block to be updated, not a watchIndex value | |
226 -- @param info the reference returned by the GetXInfo functions | |
227 -- REMEMBER: t.info and questData[questID] are the same table | |
228 mod.UpdateTrackerBlock = function (handler, blockIndex, info) | |
229 local print = B.print('ObjectiveBlockParse') | |
230 print(' |cFF00FFFFUpdateTrackerBlock('..blockIndex..'|r') | |
231 if not blockIndex or not info then | |
232 return | |
233 end | |
234 | |
235 local mainStyle = 'Normal' | |
236 local subStyle | |
237 local tracker = handler.Tracker | 159 local tracker = handler.Tracker |
238 | 160 print('|cFFFF4400'..tracker:GetName().. '|r:Update()') |
239 local t = handler:GetBlock(blockIndex) | |
240 if previousBlock then | |
241 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0) | |
242 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) | |
243 end | |
244 --print(t:GetName(), t:GetSize()) | |
245 --print(t:GetPoint(1)) | |
246 | |
247 t.info = info | |
248 | |
249 if info.questID then handler.QuestBlock[info.questID] = t end | |
250 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end | |
251 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end | |
252 | |
253 info.blockIndex = blockIndex | |
254 handler.BlockInfo[blockIndex] = info | |
255 | |
256 t.Select = handler.Select | |
257 t.Open = handler.Open | |
258 t.Remove = handler.Remove | |
259 t.Link = handler.Link | |
260 t:SetScript('OnMouseUp', handler.OnMouseUp) | |
261 t:SetScript('OnMouseDown', handler.OnMouseDown) | |
262 t.title:SetText(info.title) | |
263 | |
264 t.attachmentHeight = 0 | |
265 if info.isComplete then | |
266 t.status:Show() | |
267 t.status:SetText(info.completionText) | |
268 elseif info.numObjectives >= 1 then | |
269 t.attachmentHeight = textSpacing | |
270 t.status:Show() | |
271 print(' - objective lines:', info.numObjectives, 'can wrap:', t.status:CanWordWrap()) | |
272 | |
273 local text = '' | |
274 | |
275 --- todo: implement objective displays | |
276 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining: | |
277 -- * height - height of whatever display widget is involved in conveying the task | |
278 -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things | |
279 -- * money - boolean that determines listening for money events or not | |
280 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively | |
281 text = mod.UpdateObjectives(t, info, text) | |
282 | |
283 t.status:SetText(text) | |
284 t.status:SetWordWrap(true) | |
285 | |
286 elseif info.description then | |
287 t.status:SetText(info.description) | |
288 t.status:SetWordWrap(true) | |
289 else | |
290 t.status:SetText(nil) | |
291 end | |
292 | |
293 if info.isComplete then | |
294 mainStyle = 'Complete' | |
295 end | |
296 if info.superTracked then | |
297 subStyle = 'Super' | |
298 elseif info.isDaily then | |
299 subStyle = 'Daily' | |
300 end | |
301 | |
302 if info.specialItem and not info.itemButton then | |
303 print(' - |cFF00FFFFgenerating item button for info set') | |
304 info.itemButton = mod.SetItemButton(t, info) | |
305 else | |
306 --info.itemButton = nil | |
307 end | |
308 | |
309 if info.level then | |
310 local levelDiff = unitLevel - info.level | |
311 if levelDiff > 9 then | |
312 t.title:SetTextColor(0.7, 0.7, 0.7, 1) | |
313 elseif levelDiff > 1 then | |
314 t.title:SetTextColor(0.5, 1, 0.5, 1) | |
315 elseif levelDiff < -1 then | |
316 t.title:SetTextColor(1, 0.4, 0.25, 1) | |
317 elseif levelDiff < -4 then | |
318 t.title:SetTextColor(1, 0, 0, 1) | |
319 else | |
320 t.title:SetTextColor(1,1,1,1) | |
321 end | |
322 end | |
323 | |
324 | |
325 if Devian and Devian.InWorkspace() then | |
326 t.debugText:Show() | |
327 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (info.level and info.level or '-')) | |
328 end | |
329 | |
330 --- metrics are calculated in SetStyle | |
331 t:SetStyle('TrackerBlock', handler.name, mainStyle, subStyle) | |
332 t:Show() | |
333 | |
334 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) | |
335 return t | |
336 end | |
337 | |
338 mod.UpdateObjectives = function(block, info, text) | |
339 local print = B.print('ObjectiveBlockParse') | |
340 | |
341 local attachmentHeight = block.attachmentHeight | |
342 if info.description then | |
343 print(' -- has description text:', select('#', info.description), info.description) | |
344 text = info.description | |
345 end | |
346 local completionScore, completionMax = 0, 0 | |
347 for o, obj in ipairs(info.objectives) do | |
348 --- achievement criteria | |
349 if obj.flags then | |
350 | |
351 | |
352 if bit.band(obj.flags, 0x00000001) > 0 then | |
353 obj.type = 'ProgressBar' | |
354 elseif bit.band(obj.flags, 0x00000002) then | |
355 obj.type = 'Hidden' | |
356 obj.widget = nil | |
357 else | |
358 obj.type = 'Text' | |
359 obj.widget = nil | |
360 text = text .. ((text == '') and "" or "\n") .. obj.text | |
361 end | |
362 | |
363 print('obj.type =', obj.type) | |
364 print(' ** qtyStr:', obj.quantityString, 'qty:', obj.quantity, 'assetID:', obj.assetID) | |
365 obj.widget = mod.SetWidget(obj, info) | |
366 if obj.finished then | |
367 obj.progress = 2 | |
368 elseif obj.quantity > 0 then | |
369 obj.progress = 1 | |
370 else | |
371 obj.progress = 0 | |
372 end | |
373 | |
374 | |
375 --- none of the above (most quests) | |
376 else | |
377 local line = obj.text | |
378 local color = '00FFFF' | |
379 if obj.finished then | |
380 obj.progress = 2 | |
381 color = 'FFFFFF' | |
382 elseif obj.type == 'monster' then | |
383 color = 'FFFF00' | |
384 elseif obj.type == 'item' then | |
385 color = '44DDFF' | |
386 elseif obj.type == 'object' then | |
387 color = 'FF44DD' | |
388 end | |
389 text = text .. ((text == '') and "" or "\n") .. '|cFF'..color.. line .. '|r' | |
390 end | |
391 | |
392 if obj.widget then | |
393 | |
394 obj.widget:Show() | |
395 obj.widget:SetPoint('TOPLEFT', block.objectives, 'BOTTOMLEFT', 0, -attachmentHeight) | |
396 print('have a widget, height is', obj.widget.height) | |
397 attachmentHeight = attachmentHeight + obj.widget.height | |
398 completionScore = completionScore + obj.progress | |
399 completionMax = completionMax + 2 | |
400 end | |
401 | |
402 end | |
403 | |
404 block.completionScore = completionScore / completionMax | |
405 block.attachmentHeight = attachmentHeight | |
406 | |
407 return text | |
408 end | |
409 | |
410 mod.UpdateTracker = function(handler) | |
411 print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r') | |
412 local tracker = handler.Tracker | |
413 local blockIndex = 0 | 161 local blockIndex = 0 |
414 local trackerHeight = headerHeight | 162 local trackerHeight = headerHeight |
415 local w = 300 | 163 |
416 | 164 |
417 previousBlock = tracker.title | 165 previousBlock = tracker.title |
418 local numWatched = handler.GetNumWatched() | 166 local numWatched = handler.GetNumWatched() |
419 local numBlocks = handler.numBlocks | 167 local numBlocks = handler.numBlocks |
420 local actualBlocks = 0 | 168 local actualBlocks = 0 |
423 if watchIndex <= numWatched then | 171 if watchIndex <= numWatched then |
424 local info = handler:GetInfo(watchIndex) | 172 local info = handler:GetInfo(watchIndex) |
425 if info then | 173 if info then |
426 local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info) | 174 local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info) |
427 previousBlock = currentBlock | 175 previousBlock = currentBlock |
428 print('|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) | 176 print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) |
429 trackerHeight = trackerHeight + currentBlock.height | 177 trackerHeight = trackerHeight + currentBlock.height |
430 numBlocks = max(numBlocks, watchIndex) | 178 numBlocks = max(numBlocks, watchIndex) |
431 actualBlocks = actualBlocks + 1 | 179 actualBlocks = actualBlocks + 1 |
432 else | 180 else |
433 print('|cFFFF0000Failed to draw info for index #'..watchIndex) | 181 print(' |cFFFF0000Failed to draw info for index #'..watchIndex) |
434 end | 182 end |
435 | 183 |
436 elseif watchIndex <= numBlocks then | 184 elseif watchIndex <= numBlocks then |
437 local used = handler.usedBlocks | 185 local used = handler.usedBlocks |
438 local free = handler.freeBlocks | 186 local free = handler.freeBlocks |
442 used[blockIndex]:ClearAllPoints() | 190 used[blockIndex]:ClearAllPoints() |
443 free[#free+1]= used[blockIndex] | 191 free[#free+1]= used[blockIndex] |
444 used[blockIndex] = nil | 192 used[blockIndex] = nil |
445 end | 193 end |
446 else | 194 else |
447 print('Stopping scan at', blockIndex) | 195 print(' |cFFFF9900END|r @', blockIndex) |
448 break -- done with quest stuff | 196 break -- done with quest stuff |
449 end | 197 end |
450 end | 198 end |
451 handler.numWatched = numWatched | 199 handler.numWatched = numWatched |
452 handler.numBlocks = numBlocks | 200 handler.numBlocks = numBlocks |
453 handler.actualBlocks = actualBlocks | 201 handler.actualBlocks = actualBlocks |
454 handler:Report() | 202 handler:Report() |
455 previousBlock = nil | 203 |
456 if numBlocks > 0 then | 204 if numBlocks >= 1 then |
205 previousBlock = nil | |
457 tracker.height = trackerHeight | 206 tracker.height = trackerHeight |
458 else | 207 else |
459 tracker.height = 0 | 208 tracker.height = 0 |
460 end | 209 end |
461 | 210 |
462 print('|cFF00FF88)|r ->', numBlocks, 'blocks; height', tracker.height, 'last block: ') | 211 return tracker.numWatched, tracker.numAll |
463 end | 212 end |
213 | |
214 --- Updates the selected block frame to display the given info batch | |
215 -- If `previousBlock` is set, it will attempt to anchor to that | |
216 -- @param blockNum the ordered block to be updated, not a watchIndex value | |
217 -- @param info the reference returned by the GetXInfo functions | |
218 -- REMEMBER: t.info and questData[questID] are the same table | |
219 mod.UpdateTrackerBlock = function (handler, blockIndex, info) | |
220 local print = B.print('BlockParse') | |
221 print(' Read list item |cFF00FFFF'..blockIndex..'|r') | |
222 if not blockIndex or not info then | |
223 return | |
224 end | |
225 local tracker = handler.Tracker | |
226 local t = handler:GetBlock(blockIndex) | |
227 t.handler = handler | |
228 t.info = info | |
229 t.mainStyle = 'Normal' | |
230 t.subStyle = nil | |
231 | |
232 info.blockIndex = blockIndex | |
233 if info.questID then handler.QuestBlock[info.questID] = t end | |
234 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end | |
235 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end | |
236 handler.BlockInfo[blockIndex] = info | |
237 | |
238 | |
239 t.attachmentHeight = 0 | |
240 --if info.isComplete then | |
241 --t.status:Show() | |
242 --t.status:SetText(info.completionText) | |
243 --end | |
244 | |
245 if info.numObjectives >= 1 then | |
246 t.attachmentHeight = textSpacing | |
247 t.status:Show() | |
248 print(' lines to build:', info.numObjectives) | |
249 | |
250 local text = '' | |
251 | |
252 mod.UpdateObjectives(t, info, text) | |
253 elseif info.description then | |
254 t.status:SetText(info.description) | |
255 else | |
256 t.status:SetText(nil) | |
257 end | |
258 t.title:SetText(info.title) | |
259 | |
260 | |
261 if info.specialItem and not info.itemButton then | |
262 print(' - |cFF00FFFFgenerating item button for info set') | |
263 info.itemButton = mod.SetItemButton(t, info) | |
264 else | |
265 --info.itemButton = nil | |
266 end | |
267 | |
268 handler.SetBlockTags(t, info) | |
269 | |
270 if previousBlock then | |
271 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0) | |
272 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) | |
273 print(' anchor to|cFF0088FF', previousBlock:GetName()) | |
274 end | |
275 | |
276 --- metrics are calculated in SetStyle | |
277 t:SetStyle('TrackerBlock', handler.name, t.mainStyle, t.subStyle) | |
278 t:Show() | |
279 | |
280 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) | |
281 | |
282 | |
283 if Devian and Devian.InWorkspace() then | |
284 t.debugText:Show() | |
285 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle))) | |
286 end | |
287 return t | |
288 end | |
289 | |
290 mod.UpdateObjectives = function(block, info, text) | |
291 local print = B.print('BlockLine') | |
292 print(' |cFF00FF00objective updates for', block:GetName()) | |
293 | |
294 local attachmentHeight = block.attachmentHeight | |
295 if info.description then | |
296 print(' -- has description text:', select('#', info.description), info.description) | |
297 text = info.description | |
298 end | |
299 local completionScore, completionMax = 0, 0 | |
300 | |
301 for i, line in ipairs(info.objectives) do | |
302 print(' |cFF88FF00objective', i) | |
303 block.handler.ParseObjective(line, info) | |
304 | |
305 if line.title then | |
306 info.title = line.title | |
307 line.title = nil | |
308 end | |
309 | |
310 | |
311 if line.widget then | |
312 line.widget:Show() | |
313 line.widget:SetParent(block) | |
314 line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight ) | |
315 print(' has a widget, height is', line.widget.height) | |
316 attachmentHeight = attachmentHeight + line.widget.height | |
317 completionScore = completionScore + line.progress | |
318 completionMax = completionMax + 2 | |
319 end | |
320 | |
321 if line.displayText then | |
322 print(' has text') | |
323 text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r' | |
324 end | |
325 | |
326 end | |
327 | |
328 block.completionScore = completionScore / completionMax | |
329 block.attachmentHeight = attachmentHeight | |
330 | |
331 block.status:SetText(text) | |
332 end | |
333 | |
334 --- Objective parsers | |
335 -- defines the following variables | |
336 -- * height - height of whatever display widget is involved in conveying the task | |
337 -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things | |
338 -- * money - boolean that determines listening for money events or not | |
339 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively | |
340 mod.Tracker.ParseObjective = function(line, info) | |
341 | |
342 if line.finished then | |
343 line.progress = 2 | |
344 elseif line.quantity > 0 then | |
345 line.progress = 1 | |
346 else | |
347 line.progress = 0 | |
348 end | |
349 | |
350 end | |
351 | |
352 Bonus.ParseObjective = function(line, info) | |
353 local print = B.print('BonusLine') | |
354 for k,v in pairs(line) do | |
355 print(k, v) | |
356 end | |
357 | |
358 line.displayColor = 'FFFFFF' | |
359 if line.text and not info.title then | |
360 line.title = line.text | |
361 else | |
362 line.displayText = line.text | |
363 end | |
364 | |
365 line.progess = 0 | |
366 if line.objectiveType == 'progressbar' then | |
367 print(' |cFFFF0088==|r', line.type, line.text) | |
368 line.widgetType = 'ProgressBar' | |
369 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) | |
370 line.value = GetQuestProgressBarPercent(info.questID) or 0 | |
371 line.maxValue = 100 | |
372 if line.value >= line.maxValue then | |
373 line.progress = 1 | |
374 elseif line.value > 0 then | |
375 line.progress = 2 | |
376 end | |
377 line.format = PERCENTAGE_STRING | |
378 line.widget = mod.SetWidget(line, info, 'ProgressBar', info.questID..'-'..line.index) | |
379 print('line.type =', line.type) | |
380 print(' ** qtyStr:', line.quantityString, 'qty:', line.value, 'assetID:', line.questID) | |
381 else | |
382 line.widget = nil | |
383 end | |
384 end | |
385 | |
386 Cheevs.ParseObjective = function(line, info) | |
387 local print = B.print('CheevsLine') | |
388 line.progress = 0 | |
389 if line.flags then | |
390 if band(line.flags, 0x00000001) > 0 then | |
391 line.format = "%d/%d" | |
392 line.widget = mod.SetWidget(line, info, 'ProgressBar', line.criteriaID) | |
393 elseif band(line.flags, 0x00000002) then | |
394 line.widget = nil | |
395 else | |
396 line.widget = nil | |
397 line.displayColor = 'FFFFFF' | |
398 line.displayText = line.text | |
399 | |
400 end | |
401 end | |
402 print('line.type =', line.type) | |
403 print(' ** qtyStr:', line.quantityString, 'qty:', line.quantity, 'assetID:', line.assetID) | |
404 end | |
405 | |
406 Quest.ParseObjective = function(line) | |
407 local print = B.print('QuestLine') | |
408 print(' |cFFFF0088', line.type) | |
409 local color = '00FFFF' | |
410 line.progress = 0 | |
411 if line.finished then | |
412 line.progress = 2 | |
413 color = 'FFFFFF' | |
414 elseif line.type == 'monster' then | |
415 color = 'FFFF00' | |
416 elseif line.type == 'item' then | |
417 color = '44DDFF' | |
418 elseif line.type == 'object' then | |
419 color = 'FF44DD' | |
420 end | |
421 line.displayColor = color | |
422 line.displayText = line.text | |
423 end | |
424 | |
464 | 425 |
465 mod.Quest.numButtons = 0 | 426 mod.Quest.numButtons = 0 |
466 local usedButtons = mod.Quest.itemButtons | 427 local usedButtons = mod.Quest.itemButtons |
467 local freeButtons = mod.Quest.freeButtons | 428 local freeButtons = mod.Quest.freeButtons |
468 mod.UpdateWrapper = function() | 429 mod.UpdateWrapper = function() |
469 unitLevel = UnitLevel('player') | 430 unitLevel = UnitLevel('player') |
470 wrapperWidth = wrapperMaxWidth | 431 wrapperWidth = mod.Conf.Wrapper.WrapperWidth |
471 scrollWidth = wrapperWidth | 432 scrollWidth = mod.Conf.Wrapper.WrapperWidth |
472 local wrapperBlocks = 0 | 433 local wrapperBlocks = 0 |
473 -- Update scroll child vertical size | 434 -- Update scroll child vertical size |
474 scrollHeight = 0 | 435 scrollHeight = 0 |
475 for i, handler in ipairs(orderedHandlers) do | 436 for i, handler in ipairs(orderedHandlers) do |
476 mod.UpdateTracker(handler) | 437 mod.UpdateTracker(handler) |
438 local tracker = handler.Tracker | |
477 if handler.actualBlocks >= 1 then | 439 if handler.actualBlocks >= 1 then |
478 local tracker = handler.Tracker | |
479 print('setting', handler.Tracker, 'to anchor to offset', -scrollHeight) | |
480 tracker:SetParent(Scroll) | 440 tracker:SetParent(Scroll) |
481 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight) | 441 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight) |
482 tracker:SetSize(wrapperWidth, tracker.height) | 442 tracker:SetSize(wrapperWidth, tracker.height) |
483 print('adding ', tracker.height) | 443 print('|cFF00FFFF'..tracker:GetName()..'|r h:|cFF00FF00', tracker.height, '|r y:|cFF00FF00', -scrollHeight) |
484 scrollHeight = scrollHeight + tracker.height | 444 scrollHeight = scrollHeight + tracker.height |
445 tracker:Show() | |
446 else | |
447 tracker:Hide() | |
485 end | 448 end |
486 wrapperBlocks = wrapperBlocks + handler.actualBlocks | 449 wrapperBlocks = wrapperBlocks + handler.actualBlocks |
487 end | 450 end |
488 print('final scrollHeight:', scrollHeight) | 451 print('final scrollHeight:', scrollHeight) |
489 | 452 |
511 for i, region in ipairs(Wrapper.headerComplex) do | 474 for i, region in ipairs(Wrapper.headerComplex) do |
512 region:Hide() | 475 region:Hide() |
513 end | 476 end |
514 return | 477 return |
515 end | 478 end |
516 --wrapperHeight = scrollHeight | 479 --[[wrapperHeight = scrollHeight |
517 | 480 |
518 print('|cFFFFFF00params:|r scroller:', scrollWidth, 'x', scrollHeight) | 481 print('|cFFFFFF00params:|r scroller:', scrollWidth .. ',' .. scrollHeight, 'scroll:', scrollWidth .. ',' .. scrollHeight, |
519 print('|cFFFFFF00params:|r scroll:', scrollWidth, 'x', scrollHeight) | 482 'wrapper:', wrapperWidth .. ',' .. wrapperHeight, |
520 print('|cFFFFFF00params:|r wrapper:', wrapperWidth, 'x', wrapperHeight) | 483 'header:', headerHeight)]] |
521 print('|cFFFFFF00params:|r header:', headerHeight) | 484 |
522 | 485 --Scroller:SetSize(wrapperWidth, wrapperHeight) |
523 mod.SetBlockStyle(Scroller, 'Scroller', 'Normal') | |
524 mod.SetBlockStyle(Scroller, 'Scroll', 'Normal') | |
525 mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal') | |
526 | |
527 Scroller:SetSize(wrapperWidth, wrapperHeight) | |
528 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, 0) | 486 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, 0) |
529 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT') | 487 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT') |
530 | 488 |
531 | 489 |
532 Scroll:SetSize(scrollWidth, scrollHeight) | 490 Scroll:SetSize(scrollWidth, scrollHeight) |
534 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT') | 492 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT') |
535 | 493 |
536 --Scroller:UpdateScrollChildRect() | 494 --Scroller:UpdateScrollChildRect() |
537 Wrapper:SetSize(wrapperWidth, wrapperHeight) | 495 Wrapper:SetSize(wrapperWidth, wrapperHeight) |
538 | 496 |
539 -- update action buttons | 497 --[[ update action buttons |
540 print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(), | 498 print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(), |
541 '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(), | 499 '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(), |
542 '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(), | 500 '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(), |
543 '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5) | 501 '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5) |
544 ) | 502 ) |
545 mod.UpdateActionButtons('FULL_UPDATE') | 503 mod.UpdateActionButtons() |
504 --]] | |
546 | 505 |
547 end | 506 end |
548 | 507 |
549 --- Queue any active item buttons for update for that frame | 508 --- Queue any active item buttons for update for that frame |
550 mod.UpdateActionButtons = function(updateReason) | 509 mod.UpdateActionButtons = function(updateReason) |