Mercurial > wow > buffalo2
comparison ObjectiveTracker/Layout.lua @ 43:9480bd904f4c
- file name organizing
author | Nenue |
---|---|
date | Mon, 25 Apr 2016 13:51:58 -0400 |
parents | ObjectiveTracker/TrackerFrame.lua@03ed70f846de |
children | 756e8aeb040b |
comparison
equal
deleted
inserted
replaced
42:c73051785f19 | 43:9480bd904f4c |
---|---|
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 --- Everything that involves directly placing elements on the screen goes here. Sizing, spacing, tiling, etc. | |
7 local B = select(2,...).frame | |
8 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | |
9 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band | |
10 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove | |
11 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent | |
12 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText | |
13 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent | |
14 local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs | |
15 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame | |
16 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow | |
17 local band, bor = bit.band, bit.bor | |
18 local print = B.print('Layout') | |
19 local oprint = B.print('Objectives') | |
20 local bprint = B.print('Block') | |
21 local tprint = B.print('Tracker') | |
22 local lprint = B.print('Layout') | |
23 local unitLevel = 1 | |
24 | |
25 local REWARD_POPUP = _G.VeneerRewardsPopOut | |
26 local ANIM_STATE = 'Animation: %04X' | |
27 local INIT_STATE = 'Init: %04X' | |
28 | |
29 --- Bitfields of import | |
30 --- control value for everything | |
31 local OBJECTIVE_TRACKER_UPDATE_REASON = _G.OBJECTIVE_TRACKER_UPDATE_REASON | |
32 --- flags reason categories where frame layout requires initializing (starts high) | |
33 local initReason = 0xFFFF | |
34 --- flags reason categories where frame anchor updates must be delayed because of an ongoing animation (starts low) | |
35 local animateReason = 0x0000 | |
36 | |
37 --- FRAMES | |
38 local Wrapper = _G.VeneerObjectiveWrapper | |
39 local Scroller = Wrapper.scrollArea | |
40 local Scroll = _G.VeneerObjectiveScroll | |
41 local orderedHandlers = T.orderedHandlers | |
42 local orderedNames = T.orderedNames | |
43 | |
44 --- FRAME TEMP VARIABLES | |
45 local wrapperWidth, wrapperHeight = 0, 0 | |
46 local scrollWidth, scrollHeight | |
47 | |
48 --- SCHEMA VARIABLES | |
49 local schemaName, lastSchema = { | |
50 tracker = '', | |
51 block = '', | |
52 line = '' | |
53 }, {} | |
54 local trackerSchema, blockSchema, lineSchema | |
55 | |
56 local itemButtonSize, itemButtonSpacing = 36, 1 | |
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 = 24 | |
61 | |
62 local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2 | |
63 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0} | |
64 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE' | |
65 | |
66 local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2} | |
67 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE' | |
68 local titleColor = {0,.7,1,1} | |
69 | |
70 local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 } | |
71 local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE' | |
72 local textColor = {1,1,1,1 } | |
73 | |
74 local widgetTextFont, widgetTextSize, widgetTextOutline = [[Interface\Addons\SharedMedia_MyMedia\font\XOIREQE.TTF]], 11, 'OUTLINE' | |
75 local widgetTextColor = {1,1,1,1 } | |
76 local widgetHeight, widgetBorder = 17, 1 | |
77 | |
78 | |
79 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225} | |
80 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1 | |
81 local titleIndent, textIndent,selectionIndent = 2, 5, 50 | |
82 --- END SCHEMA | |
83 local blockPosition | |
84 | |
85 | |
86 local SetAnimate = function(reason, animate) | |
87 print('comparing', animateReason, reason) | |
88 if animate then | |
89 if band(animateReason, reason) == 0 then | |
90 animateReason = animateReason + reason | |
91 end | |
92 else | |
93 if band(animateReason, reason) > 0 then | |
94 animateReason = animateReason - reason | |
95 end | |
96 end | |
97 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason) | |
98 end | |
99 | |
100 | |
101 --- schema swapper | |
102 T.UpdateSchema = function(layer, newSchema) | |
103 if not (T.Conf.Schema[layer] and T.Conf.Schema[layer][newSchema]) then | |
104 return | |
105 elseif schemaName[layer] == newSchema then | |
106 return | |
107 end | |
108 lastSchema[layer] = schemaName[layer] | |
109 schemaName[layer] = newSchema | |
110 local c = T.Conf.Schema[layer][newSchema] | |
111 | |
112 if layer == 'tracker' then | |
113 headerHeight, headerSpacing = c.headerHeight, c.headerSpacing | |
114 headerColor = c.headerColor | |
115 headerbg = c.headerbg | |
116 headerFont, headerSize, headerOutline = unpack(c.headerFont) | |
117 trackerSchema = newSchema | |
118 elseif layer == 'block' then | |
119 titlebg = c.titlebg | |
120 titleFont, titleSize, titleOutline = unpack(c.titleFont) | |
121 selectionbg = c.selectionbg | |
122 titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing | |
123 titleIndent, textIndent,selectionIndent = c.titleIndex, c.textIndex, c.selectionIndent | |
124 titleColor = c.titleColor | |
125 print(unpack(c.titleColor)) | |
126 rewardSize = 24 | |
127 textFont, textSize, textOutline = unpack(c.textFont) | |
128 textbg = c.textbg | |
129 textIndent = c.textIndent | |
130 rewardSize = c.rewardSize | |
131 blockSchema = newSchema | |
132 elseif layer == 'line' then | |
133 textColor = c.textColor | |
134 lineSchema = newSchema | |
135 elseif layer == 'widget' then | |
136 widgetTextColor = c.textSpacing | |
137 widgetTextFont, widgetTextSize, widgetTextOutline = unpack(c.textFont) | |
138 end | |
139 tprint('|cFFFF0088 Schema:|r', layer, lastSchema[layer], '->', newSchema) | |
140 end | |
141 -- todo: figure out why objectives go invisible | |
142 local anchorPoint, anchorFrame | |
143 local abs, GetTime = math.abs, GetTime | |
144 Default.AddTracker = function(handler, frame, index) | |
145 local isInitialized = true | |
146 if initReason and (band(initReason, handler.updateReason) > 0 ) then | |
147 isInitialized = false | |
148 initReason = initReason - handler.updateReason | |
149 print('|cFF00FF00%%% initialization status update:', format('%04X', initReason)) | |
150 | |
151 frame.SlideIn:SetScript('OnPlay', function() | |
152 SetAnimate(handler.updateReasonModule, true) | |
153 end) | |
154 | |
155 frame.SlideIn:SetScript('OnFinished', function() | |
156 SetAnimate(handler.updateReasonModule, false) | |
157 end) | |
158 | |
159 if initReason == 0 then | |
160 initReason = nil | |
161 end | |
162 end | |
163 | |
164 if index == 1 then | |
165 print('|cFF00FF00### beginning wrapper layout -----------------') | |
166 anchorPoint, anchorFrame = 'TOP', Scroll | |
167 wrapperHeight = 18 | |
168 end | |
169 | |
170 frame.destinationOffset = -wrapperHeight | |
171 print(frame.destinationOffset, frame.previousOffset) | |
172 if isInitialized and (abs(frame.previousOffset - frame.destinationOffset) > 0.9) and frame:IsVisible() then | |
173 if frame.wasEmpty then | |
174 frame.previousOffset = -Wrapper:GetHeight() | |
175 end | |
176 | |
177 local postFrame, postPoint = anchorFrame, anchorPoint | |
178 local delta = frame.destinationOffset - frame.previousOffset | |
179 local _, _, _, _, offset = frame:GetPoint(1) | |
180 print(' |cFF00FFBBpushing', frame:GetName(), delta, 'pixels, from', frame.previousOffset, '(', offset, ')') | |
181 frame.SlideIn.translation:SetTarget(frame) | |
182 frame.SlideIn.translation:SetOffset(0, delta) | |
183 frame.SlideIn:Play() | |
184 --for i, b in ipairs(handler.usedBlocks) do | |
185 --b.SlideIn.translation:SetOffset(0, delta) | |
186 -- b.SlideIn:Play() | |
187 --end | |
188 local start = GetTime() | |
189 frame.SlideIn:SetScript('OnFinished', function() | |
190 print(' |cFF00BBFF'..frame:GetName(), 'moved', delta, 'over duration of ', GetTime()-start) | |
191 frame:SetParent(Scroll) | |
192 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset) | |
193 frame.previousOffset = frame.destinationOffset | |
194 frame.SlideIn:SetScript('OnFinished', nil) | |
195 if Wrapper.destinationHeight then | |
196 Wrapper:SetHeight(Wrapper.destinationHeight) | |
197 Scroller:SetHeight(Wrapper.destinationHeight) | |
198 Scroll:SetHeight(Wrapper.destinationHeight) | |
199 Wrapper.previousHeight = Wrapper.destinationHeight | |
200 Wrapper.destinationHeight = nil | |
201 end | |
202 | |
203 end) | |
204 else | |
205 print(' |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height) | |
206 print(' |cFFFF0088total height:', wrapperHeight) | |
207 frame:ClearAllPoints() | |
208 frame:Show() | |
209 frame:SetParent(Scroll) | |
210 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset) | |
211 frame:SetPoint('LEFT', Scroll, 'LEFT') | |
212 frame:SetPoint('RIGHT', Scroll, 'RIGHT') | |
213 frame.previousOffset = frame.destinationOffset | |
214 handler.initialized = true | |
215 end | |
216 | |
217 frame.title:SetFont(headerFont, headerSize, headerOutline) | |
218 frame.titlebg:SetHeight(headerHeight) | |
219 frame.title:SetTextColor(unpack(headerColor)) | |
220 | |
221 if frame.height ~= frame.previousHeight then | |
222 frame:SetHeight(frame.height) | |
223 end | |
224 | |
225 if frame.wasEmpty then | |
226 frame.headerFade:Play() | |
227 frame.wasEmpty = nil | |
228 end | |
229 | |
230 wrapperHeight = wrapperHeight + frame.height | |
231 anchorFrame = handler.frame | |
232 anchorPoint = 'BOTTOM' | |
233 | |
234 end | |
235 | |
236 Default.AddBlock = function(self, block, blockIndex) | |
237 local blockIndex = blockIndex or (self.currentBlock + 1) | |
238 local print = bprint | |
239 local tracker = self.frame | |
240 local info = block.info | |
241 | |
242 block.index = blockIndex | |
243 -- if animating, skip this segment | |
244 if not block.isAnimating then | |
245 print('blockschema', blockSchema, block.schema) | |
246 if blockSchema ~= block.schema then | |
247 T.UpdateSchema('block', block.schema) | |
248 print(' ### activating block schema:|cFF0088FF', block.schema) | |
249 end | |
250 | |
251 block:SetWidth(T.Conf.Wrapper.Width) | |
252 block.title:SetSpacing(titleSpacing) | |
253 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) | |
254 block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0) | |
255 block.title:SetTextColor(unpack(titleColor)) | |
256 block.titlebg:SetTexture(1,1,1,1) | |
257 block.titlebg:SetGradientAlpha(unpack(titlebg)) | |
258 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) | |
259 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) | |
260 block.status:SetSpacing(textSpacing) | |
261 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing) | |
262 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0) | |
263 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) | |
264 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) | |
265 block.statusbg:SetTexture(1,1,1,1) | |
266 block.statusbg:SetGradientAlpha(unpack(textbg)) | |
267 block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg)) | |
268 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0) | |
269 block.SelectionOverlay:SetPoint('BOTTOMRIGHT') | |
270 | |
271 local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2 | |
272 for i, tile in ipairs(block.rewardTile) do | |
273 --print(rewardSize) | |
274 tile:SetSize(rewardSize, rewardSize) | |
275 tile:ClearAllPoints() | |
276 tile:SetPoint(anchor, target, point, x, y) | |
277 block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0) | |
278 anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0 | |
279 end | |
280 | |
281 | |
282 local titleHeight = floor(block.title:GetHeight()+.5) | |
283 local titlebgHeight = titleHeight + titleSpacing*2 | |
284 block.titlebg:SetHeight(titlebgHeight) | |
285 | |
286 local statusHeight = floor(block.status:GetHeight()+.5) | |
287 local statusbgHeight = statusHeight + textSpacing*2 | |
288 local attachmentHeight =floor(block.attachmentHeight + .5) | |
289 | |
290 self.print('AddBlock', 'anchor to|cFF0088FF', self.currentAnchor:GetName()) | |
291 self.print('AddBlock', 'attachment:|cFF00FF00', attachmentHeight, '|rtitle:|cFF00FF00', titlebgHeight, '|r('.. titleHeight..')') | |
292 if attachmentHeight > 0 then | |
293 attachmentHeight = attachmentHeight + textSpacing | |
294 end | |
295 | |
296 block.height = titlebgHeight + attachmentHeight | |
297 block:SetHeight(block.height) | |
298 end | |
299 | |
300 if block.debug then | |
301 local func = (B.Conf.GuidesMode == true) and 'Show' or 'Hide' | |
302 for _, region in ipairs(block.debug) do | |
303 region[func]() | |
304 end | |
305 end | |
306 | |
307 --- Handler vars | |
308 if blockIndex == 1 then | |
309 tracker.previousHeight = tracker.height | |
310 tracker.height = headerHeight | |
311 blockPosition = -headerHeight | |
312 self.print('AddBlock', 'new layout: headerHeight:|cFF00FF00', headerHeight, '|rpreviousHeight:|cFF00FF00', tracker.previousHeight) | |
313 else | |
314 blockPosition = blockPosition | |
315 self.print('AddBlock', 'advancing: height:|cFF8888FF', tracker.height) | |
316 end | |
317 self.currentBlock = blockIndex | |
318 self.currentAnchor = block | |
319 | |
320 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition) | |
321 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) | |
322 self.numBlocks = self.numBlocks + 1 | |
323 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height) | |
324 tracker.height = tracker.height + block.height | |
325 blockPosition = blockPosition - block.height | |
326 | |
327 block:Show() | |
328 | |
329 | |
330 if Devian and Devian.InWorkspace() then | |
331 block.DebugTab:SetParent(UIParent) | |
332 block.DebugTab:SetPoint('TOPRIGHT', block, 'TOPLEFT', 0, 0) | |
333 block.DebugTab.status:SetText(tostring(block.schema) .. ' @|cFF00FF00' .. tostring(block.posIndex) .. '|r #|cFFFFFF00'.. tostring(info.logIndex or info.id) .. '|r'.. | |
334 ' H|cFFFFFF00' .. tostring(block.height) .. ' L|cFF00FFFF' .. tostring(block.numLines) ..'|r') | |
335 block.DebugTab:Show() | |
336 end | |
337 end | |
338 | |
339 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons) | |
340 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative) | |
341 local print = bprint | |
342 | |
343 for order, tagName in ipairs(block.info.tagInfo) do | |
344 local tag = block[tagName] | |
345 if block.tagCoords[tagName] and tag then | |
346 tag:SetTexCoord(unpack(block.tagCoords[tagName])) | |
347 tag:Show() | |
348 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
349 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT' | |
350 else | |
351 block[tagName]:Hide() | |
352 end | |
353 end | |
354 | |
355 return tagPoint, tagAnchor, tagRelative | |
356 end | |
357 | |
358 | |
359 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call. | |
360 Default.AddLine = function(handler, block, text, attachment, template) | |
361 local print = lprint | |
362 local lineIndex = block.currentLine + 1 | |
363 local line = handler:GetLine(block, lineIndex) | |
364 | |
365 line.index = lineIndex | |
366 template = template or 'default' | |
367 if template and lineSchema ~= template then | |
368 print(' |cFF00FF00change schema', template) | |
369 T.UpdateSchema('line', template) | |
370 end | |
371 line.status:SetSpacing(textSpacing) | |
372 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0) | |
373 line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0) | |
374 line.status:SetTextColor(unpack(textColor)) | |
375 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing) | |
376 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0) | |
377 line:SetPoint('LEFT', block, 'LEFT') | |
378 line:SetPoint('RIGHT', block, 'RIGHT') | |
379 line:Show() | |
380 line:SetScript('OnMouseUp', function(self, button) | |
381 handler.OnMouseUp(block, button) | |
382 end) | |
383 | |
384 | |
385 handler.print('AddLine', '|cFF00FFFF'..tostring(line.schema)..'|r', line:GetName()) | |
386 --[[ | |
387 for i = 1, line:GetNumPoints() do | |
388 tprint(' - ', line:GetPoint(i)) | |
389 end | |
390 tprint(' - ', line:GetSize()) | |
391 tprint(' - ', line:GetParent(), line:GetParent():IsVisible()) | |
392 tprint(' - ', line:IsVisible()) | |
393 --]] | |
394 | |
395 | |
396 | |
397 | |
398 -- fill in the text, then derive pixel-rounded height | |
399 line.status:SetText(text) | |
400 line.height = floor(line.status:GetStringHeight()+.5) | |
401 | |
402 -- For progressbar and timer lines, status text may be used as the title heading | |
403 if attachment then | |
404 attachment:SetPoint('TOP', line, 'TOP') | |
405 attachment:SetPoint('LEFT', line, 'LEFT', textIndent, 0) | |
406 attachment:SetPoint('RIGHT', line, 'RIGHT') | |
407 print(' |cFFFF0088doing things with a widget', attachment:GetSize()) | |
408 line.height = attachment:GetHeight() | |
409 if text then | |
410 line.height = max(line.height, line.status:GetStringHeight()) | |
411 end | |
412 if attachment.status:GetText() then | |
413 line.height = max(line.height, attachment.status:GetStringHeight()) | |
414 end | |
415 attachment:Show() | |
416 end | |
417 | |
418 line:SetHeight(line.height) | |
419 block.attachmentHeight = block.attachmentHeight + line.height + textSpacing | |
420 | |
421 local debug_points = '' | |
422 for i = 1, line:GetNumPoints() do | |
423 local point, parent, anchor = line:GetPoint(i) | |
424 debug_points = debug_points .. tostring(parent:GetName()) .. ', ' .. anchor .. ' ' | |
425 end | |
426 | |
427 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height, | |
428 "|cFF0088FFpoint:|r", debug_points, "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N')) | |
429 block.currentLine = lineIndex | |
430 block.endPoint = line -- edge used for the next block | |
431 | |
432 return lineIndex | |
433 end | |
434 | |
435 | |
436 | |
437 ---------- | |
438 --- Top level methods | |
439 | |
440 | |
441 T.UpdateItemButtonAnchor = function (block, itemButton) | |
442 local print = bprint | |
443 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') | |
444 if itemButton.questID ~= block.info.questID then | |
445 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID) | |
446 -- something happened between this and last frame, go back and set new probes | |
447 return T.UpdateActionButtons() | |
448 end | |
449 | |
450 local previousItem = itemButton.previousItem | |
451 local upper_bound = Scroller:GetTop() + Scroller.snap_upper | |
452 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize | |
453 local point, anchor, relative | |
454 | |
455 if block:GetBottom() < lower_bound then | |
456 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5)) | |
457 if previousItem then | |
458 print('adjusting', previousItem:GetName()) | |
459 previousItem:ClearAllPoints() | |
460 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing) | |
461 end | |
462 itemButton:ClearAllPoints() | |
463 itemButton.x = Wrapper:GetLeft() -4 | |
464 itemButton.y = Wrapper:GetBottom() | |
465 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT' | |
466 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing | |
467 | |
468 elseif block:GetTop() > upper_bound then | |
469 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5)) | |
470 itemButton:ClearAllPoints() | |
471 if previousItem then | |
472 print('latch onto another piece') | |
473 point, anchor, relative ='TOP', previousItem, 'BOTTOM' | |
474 itemButton.x = 0 | |
475 itemButton.y = -itemButtonSpacing | |
476 else | |
477 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop()) | |
478 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' | |
479 itemButton.x = Scroller:GetLeft() -4 | |
480 itemButton.y = Scroller:GetTop() | |
481 end | |
482 itemButton:Show() | |
483 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing) | |
484 else | |
485 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5)) | |
486 itemButton:ClearAllPoints() | |
487 itemButton.x = block:GetLeft() - itemButtonSpacing | |
488 itemButton.y = block:GetTop() | |
489 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' | |
490 end | |
491 | |
492 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y) | |
493 itemButton:Show() | |
494 end | |
495 | |
496 T.UpdateItemButtonCooldown = function(button) | |
497 | |
498 end | |
499 | |
500 function T:FinishWrapper () | |
501 if wrapperHeight > Wrapper.previousHeight then | |
502 Wrapper:SetHeight(wrapperHeight) | |
503 Scroller:SetHeight(wrapperHeight*3) | |
504 Scroll:SetHeight(wrapperHeight) | |
505 Wrapper.previousHeight = wrapperHeight | |
506 Wrapper.destinationHeight = wrapperHeight | |
507 end | |
508 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0) | |
509 print('|cFF00FF00### end of wrapper layout', Wrapper:GetSize()) | |
510 print(' |cFF00FF00Scroller:', Scroller:GetSize()) | |
511 print(' |cFF00FF00Scroll:', Scroll:GetSize()) | |
512 for i = 1, Wrapper:GetNumPoints() do | |
513 print('|cFF00FF00 ', Wrapper:GetPoint(i)) | |
514 end | |
515 for i = 1, Scroller:GetNumPoints() do | |
516 print('|cFF00FF00 ', Scroller:GetPoint(i)) | |
517 end | |
518 for i = 1, Scroll:GetNumPoints() do | |
519 print('|cFF00FF00 ', Scroll:GetPoint(i)) | |
520 end | |
521 | |
522 if Devian and Devian.InWorkspace() then | |
523 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason) | |
524 Wrapper.AnimState:Show() | |
525 end | |
526 | |
527 Wrapper:Show() | |
528 Scroller:Show() | |
529 Scroll:Show() | |
530 end | |
531 | |
532 | |
533 ----------------------------------------- | |
534 -- Criteria frames | |
535 | |
536 --[[ | |
537 text = description, | |
538 type = type, | |
539 finished = completed, | |
540 quantity = quantity, | |
541 requiredQuantity = requiredQuantity, | |
542 characterName = characterName, | |
543 flags = flags, | |
544 assetID = assetID, | |
545 quantityString = quantityString, | |
546 criteriaID = criteriaID, | |
547 ]] | |
548 T.WidgetRegistry = {} | |
549 local wr = T.WidgetRegistry | |
550 | |
551 --- WidgetTemplate 'OnShow' | |
552 local wrapperWidth, textIndent | |
553 T.InitializeWidget = setmetatable({}, { | |
554 __call = function(t, frame, isNew, ...) | |
555 -- todo: config pull | |
556 if not wrapperWidth then | |
557 wrapperWidth = T.Conf.Wrapper.Width | |
558 textIndent = T.Conf.Wrapper.TextIndent | |
559 end | |
560 | |
561 tprint('Initialize', frame:GetName(), isNew, ...) | |
562 frame:SetWidth(wrapperWidth - textIndent * 2) | |
563 frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType]) | |
564 frame:RegisterEvent('QUEST_LOG_UPDATE') | |
565 frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE') | |
566 frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED') | |
567 frame:RegisterEvent('CRITERIA_UPDATE') | |
568 frame:RegisterEvent('CRITERIA_COMPLETE') | |
569 frame:RegisterEvent('CRITERIA_EARNED') | |
570 t[frame.widgetType](frame, isNew) | |
571 T.UpdateWidget[frame.widgetType](frame, isNew) | |
572 end, | |
573 }) | |
574 | |
575 --- WidgetTemplate 'OnEvent' | |
576 T.UpdateWidget = setmetatable({}, { | |
577 __call = function(t, frame, isNew, ...) | |
578 tprint('Update', frame:GetName(), isNew, ...) | |
579 if not frame.widgetType then | |
580 return | |
581 end | |
582 | |
583 return t[frame.widgetType](frame, isNew) | |
584 end | |
585 }) | |
586 | |
587 | |
588 local progressHeight = 17 | |
589 local progressBorder = 1 | |
590 local progressFont = _G.VeneerCriteriaFontNormal | |
591 | |
592 local lprint = B.print('Line') | |
593 T.InitializeWidget.StatusBar = function(self, isNew) | |
594 local print = lprint | |
595 local c = T.Conf.Wrapper | |
596 | |
597 tprint(self:GetName(), isNew) | |
598 if isNew then | |
599 self:SetMinMaxValues(0, self.maxValue) | |
600 | |
601 self:SetHeight(widgetHeight) | |
602 self.height = widgetHeight | |
603 | |
604 self.status:SetFont(widgetTextFont, widgetTextSize, widgetTextOutline) | |
605 self.status:SetTextColor(unpack(widgetTextColor)) | |
606 end | |
607 self:SetValue(self.value) | |
608 | |
609 self.status:SetText(self.objective.quantityString) | |
610 end | |
611 | |
612 T.UpdateWidget.StatusBar = function (self) | |
613 local value, maxValue = self.value, self.maxValue | |
614 print('update vals:') | |
615 for k,v in pairs(self) do | |
616 print(k, v) | |
617 end | |
618 self.width = self.width or self:GetWidth() | |
619 self:SetValue(self.value) | |
620 local format = self.format or '%d/%d' | |
621 self.status:SetFormattedText(format, value, maxValue) | |
622 local progress = (value / maxValue) | |
623 if progress > 0 then | |
624 print('color:', 1-progress*2 , progress*2 - 1,0,1) | |
625 print('width:', (self.width -progressBorder * 2) * progress) | |
626 self:SetStatusBarColor(1-progress*2 , progress*2,0,1) | |
627 end | |
628 end | |
629 | |
630 | |
631 T.InitializeWidget.Hidden = function (self) | |
632 self.height = 0 | |
633 end | |
634 T.UpdateWidget.Hidden = function (self) | |
635 self.height= 0 | |
636 end | |
637 | |
638 | |
639 --- Queue any active item buttons for update for that frame | |
640 local iprint = B.print('ItemButton') | |
641 local Quest = T.Quest | |
642 local IsQuestWatched, InCombatLockdown = IsQuestWatched, InCombatLockdown | |
643 T.UpdateActionButtons = function(updateReason) | |
644 local print = iprint | |
645 Scroller.snap_upper = 0 | |
646 Scroller.snap_lower = 0 | |
647 local print = B.print('ItemButton') | |
648 if updateReason then | |
649 print = B.print('IB_'..updateReason) | |
650 end | |
651 | |
652 local previousItem | |
653 for questID, itemButton in pairs(Quest.itemButtons) do | |
654 local info= T.Quest.Info[questID] | |
655 | |
656 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) | |
657 local block = T.Quest.QuestBlock[questID] | |
658 if block then | |
659 -- Dispatch the probe | |
660 if IsQuestWatched(info.logIndex) then | |
661 itemButton.previousItem = previousItem | |
662 print(' |cFFFFFF00probing', block:GetName()) | |
663 block:SetScript('OnUpdate', function() | |
664 if block:GetBottom() and not InCombatLockdown() then | |
665 print(' '..block:GetName()..' |cFF00FF00probe hit!') | |
666 T.UpdateItemButtonAnchor(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope | |
667 block:SetScript('OnUpdate', nil) | |
668 | |
669 end | |
670 end) | |
671 previousItem = itemButton | |
672 else | |
673 print('hidden block or unwatched quest') | |
674 itemButton.previousItem = nil | |
675 itemButton:Hide() | |
676 end | |
677 elseif itemButton:IsVisible() then | |
678 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName()) | |
679 itemButton.previousItem = nil | |
680 itemButton:Hide() | |
681 else | |
682 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName()) | |
683 end | |
684 end | |
685 end | |
686 | |
687 Default.FadeOutBlock = function (handler, blockIndex) | |
688 | |
689 end |