annotate ObjectiveTracker/Frame.lua @ 32:a3afe6c3771e

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