annotate ObjectiveTracker/Frame.lua @ 33:64f2a9bbea79

- implementing structural revisions in bonus objectives - prevent instances of nil arithmetic - decide on where to keep style values - start widgets with dummy values for operability
author Nenue
date Fri, 15 Apr 2016 17:01:06 -0400
parents a3afe6c3771e
children 9856ebc63fa4
rev   line source
Nenue@28 1 --- ${PACKAGE_NAME}
Nenue@28 2 -- @file-author@
Nenue@28 3 -- @project-revision@ @project-hash@
Nenue@28 4 -- @file-revision@ @file-hash@
Nenue@28 5 -- Created: 3/30/2016 12:49 AM
Nenue@28 6 local B = select(2,...).frame
Nenue@30 7 local Module = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@28 8 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
Nenue@28 9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion
Nenue@28 10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
Nenue@28 11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
Nenue@28 12 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
Nenue@30 13 local Default, AutoQuest, Quest, Bonus, Cheevs = Module.DefaultHandler, Module.AutoQuest, Module.Quest, Module.Bonus, Module.Cheevs
Nenue@28 14 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
Nenue@29 15 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow
Nenue@28 16 local print = B.print('Tracker')
Nenue@28 17 local unitLevel = 1
Nenue@28 18 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON
Nenue@28 19 local debug = false
Nenue@28 20
Nenue@28 21 --- Upvalues
Nenue@28 22 local Wrapper = _G.VeneerObjectiveWrapper
Nenue@28 23 local Scroller = Wrapper.scrollArea
Nenue@28 24 local Scroll = _G.VeneerObjectiveScroll
Nenue@30 25 local orderedHandlers = Module.orderedHandlers
Nenue@30 26 local orderedNames = Module.orderedNames
Nenue@28 27
Nenue@28 28 --- Temp values set during updates
Nenue@28 29 local wrapperWidth, wrapperHeight
Nenue@28 30 local scrollWidth, scrollHeight
Nenue@28 31 local previousBlock
Nenue@28 32 local currentBlock
Nenue@28 33 --- todo: source these from config
Nenue@28 34 local itemButtonSize, itemButtonSpacing = 36, 1
Nenue@28 35
Nenue@30 36 local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2
Nenue@28 37 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}
Nenue@28 38 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'
Nenue@28 39
Nenue@31 40 local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2}
Nenue@31 41 local titlebg_daily = {'HORIZONTAL', 0, .7, 1, 0, 0, 1, .7, .2 }
Nenue@31 42 local titlebg_account = {'HORIZONTAL', 0, .45, 1, 0, 0, .45, 1, .2}
Nenue@28 43 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
Nenue@28 44
Nenue@28 45 local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
Nenue@28 46 local textbg_daily = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 }
Nenue@28 47 local textbg_account = {'HORIZONTAL', 0, .45, 1, 0.4, 0, .41, 1, .085 }
Nenue@28 48 local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'
Nenue@28 49
Nenue@28 50
Nenue@28 51 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}
Nenue@28 52 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1
Nenue@28 53 local titleIndent, textIndent,selectionIndent = 2, 5, 50
Nenue@28 54
Nenue@30 55 local lineColors = {
Nenue@31 56 normal = {
Nenue@31 57 text = {.5,.75,1},
Nenue@31 58 },
Nenue@31 59 completed = {
Nenue@33 60 text = {0, 1, 0}
Nenue@31 61 },
Nenue@31 62 failed = {
Nenue@31 63 text = {1,0,0 }
Nenue@31 64 },
Nenue@31 65 autocomplete = {
Nenue@31 66 text = {0,1,0 }
Nenue@31 67 },
Nenue@31 68 object = {
Nenue@31 69 text = {0,1,1}
Nenue@31 70 },
Nenue@31 71 monster = {
Nenue@31 72 text = {1,1,0}
Nenue@31 73 },
Nenue@31 74 item = {
Nenue@31 75 text = {1,.25,.5}
Nenue@31 76 }
Nenue@30 77 }
Nenue@30 78
Nenue@28 79 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
Nenue@28 80 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
Nenue@28 81 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
Nenue@32 82 local rewardSize = 24
Nenue@28 83 local oprint = B.print('Objectives')
Nenue@28 84 local bprint = B.print('Block')
Nenue@28 85 local tprint = B.print('Tracker')
Nenue@28 86 local lprint = B.print('Line')
Nenue@28 87
Nenue@30 88 Default.AddBlock = function(self, block, blockIndex)
Nenue@30 89 local blockIndex = blockIndex or (self.currentBlock + 1)
Nenue@28 90 local print = bprint
Nenue@28 91 local tracker = self.frame
Nenue@28 92 local info = block.info
Nenue@30 93
Nenue@30 94 block.index = blockIndex
Nenue@30 95 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, block.offset)
Nenue@29 96 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
Nenue@30 97 self.currentBlock = blockIndex
Nenue@29 98 self.currentAnchor = block
Nenue@29 99 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
Nenue@29 100 tracker.height = tracker.height + block.height
Nenue@30 101 self.numBlocks = max(self.numBlocks, blockIndex)
Nenue@29 102 self.actualBlocks = self.actualBlocks + 1
Nenue@28 103 end
Nenue@28 104
Nenue@28 105 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
Nenue@30 106 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative)
Nenue@28 107 local print = bprint
Nenue@30 108
Nenue@30 109 for order, tagName in ipairs(block.info.tagInfo) do
Nenue@30 110 local tag = block[tagName]
Nenue@30 111 if block.tagCoords[tagName] and tag then
Nenue@30 112 tag:SetTexCoord(unpack(block.tagCoords[tagName]))
Nenue@30 113 tag:Show()
Nenue@30 114 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
Nenue@30 115 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
Nenue@30 116 else
Nenue@30 117 block[tagName]:Hide()
Nenue@30 118 end
Nenue@28 119 end
Nenue@30 120
Nenue@28 121 return tagPoint, tagAnchor, tagRelative
Nenue@28 122 end
Nenue@28 123
Nenue@28 124 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
Nenue@30 125 Default.AddLine = function(handler, block, text, attachment, template)
Nenue@28 126 local print = lprint
Nenue@30 127 local lineIndex = block.currentLine + 1
Nenue@30 128 local line = handler:GetLine(block)
Nenue@31 129 line.index = lineIndex
Nenue@28 130 line:ClearAllPoints()
Nenue@28 131 line:SetPoint('LEFT', block, 'LEFT', 0, 0)
Nenue@31 132 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, 0)
Nenue@28 133 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0)
Nenue@28 134 line:Show()
Nenue@28 135
Nenue@31 136 print(' |cFF0088FFAddLine >>|r', block, '::', block.endPoint:GetName(),'"'.. text .. '"', attachment, template)
Nenue@30 137 line.status:SetText(text)
Nenue@30 138 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing
Nenue@30 139 line:SetHeight(line.height)
Nenue@31 140
Nenue@31 141 local r, g, b, a = 1, 1, 1, 1
Nenue@31 142 if lineColors[template] then
Nenue@31 143 r, g, b = unpack(lineColors[template].text)
Nenue@31 144 end
Nenue@30 145 line.status:SetTextColor(r, g, b, a)
Nenue@30 146
Nenue@30 147 -- For progressbar and timer lines, status text may be used as the title heading
Nenue@30 148 if attachment then
Nenue@31 149 local widgetOffset = 0
Nenue@33 150 line.height = attachment:GetHeight() + textSpacing
Nenue@31 151 if text and #text >= 1 then
Nenue@31 152 widgetOffset = line.status:GetHeight() + textSpacing
Nenue@33 153 line.height = line.height + floor(line.status:GetStringHeight()+.5) + textSpacing
Nenue@31 154 print(' |cFFFF0088doing things with captioned widget')
Nenue@31 155 else
Nenue@31 156 print(' |cFFFF0088doing things with a widget')
Nenue@31 157 end
Nenue@31 158 attachment:SetPoint('TOP', line, 'TOP', 0, -widgetOffset)
Nenue@30 159 attachment:Show()
Nenue@30 160 end
Nenue@30 161
Nenue@31 162 block.attachmentHeight = block.attachmentHeight + line.height
Nenue@30 163 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
Nenue@28 164 "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
Nenue@30 165 block.currentLine = lineIndex
Nenue@31 166 block.endPoint = line.statusbg -- edge used for the next block
Nenue@31 167
Nenue@31 168 return lineIndex
Nenue@28 169 end
Nenue@28 170
Nenue@28 171 --- Creates or retrieves a complete line data object
Nenue@30 172 Default.GetLine = function(handler, block, lineIndex)
Nenue@28 173 local print = lprint
Nenue@28 174 local blockIndex = block.index
Nenue@30 175 local lines = block.lines
Nenue@30 176 if not lineIndex then
Nenue@30 177 lineIndex = block.currentLine + 1
Nenue@31 178 print(' fetching the "next" line:', lineIndex)
Nenue@30 179 else
Nenue@31 180 print(' fetching explicit offset:', lineIndex)
Nenue@28 181 end
Nenue@30 182
Nenue@30 183 block.numLines = max(block.numLines, lineIndex)
Nenue@31 184 print(' |cFF00FFFFposition|r', block.currentLine, '|cFF00FFFFof|r|cFFFFFF00' , block.numLines)
Nenue@30 185
Nenue@28 186 if not lines[lineIndex] then
Nenue@28 187 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex)
Nenue@28 188 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective')
Nenue@28 189 local line = lines[lineIndex]
Nenue@28 190 line.index = lineIndex
Nenue@28 191 line.height = 0
Nenue@28 192 line.status:SetSpacing(textSpacing)
Nenue@28 193 line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
Nenue@28 194 B.SetConfigLayers(line)
Nenue@28 195
Nenue@28 196 if lines[lineIndex+1] then
Nenue@28 197 lines[lineIndex+1]:ClearAllPoints()
Nenue@28 198 end
Nenue@28 199
Nenue@28 200 if debug then
Nenue@28 201 for _, region in ipairs(lines[lineIndex].debug) do
Nenue@28 202 region:Show()
Nenue@28 203 end
Nenue@28 204 end
Nenue@28 205
Nenue@28 206 end
Nenue@28 207 return lines[lineIndex]
Nenue@28 208 end
Nenue@28 209
Nenue@29 210
Nenue@29 211
Nenue@28 212 --- Creates or retrieves a complete block frame object
Nenue@30 213 Default.GetBlock = function(handler, blockIndex)
Nenue@28 214 local print = bprint
Nenue@28 215 local block = handler.usedBlocks[blockIndex]
Nenue@28 216
Nenue@28 217 if not handler.usedBlocks[blockIndex] then
Nenue@28 218 if #handler.freeBlocks >= 1 then
Nenue@28 219 block = handler.freeBlocks[#handler.freeBlocks]
Nenue@28 220 handler.freeBlocks[#handler.freeBlocks] = nil
Nenue@28 221 else
Nenue@30 222 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, handler.frame, 'VeneerTrackerBlock')
Nenue@28 223
Nenue@30 224 local c = Module.Conf.Wrapper
Nenue@28 225 block.index = blockIndex
Nenue@30 226 block.lines = {}
Nenue@30 227 block.numLines = 0
Nenue@30 228 block.currentLine = 0
Nenue@28 229 block:SetWidth(c.Width)
Nenue@28 230
Nenue@28 231 block.title:SetSpacing(c.TitleSpacing)
Nenue@28 232 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
Nenue@33 233 block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
Nenue@28 234
Nenue@28 235 block.titlebg:SetTexture(1,1,1,1)
Nenue@31 236 block.titlebg:SetGradientAlpha(unpack(titlebg))
Nenue@28 237 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
Nenue@28 238 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
Nenue@28 239
Nenue@28 240 block.status:SetSpacing(c.TextSpacing)
Nenue@28 241 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
Nenue@28 242 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
Nenue@28 243
Nenue@28 244 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
Nenue@28 245 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
Nenue@28 246 block.statusbg:SetTexture(1,1,1,1)
Nenue@31 247 block.statusbg:SetGradientAlpha(unpack(textbg))
Nenue@28 248
Nenue@30 249 block.SelectionOverlay:SetGradientAlpha(unpack(Module.colors.default.selectionbg))
Nenue@28 250 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
Nenue@28 251 block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
Nenue@28 252
Nenue@32 253 --block.icon:SetSize(rewardSize, rewardSize)
Nenue@32 254 --block.icon:SetPoint()
Nenue@32 255 local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
Nenue@32 256 for i, tile in ipairs(block.rewardTile) do
Nenue@32 257 print(rewardSize)
Nenue@32 258 tile:SetSize(rewardSize, rewardSize)
Nenue@32 259 tile:ClearAllPoints()
Nenue@32 260 tile:SetPoint(anchor, target, point, x, y)
Nenue@32 261 block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, -2)
Nenue@32 262 anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
Nenue@32 263 end
Nenue@28 264
Nenue@28 265
Nenue@28 266 --- methods for event handlers
Nenue@28 267
Nenue@28 268 block.Select = handler.Select
Nenue@28 269 block.Open = handler.Open
Nenue@28 270 block.Remove = handler.Remove
Nenue@28 271 block.Link = handler.Link
Nenue@28 272 block.clickZone:SetScript('OnMouseUp', function(self, ...) handler.OnMouseUp(block, ...) end)
Nenue@28 273 block.clickZone:SetScript('OnMouseDown', function(self, ...) handler.OnMouseDown(block, ...) end)
Nenue@28 274 block.attachmentHeight = 0
Nenue@28 275 block:ClearAllPoints()
Nenue@28 276
Nenue@28 277 B.SetConfigLayers(block)
Nenue@28 278
Nenue@28 279 if debug then
Nenue@28 280 for _, region in ipairs(block.debug) do
Nenue@28 281 region:Show()
Nenue@28 282 end
Nenue@28 283 end
Nenue@28 284 end
Nenue@28 285 handler.usedBlocks[blockIndex] = block
Nenue@28 286 end
Nenue@28 287 return handler.usedBlocks[blockIndex]
Nenue@28 288 end
Nenue@28 289
Nenue@30 290 local currentPosition, anchorFrame, anchorPoint
Nenue@30 291 --- Positioning and stuff
Nenue@30 292 local tick = 0
Nenue@30 293 local maxReason = 0
Nenue@30 294 function Module:Update (reason, ...)
Nenue@30 295 tick = tick + 1
Nenue@30 296 -- is this the first time updating?
Nenue@30 297 if maxReason == 0 then
Nenue@30 298 reason = OBJECTIVE_TRACKER_UPDATE_ALL
Nenue@30 299 elseif not reason then
Nenue@30 300 reason = OBJECTIVE_TRACKER_UPDATE_REASON
Nenue@30 301 end
Nenue@30 302
Nenue@30 303 local print = tprint
Nenue@30 304 local updateWrapper = 0
Nenue@30 305 local hasStuff
Nenue@30 306 local insertingStuff
Nenue@30 307
Nenue@30 308 print(format('%d |cFFFF%04X Update()', tick, lshift(reason, 4)), reason, ...)
Nenue@30 309 currentPosition = 0
Nenue@30 310 anchorPoint = 'TOP'
Nenue@30 311 anchorFrame = Scroll
Nenue@30 312
Nenue@30 313 local wrapperHeight = 0
Nenue@30 314 for id, handler in pairs(Module.orderedHandlers) do
Nenue@30 315 local frame = handler.frame
Nenue@30 316
Nenue@30 317 print(format('|cFF00FFFF%s and(%04X vs %04x+%04x) = %04X|r', handler.name, reason, handler.updateReasonModule, handler.updateReasonEvents, band(reason, handler.updateReasonModule + handler.updateReasonEvents)))
Nenue@30 318 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then
Nenue@30 319 handler:UpdateTracker(reason, ...)
Nenue@30 320 print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched)
Nenue@30 321 insertingStuff = true
Nenue@30 322 else
Nenue@30 323 print(' |cFFFF0088'..id..'|r', 'no reason to update')
Nenue@30 324 end
Nenue@30 325
Nenue@30 326 if handler.numWatched >= 1 then
Nenue@30 327 hasStuff = true
Nenue@30 328 currentPosition = currentPosition + 1
Nenue@30 329 frame.destinationOffset = -wrapperHeight
Nenue@30 330 if frame.previousOffset ~= wrapperHeight and frame:IsVisible() then
Nenue@30 331 print(frame.SlideIn.translation)
Nenue@30 332 local postFrame, postPoint = anchorFrame, anchorPoint
Nenue@30 333 local delta = frame.destinationOffset - frame.previousOffset
Nenue@30 334 local _, _, _, _, offset = frame:GetPoint(1)
Nenue@30 335 print(' |cFF00BBFFstart slide for', delta, 'pixels, from', frame.previousOffset, '(', offset, ')')
Nenue@30 336 frame.SlideIn.translation:SetTarget(frame)
Nenue@30 337 frame.SlideIn.translation:SetOffset(0, delta)
Nenue@30 338 frame.SlideIn:Play()
Nenue@30 339 for i, b in ipairs(handler.usedBlocks) do
Nenue@30 340 b.SlideIn.translation:SetOffset(0, delta)
Nenue@30 341 b.SlideIn:Play()
Nenue@30 342 end
Nenue@30 343 frame.SlideIn:SetScript('OnFinished', function()
Nenue@30 344 print(' |cFF00BBFFsliding finished:', delta, 'pixels covered')
Nenue@30 345 frame:SetParent(Scroll)
Nenue@30 346 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
Nenue@30 347 frame.previousOffset = frame.destinationOffset
Nenue@30 348 frame.SlideIn:SetScript('OnFinished', nil)
Nenue@30 349 if Wrapper.destinationHeight then
Nenue@30 350 Wrapper:SetHeight(Wrapper.destinationHeight)
Nenue@30 351 Scroller:SetHeight(Wrapper.destinationHeight)
Nenue@30 352 Scroll:SetHeight(Wrapper.destinationHeight)
Nenue@30 353 Wrapper.previousHeight = Wrapper.destinationHeight
Nenue@30 354 Wrapper.destinationHeight = nil
Nenue@30 355 end
Nenue@30 356
Nenue@30 357 end)
Nenue@30 358 else
Nenue@30 359 print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint)
Nenue@30 360 frame:SetParent(Scroll)
Nenue@30 361 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
Nenue@30 362 end
Nenue@30 363
Nenue@30 364 frame:Show()
Nenue@30 365 anchorFrame = handler.frame
Nenue@30 366 anchorPoint = 'BOTTOM'
Nenue@30 367
Nenue@30 368 print('current frame height:', frame.height)
Nenue@30 369 wrapperHeight = wrapperHeight + frame.height
Nenue@30 370 print('|cFFFF0088total height:', wrapperHeight)
Nenue@30 371 else
Nenue@30 372 frame:SetPoint('TOP', Scroll, 'TOP', 0, 0)
Nenue@30 373 frame.destinationOffset = 0
Nenue@30 374 frame.previousOffset = 0
Nenue@30 375 handler.frame:Hide()
Nenue@30 376 end
Nenue@30 377 end
Nenue@30 378
Nenue@30 379
Nenue@30 380 if hasStuff or insertingStuff then
Nenue@30 381 print('updating height to', wrapperHeight)
Nenue@30 382 if wrapperHeight > Wrapper.previousHeight then
Nenue@30 383 Wrapper:SetHeight(wrapperHeight)
Nenue@30 384 Scroller:SetHeight(wrapperHeight)
Nenue@30 385 Scroll:SetHeight(wrapperHeight)
Nenue@30 386 Wrapper.previousHeight = wrapperHeight
Nenue@30 387 Wrapper.destinationHeight = wrapperHeight
Nenue@30 388 end
Nenue@30 389 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
Nenue@30 390 print('|cFFFF8800Wrapper:', Wrapper:GetSize())
Nenue@30 391 for i = 1, Wrapper:GetNumPoints() do
Nenue@30 392 print(' ', Wrapper:GetPoint(i))
Nenue@30 393 end
Nenue@30 394 print(' |cFF00FFFFScroller:', Scroller:GetSize())
Nenue@30 395 for i = 1, Scroller:GetNumPoints() do
Nenue@30 396 print(' ', Scroller:GetPoint(i))
Nenue@30 397 end
Nenue@30 398 print(' |cFF00FFFFScroll:', Scroll:GetSize())
Nenue@30 399 for i = 1, Scroll:GetNumPoints() do
Nenue@30 400 print(' ', Scroll:GetPoint(i))
Nenue@30 401 end
Nenue@30 402
Nenue@30 403 Wrapper:Show()
Nenue@30 404 Scroller:Show()
Nenue@30 405 Scroll:Show()
Nenue@30 406 end
Nenue@30 407 Quest.GetClosest()
Nenue@30 408 --Module.UpdateActionButtons(reason)
Nenue@30 409 end
Nenue@30 410
Nenue@28 411 --- Content generator base
Nenue@30 412 Default.UpdateTracker = function (handler, reason, id, isNew)
Nenue@28 413 local print = tprint
Nenue@30 414 local tracker = handler.frame
Nenue@28 415 local blockIndex = 0
Nenue@28 416 tracker.previousHeight = tracker.height
Nenue@28 417 tracker.height = 0
Nenue@28 418
Nenue@28 419 tracker.title:SetFont(headerFont, headerSize, headerOutline)
Nenue@28 420 tracker.titlebg:SetHeight(headerHeight)
Nenue@28 421 tracker.title:SetTextColor(unpack(headerColor))
Nenue@28 422
Nenue@30 423 handler.updateReason = reason
Nenue@30 424 handler.numWatched = handler:GetNumWatched()
Nenue@30 425 handler.currentBlock = 0
Nenue@30 426 handler.currentAnchor = tracker.titlebg
Nenue@30 427 local blockPosition = -headerHeight
Nenue@30 428 for blockIndex = 1, handler.numWatched do
Nenue@30 429 local currentBlock = handler:UpdateBlock(blockIndex, id, isNew)
Nenue@30 430 if currentBlock then
Nenue@30 431 currentBlock.offset = blockPosition
Nenue@30 432 handler:AddBlock(currentBlock)
Nenue@30 433 blockPosition = blockPosition - currentBlock.height
Nenue@28 434 else
Nenue@28 435 print(' |cFFFF9900END|r @', blockIndex)
Nenue@28 436 break -- done with quest stuff
Nenue@28 437 end
Nenue@28 438 end
Nenue@28 439
Nenue@30 440 for i = handler.currentBlock+1, handler.numBlocks do
Nenue@30 441 local used = handler.usedBlocks
Nenue@30 442 local free = handler.freeBlocks
Nenue@30 443 print('clean up dead quest block')
Nenue@30 444 if used[i] then
Nenue@30 445 used[i]:Hide()
Nenue@30 446 used[i]:ClearAllPoints()
Nenue@30 447 free[#free+1]= used[blockIndex]
Nenue@30 448 used[i] = nil
Nenue@30 449 end
Nenue@30 450 end
Nenue@28 451
Nenue@30 452
Nenue@30 453 if handler.currentBlock >= 1 then
Nenue@28 454 tracker.height = tracker.height + headerHeight
Nenue@28 455 tracker:Show()
Nenue@28 456
Nenue@28 457 if tracker.wasEmpty then
Nenue@28 458 tracker.headerFade:Play()
Nenue@28 459 tracker.wasEmpty = nil
Nenue@28 460 end
Nenue@28 461 if tracker.height ~= tracker.previousHeight then
Nenue@28 462 tracker:SetHeight(tracker.height)
Nenue@28 463 end
Nenue@29 464 print(' |cFFFFFF00', tracker.height, tracker:GetWidth())
Nenue@28 465 else
Nenue@28 466 tracker:Hide()
Nenue@28 467 tracker.wasEmpty = true
Nenue@28 468 end
Nenue@28 469
Nenue@28 470 return tracker.numWatched, tracker.numAll
Nenue@28 471 end
Nenue@28 472
Nenue@28 473 --- Updates the selected block frame to display the given info batch
Nenue@28 474 -- If `previousBlock` is set, it will attempt to anchor to that
Nenue@28 475 -- @param blockNum the ordered block to be updated, not a watchIndex value
Nenue@28 476 -- @param info the reference returned by the GetXInfo functions
Nenue@28 477 -- REMEMBER: t.info and questData[questID] are the same table
Nenue@30 478 Default.UpdateBlock = function (handler, blockIndex, id, added)
Nenue@28 479 local print = bprint
Nenue@30 480 print(' Updating |cFF00FF00'..handler.displayName..'|r|cFF00FFFF'..blockIndex..'|r')
Nenue@30 481 if not blockIndex then
Nenue@30 482 return
Nenue@30 483 end
Nenue@30 484 local info = handler:GetInfo(blockIndex) -- should match up with whatever the internal watch list has
Nenue@30 485 if not info then
Nenue@28 486 return
Nenue@28 487 end
Nenue@28 488 local frame = handler.frame
Nenue@30 489 local block = handler:GetBlock(blockIndex)
Nenue@30 490
Nenue@30 491 block.questID = info.questID
Nenue@30 492 if id == info.questID then
Nenue@30 493 --block.questFadeIn:Play()
Nenue@30 494 end
Nenue@30 495
Nenue@28 496 block.handler = handler
Nenue@28 497 block.info = info
Nenue@28 498 block.mainStyle = info.mainStyle or 'Normal'
Nenue@28 499 block.subStyle = info.subStyle
Nenue@28 500
Nenue@28 501 info.blockIndex = blockIndex
Nenue@28 502 if info.questID then handler.QuestBlock[info.questID] = block end
Nenue@28 503 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = block end
Nenue@28 504 if info.watchIndex then handler.WatchBlock[info.watchIndex] = block end
Nenue@28 505 handler.BlockInfo[blockIndex] = info
Nenue@28 506 handler:UpdateObjectives(block)
Nenue@28 507
Nenue@28 508 block.title:SetText(info.title)
Nenue@28 509 local titleHeight = floor(block.title:GetHeight()+.5)
Nenue@28 510 local titlebgHeight = titleHeight + titleSpacing*2
Nenue@28 511 block.titlebg:SetHeight(titlebgHeight)
Nenue@28 512
Nenue@30 513 local statusHeight = floor(block.status:GetHeight()+.5)
Nenue@30 514 local statusbgHeight = statusHeight + textSpacing*2
Nenue@30 515 local attachmentHeight =floor(block.attachmentHeight + .5)
Nenue@28 516
Nenue@28 517 print(' |cFF0088FFanchor to', handler.currentAnchor:GetName())
Nenue@30 518 print(' |cFF00FF00attachment:|r', attachmentHeight, '|cFF00FF00title:|r', titlebgHeight, '('.. titleHeight..')')
Nenue@30 519 --block.titlebg:SetHeight(block.title:GetHeight() + Module.Conf.Wrapper.TitleSpacing)
Nenue@30 520 block.height = titlebgHeight + attachmentHeight
Nenue@28 521
Nenue@28 522 if statusHeight > 1 then
Nenue@28 523 block.height = block.height + statusbgHeight
Nenue@28 524 print(' status:', statusbgHeight, '('.. statusHeight..')')
Nenue@28 525 else
Nenue@28 526 print(' |cFFFF0088 skipped')
Nenue@28 527 end
Nenue@28 528 block:SetHeight(block.height)
Nenue@28 529
Nenue@28 530 print(' |cFFFFFF00height|r:', block.height)
Nenue@28 531 print(' |cFF00FFFF)|r -> ', block, block:GetHeight())
Nenue@28 532
Nenue@28 533 block:Show()
Nenue@28 534
Nenue@28 535 if info.specialItem and not info.itemButton then
Nenue@28 536 print(' - |cFF00FFFFgenerating item button for info set')
Nenue@30 537 info.itemButton = Module.SetItemButton(block, info)
Nenue@28 538 else
Nenue@28 539 --info.itemButton = nil
Nenue@28 540 end
Nenue@28 541
Nenue@32 542 local tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
Nenue@28 543
Nenue@32 544 local numCurrency = 0
Nenue@32 545 for i, rewardTile in ipairs(block.rewardTile) do
Nenue@33 546 if info.rewardInfo and info.rewardInfo[i] then
Nenue@33 547 local reward = info.rewardInfo[i]
Nenue@33 548 --rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
Nenue@32 549 rewardTile:SetTexture(reward.texture)
Nenue@32 550 rewardTile:Show()
Nenue@32 551
Nenue@32 552 print('updating reward tile #'.. i, reward.type, reward.count, reward.text, reward.texture)
Nenue@32 553 if reward.count and reward.count > 1 then
Nenue@32 554 block.rewardLabel[i]:SetText(reward.count)
Nenue@32 555 block.rewardLabel[i]:Show()
Nenue@32 556 end
Nenue@32 557
Nenue@32 558 rewardTile:ClearAllPoints()
Nenue@32 559 rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, x, y)
Nenue@32 560 tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', rewardTile, 'TOPLEFT', -2, 0
Nenue@32 561 else
Nenue@32 562 rewardTile:Hide()
Nenue@32 563 block.rewardLabel[i]:Hide()
Nenue@28 564 end
Nenue@28 565 end
Nenue@28 566
Nenue@28 567 if info.selected then
Nenue@28 568 block.SelectionOverlay:Show()
Nenue@28 569 else
Nenue@28 570 block.SelectionOverlay:Hide()
Nenue@28 571 end
Nenue@28 572 -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel
Nenue@28 573 --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1)
Nenue@28 574 --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1)
Nenue@28 575
Nenue@31 576 if info.tagInfo then
Nenue@31 577 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative)
Nenue@31 578 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative)
Nenue@31 579 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative)
Nenue@31 580 end
Nenue@28 581 return block
Nenue@28 582 end
Nenue@28 583
Nenue@28 584
Nenue@28 585
Nenue@28 586
Nenue@28 587 --- Does the main iterations for populating block content.
Nenue@28 588 -- Hooked by corresponding handler functions where additional details need to be sorted.
Nenue@28 589 Default.UpdateObjectives = function(handler, block)
Nenue@28 590 local print = lprint
Nenue@28 591 local info = block.info
Nenue@31 592 print('|cFF00FF00default.objectives', block:GetName())
Nenue@31 593 -- reset the starting positions
Nenue@30 594 block.endPoint = block.titlebg
Nenue@30 595 block.attachmentHeight = 0
Nenue@30 596 block.currentLine = 0
Nenue@28 597
Nenue@28 598 local displayObjectiveHeader = false
Nenue@28 599
Nenue@31 600 block.attachmentHeight = 0
Nenue@31 601 local text, attachment, template
Nenue@28 602
Nenue@28 603
Nenue@28 604 if info.description and #info.description >= 1 then
Nenue@28 605 print(' |cFF00FFFF header line:|r', info.description)
Nenue@30 606 text = info.description
Nenue@30 607 handler:AddLine(block, text, nil)
Nenue@28 608 end
Nenue@28 609
Nenue@28 610 if (info.isComplete or info.numObjectives == 0) and info.completionText then
Nenue@28 611 print(' overriding line #1 for completion text:', info.completionText)
Nenue@30 612 text = info.completionText
Nenue@33 613 handler:AddLine(block, text, nil, 'completed')
Nenue@28 614 else
Nenue@28 615 if info.objectives then
Nenue@28 616 for i, data in ipairs(info.objectives) do
Nenue@30 617 local line = handler:GetLine(block)
Nenue@28 618 displayObjectiveHeader = true
Nenue@28 619 line.height = 0
Nenue@31 620 text, attachment, template = handler:UpdateLine(block, line, data)
Nenue@30 621 print(' |cFF88FF00#', i, data.type, text)
Nenue@31 622 handler:AddLine(block, text, attachment, template)
Nenue@28 623
Nenue@28 624 end
Nenue@28 625 end
Nenue@28 626 end
Nenue@28 627
Nenue@32 628 if info.statusKey and (Devian and Devian.InWorkspace()) then
Nenue@32 629 handler:AddLine(block, info.statusKey, nil)
Nenue@32 630 end
Nenue@32 631
Nenue@30 632 for i = block.currentLine + 1, block.numLines do
Nenue@30 633 print(i, block.numLines)
Nenue@30 634 print(' - hide |cFFFF0088'..i..'|r', block.lines[i])
Nenue@30 635 block.lines[i]:ClearAllPoints()
Nenue@30 636 block.lines[i]:Hide()
Nenue@28 637 end
Nenue@28 638
Nenue@30 639 if block.currentLine > 0 then
Nenue@31 640 block.attachmentHeight = block.attachmentHeight + textSpacing
Nenue@28 641 print(' |cFF00FF00attachment:', block.attachmentHeight)
Nenue@28 642 end
Nenue@28 643 end
Nenue@28 644
Nenue@28 645
Nenue@28 646 --- Module-specific display variables
Nenue@28 647 -- * height - height of whatever display widget is involved in conveying the task
Nenue@28 648 -- * money - boolean that determines listening for money events or not
Nenue@28 649 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively
Nenue@28 650
Nenue@28 651
Nenue@31 652 Default.UpdateLine = function(handler, block, line, data)
Nenue@28 653 if line.finished then
Nenue@28 654 line.progress = 2
Nenue@28 655 elseif line.quantity > 0 then
Nenue@28 656 line.progress = 1
Nenue@28 657 else
Nenue@28 658 line.progress = 0
Nenue@28 659 end
Nenue@31 660 return data.text, line.widget, 'normal'
Nenue@28 661 end
Nenue@28 662 ----------
Nenue@28 663 --- Top level methods
Nenue@28 664
Nenue@28 665 --- Queue any active item buttons for update for that frame
Nenue@28 666 local iprint = B.print('ItemButton')
Nenue@30 667 Module.UpdateActionButtons = function(updateReason)
Nenue@28 668 local print = iprint
Nenue@28 669 Scroller.snap_upper = 0
Nenue@28 670 Scroller.snap_lower = 0
Nenue@28 671 local print = B.print('ItemButton')
Nenue@28 672 if updateReason then
Nenue@28 673 print = B.print('IB_'..updateReason)
Nenue@28 674 end
Nenue@28 675
Nenue@28 676 local previousItem
Nenue@28 677 for questID, itemButton in pairs(Quest.itemButtons) do
Nenue@30 678 local info= Module.Quest.Info[questID]
Nenue@28 679
Nenue@28 680 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
Nenue@30 681 local block = Module.Quest.QuestBlock[questID]
Nenue@28 682 if block then
Nenue@28 683 -- Dispatch the probe
Nenue@28 684 if IsQuestWatched(info.questLogIndex) then
Nenue@28 685 itemButton.previousItem = previousItem
Nenue@28 686 print(' |cFFFFFF00probing', block:GetName())
Nenue@28 687 block:SetScript('OnUpdate', function()
Nenue@28 688 if block:GetBottom() and not InCombatLockdown() then
Nenue@28 689 print(' '..block:GetName()..' |cFF00FF00probe hit!')
Nenue@30 690 Module.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
Nenue@28 691 block:SetScript('OnUpdate', nil)
Nenue@28 692
Nenue@28 693 end
Nenue@28 694 end)
Nenue@28 695 previousItem = itemButton
Nenue@28 696 else
Nenue@28 697 print('hidden block or unwatched quest')
Nenue@28 698 itemButton.previousItem = nil
Nenue@28 699 itemButton:Hide()
Nenue@28 700 end
Nenue@28 701 elseif itemButton:IsVisible() then
Nenue@28 702 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
Nenue@28 703 itemButton.previousItem = nil
Nenue@28 704 itemButton:Hide()
Nenue@28 705 else
Nenue@28 706 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
Nenue@28 707 end
Nenue@28 708 end
Nenue@28 709 end
Nenue@28 710
Nenue@30 711 Module.UpdateBlockAction = function (block, itemButton)
Nenue@28 712 local print = iprint
Nenue@28 713 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
Nenue@28 714 if itemButton.questID ~= block.info.questID then
Nenue@28 715 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
Nenue@28 716 -- something happened between this and last frame, go back and set new probes
Nenue@30 717 return Module.UpdateActionButtons()
Nenue@28 718 end
Nenue@28 719
Nenue@28 720 local previousItem = itemButton.previousItem
Nenue@28 721 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
Nenue@28 722 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
Nenue@28 723 local point, anchor, relative
Nenue@28 724
Nenue@28 725 if block:GetBottom() < lower_bound then
Nenue@28 726 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@28 727 if previousItem then
Nenue@28 728 print('adjusting', previousItem:GetName())
Nenue@28 729 previousItem:ClearAllPoints()
Nenue@28 730 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
Nenue@28 731 end
Nenue@28 732 itemButton:ClearAllPoints()
Nenue@28 733 itemButton.x = Wrapper:GetLeft() -4
Nenue@28 734 itemButton.y = Wrapper:GetBottom()
Nenue@28 735 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 736 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
Nenue@28 737
Nenue@28 738 elseif block:GetTop() > upper_bound then
Nenue@28 739 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
Nenue@28 740 itemButton:ClearAllPoints()
Nenue@28 741 if previousItem then
Nenue@28 742 print('latch onto another piece')
Nenue@28 743 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
Nenue@28 744 itemButton.x = 0
Nenue@28 745 itemButton.y = -itemButtonSpacing
Nenue@28 746 else
Nenue@28 747 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
Nenue@28 748 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 749 itemButton.x = Scroller:GetLeft() -4
Nenue@28 750 itemButton.y = Scroller:GetTop()
Nenue@28 751 end
Nenue@28 752 itemButton:Show()
Nenue@28 753 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
Nenue@28 754 else
Nenue@28 755 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@28 756 itemButton:ClearAllPoints()
Nenue@28 757 itemButton.x = block:GetLeft() - itemButtonSpacing
Nenue@28 758 itemButton.y = block:GetTop()
Nenue@28 759 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@28 760 end
Nenue@28 761
Nenue@28 762 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
Nenue@28 763 itemButton:Show()
Nenue@28 764 end
Nenue@28 765
Nenue@30 766 Module.UpdateItemButtonCooldown = function(button)
Nenue@28 767
Nenue@28 768 end
Nenue@28 769
Nenue@29 770 Default.Select = function(handler, block)
Nenue@30 771 Module:Update(handler.watchReasonModule)
Nenue@28 772 end
Nenue@29 773 Default.Open = function(handler, block)
Nenue@30 774 Module:Update(handler.watchReasonModule)
Nenue@28 775 end
Nenue@29 776 Default.Remove = function(handler, block)
Nenue@30 777 Module:Update(handler.watchReasonModule)
Nenue@28 778 end
Nenue@29 779 Default.Report = function(handler, block)
Nenue@29 780 print('Stats:', handler.numWatched,'items tracked,', handler.numBlocks,'blocks assigned.')
Nenue@28 781 end
Nenue@28 782
Nenue@28 783 Default.OnMouseUp = function(self, button)
Nenue@28 784 print(self.handler.name, self.mainStyle, self.subStyle)
Nenue@28 785 if button == 'LeftButton' then
Nenue@28 786 if IsModifiedClick("CHATLINK") and ChatEdit_GetActiveWindow() then
Nenue@29 787 self.Link(self.handler, self)
Nenue@28 788 elseif IsModifiedClick("QUESTWATCHTOGGLE") then
Nenue@29 789 self.Remove(self.handler, self)
Nenue@28 790 else
Nenue@29 791 self.Select(self.handler, self)
Nenue@28 792 end
Nenue@28 793 elseif button == 'RightButton' then
Nenue@29 794 self.Open(self.handler, self)
Nenue@28 795 end
Nenue@28 796 self.initialButton = nil
Nenue@28 797 self.modChatLink = nil
Nenue@28 798 self.modQuestWatch = nil
Nenue@30 799 Module:Update(self.handler.updateReasonModule)
Nenue@28 800 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r')
Nenue@28 801 end
Nenue@28 802 Default.OnMouseDown = function(self, button)
Nenue@28 803 print(self.info.title)
Nenue@28 804 end