comparison ObjectiveTracker/Frame.lua @ 28:c33c17dd97e7

file renames
author Nenue
date Wed, 13 Apr 2016 20:19:37 -0400
parents
children adcd7c328d07
comparison
equal deleted inserted replaced
27:c3aa94bc6be2 28:c33c17dd97e7
1 --- ${PACKAGE_NAME}
2 -- @file-author@
3 -- @project-revision@ @project-hash@
4 -- @file-revision@ @file-hash@
5 -- Created: 3/30/2016 12:49 AM
6 local B = select(2,...).frame
7 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
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 IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion
10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
12 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
13 local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs
14 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
15 local print = B.print('Tracker')
16 local unitLevel = 1
17 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON
18 local debug = false
19 --------------------------------------------------------------------
20 --- Global frame layout
21 --------------------------------------------------------------------
22
23 --- Upvalues
24 local Wrapper = _G.VeneerObjectiveWrapper
25 local Scroller = Wrapper.scrollArea
26 local Scroll = _G.VeneerObjectiveScroll
27 local orderedHandlers = T.orderedHandlers
28 local orderedNames = T.orderedNames
29
30 --- Temp values set during updates
31 local wrapperWidth, wrapperHeight
32 local scrollWidth, scrollHeight
33 local previousBlock
34 local currentBlock
35 --- todo: source these from config
36 local itemButtonSize, itemButtonSpacing = 36, 1
37
38 local headerHeight, headerColor, headerSpacing = 16, {1,1,1,1}, 2
39 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}
40 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'
41
42 local titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125}
43 local titlebg_daily = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125 }
44 local titlebg_account = {'HORIZONTAL', 0, .45, 1, .25, 0, .45, 1, .125}
45 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
46
47 local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
48 local textbg_daily = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 }
49 local textbg_account = {'HORIZONTAL', 0, .45, 1, 0.4, 0, .41, 1, .085 }
50 local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'
51
52
53 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}
54 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1
55 local titleIndent, textIndent,selectionIndent = 2, 5, 50
56
57 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
58 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
59 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
60 local rewardSize = 32
61 local oprint = B.print('Objectives')
62 local bprint = B.print('Block')
63 local tprint = B.print('Tracker')
64 local lprint = B.print('Line')
65
66 local currentPosition, anchorFrame, anchorPoint
67
68 --- Positioning and stuff
69 local tick = 0
70 function T:Update (reason, ...)
71 tick = tick + 1
72 local print = tprint
73 reason = reason or OBJECTIVE_TRACKER_UPDATE_REASON
74 local updateWrapper = 0
75 local hasStuff
76 local insertingStuff
77
78 print(format('%d |cFFFF%04X Update()', tick, lshift(reason, 4)), reason, ...)
79 currentPosition = 0
80 anchorPoint = 'TOP'
81 anchorFrame = Scroll
82
83 local wrapperHeight = 0
84 for id, handler in pairs(T.orderedHandlers) do
85 local frame = handler.frame
86
87 print(format('|cFF00FFFF%s and(%04X vs %04x+%04x) = %04X|r', handler.name, reason, handler.updateReasonModule, handler.updateReasonEvents, band(reason, handler.updateReasonModule + handler.updateReasonEvents)))
88 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then
89 handler:Update(reason, ...)
90 print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched)
91 insertingStuff = true
92 else
93 print(' |cFFFF0088'..id..'|r', 'no reason to update')
94 end
95
96 if handler.numWatched >= 1 then
97 hasStuff = true
98 currentPosition = currentPosition + 1
99 frame:SetParent(Scroll)
100 frame:SetPoint('TOP', anchorFrame, anchorPoint, 0, 0)
101 print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint)
102 anchorFrame = handler.frame
103 anchorPoint = 'BOTTOM'
104
105 print('current frame height:', frame.height)
106 wrapperHeight = wrapperHeight + frame.height
107 print('|cFFFF0088total height:', wrapperHeight)
108 else
109 handler.frame:Hide()
110 end
111 end
112
113
114 if hasStuff or insertingStuff then
115 print('updating height to', wrapperHeight)
116 Wrapper:SetHeight(wrapperHeight)
117 Scroller:SetHeight(wrapperHeight)
118 Scroll:SetHeight(wrapperHeight)
119 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
120 print('|cFFFF8800Wrapper:', Wrapper:GetSize())
121 for i = 1, Wrapper:GetNumPoints() do
122 print(' ', Wrapper:GetPoint(i))
123 end
124 print(' |cFF00FFFFScroller:', Scroller:GetSize())
125 for i = 1, Scroller:GetNumPoints() do
126 print(' ', Scroller:GetPoint(i))
127 end
128 print(' |cFF00FFFFScroll:', Scroll:GetSize())
129 for i = 1, Scroll:GetNumPoints() do
130 print(' ', Scroll:GetPoint(i))
131 end
132
133 Wrapper:Show()
134 Scroller:Show()
135 Scroll:Show()
136 end
137 Quest.GetClosest()
138 --T.UpdateActionButtons(reason)
139 end
140
141 T.AddBlock = function(self, block)
142 local print = bprint
143 local tracker = self.frame
144 local info = block.info
145 currentBlock:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, 0)
146 currentBlock:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
147 self.currentAnchor = currentBlock
148 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height, tracker.height)
149 tracker.height = tracker.height + currentBlock.height
150 tracker.numBlocks = max(tracker.numBlocks, info.blockIndex)
151 tracker.actualBlocks = tracker.actualBlocks + 1
152 end
153
154 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
155 T.AddTag = function (block, tagName, tagPoint, tagAnchor, tagRelative)
156 local print = bprint
157 local tag = block[tagName]
158 if block.info[tagName] and tag then
159 tag:SetTexCoord(unpack(block.info[tagName]))
160 tag:Show()
161 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
162 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
163 else
164 block[tagName]:Hide()
165 end
166 return tagPoint, tagAnchor, tagRelative
167 end
168
169 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
170 T.AddLine = function(block, line)
171 local print = lprint
172 line:ClearAllPoints()
173 line:SetPoint('LEFT', block, 'LEFT', 0, 0)
174 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
175 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0)
176 line:SetHeight(line.height)
177 line:Show()
178
179 block.endIndex = line.index
180 block.numLines = block.numLines + 1
181 block.attachmentHeight = block.attachmentHeight + (line.height + textSpacing)
182 print(' |cFF0088FFsetting line #'..block.numLines..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
183 "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
184 block.endPoint = line
185 end
186
187 --- Creates or retrieves a complete line data object
188 T.GetLine = function(handler, block, lineIndex)
189 local print = lprint
190 local blockIndex = block.index
191 if not block.lines then
192 block.lines = {}
193 end
194 local lines = block.lines
195 if not lines[lineIndex] then
196 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex)
197 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective')
198 local line = lines[lineIndex]
199 line.index = lineIndex
200 line.height = 0
201 line.status:SetSpacing(textSpacing)
202 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
203 B.SetConfigLayers(line)
204
205 if lines[lineIndex+1] then
206 lines[lineIndex+1]:ClearAllPoints()
207 end
208
209 if debug then
210 for _, region in ipairs(lines[lineIndex].debug) do
211 region:Show()
212 end
213 end
214
215 end
216 return lines[lineIndex]
217 end
218
219 --- Creates or retrieves a complete block frame object
220 T.GetBlock = function(handler, blockIndex)
221 local print = bprint
222 local block = handler.usedBlocks[blockIndex]
223
224 if not handler.usedBlocks[blockIndex] then
225 if #handler.freeBlocks >= 1 then
226 block = handler.freeBlocks[#handler.freeBlocks]
227 handler.freeBlocks[#handler.freeBlocks] = nil
228 else
229 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock')
230
231
232
233 local c = T.Conf.Wrapper
234 block.index = blockIndex
235 block.SetStyle = T.SetBlockStyle
236 block:SetWidth(c.Width)
237
238 block.title:SetSpacing(c.TitleSpacing)
239 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
240
241 block.titlebg:SetTexture(1,1,1,1)
242 block.titlebg:SetGradientAlpha(unpack(T.colors.default.titlebg))
243 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
244 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
245
246 block.status:SetSpacing(c.TextSpacing)
247 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
248 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
249
250 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
251 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
252 block.statusbg:SetTexture(1,1,1,1)
253 block.statusbg:SetGradientAlpha(unpack(T.colors.default.textbg))
254
255 block.SelectionOverlay:SetGradientAlpha(unpack(T.colors.default.selectionbg))
256 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
257 block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
258
259 block.icon:SetSize(rewardSize, rewardSize)
260 block.icon:SetPoint('TOPRIGHT', block, 'TOPRIGHT', -2, -2)
261
262
263 --- methods for event handlers
264
265 block.Select = handler.Select
266 block.Open = handler.Open
267 block.Remove = handler.Remove
268 block.Link = handler.Link
269 block.clickZone:SetScript('OnMouseUp', function(self, ...) handler.OnMouseUp(block, ...) end)
270 block.clickZone:SetScript('OnMouseDown', function(self, ...) handler.OnMouseDown(block, ...) end)
271 block.attachmentHeight = 0
272 block:ClearAllPoints()
273
274 B.SetConfigLayers(block)
275
276 if debug then
277 for _, region in ipairs(block.debug) do
278 region:Show()
279 end
280 end
281 end
282 handler.usedBlocks[blockIndex] = block
283 end
284 return handler.usedBlocks[blockIndex]
285 end
286
287 --- Content generator base
288 Default.Update = function (self, reason, ...)
289 local print = tprint
290 local tracker = self.frame
291 local blockIndex = 0
292 tracker.previousHeight = tracker.height
293 tracker.height = 0
294
295 tracker.title:SetFont(headerFont, headerSize, headerOutline)
296 tracker.titlebg:SetHeight(headerHeight)
297 tracker.title:SetTextColor(unpack(headerColor))
298
299 self.currentAnchor = tracker.titlebg
300 local numWatched = self:GetNumWatched()
301 local numBlocks = self.numBlocks
302 local actualBlocks = 0
303 for watchIndex = 1, 25 do
304 blockIndex = blockIndex + 1
305 if watchIndex <= numWatched then
306 local info = self:GetInfo(watchIndex)
307 if info then
308 local currentBlock = self:UpdateBlock(blockIndex, info)
309 T.AddBlock(currentBlock)
310 else
311 print(' |cFFFF0000bad GetInfo data for #'..watchIndex)
312 end
313 elseif watchIndex <= numBlocks then
314 local used = self.usedBlocks
315 local free = self.freeBlocks
316 print('clean up dead quest block')
317 if used[blockIndex] then
318 used[blockIndex]:Hide()
319 used[blockIndex]:ClearAllPoints()
320 free[#free+1]= used[blockIndex]
321 used[blockIndex] = nil
322 end
323 else
324 print(' |cFFFF9900END|r @', blockIndex)
325 break -- done with quest stuff
326 end
327 end
328
329 self.numWatched = numWatched
330 self.numBlocks = numBlocks
331 self.actualBlocks = actualBlocks
332
333 if numBlocks >= 1 then
334 tracker.height = tracker.height + headerHeight
335 tracker:Show()
336
337 if tracker.wasEmpty then
338 tracker.headerFade:Play()
339 tracker.wasEmpty = nil
340 end
341 if tracker.height ~= tracker.previousHeight then
342 tracker:SetHeight(tracker.height)
343 end
344 else
345 tracker:Hide()
346 tracker.wasEmpty = true
347 end
348
349 return tracker.numWatched, tracker.numAll
350 end
351
352 --- Updates the selected block frame to display the given info batch
353 -- If `previousBlock` is set, it will attempt to anchor to that
354 -- @param blockNum the ordered block to be updated, not a watchIndex value
355 -- @param info the reference returned by the GetXInfo functions
356 -- REMEMBER: t.info and questData[questID] are the same table
357 Default.UpdateBlock = function (handler, blockIndex, info)
358 local print = bprint
359 print(' Read list item |cFF00FFFF'..blockIndex..'|r')
360 if not blockIndex or not info then
361 return
362 end
363 local frame = handler.frame
364 local block = T.GetBlock(handler, blockIndex)
365 block.handler = handler
366 block.info = info
367 block.mainStyle = info.mainStyle or 'Normal'
368 block.subStyle = info.subStyle
369
370 info.blockIndex = blockIndex
371 if info.questID then handler.QuestBlock[info.questID] = block end
372 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = block end
373 if info.watchIndex then handler.WatchBlock[info.watchIndex] = block end
374 handler.BlockInfo[blockIndex] = info
375
376 block.endPoint = block.titlebg
377 block.attachmentHeight = 0
378 handler:UpdateObjectives(block)
379
380 block.title:SetText(info.title)
381 local titleHeight = floor(block.title:GetHeight()+.5)
382 local statusHeight = floor(block.status:GetHeight()+.5)
383 local attachmentHeight =floor(block.attachmentHeight + .5)
384 local titlebgHeight = titleHeight + titleSpacing*2
385 local statusbgHeight = statusHeight + textSpacing*2
386
387 block.titlebg:SetHeight(titlebgHeight)
388
389
390 print(' |cFF0088FFanchor to', handler.currentAnchor:GetName())
391
392 print(' |cFF00FF00total sizes:')
393 print(' attachment:', attachmentHeight)
394 print(' title:', titlebgHeight, '('.. titleHeight..')')
395 --block.titlebg:SetHeight(block.title:GetHeight() + T.Conf.Wrapper.TitleSpacing)
396 block.height = titlebgHeight + attachmentHeight
397 if statusHeight > 1 then
398 block.height = block.height + statusbgHeight
399 print(' status:', statusbgHeight, '('.. statusHeight..')')
400 else
401 print(' |cFFFF0088 skipped')
402 end
403 block:SetHeight(block.height)
404
405 print(' |cFFFFFF00height|r:', block.height)
406 print(' |cFF00FFFF)|r -> ', block, block:GetHeight())
407
408 block:Show()
409
410 if info.specialItem and not info.itemButton then
411 print(' - |cFF00FFFFgenerating item button for info set')
412 info.itemButton = T.SetItemButton(block, info)
413 else
414 --info.itemButton = nil
415 end
416
417 local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block, 'TOPRIGHT'
418
419 if info.rewardInfo then
420 print('has immediate reward')
421 if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then
422 block.icon:Show()
423 block.iconLabel:SetText(info.rewardInfo[1].count)
424 block.icon:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
425 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block.icon, 'TOPLEFT'
426 block.icon:SetTexture(info.rewardInfo[1].texture)
427 end
428 else
429 block.icon:Hide()
430 end
431
432 if info.selected then
433 block.SelectionOverlay:Show()
434 else
435 block.SelectionOverlay:Hide()
436 end
437 -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel
438 --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1)
439 --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1)
440
441 tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative)
442 tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative)
443 tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative)
444
445 return block
446 end
447
448
449
450
451 --- Does the main iterations for populating block content.
452 -- Hooked by corresponding handler functions where additional details need to be sorted.
453 Default.UpdateObjectives = function(handler, block)
454 local print = lprint
455 local info = block.info
456 print(' |cFF00FF00default objectives routine', block:GetName())
457
458 -- reset the starting positions
459 block.attachmentHeight = 0
460 block.endPoint = block.titlebg
461 local completionScore, completionMax = 0, 0
462 local displayObjectiveHeader = false
463
464
465 --- The first line is going to be used no matter what, so it is hard-pulled.
466 -- It also ensures that we're in the right position for cleaning up the leftover lines.
467 local lineIndex = 1
468 local line = T.GetLine(handler, block, lineIndex)
469
470 block.numLines = 0
471 block.attachmentHeight = 0
472
473 if info.description and #info.description >= 1 then
474 print(' |cFF00FFFF header line:|r', info.description)
475 line.status:SetText(info.description)
476 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing
477 if line.widget then
478 line.widget:Hide()
479 end
480 T.AddLine(block, line)
481
482 lineIndex = lineIndex + 1
483 line = T.GetLine(handler, block, lineIndex)
484 end
485
486 if (info.isComplete or info.numObjectives == 0) and info.completionText then
487 print(' overriding line #1 for completion text:', info.completionText)
488 line.status:SetText(info.completionText)
489 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing
490 if line.widget then
491 line.widget:Hide()
492 end
493 T.AddLine(block, line)
494 else
495 if info.objectives then
496 for i, data in ipairs(info.objectives) do
497 print(' |cFF88FF00#', i, data.type, data.text)
498 displayObjectiveHeader = true
499 line.height = 0
500 handler:UpdateLine(block, line, data)
501
502 -- For progressbar and timer lines, status text may be used as the title heading
503 if line.widget then
504 local widgetPosition = 0
505 --- WIDGET POSITION -------------------------------------------------
506 line.widget:SetPoint('TOP', line, 'TOP', 0, -widgetPosition)
507 line.widget:Show()
508 line.height = line.widget:GetHeight() + textSpacing
509 ---------------------------------------------------------------------
510 if line.displayText and #line.displayText >= 1 then
511 widgetPosition = line.status:GetHeight() + textSpacing
512 line.status:SetText(line.displayText)
513 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + line.widget.height
514 print(' - progressbar has text, adjust')
515 end
516 elseif line.displayText then
517 line.status:SetText(line.displayText)
518 line.height = floor(line.status:GetStringHeight()+.5)
519 end
520
521 T.AddLine(block, line)
522
523 --print(' sz', line:GetWidth(), line:GetHeight(), 'pt', line:GetPoint(1))
524 --print(' |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg)
525
526 lineIndex = lineIndex + 1
527 line = T.GetLine(handler, block, lineIndex)
528 end
529 end
530 end
531
532 while (block.lines[lineIndex+1]) do
533 print(' - hide |cFFFF0088'..lineIndex..'|r')
534 block.lines[lineIndex]:Hide()
535 lineIndex = lineIndex +1
536 end
537
538
539
540 if lineIndex > 0 then
541 block.attachmentHeight = block.attachmentHeight + textSpacing * 2
542 print(' |cFF00FF00attachment:', block.attachmentHeight)
543 end
544
545
546 --[[
547 local lines = handler.lines[block.index]
548 if lines and #lines > block.numLines then
549 print(' |cFFFF008' .. (#lines - block.numLines) .. ' extra lines to hide.')
550 for i = block.numLines + 1, #lines do
551 print(' hide', i, lines[i]:GetName())
552 lines[i]:Hide()
553 end
554 end
555 ]]
556
557
558 if debug then
559 for i, region in ipairs(block.debug) do
560 for j = 1, region:GetNumPoints() do
561 local _, target = region:GetPoint(j)
562 if target:IsVisible() then
563 region:Hide()
564 else
565 region:Show()
566 end
567 end
568 end
569 end
570
571 block.completionScore = completionScore / completionMax
572 end
573
574
575 --- Module-specific display variables
576 -- * height - height of whatever display widget is involved in conveying the task
577 -- * money - boolean that determines listening for money events or not
578 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively
579
580
581 Default.UpdateLine = function(block, line)
582 if line.finished then
583 line.progress = 2
584 elseif line.quantity > 0 then
585 line.progress = 1
586 else
587 line.progress = 0
588 end
589 return line
590 end
591 ----------
592 --- Top level methods
593
594 --- Queue any active item buttons for update for that frame
595 local iprint = B.print('ItemButton')
596 T.UpdateActionButtons = function(updateReason)
597 local print = iprint
598 Scroller.snap_upper = 0
599 Scroller.snap_lower = 0
600 local print = B.print('ItemButton')
601 if updateReason then
602 print = B.print('IB_'..updateReason)
603 end
604
605 local previousItem
606 for questID, itemButton in pairs(Quest.itemButtons) do
607 local info= T.Quest.Info[questID]
608
609 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
610 local block = T.Quest.QuestBlock[questID]
611 if block then
612 -- Dispatch the probe
613 if IsQuestWatched(info.questLogIndex) then
614 itemButton.previousItem = previousItem
615 print(' |cFFFFFF00probing', block:GetName())
616 block:SetScript('OnUpdate', function()
617 if block:GetBottom() and not InCombatLockdown() then
618 print(' '..block:GetName()..' |cFF00FF00probe hit!')
619 T.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
620 block:SetScript('OnUpdate', nil)
621
622 end
623 end)
624 previousItem = itemButton
625 else
626 print('hidden block or unwatched quest')
627 itemButton.previousItem = nil
628 itemButton:Hide()
629 end
630 elseif itemButton:IsVisible() then
631 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
632 itemButton.previousItem = nil
633 itemButton:Hide()
634 else
635 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
636 end
637 end
638 end
639
640 T.UpdateBlockAction = function (block, itemButton)
641 local print = iprint
642 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
643 if itemButton.questID ~= block.info.questID then
644 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
645 -- something happened between this and last frame, go back and set new probes
646 return T.UpdateActionButtons()
647 end
648
649 local previousItem = itemButton.previousItem
650 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
651 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
652 local point, anchor, relative
653
654 if block:GetBottom() < lower_bound then
655 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
656 if previousItem then
657 print('adjusting', previousItem:GetName())
658 previousItem:ClearAllPoints()
659 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
660 end
661 itemButton:ClearAllPoints()
662 itemButton.x = Wrapper:GetLeft() -4
663 itemButton.y = Wrapper:GetBottom()
664 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
665 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
666
667 elseif block:GetTop() > upper_bound then
668 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
669 itemButton:ClearAllPoints()
670 if previousItem then
671 print('latch onto another piece')
672 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
673 itemButton.x = 0
674 itemButton.y = -itemButtonSpacing
675 else
676 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
677 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
678 itemButton.x = Scroller:GetLeft() -4
679 itemButton.y = Scroller:GetTop()
680 end
681 itemButton:Show()
682 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
683 else
684 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
685 itemButton:ClearAllPoints()
686 itemButton.x = block:GetLeft() - itemButtonSpacing
687 itemButton.y = block:GetTop()
688 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
689 end
690
691 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
692 itemButton:Show()
693 end
694
695 T.UpdateItemButtonCooldown = function(button)
696
697 end
698
699 Default.Select = function(self)
700 T:Update(self.watchReasonModule)
701 end
702 Default.Open = function(self)
703 T:Update(self.watchReasonModule)
704 end
705 Default.Remove = function(self)
706 T:Update(self.watchReasonModule)
707 end
708 Default.Report = function(self)
709 print('Stats:', self.numWatched,'items tracked,', self.numBlocks,'blocks assigned.')
710 end
711
712 Default.OnMouseUp = function(self, button)
713
714 print(self.handler.name, self.mainStyle, self.subStyle)
715 if button == 'LeftButton' then
716 if IsModifiedClick("CHATLINK") and ChatEdit_GetActiveWindow() then
717 self:Link()
718 elseif IsModifiedClick("QUESTWATCHTOGGLE") then
719 self:Remove()
720 else
721 self:Select()
722 end
723 elseif button == 'RightButton' then
724 self:Open()
725 end
726 self.initialButton = nil
727 self.modChatLink = nil
728 self.modQuestWatch = nil
729 mod:Update(self.handler.updateReasonModule)
730 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r')
731 end
732
733 Default.OnMouseDown = function(self, button)
734
735 print(IsModifiedClick("CHATLINK"), IsModifiedClick("QUESTWATCHTOGGLE"))
736 print(self.info.title)
737 end