annotate ObjectiveTracker/Frame.lua @ 29:adcd7c328d07

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