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