annotate ObjectiveTracker/TrackerFrame.lua @ 40:03ed70f846de

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