annotate 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
rev   line source
Nenue@28 1 --- ${PACKAGE_NAME}
Nenue@28 2 -- @file-author@
Nenue@28 3 -- @project-revision@ @project-hash@
Nenue@28 4 -- @file-revision@ @file-hash@
Nenue@28 5 -- Created: 3/30/2016 12:49 AM
Nenue@28 6 local B = select(2,...).frame
Nenue@35 7 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@28 8 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
Nenue@34 9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove
Nenue@28 10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
Nenue@28 11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
Nenue@28 12 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
Nenue@35 13 local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs
Nenue@28 14 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
Nenue@29 15 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow
Nenue@38 16 local band, bor = bit.band, bit.bor
Nenue@35 17 local print = B.print('Layout')
Nenue@34 18 local oprint = B.print('Objectives')
Nenue@34 19 local bprint = B.print('Block')
Nenue@34 20 local tprint = B.print('Tracker')
Nenue@35 21 local lprint = B.print('Layout')
Nenue@28 22 local unitLevel = 1
Nenue@38 23
Nenue@38 24 local ANIM_STATE = 'Animation: %04X'
Nenue@38 25 local INIT_STATE = 'Init: %04X'
Nenue@38 26
Nenue@38 27 --- Bitfields of import
Nenue@38 28 --- control value for everything
Nenue@38 29 local OBJECTIVE_TRACKER_UPDATE_REASON = _G.OBJECTIVE_TRACKER_UPDATE_REASON
Nenue@38 30 --- flags reason categories where frame layout requires initializing (starts high)
Nenue@38 31 local initReason = 0xFFFF
Nenue@38 32 --- flags reason categories where frame anchor updates must be delayed because of an ongoing animation (starts low)
Nenue@38 33 local animateReason = 0x0000
Nenue@28 34
Nenue@34 35 --- FRAMES
Nenue@28 36 local Wrapper = _G.VeneerObjectiveWrapper
Nenue@28 37 local Scroller = Wrapper.scrollArea
Nenue@28 38 local Scroll = _G.VeneerObjectiveScroll
Nenue@35 39 local orderedHandlers = T.orderedHandlers
Nenue@35 40 local orderedNames = T.orderedNames
Nenue@28 41
Nenue@34 42 --- FRAME TEMP VARIABLES
Nenue@37 43 local wrapperWidth, wrapperHeight = 0, 0
Nenue@28 44 local scrollWidth, scrollHeight
Nenue@34 45
Nenue@34 46 --- SCHEMA VARIABLES
Nenue@34 47 local schemaName, lastSchema = {
Nenue@34 48 tracker = '',
Nenue@34 49 block = '',
Nenue@34 50 line = ''
Nenue@34 51 }, {}
Nenue@34 52 local trackerSchema, blockSchema, lineSchema
Nenue@34 53
Nenue@28 54 local itemButtonSize, itemButtonSpacing = 36, 1
Nenue@34 55 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
Nenue@34 56 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
Nenue@34 57 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
Nenue@34 58 local rewardSize = 24
Nenue@28 59
Nenue@30 60 local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2
Nenue@28 61 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}
Nenue@28 62 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'
Nenue@28 63
Nenue@31 64 local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2}
Nenue@28 65 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
Nenue@34 66 local titleColor = {0,.7,1,1}
Nenue@28 67
Nenue@28 68 local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
Nenue@28 69 local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'
Nenue@34 70 local textColor = {1,1,1,1}
Nenue@28 71
Nenue@28 72 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}
Nenue@28 73 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1
Nenue@28 74 local titleIndent, textIndent,selectionIndent = 2, 5, 50
Nenue@34 75 --- END SCHEMA
Nenue@35 76 local blockPosition
Nenue@35 77
Nenue@38 78
Nenue@38 79 local SetAnimate = function(reason, animate)
Nenue@38 80 print('comparing', animateReason, reason)
Nenue@38 81 if animate then
Nenue@38 82 if band(animateReason, reason) == 0 then
Nenue@38 83 animateReason = animateReason + reason
Nenue@38 84 end
Nenue@38 85 else
Nenue@38 86 if band(animateReason, reason) > 0 then
Nenue@38 87 animateReason = animateReason - reason
Nenue@38 88 end
Nenue@38 89 end
Nenue@38 90 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
Nenue@38 91 end
Nenue@38 92
Nenue@38 93
Nenue@34 94 --- schema swapper
Nenue@35 95 T.UpdateSchema = function(layer, newSchema)
Nenue@35 96 if not (T.Conf.Schema[layer] and T.Conf.Schema[layer][newSchema]) then
Nenue@34 97 return
Nenue@34 98 elseif schemaName[layer] == newSchema then
Nenue@34 99 return
Nenue@34 100 end
Nenue@34 101 lastSchema[layer] = schemaName[layer]
Nenue@34 102 schemaName[layer] = newSchema
Nenue@35 103 local c = T.Conf.Schema[layer][newSchema]
Nenue@28 104
Nenue@34 105 if layer == 'tracker' then
Nenue@34 106 headerHeight, headerSpacing = c.headerHeight, c.headerSpacing
Nenue@34 107 headerColor = c.headerColor
Nenue@34 108 headerbg = c.headerbg
Nenue@37 109 headerFont, headerSize, headerOutline = unpack(c.headerFont)
Nenue@34 110 trackerSchema = newSchema
Nenue@34 111 elseif layer == 'block' then
Nenue@34 112 titlebg = c.titlebg
Nenue@37 113 titleFont, titleSize, titleOutline = unpack(c.titleFont)
Nenue@34 114 selectionbg = c.selectionbg
Nenue@34 115 titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing
Nenue@37 116 titleIndent, textIndent,selectionIndent = c.titleIndex, c.textIndex, c.selectionIndent
Nenue@34 117 titleColor = c.titleColor
Nenue@37 118 print(unpack(c.titleColor))
Nenue@34 119 rewardSize = 24
Nenue@37 120 textFont, textSize, textOutline = unpack(c.textFont)
Nenue@34 121 textbg = c.textbg
Nenue@34 122 textIndent = c.textIndent
Nenue@34 123 rewardSize = c.rewardSize
Nenue@37 124 blockSchema = newSchema
Nenue@34 125 elseif layer == 'line' then
Nenue@34 126 textColor = c.textColor
Nenue@34 127 lineSchema = newSchema
Nenue@34 128 end
Nenue@38 129 tprint('|cFFFF0088 Schema:|r', layer, lastSchema[layer], '->', newSchema)
Nenue@34 130 end
Nenue@35 131 -- todo: figure out why objectives go invisible
Nenue@35 132 local anchorPoint, anchorFrame
Nenue@35 133 local abs, GetTime = math.abs, GetTime
Nenue@35 134 Default.AddTracker = function(handler, frame, index)
Nenue@38 135 local isInitialized = true
Nenue@38 136 if initReason and (band(initReason, handler.updateReason) > 0 ) then
Nenue@38 137 isInitialized = false
Nenue@38 138 initReason = initReason - handler.updateReason
Nenue@38 139 print('|cFF00FF00%%% initialization status update:', format('%04X', initReason))
Nenue@38 140
Nenue@38 141 frame.SlideIn:SetScript('OnPlay', function()
Nenue@38 142 SetAnimate(handler.updateReasonModule, true)
Nenue@38 143 end)
Nenue@38 144
Nenue@38 145 frame.SlideIn:SetScript('OnFinished', function()
Nenue@38 146 SetAnimate(handler.updateReasonModule, false)
Nenue@38 147 end)
Nenue@38 148
Nenue@38 149 if initReason == 0 then
Nenue@38 150 initReason = nil
Nenue@38 151 end
Nenue@38 152 end
Nenue@38 153
Nenue@35 154 if index == 1 then
Nenue@35 155 print('|cFF00FF00### beginning wrapper layout -----------------')
Nenue@35 156 anchorPoint, anchorFrame = 'TOP', Scroll
Nenue@35 157 wrapperHeight = 0
Nenue@35 158 end
Nenue@35 159
Nenue@35 160 frame.destinationOffset = -wrapperHeight
Nenue@35 161 print(frame.destinationOffset, frame.previousOffset)
Nenue@38 162 if isInitialized and (abs(frame.previousOffset - frame.destinationOffset) > 0.9) and frame:IsVisible() then
Nenue@35 163 if frame.wasEmpty then
Nenue@35 164 frame.previousOffset = -Wrapper:GetHeight()
Nenue@35 165 end
Nenue@35 166
Nenue@35 167 local postFrame, postPoint = anchorFrame, anchorPoint
Nenue@35 168 local delta = frame.destinationOffset - frame.previousOffset
Nenue@35 169 local _, _, _, _, offset = frame:GetPoint(1)
Nenue@35 170 print(' |cFF00FFBBpushing', frame:GetName(), delta, 'pixels, from', frame.previousOffset, '(', offset, ')')
Nenue@35 171 frame.SlideIn.translation:SetTarget(frame)
Nenue@35 172 frame.SlideIn.translation:SetOffset(0, delta)
Nenue@35 173 frame.SlideIn:Play()
Nenue@35 174 --for i, b in ipairs(handler.usedBlocks) do
Nenue@35 175 --b.SlideIn.translation:SetOffset(0, delta)
Nenue@35 176 -- b.SlideIn:Play()
Nenue@35 177 --end
Nenue@35 178 local start = GetTime()
Nenue@35 179 frame.SlideIn:SetScript('OnFinished', function()
Nenue@35 180 print(' |cFF00BBFF'..frame:GetName(), 'moved', delta, 'over duration of ', GetTime()-start)
Nenue@35 181 frame:SetParent(Scroll)
Nenue@35 182 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
Nenue@35 183 frame.previousOffset = frame.destinationOffset
Nenue@35 184 frame.SlideIn:SetScript('OnFinished', nil)
Nenue@35 185 if Wrapper.destinationHeight then
Nenue@35 186 Wrapper:SetHeight(Wrapper.destinationHeight)
Nenue@35 187 Scroller:SetHeight(Wrapper.destinationHeight)
Nenue@35 188 Scroll:SetHeight(Wrapper.destinationHeight)
Nenue@35 189 Wrapper.previousHeight = Wrapper.destinationHeight
Nenue@35 190 Wrapper.destinationHeight = nil
Nenue@35 191 end
Nenue@35 192
Nenue@35 193 end)
Nenue@35 194 else
Nenue@37 195 print(' |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
Nenue@35 196 print(' |cFFFF0088total height:', wrapperHeight)
Nenue@35 197 frame:ClearAllPoints()
Nenue@35 198 frame:SetParent(Scroll)
Nenue@35 199 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
Nenue@38 200 frame:SetPoint('LEFT', Scroll, 'LEFT')
Nenue@38 201 frame:SetPoint('RIGHT', Scroll, 'RIGHT')
Nenue@35 202 frame.previousOffset = frame.destinationOffset
Nenue@35 203 handler.initialized = true
Nenue@35 204 end
Nenue@35 205
Nenue@35 206 frame.title:SetFont(headerFont, headerSize, headerOutline)
Nenue@35 207 frame.titlebg:SetHeight(headerHeight)
Nenue@35 208 frame.title:SetTextColor(unpack(headerColor))
Nenue@35 209
Nenue@35 210 if frame.height ~= frame.previousHeight then
Nenue@35 211 frame:SetHeight(frame.height)
Nenue@35 212 end
Nenue@35 213
Nenue@35 214 frame:Show()
Nenue@35 215 if frame.wasEmpty then
Nenue@35 216 frame.headerFade:Play()
Nenue@35 217 frame.wasEmpty = nil
Nenue@35 218 end
Nenue@35 219
Nenue@35 220 wrapperHeight = wrapperHeight + frame.height
Nenue@35 221 anchorFrame = handler.frame
Nenue@35 222 anchorPoint = 'BOTTOM'
Nenue@35 223
Nenue@35 224 end
Nenue@28 225
Nenue@30 226 Default.AddBlock = function(self, block, blockIndex)
Nenue@30 227 local blockIndex = blockIndex or (self.currentBlock + 1)
Nenue@28 228 local print = bprint
Nenue@28 229 local tracker = self.frame
Nenue@28 230 local info = block.info
Nenue@30 231
Nenue@35 232 block.index = blockIndex
Nenue@35 233
Nenue@37 234 print('blockschema', blockSchema, block.schema)
Nenue@34 235 if blockSchema ~= block.schema then
Nenue@37 236 T.UpdateSchema('block', block.schema)
Nenue@38 237 print(' ### activating block schema:|cFF0088FF', block.schema)
Nenue@37 238 end
Nenue@34 239
Nenue@37 240 block:SetWidth(T.Conf.Wrapper.Width)
Nenue@37 241 block.title:SetSpacing(titleSpacing)
Nenue@37 242 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
Nenue@37 243 block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
Nenue@37 244 block.title:SetTextColor(unpack(titleColor))
Nenue@37 245 block.titlebg:SetTexture(1,1,1,1)
Nenue@37 246 block.titlebg:SetGradientAlpha(unpack(titlebg))
Nenue@37 247 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
Nenue@37 248 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
Nenue@37 249 block.status:SetSpacing(textSpacing)
Nenue@37 250 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
Nenue@37 251 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
Nenue@37 252 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
Nenue@37 253 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
Nenue@37 254 block.statusbg:SetTexture(1,1,1,1)
Nenue@37 255 block.statusbg:SetGradientAlpha(unpack(textbg))
Nenue@37 256 block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
Nenue@37 257 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
Nenue@37 258 block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
Nenue@37 259
Nenue@37 260 local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
Nenue@37 261 for i, tile in ipairs(block.rewardTile) do
Nenue@37 262 --print(rewardSize)
Nenue@37 263 tile:SetSize(rewardSize, rewardSize)
Nenue@37 264 tile:ClearAllPoints()
Nenue@37 265 tile:SetPoint(anchor, target, point, x, y)
Nenue@37 266 block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
Nenue@37 267 anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
Nenue@34 268 end
Nenue@34 269
Nenue@35 270
Nenue@35 271 local titleHeight = floor(block.title:GetHeight()+.5)
Nenue@35 272 local titlebgHeight = titleHeight + titleSpacing*2
Nenue@35 273 block.titlebg:SetHeight(titlebgHeight)
Nenue@35 274
Nenue@35 275 local statusHeight = floor(block.status:GetHeight()+.5)
Nenue@35 276 local statusbgHeight = statusHeight + textSpacing*2
Nenue@35 277 local attachmentHeight =floor(block.attachmentHeight + .5)
Nenue@35 278
Nenue@35 279 print(' |cFF0088FFanchor to', self.currentAnchor:GetName())
Nenue@35 280 print(' |cFF00FF00attachment:|r', attachmentHeight, '|cFF00FF00title:|r', titlebgHeight, '('.. titleHeight..')')
Nenue@35 281 if attachmentHeight > 0 then
Nenue@35 282 attachmentHeight = attachmentHeight + textSpacing
Nenue@35 283 end
Nenue@35 284
Nenue@35 285 block.height = titlebgHeight + attachmentHeight
Nenue@35 286 block:SetHeight(block.height)
Nenue@35 287
Nenue@34 288 if block.debug then
Nenue@34 289 local func = (B.Conf.GuidesMode == true) and 'Show' or 'Hide'
Nenue@34 290 for _, region in ipairs(block.debug) do
Nenue@34 291 region[func]()
Nenue@34 292 end
Nenue@34 293 end
Nenue@34 294
Nenue@35 295 --- Handler vars
Nenue@35 296 if blockIndex == 1 then
Nenue@35 297 tracker.previousHeight = tracker.height
Nenue@35 298 tracker.height = headerHeight
Nenue@35 299 blockPosition = -headerHeight
Nenue@35 300 tprint(' |cFF88FF00AddBlock:|r new layout: headerHeight =', headerHeight, 'previousHeight =', tracker.previousHeight)
Nenue@35 301 else
Nenue@35 302 blockPosition = blockPosition
Nenue@35 303 tprint(' |cFF8888FFAddBlock:|r advancing: height =', tracker.height)
Nenue@35 304 end
Nenue@30 305 self.currentBlock = blockIndex
Nenue@29 306 self.currentAnchor = block
Nenue@35 307
Nenue@35 308 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition)
Nenue@35 309 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
Nenue@38 310 block:Show()
Nenue@35 311 self.numBlocks = self.numBlocks + 1
Nenue@29 312 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
Nenue@29 313 tracker.height = tracker.height + block.height
Nenue@35 314 blockPosition = blockPosition - block.height
Nenue@38 315
Nenue@38 316
Nenue@38 317
Nenue@38 318 if Devian and Devian.InWorkspace() then
Nenue@38 319 block.DebugTab:SetParent(UIParent)
Nenue@38 320 block.DebugTab:SetPoint('TOPRIGHT', block, 'TOPLEFT', 0, 0)
Nenue@38 321 block.DebugTab.status:SetText(tostring(block.schema) .. ' @|cFF00FF00' .. tostring(block.posIndex) .. '|r #|cFFFFFF00'.. tostring(info.logIndex or info.id) .. '|r'..
Nenue@38 322 ' H|cFFFFFF00' .. tostring(block.height) .. ' L|cFF00FFFF' .. tostring(block.numLines) ..'|r')
Nenue@38 323 block.DebugTab:Show()
Nenue@38 324 end
Nenue@28 325 end
Nenue@28 326
Nenue@28 327 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
Nenue@30 328 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative)
Nenue@28 329 local print = bprint
Nenue@30 330
Nenue@30 331 for order, tagName in ipairs(block.info.tagInfo) do
Nenue@30 332 local tag = block[tagName]
Nenue@30 333 if block.tagCoords[tagName] and tag then
Nenue@30 334 tag:SetTexCoord(unpack(block.tagCoords[tagName]))
Nenue@30 335 tag:Show()
Nenue@30 336 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
Nenue@30 337 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
Nenue@30 338 else
Nenue@30 339 block[tagName]:Hide()
Nenue@30 340 end
Nenue@28 341 end
Nenue@30 342
Nenue@28 343 return tagPoint, tagAnchor, tagRelative
Nenue@28 344 end
Nenue@28 345
Nenue@38 346 Default.AddReward = function(handler, block, rewardInfo, tagPoint, tagAnchor, tagRelative)
Nenue@38 347 local print = bprint
Nenue@38 348
Nenue@38 349 for order, reward in ipairs(rewardInfo) do
Nenue@38 350
Nenue@38 351 end
Nenue@38 352 end
Nenue@38 353
Nenue@28 354 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
Nenue@30 355 Default.AddLine = function(handler, block, text, attachment, template)
Nenue@28 356 local print = lprint
Nenue@30 357 local lineIndex = block.currentLine + 1
Nenue@34 358 local line = handler:GetLine(block, lineIndex)
Nenue@36 359
Nenue@31 360 line.index = lineIndex
Nenue@38 361 template = template or 'default'
Nenue@38 362 if template and lineSchema ~= template then
Nenue@35 363 print(' |cFF00FF00change schema', template)
Nenue@35 364 T.UpdateSchema('line', template)
Nenue@34 365 end
Nenue@38 366 line.status:SetSpacing(textSpacing)
Nenue@38 367 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
Nenue@38 368 line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0)
Nenue@38 369 line.status:SetTextColor(unpack(textColor))
Nenue@34 370 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
Nenue@37 371 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
Nenue@37 372 line:SetPoint('LEFT', block, 'LEFT')
Nenue@37 373 line:SetPoint('RIGHT', block, 'RIGHT')
Nenue@28 374 line:Show()
Nenue@38 375 line:SetScript('OnMouseUp', function(self, button)
Nenue@38 376 handler.OnMouseUp(block, button)
Nenue@38 377 end)
Nenue@28 378
Nenue@34 379
Nenue@35 380 tprint(' |cFF0088FFAddLine|r (|cFF00FFFF'..tostring(line.schema)..'|r):', line:GetName())
Nenue@38 381 --[[
Nenue@38 382 for i = 1, line:GetNumPoints() do
Nenue@38 383 tprint(' - ', line:GetPoint(i))
Nenue@38 384 end
Nenue@38 385 tprint(' - ', line:GetSize())
Nenue@38 386 tprint(' - ', line:GetParent(), line:GetParent():IsVisible())
Nenue@38 387 tprint(' - ', line:IsVisible())
Nenue@38 388 --]]
Nenue@38 389
Nenue@38 390
Nenue@34 391
Nenue@34 392
Nenue@34 393 -- fill in the text, then derive pixel-rounded height
Nenue@30 394 line.status:SetText(text)
Nenue@34 395 line.height = floor(line.status:GetStringHeight()+.5)
Nenue@30 396
Nenue@30 397 -- For progressbar and timer lines, status text may be used as the title heading
Nenue@30 398 if attachment then
Nenue@38 399 attachment:SetPoint('TOP', line, 'TOP')
Nenue@38 400 attachment:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
Nenue@38 401 attachment:SetPoint('RIGHT', line, 'RIGHT')
Nenue@35 402 print(' |cFFFF0088doing things with a widget', attachment:GetSize())
Nenue@34 403 line.height = attachment:GetHeight()
Nenue@34 404 if text then
Nenue@34 405 line.height = max(line.height, line.status:GetStringHeight())
Nenue@31 406 end
Nenue@34 407 if attachment.status:GetText() then
Nenue@34 408 line.height = max(line.height, attachment.status:GetStringHeight())
Nenue@34 409 end
Nenue@30 410 attachment:Show()
Nenue@30 411 end
Nenue@30 412
Nenue@34 413 line:SetHeight(line.height)
Nenue@34 414 block.attachmentHeight = block.attachmentHeight + line.height + textSpacing
Nenue@35 415
Nenue@35 416 local debug_points = ''
Nenue@35 417 for i = 1, line:GetNumPoints() do
Nenue@35 418 local point, parent, anchor = line:GetPoint(i)
Nenue@35 419 debug_points = debug_points .. tostring(parent:GetName()) .. ', ' .. anchor .. ' '
Nenue@35 420 end
Nenue@35 421
Nenue@35 422 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
Nenue@35 423 "|cFF0088FFpoint:|r", debug_points, "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
Nenue@30 424 block.currentLine = lineIndex
Nenue@36 425 block.endPoint = line -- edge used for the next block
Nenue@31 426
Nenue@31 427 return lineIndex
Nenue@28 428 end
Nenue@28 429
Nenue@28 430 --- Creates or retrieves a complete line data object
Nenue@30 431 Default.GetLine = function(handler, block, lineIndex)
Nenue@28 432 local print = lprint
Nenue@28 433 local blockIndex = block.index
Nenue@30 434 local lines = block.lines
Nenue@30 435 if not lineIndex then
Nenue@30 436 lineIndex = block.currentLine + 1
Nenue@34 437 print(' |cFFFFFF00generating a frame')
Nenue@28 438 end
Nenue@30 439
Nenue@30 440 block.numLines = max(block.numLines, lineIndex)
Nenue@30 441
Nenue@28 442 if not lines[lineIndex] then
Nenue@28 443 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex)
Nenue@28 444 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective')
Nenue@28 445 local line = lines[lineIndex]
Nenue@28 446 line.index = lineIndex
Nenue@28 447 line.height = 0
Nenue@37 448 line.schema = ''
Nenue@28 449 B.SetConfigLayers(line)
Nenue@28 450
Nenue@28 451 if debug then
Nenue@28 452 for _, region in ipairs(lines[lineIndex].debug) do
Nenue@28 453 region:Show()
Nenue@28 454 end
Nenue@28 455 end
Nenue@28 456
Nenue@28 457 end
Nenue@28 458 return lines[lineIndex]
Nenue@28 459 end
Nenue@28 460
Nenue@29 461
Nenue@29 462
Nenue@28 463 --- Creates or retrieves a complete block frame object
Nenue@34 464 --- todo: make it use data index to avoid re-coloring every block
Nenue@37 465 Default.GetBlock = function(handler, index)
Nenue@28 466 local print = bprint
Nenue@37 467 print('|cFF0088FFgetting a block for index', index ..',', #handler.usedBlocks,'used', #handler.freeBlocks, 'free')
Nenue@37 468 local block = handler.InfoBlock[index]
Nenue@35 469 local used = handler.usedBlocks
Nenue@28 470
Nenue@34 471 if not block then
Nenue@28 472 if #handler.freeBlocks >= 1 then
Nenue@34 473 block = tremove(handler.freeBlocks)
Nenue@35 474 tinsert(handler.usedBlocks, block)
Nenue@35 475 block.posIndex = #handler.usedBlocks
Nenue@35 476 print(' |cFF00FF00 assigning from free heap', block:GetName())
Nenue@28 477 else
Nenue@34 478
Nenue@35 479 local blockIndex = (#handler.usedBlocks + #handler.freeBlocks) + 1
Nenue@30 480 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, handler.frame, 'VeneerTrackerBlock')
Nenue@35 481 --block:SetParent()
Nenue@37 482 block.schema = ''
Nenue@30 483 block.lines = {}
Nenue@30 484 block.numLines = 0
Nenue@30 485 block.currentLine = 0
Nenue@34 486 block.attachmentHeight = 0
Nenue@35 487 block.offset = 0
Nenue@34 488 B.SetConfigLayers(block)
Nenue@28 489 --- methods for event handlers
Nenue@28 490
Nenue@28 491 block.Select = handler.Select
Nenue@28 492 block.Open = handler.Open
Nenue@28 493 block.Remove = handler.Remove
Nenue@28 494 block.Link = handler.Link
Nenue@28 495 block.clickZone:SetScript('OnMouseUp', function(self, ...) handler.OnMouseUp(block, ...) end)
Nenue@28 496 block.clickZone:SetScript('OnMouseDown', function(self, ...) handler.OnMouseDown(block, ...) end)
Nenue@28 497 block:ClearAllPoints()
Nenue@34 498 block.index = blockIndex
Nenue@35 499 print(' |cFF00FFBBcreating new|r', block:GetName())
Nenue@28 500 end
Nenue@37 501 handler.InfoBlock[index] = block
Nenue@34 502 tinsert(handler.usedBlocks, block)
Nenue@35 503 block.posIndex = #handler.usedBlocks
Nenue@34 504 else
Nenue@34 505 print(' |cFFFFFF00use existing block|r', block:GetName())
Nenue@35 506 local found = false
Nenue@35 507 for i, entry in ipairs(used) do
Nenue@35 508 if entry == block then
Nenue@35 509 found = true
Nenue@35 510 break
Nenue@35 511 end
Nenue@35 512 end
Nenue@35 513 if not found then
Nenue@35 514 tinsert(used, block)
Nenue@35 515 block.posIndex = #used
Nenue@35 516 end
Nenue@28 517 end
Nenue@34 518 return block
Nenue@28 519 end
Nenue@28 520
Nenue@34 521
Nenue@30 522
Nenue@28 523 ----------
Nenue@28 524 --- Top level methods
Nenue@28 525
Nenue@28 526
Nenue@35 527 T.UpdateBlockAction = function (block, itemButton)
Nenue@35 528 local print = bprint
Nenue@28 529 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
Nenue@28 530 if itemButton.questID ~= block.info.questID then
Nenue@28 531 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
Nenue@28 532 -- something happened between this and last frame, go back and set new probes
Nenue@35 533 return T.UpdateActionButtons()
Nenue@28 534 end
Nenue@28 535
Nenue@28 536 local previousItem = itemButton.previousItem
Nenue@28 537 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
Nenue@28 538 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
Nenue@28 539 local point, anchor, relative
Nenue@28 540
Nenue@28 541 if block:GetBottom() < lower_bound then
Nenue@28 542 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@28 543 if previousItem then
Nenue@28 544 print('adjusting', previousItem:GetName())
Nenue@28 545 previousItem:ClearAllPoints()
Nenue@28 546 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
Nenue@28 547 end
Nenue@28 548 itemButton:ClearAllPoints()
Nenue@28 549 itemButton.x = Wrapper:GetLeft() -4
Nenue@28 550 itemButton.y = Wrapper:GetBottom()
Nenue@28 551 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 552 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
Nenue@28 553
Nenue@28 554 elseif block:GetTop() > upper_bound then
Nenue@28 555 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
Nenue@28 556 itemButton:ClearAllPoints()
Nenue@28 557 if previousItem then
Nenue@28 558 print('latch onto another piece')
Nenue@28 559 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
Nenue@28 560 itemButton.x = 0
Nenue@28 561 itemButton.y = -itemButtonSpacing
Nenue@28 562 else
Nenue@28 563 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
Nenue@28 564 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 565 itemButton.x = Scroller:GetLeft() -4
Nenue@28 566 itemButton.y = Scroller:GetTop()
Nenue@28 567 end
Nenue@28 568 itemButton:Show()
Nenue@28 569 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
Nenue@28 570 else
Nenue@28 571 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@28 572 itemButton:ClearAllPoints()
Nenue@28 573 itemButton.x = block:GetLeft() - itemButtonSpacing
Nenue@28 574 itemButton.y = block:GetTop()
Nenue@28 575 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 576 end
Nenue@28 577
Nenue@28 578 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
Nenue@28 579 itemButton:Show()
Nenue@28 580 end
Nenue@28 581
Nenue@35 582 T.UpdateItemButtonCooldown = function(button)
Nenue@28 583
Nenue@28 584 end
Nenue@28 585
Nenue@35 586 function T:FinishWrapper ()
Nenue@35 587 if wrapperHeight > Wrapper.previousHeight then
Nenue@35 588 Wrapper:SetHeight(wrapperHeight)
Nenue@35 589 Scroller:SetHeight(wrapperHeight*3)
Nenue@35 590 Scroll:SetHeight(wrapperHeight)
Nenue@35 591 Wrapper.previousHeight = wrapperHeight
Nenue@35 592 Wrapper.destinationHeight = wrapperHeight
Nenue@35 593 end
Nenue@35 594 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
Nenue@35 595 print('|cFF00FF00### end of wrapper layout', Wrapper:GetSize())
Nenue@35 596 print(' |cFF00FF00Scroller:', Scroller:GetSize())
Nenue@35 597 print(' |cFF00FF00Scroll:', Scroll:GetSize())
Nenue@35 598 for i = 1, Wrapper:GetNumPoints() do
Nenue@35 599 print('|cFF00FF00 ', Wrapper:GetPoint(i))
Nenue@35 600 end
Nenue@35 601 for i = 1, Scroller:GetNumPoints() do
Nenue@35 602 print('|cFF00FF00 ', Scroller:GetPoint(i))
Nenue@35 603 end
Nenue@35 604 for i = 1, Scroll:GetNumPoints() do
Nenue@35 605 print('|cFF00FF00 ', Scroll:GetPoint(i))
Nenue@35 606 end
Nenue@34 607
Nenue@38 608 if Devian and Devian.InWorkspace() then
Nenue@38 609 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
Nenue@38 610 end
Nenue@38 611
Nenue@35 612 Wrapper:Show()
Nenue@35 613 Scroller:Show()
Nenue@35 614 Scroll:Show()
Nenue@28 615 end
Nenue@28 616