annotate ObjectiveTracker/Frame.lua @ 28:c33c17dd97e7

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