comparison ObjectiveTracker/Frame.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
11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText 11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
12 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent 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 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 14 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
15 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow 15 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow
16 local band, bor = bit.band, bit.bor
16 local print = B.print('Layout') 17 local print = B.print('Layout')
17 local oprint = B.print('Objectives') 18 local oprint = B.print('Objectives')
18 local bprint = B.print('Block') 19 local bprint = B.print('Block')
19 local tprint = B.print('Tracker') 20 local tprint = B.print('Tracker')
20 local lprint = B.print('Layout') 21 local lprint = B.print('Layout')
21 local unitLevel = 1 22 local unitLevel = 1
22 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON 23
23 local debug = false 24 local ANIM_STATE = 'Animation: %04X'
25 local INIT_STATE = 'Init: %04X'
26
27 --- Bitfields of import
28 --- control value for everything
29 local OBJECTIVE_TRACKER_UPDATE_REASON = _G.OBJECTIVE_TRACKER_UPDATE_REASON
30 --- flags reason categories where frame layout requires initializing (starts high)
31 local initReason = 0xFFFF
32 --- flags reason categories where frame anchor updates must be delayed because of an ongoing animation (starts low)
33 local animateReason = 0x0000
24 34
25 --- FRAMES 35 --- FRAMES
26 local Wrapper = _G.VeneerObjectiveWrapper 36 local Wrapper = _G.VeneerObjectiveWrapper
27 local Scroller = Wrapper.scrollArea 37 local Scroller = Wrapper.scrollArea
28 local Scroll = _G.VeneerObjectiveScroll 38 local Scroll = _G.VeneerObjectiveScroll
62 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225} 72 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}
63 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1 73 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1
64 local titleIndent, textIndent,selectionIndent = 2, 5, 50 74 local titleIndent, textIndent,selectionIndent = 2, 5, 50
65 --- END SCHEMA 75 --- END SCHEMA
66 local blockPosition 76 local blockPosition
77
78
79 local SetAnimate = function(reason, animate)
80 print('comparing', animateReason, reason)
81 if animate then
82 if band(animateReason, reason) == 0 then
83 animateReason = animateReason + reason
84 end
85 else
86 if band(animateReason, reason) > 0 then
87 animateReason = animateReason - reason
88 end
89 end
90 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
91 end
92
67 93
68 --- schema swapper 94 --- schema swapper
69 T.UpdateSchema = function(layer, newSchema) 95 T.UpdateSchema = function(layer, newSchema)
70 if not (T.Conf.Schema[layer] and T.Conf.Schema[layer][newSchema]) then 96 if not (T.Conf.Schema[layer] and T.Conf.Schema[layer][newSchema]) then
71 return 97 return
98 blockSchema = newSchema 124 blockSchema = newSchema
99 elseif layer == 'line' then 125 elseif layer == 'line' then
100 textColor = c.textColor 126 textColor = c.textColor
101 lineSchema = newSchema 127 lineSchema = newSchema
102 end 128 end
103 tprint('|cFFFF0088UpdateSchema:|r', layer, lastSchema[layer], '->', newSchema) 129 tprint('|cFFFF0088 Schema:|r', layer, lastSchema[layer], '->', newSchema)
104 end 130 end
105 -- todo: figure out why objectives go invisible 131 -- todo: figure out why objectives go invisible
106 local anchorPoint, anchorFrame 132 local anchorPoint, anchorFrame
107 local abs, GetTime = math.abs, GetTime 133 local abs, GetTime = math.abs, GetTime
108 Default.AddTracker = function(handler, frame, index) 134 Default.AddTracker = function(handler, frame, index)
135 local isInitialized = true
136 if initReason and (band(initReason, handler.updateReason) > 0 ) then
137 isInitialized = false
138 initReason = initReason - handler.updateReason
139 print('|cFF00FF00%%% initialization status update:', format('%04X', initReason))
140
141 frame.SlideIn:SetScript('OnPlay', function()
142 SetAnimate(handler.updateReasonModule, true)
143 end)
144
145 frame.SlideIn:SetScript('OnFinished', function()
146 SetAnimate(handler.updateReasonModule, false)
147 end)
148
149 if initReason == 0 then
150 initReason = nil
151 end
152 end
153
109 if index == 1 then 154 if index == 1 then
110 print('|cFF00FF00### beginning wrapper layout -----------------') 155 print('|cFF00FF00### beginning wrapper layout -----------------')
111 anchorPoint, anchorFrame = 'TOP', Scroll 156 anchorPoint, anchorFrame = 'TOP', Scroll
112 wrapperHeight = 0 157 wrapperHeight = 0
113 end 158 end
114 159
115 frame.destinationOffset = -wrapperHeight 160 frame.destinationOffset = -wrapperHeight
116 print(frame.destinationOffset, frame.previousOffset) 161 print(frame.destinationOffset, frame.previousOffset)
117 if handler.initialized and (abs(frame.previousOffset - frame.destinationOffset) > 0.9) and frame:IsVisible() then 162 if isInitialized and (abs(frame.previousOffset - frame.destinationOffset) > 0.9) and frame:IsVisible() then
118 if frame.wasEmpty then 163 if frame.wasEmpty then
119 frame.previousOffset = -Wrapper:GetHeight() 164 frame.previousOffset = -Wrapper:GetHeight()
120 end 165 end
121 166
122 local postFrame, postPoint = anchorFrame, anchorPoint 167 local postFrame, postPoint = anchorFrame, anchorPoint
150 print(' |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height) 195 print(' |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
151 print(' |cFFFF0088total height:', wrapperHeight) 196 print(' |cFFFF0088total height:', wrapperHeight)
152 frame:ClearAllPoints() 197 frame:ClearAllPoints()
153 frame:SetParent(Scroll) 198 frame:SetParent(Scroll)
154 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset) 199 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
200 frame:SetPoint('LEFT', Scroll, 'LEFT')
201 frame:SetPoint('RIGHT', Scroll, 'RIGHT')
155 frame.previousOffset = frame.destinationOffset 202 frame.previousOffset = frame.destinationOffset
156 handler.initialized = true 203 handler.initialized = true
157 end 204 end
158 205
159 frame.title:SetFont(headerFont, headerSize, headerOutline) 206 frame.title:SetFont(headerFont, headerSize, headerOutline)
185 block.index = blockIndex 232 block.index = blockIndex
186 233
187 print('blockschema', blockSchema, block.schema) 234 print('blockschema', blockSchema, block.schema)
188 if blockSchema ~= block.schema then 235 if blockSchema ~= block.schema then
189 T.UpdateSchema('block', block.schema) 236 T.UpdateSchema('block', block.schema)
190 print('new schema detected, applicating...') 237 print(' ### activating block schema:|cFF0088FF', block.schema)
191 end 238 end
192 239
193 block:SetWidth(T.Conf.Wrapper.Width) 240 block:SetWidth(T.Conf.Wrapper.Width)
194 block.title:SetSpacing(titleSpacing) 241 block.title:SetSpacing(titleSpacing)
195 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) 242 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
258 self.currentBlock = blockIndex 305 self.currentBlock = blockIndex
259 self.currentAnchor = block 306 self.currentAnchor = block
260 307
261 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition) 308 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition)
262 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) 309 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
310 block:Show()
263 self.numBlocks = self.numBlocks + 1 311 self.numBlocks = self.numBlocks + 1
264 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height) 312 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
265 tracker.height = tracker.height + block.height 313 tracker.height = tracker.height + block.height
266 blockPosition = blockPosition - block.height 314 blockPosition = blockPosition - block.height
315
316
317
318 if Devian and Devian.InWorkspace() then
319 block.DebugTab:SetParent(UIParent)
320 block.DebugTab:SetPoint('TOPRIGHT', block, 'TOPLEFT', 0, 0)
321 block.DebugTab.status:SetText(tostring(block.schema) .. ' @|cFF00FF00' .. tostring(block.posIndex) .. '|r #|cFFFFFF00'.. tostring(info.logIndex or info.id) .. '|r'..
322 ' H|cFFFFFF00' .. tostring(block.height) .. ' L|cFF00FFFF' .. tostring(block.numLines) ..'|r')
323 block.DebugTab:Show()
324 end
267 end 325 end
268 326
269 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons) 327 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
270 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative) 328 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative)
271 local print = bprint 329 local print = bprint
283 end 341 end
284 342
285 return tagPoint, tagAnchor, tagRelative 343 return tagPoint, tagAnchor, tagRelative
286 end 344 end
287 345
346 Default.AddReward = function(handler, block, rewardInfo, tagPoint, tagAnchor, tagRelative)
347 local print = bprint
348
349 for order, reward in ipairs(rewardInfo) do
350
351 end
352 end
353
288 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call. 354 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
289 Default.AddLine = function(handler, block, text, attachment, template) 355 Default.AddLine = function(handler, block, text, attachment, template)
290 local print = lprint 356 local print = lprint
291 local lineIndex = block.currentLine + 1 357 local lineIndex = block.currentLine + 1
292 local line = handler:GetLine(block, lineIndex) 358 local line = handler:GetLine(block, lineIndex)
293 359
294 line.index = lineIndex 360 line.index = lineIndex
295 if template then 361 template = template or 'default'
296 if line.schema ~= template then 362 if template and lineSchema ~= template then
297 print(' |cFF00FF00change schema', template) 363 print(' |cFF00FF00change schema', template)
298 T.UpdateSchema('line', template) 364 T.UpdateSchema('line', template)
299 line.status:SetSpacing(textSpacing) 365 end
300 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0) 366 line.status:SetSpacing(textSpacing)
301 line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0) 367 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
302 line.status:SetTextColor(unpack(textColor)) 368 line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0)
303 line.schema = template 369 line.status:SetTextColor(unpack(textColor))
304 else
305 print(' |cFFFFFF00keep schema', line.schema)
306 end
307 end
308 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing) 370 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
309 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0) 371 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
310 line:SetPoint('LEFT', block, 'LEFT') 372 line:SetPoint('LEFT', block, 'LEFT')
311 line:SetPoint('RIGHT', block, 'RIGHT') 373 line:SetPoint('RIGHT', block, 'RIGHT')
312 line:Show() 374 line:Show()
375 line:SetScript('OnMouseUp', function(self, button)
376 handler.OnMouseUp(block, button)
377 end)
313 378
314 379
315 tprint(' |cFF0088FFAddLine|r (|cFF00FFFF'..tostring(line.schema)..'|r):', line:GetName()) 380 tprint(' |cFF0088FFAddLine|r (|cFF00FFFF'..tostring(line.schema)..'|r):', line:GetName())
381 --[[
382 for i = 1, line:GetNumPoints() do
383 tprint(' - ', line:GetPoint(i))
384 end
385 tprint(' - ', line:GetSize())
386 tprint(' - ', line:GetParent(), line:GetParent():IsVisible())
387 tprint(' - ', line:IsVisible())
388 --]]
389
390
316 391
317 392
318 -- fill in the text, then derive pixel-rounded height 393 -- fill in the text, then derive pixel-rounded height
319 line.status:SetText(text) 394 line.status:SetText(text)
320 line.height = floor(line.status:GetStringHeight()+.5) 395 line.height = floor(line.status:GetStringHeight()+.5)
321 396
322 -- For progressbar and timer lines, status text may be used as the title heading 397 -- For progressbar and timer lines, status text may be used as the title heading
323 if attachment then 398 if attachment then
399 attachment:SetPoint('TOP', line, 'TOP')
400 attachment:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
401 attachment:SetPoint('RIGHT', line, 'RIGHT')
324 print(' |cFFFF0088doing things with a widget', attachment:GetSize()) 402 print(' |cFFFF0088doing things with a widget', attachment:GetSize())
325 line.height = attachment:GetHeight() 403 line.height = attachment:GetHeight()
326 if text then 404 if text then
327 line.height = max(line.height, line.status:GetStringHeight()) 405 line.height = max(line.height, line.status:GetStringHeight())
328 end 406 end
437 block.posIndex = #used 515 block.posIndex = #used
438 end 516 end
439 end 517 end
440 return block 518 return block
441 end 519 end
442
443 520
444 521
445 522
446 ---------- 523 ----------
447 --- Top level methods 524 --- Top level methods
526 end 603 end
527 for i = 1, Scroll:GetNumPoints() do 604 for i = 1, Scroll:GetNumPoints() do
528 print('|cFF00FF00 ', Scroll:GetPoint(i)) 605 print('|cFF00FF00 ', Scroll:GetPoint(i))
529 end 606 end
530 607
608 if Devian and Devian.InWorkspace() then
609 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
610 end
611
531 Wrapper:Show() 612 Wrapper:Show()
532 Scroller:Show() 613 Scroller:Show()
533 Scroll:Show() 614 Scroll:Show()
534 end 615 end
535 616