annotate 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
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@43 243 -- if animating, skip this segment
Nenue@43 244 if not block.isAnimating then
Nenue@43 245 print('blockschema', blockSchema, block.schema)
Nenue@43 246 if blockSchema ~= block.schema then
Nenue@43 247 T.UpdateSchema('block', block.schema)
Nenue@43 248 print(' ### activating block schema:|cFF0088FF', block.schema)
Nenue@43 249 end
Nenue@35 250
Nenue@43 251 block:SetWidth(T.Conf.Wrapper.Width)
Nenue@43 252 block.title:SetSpacing(titleSpacing)
Nenue@43 253 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
Nenue@43 254 block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
Nenue@43 255 block.title:SetTextColor(unpack(titleColor))
Nenue@43 256 block.titlebg:SetTexture(1,1,1,1)
Nenue@43 257 block.titlebg:SetGradientAlpha(unpack(titlebg))
Nenue@43 258 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
Nenue@43 259 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
Nenue@43 260 block.status:SetSpacing(textSpacing)
Nenue@43 261 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
Nenue@43 262 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
Nenue@43 263 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
Nenue@43 264 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
Nenue@43 265 block.statusbg:SetTexture(1,1,1,1)
Nenue@43 266 block.statusbg:SetGradientAlpha(unpack(textbg))
Nenue@43 267 block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
Nenue@43 268 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
Nenue@43 269 block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
Nenue@43 270
Nenue@43 271 local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
Nenue@43 272 for i, tile in ipairs(block.rewardTile) do
Nenue@43 273 --print(rewardSize)
Nenue@43 274 tile:SetSize(rewardSize, rewardSize)
Nenue@43 275 tile:ClearAllPoints()
Nenue@43 276 tile:SetPoint(anchor, target, point, x, y)
Nenue@43 277 block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
Nenue@43 278 anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
Nenue@43 279 end
Nenue@43 280
Nenue@43 281
Nenue@43 282 local titleHeight = floor(block.title:GetHeight()+.5)
Nenue@43 283 local titlebgHeight = titleHeight + titleSpacing*2
Nenue@43 284 block.titlebg:SetHeight(titlebgHeight)
Nenue@43 285
Nenue@43 286 local statusHeight = floor(block.status:GetHeight()+.5)
Nenue@43 287 local statusbgHeight = statusHeight + textSpacing*2
Nenue@43 288 local attachmentHeight =floor(block.attachmentHeight + .5)
Nenue@43 289
Nenue@43 290 self.print('AddBlock', 'anchor to|cFF0088FF', self.currentAnchor:GetName())
Nenue@43 291 self.print('AddBlock', 'attachment:|cFF00FF00', attachmentHeight, '|rtitle:|cFF00FF00', titlebgHeight, '|r('.. titleHeight..')')
Nenue@43 292 if attachmentHeight > 0 then
Nenue@43 293 attachmentHeight = attachmentHeight + textSpacing
Nenue@43 294 end
Nenue@43 295
Nenue@43 296 block.height = titlebgHeight + attachmentHeight
Nenue@43 297 block:SetHeight(block.height)
Nenue@37 298 end
Nenue@34 299
Nenue@34 300 if block.debug then
Nenue@34 301 local func = (B.Conf.GuidesMode == true) and 'Show' or 'Hide'
Nenue@34 302 for _, region in ipairs(block.debug) do
Nenue@34 303 region[func]()
Nenue@34 304 end
Nenue@34 305 end
Nenue@34 306
Nenue@35 307 --- Handler vars
Nenue@35 308 if blockIndex == 1 then
Nenue@35 309 tracker.previousHeight = tracker.height
Nenue@35 310 tracker.height = headerHeight
Nenue@35 311 blockPosition = -headerHeight
Nenue@40 312 self.print('AddBlock', 'new layout: headerHeight:|cFF00FF00', headerHeight, '|rpreviousHeight:|cFF00FF00', tracker.previousHeight)
Nenue@35 313 else
Nenue@35 314 blockPosition = blockPosition
Nenue@40 315 self.print('AddBlock', 'advancing: height:|cFF8888FF', tracker.height)
Nenue@35 316 end
Nenue@30 317 self.currentBlock = blockIndex
Nenue@29 318 self.currentAnchor = block
Nenue@35 319
Nenue@35 320 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition)
Nenue@35 321 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
Nenue@35 322 self.numBlocks = self.numBlocks + 1
Nenue@29 323 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
Nenue@29 324 tracker.height = tracker.height + block.height
Nenue@35 325 blockPosition = blockPosition - block.height
Nenue@38 326
Nenue@40 327 block:Show()
Nenue@38 328
Nenue@38 329
Nenue@38 330 if Devian and Devian.InWorkspace() then
Nenue@38 331 block.DebugTab:SetParent(UIParent)
Nenue@38 332 block.DebugTab:SetPoint('TOPRIGHT', block, 'TOPLEFT', 0, 0)
Nenue@38 333 block.DebugTab.status:SetText(tostring(block.schema) .. ' @|cFF00FF00' .. tostring(block.posIndex) .. '|r #|cFFFFFF00'.. tostring(info.logIndex or info.id) .. '|r'..
Nenue@38 334 ' H|cFFFFFF00' .. tostring(block.height) .. ' L|cFF00FFFF' .. tostring(block.numLines) ..'|r')
Nenue@38 335 block.DebugTab:Show()
Nenue@38 336 end
Nenue@28 337 end
Nenue@28 338
Nenue@28 339 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
Nenue@30 340 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative)
Nenue@28 341 local print = bprint
Nenue@30 342
Nenue@30 343 for order, tagName in ipairs(block.info.tagInfo) do
Nenue@30 344 local tag = block[tagName]
Nenue@30 345 if block.tagCoords[tagName] and tag then
Nenue@30 346 tag:SetTexCoord(unpack(block.tagCoords[tagName]))
Nenue@30 347 tag:Show()
Nenue@30 348 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
Nenue@30 349 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
Nenue@30 350 else
Nenue@30 351 block[tagName]:Hide()
Nenue@30 352 end
Nenue@28 353 end
Nenue@30 354
Nenue@28 355 return tagPoint, tagAnchor, tagRelative
Nenue@28 356 end
Nenue@28 357
Nenue@38 358
Nenue@28 359 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
Nenue@30 360 Default.AddLine = function(handler, block, text, attachment, template)
Nenue@28 361 local print = lprint
Nenue@30 362 local lineIndex = block.currentLine + 1
Nenue@34 363 local line = handler:GetLine(block, lineIndex)
Nenue@36 364
Nenue@31 365 line.index = lineIndex
Nenue@38 366 template = template or 'default'
Nenue@38 367 if template and lineSchema ~= template then
Nenue@35 368 print(' |cFF00FF00change schema', template)
Nenue@35 369 T.UpdateSchema('line', template)
Nenue@34 370 end
Nenue@38 371 line.status:SetSpacing(textSpacing)
Nenue@38 372 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
Nenue@38 373 line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0)
Nenue@38 374 line.status:SetTextColor(unpack(textColor))
Nenue@34 375 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
Nenue@37 376 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
Nenue@37 377 line:SetPoint('LEFT', block, 'LEFT')
Nenue@37 378 line:SetPoint('RIGHT', block, 'RIGHT')
Nenue@28 379 line:Show()
Nenue@38 380 line:SetScript('OnMouseUp', function(self, button)
Nenue@38 381 handler.OnMouseUp(block, button)
Nenue@38 382 end)
Nenue@28 383
Nenue@34 384
Nenue@40 385 handler.print('AddLine', '|cFF00FFFF'..tostring(line.schema)..'|r', line:GetName())
Nenue@38 386 --[[
Nenue@38 387 for i = 1, line:GetNumPoints() do
Nenue@38 388 tprint(' - ', line:GetPoint(i))
Nenue@38 389 end
Nenue@38 390 tprint(' - ', line:GetSize())
Nenue@38 391 tprint(' - ', line:GetParent(), line:GetParent():IsVisible())
Nenue@38 392 tprint(' - ', line:IsVisible())
Nenue@38 393 --]]
Nenue@38 394
Nenue@38 395
Nenue@34 396
Nenue@34 397
Nenue@34 398 -- fill in the text, then derive pixel-rounded height
Nenue@30 399 line.status:SetText(text)
Nenue@34 400 line.height = floor(line.status:GetStringHeight()+.5)
Nenue@30 401
Nenue@30 402 -- For progressbar and timer lines, status text may be used as the title heading
Nenue@30 403 if attachment then
Nenue@38 404 attachment:SetPoint('TOP', line, 'TOP')
Nenue@38 405 attachment:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
Nenue@38 406 attachment:SetPoint('RIGHT', line, 'RIGHT')
Nenue@35 407 print(' |cFFFF0088doing things with a widget', attachment:GetSize())
Nenue@34 408 line.height = attachment:GetHeight()
Nenue@34 409 if text then
Nenue@34 410 line.height = max(line.height, line.status:GetStringHeight())
Nenue@31 411 end
Nenue@34 412 if attachment.status:GetText() then
Nenue@34 413 line.height = max(line.height, attachment.status:GetStringHeight())
Nenue@34 414 end
Nenue@30 415 attachment:Show()
Nenue@30 416 end
Nenue@30 417
Nenue@34 418 line:SetHeight(line.height)
Nenue@34 419 block.attachmentHeight = block.attachmentHeight + line.height + textSpacing
Nenue@35 420
Nenue@35 421 local debug_points = ''
Nenue@35 422 for i = 1, line:GetNumPoints() do
Nenue@35 423 local point, parent, anchor = line:GetPoint(i)
Nenue@35 424 debug_points = debug_points .. tostring(parent:GetName()) .. ', ' .. anchor .. ' '
Nenue@35 425 end
Nenue@35 426
Nenue@35 427 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
Nenue@35 428 "|cFF0088FFpoint:|r", debug_points, "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
Nenue@30 429 block.currentLine = lineIndex
Nenue@36 430 block.endPoint = line -- edge used for the next block
Nenue@31 431
Nenue@31 432 return lineIndex
Nenue@28 433 end
Nenue@28 434
Nenue@34 435
Nenue@30 436
Nenue@28 437 ----------
Nenue@28 438 --- Top level methods
Nenue@28 439
Nenue@28 440
Nenue@40 441 T.UpdateItemButtonAnchor = function (block, itemButton)
Nenue@35 442 local print = bprint
Nenue@28 443 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
Nenue@28 444 if itemButton.questID ~= block.info.questID then
Nenue@28 445 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
Nenue@28 446 -- something happened between this and last frame, go back and set new probes
Nenue@35 447 return T.UpdateActionButtons()
Nenue@28 448 end
Nenue@28 449
Nenue@28 450 local previousItem = itemButton.previousItem
Nenue@28 451 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
Nenue@28 452 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
Nenue@28 453 local point, anchor, relative
Nenue@28 454
Nenue@28 455 if block:GetBottom() < lower_bound then
Nenue@28 456 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@28 457 if previousItem then
Nenue@28 458 print('adjusting', previousItem:GetName())
Nenue@28 459 previousItem:ClearAllPoints()
Nenue@28 460 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
Nenue@28 461 end
Nenue@28 462 itemButton:ClearAllPoints()
Nenue@28 463 itemButton.x = Wrapper:GetLeft() -4
Nenue@28 464 itemButton.y = Wrapper:GetBottom()
Nenue@28 465 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 466 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
Nenue@28 467
Nenue@28 468 elseif block:GetTop() > upper_bound then
Nenue@28 469 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
Nenue@28 470 itemButton:ClearAllPoints()
Nenue@28 471 if previousItem then
Nenue@28 472 print('latch onto another piece')
Nenue@28 473 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
Nenue@28 474 itemButton.x = 0
Nenue@28 475 itemButton.y = -itemButtonSpacing
Nenue@28 476 else
Nenue@28 477 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
Nenue@28 478 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 479 itemButton.x = Scroller:GetLeft() -4
Nenue@28 480 itemButton.y = Scroller:GetTop()
Nenue@28 481 end
Nenue@28 482 itemButton:Show()
Nenue@28 483 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
Nenue@28 484 else
Nenue@28 485 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@28 486 itemButton:ClearAllPoints()
Nenue@28 487 itemButton.x = block:GetLeft() - itemButtonSpacing
Nenue@28 488 itemButton.y = block:GetTop()
Nenue@28 489 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 490 end
Nenue@28 491
Nenue@28 492 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
Nenue@28 493 itemButton:Show()
Nenue@28 494 end
Nenue@28 495
Nenue@35 496 T.UpdateItemButtonCooldown = function(button)
Nenue@28 497
Nenue@28 498 end
Nenue@28 499
Nenue@35 500 function T:FinishWrapper ()
Nenue@35 501 if wrapperHeight > Wrapper.previousHeight then
Nenue@35 502 Wrapper:SetHeight(wrapperHeight)
Nenue@35 503 Scroller:SetHeight(wrapperHeight*3)
Nenue@35 504 Scroll:SetHeight(wrapperHeight)
Nenue@35 505 Wrapper.previousHeight = wrapperHeight
Nenue@35 506 Wrapper.destinationHeight = wrapperHeight
Nenue@35 507 end
Nenue@35 508 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
Nenue@35 509 print('|cFF00FF00### end of wrapper layout', Wrapper:GetSize())
Nenue@35 510 print(' |cFF00FF00Scroller:', Scroller:GetSize())
Nenue@35 511 print(' |cFF00FF00Scroll:', Scroll:GetSize())
Nenue@35 512 for i = 1, Wrapper:GetNumPoints() do
Nenue@35 513 print('|cFF00FF00 ', Wrapper:GetPoint(i))
Nenue@35 514 end
Nenue@35 515 for i = 1, Scroller:GetNumPoints() do
Nenue@35 516 print('|cFF00FF00 ', Scroller:GetPoint(i))
Nenue@35 517 end
Nenue@35 518 for i = 1, Scroll:GetNumPoints() do
Nenue@35 519 print('|cFF00FF00 ', Scroll:GetPoint(i))
Nenue@35 520 end
Nenue@34 521
Nenue@38 522 if Devian and Devian.InWorkspace() then
Nenue@38 523 Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
Nenue@43 524 Wrapper.AnimState:Show()
Nenue@38 525 end
Nenue@38 526
Nenue@35 527 Wrapper:Show()
Nenue@35 528 Scroller:Show()
Nenue@35 529 Scroll:Show()
Nenue@28 530 end
Nenue@28 531
Nenue@39 532
Nenue@39 533 -----------------------------------------
Nenue@39 534 -- Criteria frames
Nenue@39 535
Nenue@39 536 --[[
Nenue@39 537 text = description,
Nenue@39 538 type = type,
Nenue@39 539 finished = completed,
Nenue@39 540 quantity = quantity,
Nenue@39 541 requiredQuantity = requiredQuantity,
Nenue@39 542 characterName = characterName,
Nenue@39 543 flags = flags,
Nenue@39 544 assetID = assetID,
Nenue@39 545 quantityString = quantityString,
Nenue@39 546 criteriaID = criteriaID,
Nenue@39 547 ]]
Nenue@39 548 T.WidgetRegistry = {}
Nenue@39 549 local wr = T.WidgetRegistry
Nenue@39 550
Nenue@39 551 --- WidgetTemplate 'OnShow'
Nenue@39 552 local wrapperWidth, textIndent
Nenue@39 553 T.InitializeWidget = setmetatable({}, {
Nenue@39 554 __call = function(t, frame, isNew, ...)
Nenue@39 555 -- todo: config pull
Nenue@39 556 if not wrapperWidth then
Nenue@39 557 wrapperWidth = T.Conf.Wrapper.Width
Nenue@39 558 textIndent = T.Conf.Wrapper.TextIndent
Nenue@39 559 end
Nenue@39 560
Nenue@39 561 tprint('Initialize', frame:GetName(), isNew, ...)
Nenue@39 562 frame:SetWidth(wrapperWidth - textIndent * 2)
Nenue@39 563 frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType])
Nenue@39 564 frame:RegisterEvent('QUEST_LOG_UPDATE')
Nenue@39 565 frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE')
Nenue@39 566 frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED')
Nenue@39 567 frame:RegisterEvent('CRITERIA_UPDATE')
Nenue@39 568 frame:RegisterEvent('CRITERIA_COMPLETE')
Nenue@39 569 frame:RegisterEvent('CRITERIA_EARNED')
Nenue@39 570 t[frame.widgetType](frame, isNew)
Nenue@39 571 T.UpdateWidget[frame.widgetType](frame, isNew)
Nenue@39 572 end,
Nenue@39 573 })
Nenue@39 574
Nenue@39 575 --- WidgetTemplate 'OnEvent'
Nenue@39 576 T.UpdateWidget = setmetatable({}, {
Nenue@39 577 __call = function(t, frame, isNew, ...)
Nenue@39 578 tprint('Update', frame:GetName(), isNew, ...)
Nenue@39 579 if not frame.widgetType then
Nenue@39 580 return
Nenue@39 581 end
Nenue@39 582
Nenue@39 583 return t[frame.widgetType](frame, isNew)
Nenue@39 584 end
Nenue@39 585 })
Nenue@39 586
Nenue@39 587
Nenue@39 588 local progressHeight = 17
Nenue@39 589 local progressBorder = 1
Nenue@39 590 local progressFont = _G.VeneerCriteriaFontNormal
Nenue@39 591
Nenue@39 592 local lprint = B.print('Line')
Nenue@39 593 T.InitializeWidget.StatusBar = function(self, isNew)
Nenue@39 594 local print = lprint
Nenue@39 595 local c = T.Conf.Wrapper
Nenue@39 596
Nenue@39 597 tprint(self:GetName(), isNew)
Nenue@39 598 if isNew then
Nenue@39 599 self:SetMinMaxValues(0, self.maxValue)
Nenue@39 600
Nenue@39 601 self:SetHeight(widgetHeight)
Nenue@39 602 self.height = widgetHeight
Nenue@39 603
Nenue@39 604 self.status:SetFont(widgetTextFont, widgetTextSize, widgetTextOutline)
Nenue@39 605 self.status:SetTextColor(unpack(widgetTextColor))
Nenue@39 606 end
Nenue@39 607 self:SetValue(self.value)
Nenue@39 608
Nenue@39 609 self.status:SetText(self.objective.quantityString)
Nenue@39 610 end
Nenue@39 611
Nenue@39 612 T.UpdateWidget.StatusBar = function (self)
Nenue@39 613 local value, maxValue = self.value, self.maxValue
Nenue@39 614 print('update vals:')
Nenue@39 615 for k,v in pairs(self) do
Nenue@39 616 print(k, v)
Nenue@39 617 end
Nenue@39 618 self.width = self.width or self:GetWidth()
Nenue@39 619 self:SetValue(self.value)
Nenue@39 620 local format = self.format or '%d/%d'
Nenue@39 621 self.status:SetFormattedText(format, value, maxValue)
Nenue@39 622 local progress = (value / maxValue)
Nenue@39 623 if progress > 0 then
Nenue@39 624 print('color:', 1-progress*2 , progress*2 - 1,0,1)
Nenue@39 625 print('width:', (self.width -progressBorder * 2) * progress)
Nenue@39 626 self:SetStatusBarColor(1-progress*2 , progress*2,0,1)
Nenue@39 627 end
Nenue@39 628 end
Nenue@39 629
Nenue@39 630
Nenue@39 631 T.InitializeWidget.Hidden = function (self)
Nenue@39 632 self.height = 0
Nenue@39 633 end
Nenue@39 634 T.UpdateWidget.Hidden = function (self)
Nenue@39 635 self.height= 0
Nenue@39 636 end
Nenue@39 637
Nenue@39 638
Nenue@39 639 --- Queue any active item buttons for update for that frame
Nenue@39 640 local iprint = B.print('ItemButton')
Nenue@39 641 local Quest = T.Quest
Nenue@39 642 local IsQuestWatched, InCombatLockdown = IsQuestWatched, InCombatLockdown
Nenue@39 643 T.UpdateActionButtons = function(updateReason)
Nenue@39 644 local print = iprint
Nenue@39 645 Scroller.snap_upper = 0
Nenue@39 646 Scroller.snap_lower = 0
Nenue@39 647 local print = B.print('ItemButton')
Nenue@39 648 if updateReason then
Nenue@39 649 print = B.print('IB_'..updateReason)
Nenue@39 650 end
Nenue@39 651
Nenue@39 652 local previousItem
Nenue@39 653 for questID, itemButton in pairs(Quest.itemButtons) do
Nenue@39 654 local info= T.Quest.Info[questID]
Nenue@39 655
Nenue@39 656 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
Nenue@39 657 local block = T.Quest.QuestBlock[questID]
Nenue@39 658 if block then
Nenue@39 659 -- Dispatch the probe
Nenue@39 660 if IsQuestWatched(info.logIndex) then
Nenue@39 661 itemButton.previousItem = previousItem
Nenue@39 662 print(' |cFFFFFF00probing', block:GetName())
Nenue@39 663 block:SetScript('OnUpdate', function()
Nenue@39 664 if block:GetBottom() and not InCombatLockdown() then
Nenue@39 665 print(' '..block:GetName()..' |cFF00FF00probe hit!')
Nenue@40 666 T.UpdateItemButtonAnchor(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
Nenue@39 667 block:SetScript('OnUpdate', nil)
Nenue@39 668
Nenue@39 669 end
Nenue@39 670 end)
Nenue@39 671 previousItem = itemButton
Nenue@39 672 else
Nenue@39 673 print('hidden block or unwatched quest')
Nenue@39 674 itemButton.previousItem = nil
Nenue@39 675 itemButton:Hide()
Nenue@39 676 end
Nenue@39 677 elseif itemButton:IsVisible() then
Nenue@39 678 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
Nenue@39 679 itemButton.previousItem = nil
Nenue@39 680 itemButton:Hide()
Nenue@39 681 else
Nenue@39 682 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
Nenue@39 683 end
Nenue@39 684 end
Nenue@40 685 end
Nenue@40 686
Nenue@40 687 Default.FadeOutBlock = function (handler, blockIndex)
Nenue@40 688
Nenue@39 689 end