annotate ObjectiveTracker/Layout.lua @ 45:dd1ae565f559

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