annotate ObjectiveFrame.lua @ 21:d5ee940de273

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