annotate ObjectiveFrame.lua @ 16:880828018bf4

ObjectiveEvents - trim down the number of events that fire full updates - begin the general outline for determining which trackers need to refresh - handlers for accepting and completing auto-popup quests ObjectiveFrame - correct variables for money reward calculation - make sure everythign is scaling to the font strings and that the font strings aren't being pinned by SetSize ObjectiveInfo - implementation of autoquest popups - discern between internal and client bonus objective indexes - acquire the correct data set from bonus objective query ObjectiveStyle - look for a style table under the previously interpreted set before deferring standard options - horizontal/vertical options in gradient - remove height-fixing for font strings
author Nenue
date Tue, 05 Apr 2016 00:39:12 -0400
parents f660f1c1e0aa
children d1812fb10ae6
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@14 11 local Quest, Bonus, Cheevs = mod.Quest, mod.Bonus, mod.Cheevs
Nenue@1 12 local CreateFrame = CreateFrame
Nenue@1 13 local print = B.print('Objectives')
Nenue@13 14 local unitLevel = 1
Nenue@1 15 --------------------------------------------------------------------
Nenue@1 16 --- Global frame layout
Nenue@1 17 --------------------------------------------------------------------
Nenue@1 18
Nenue@1 19 --- Upvalues
Nenue@2 20 local Wrapper = VeneerObjectiveWrapper
Nenue@1 21 local Scroller = Wrapper.scrollArea
Nenue@2 22 local Scroll = VeneerObjectiveScroll
Nenue@1 23 local orderedHandlers = mod.orderedHandlers
Nenue@1 24 local orderedNames = mod.orderedNames
Nenue@1 25
Nenue@1 26 --- Temp values set during updates
Nenue@1 27 local wrapperWidth, wrapperHeight
Nenue@1 28 local scrollWidth, scrollHeight
Nenue@1 29 local previousBlock
Nenue@1 30 local currentBlock
Nenue@10 31 --- todo: source these from config
Nenue@6 32 local itemButtonSize, itemButtonSpacing = 36, 1
Nenue@1 33 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]]
Nenue@1 34 local titleSize, textSize = 15, 15
Nenue@1 35 local titleOutline, textOutline = "OUTLINE", "OUTLINE"
Nenue@1 36 local titleSpacing, textSpacing = 4, 3
Nenue@1 37 local textIndent = 5
Nenue@12 38 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
Nenue@2 39 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
Nenue@1 40 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24
Nenue@2 41 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2
Nenue@1 42 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0}
Nenue@1 43
Nenue@7 44
Nenue@14 45 mod.InitializeWrapper = function()
Nenue@3 46
Nenue@14 47 mod.SetBlockStyle(Scroller, 'Scroller', 'Normal')
Nenue@14 48 mod.SetBlockStyle(Scroller, 'Scroll', 'Normal')
Nenue@14 49 mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal')
Nenue@2 50
Nenue@2 51 for i, name in ipairs(orderedNames) do
Nenue@2 52 if not mod.orderedHandlers[i] then
Nenue@2 53 if mod.Tracker(name, i) then
Nenue@2 54 local handler = mod[name]
Nenue@2 55 local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate')
Nenue@14 56 tracker.title:SetText(handler.displayName)
Nenue@10 57 mod.SetBlockStyle(tracker, 'Tracker', 'Normal')
Nenue@2 58 handler.Tracker = tracker
Nenue@2 59 mod.orderedTrackers[i] = tracker
Nenue@2 60 mod.namedTrackers[name] = tracker
Nenue@2 61 mod.indexedTrackers[handler] = tracker
Nenue@2 62 print('created new tracker frames for new handler')
Nenue@2 63 end
Nenue@2 64 end
Nenue@2 65 end
Nenue@2 66
Nenue@2 67 Scroller:SetScrollChild(Scroll)
Nenue@14 68
Nenue@14 69 mod.InitializeWrapperWidgets()
Nenue@13 70 if B.Conf.ObjectiveTrackerMinimized then
Nenue@13 71 Scroller_OnShow(Scroller)
Nenue@13 72 end
Nenue@2 73 mod.UpdateWrapperStyle()
Nenue@2 74 end
Nenue@2 75
Nenue@2 76 mod.InitializeXPTracker = function()
Nenue@2 77 local XPBar = Wrapper.XPBar
Nenue@2 78 if UnitLevel('player') == 100 then
Nenue@2 79 XPBar:Hide()
Nenue@2 80 return
Nenue@2 81 end
Nenue@2 82
Nenue@2 83 --- xp bar
Nenue@16 84 XPBar:SetWidth(mod.Conf.Wrapper.WrapperWidth - Wrapper.CloseButton:GetWidth())
Nenue@12 85 XPBar.statusbg:SetAllPoints(XPBar)
Nenue@6 86 XPBar:RegisterEvent('DISABLE_XP_GAIN')
Nenue@6 87 XPBar:RegisterEvent('ENABLE_XP_GAIN')
Nenue@2 88 XPBar:SetScript('OnEvent', mod.UpdateXP)
Nenue@6 89
Nenue@6 90 if not IsXPUserDisabled() then
Nenue@6 91 mod.EnableXP(XPBar)
Nenue@6 92 else
Nenue@6 93 mod.DisableXP(XPBar)
Nenue@6 94 end
Nenue@6 95
Nenue@6 96 mod.UpdateXP(XPBar)
Nenue@2 97 end
Nenue@2 98
Nenue@6 99 mod.EnableXP = function(self)
Nenue@6 100 self:RegisterEvent('PLAYER_XP_UPDATE')
Nenue@6 101 self:RegisterEvent('PLAYER_LEVEL_UP')
Nenue@6 102 self:RegisterEvent('PLAYER_UPDATE_RESTING')
Nenue@12 103 self.statusbg:SetTexture(0,0,0,.25)
Nenue@6 104 self:Show()
Nenue@6 105 end
Nenue@2 106
Nenue@6 107 mod.DisableXP = function(self)
Nenue@6 108 self:UnregisterEvent('PLAYER_XP_UPDATE')
Nenue@6 109 self:UnregisterEvent('PLAYER_LEVEL_UP')
Nenue@6 110 self:UnregisterEvent('PLAYER_UPDATE_RESTING')
Nenue@12 111 self.statusbg:SetTexture(0.5,0.5,0.5,0.5)
Nenue@6 112 self:Hide()
Nenue@6 113 end
Nenue@2 114
Nenue@6 115 mod.UpdateXP = function(self, event)
Nenue@6 116 if event == 'DISABLE_XP_GAIN' then
Nenue@6 117 mod.DisableXP(self)
Nenue@6 118 elseif event == 'ENABLE_XP_GAIN' then
Nenue@6 119 mod.EnableXP(self)
Nenue@2 120 end
Nenue@2 121
Nenue@6 122 if not IsXPUserDisabled() then
Nenue@6 123
Nenue@6 124 local xp = UnitXP('player')
Nenue@6 125 local xpmax = UnitXPMax('player')
Nenue@6 126 local rest = GetXPExhaustion()
Nenue@12 127 self.foreground:SetWidth((xp/xpmax) * self:GetWidth())
Nenue@6 128 if rest then
Nenue@6 129 self.rested:ClearAllPoints()
Nenue@6 130 if xp == 0 then
Nenue@6 131 self.rested:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
Nenue@6 132 else
Nenue@6 133 self.rested:SetPoint('TOPLEFT', self.fg, 'TOPRIGHT', 0, 0)
Nenue@6 134 end
Nenue@6 135
Nenue@6 136 if (xp + rest) > xpmax then
Nenue@6 137 self.rested:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, 0)
Nenue@6 138 else
Nenue@6 139 self.rested:SetWidth((rest/xpmax) * self:GetWidth())
Nenue@6 140 end
Nenue@6 141 self.rested:SetPoint('BOTTOM', self, 'BOTTOM')
Nenue@6 142 self.rested:Show()
Nenue@2 143 else
Nenue@6 144 self.rested:Hide()
Nenue@2 145 end
Nenue@2 146
Nenue@6 147 if IsResting() then
Nenue@12 148 self.statusbg:SetTexture(.2,.8,.2,.5)
Nenue@2 149 else
Nenue@12 150 self.statusbg:SetTexture(0,0,0,.25)
Nenue@2 151 end
Nenue@6 152 self.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or ''))
Nenue@2 153 end
Nenue@2 154 end
Nenue@2 155
Nenue@1 156
Nenue@2 157
Nenue@14 158 mod.UpdateTracker = function(handler)
Nenue@1 159 local tracker = handler.Tracker
Nenue@14 160 print('|cFFFF4400'..tracker:GetName().. '|r:Update()')
Nenue@1 161 local blockIndex = 0
Nenue@1 162 local trackerHeight = headerHeight
Nenue@14 163
Nenue@1 164
Nenue@10 165 previousBlock = tracker.title
Nenue@1 166 local numWatched = handler.GetNumWatched()
Nenue@1 167 local numBlocks = handler.numBlocks
Nenue@9 168 local actualBlocks = 0
Nenue@1 169 for watchIndex = 1, 25 do
Nenue@1 170 blockIndex = blockIndex + 1
Nenue@1 171 if watchIndex <= numWatched then
Nenue@1 172 local info = handler:GetInfo(watchIndex)
Nenue@1 173 if info then
Nenue@1 174 local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info)
Nenue@1 175 previousBlock = currentBlock
Nenue@14 176 print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height)
Nenue@1 177 trackerHeight = trackerHeight + currentBlock.height
Nenue@1 178 numBlocks = max(numBlocks, watchIndex)
Nenue@1 179 actualBlocks = actualBlocks + 1
Nenue@1 180 else
Nenue@14 181 print(' |cFFFF0000Failed to draw info for index #'..watchIndex)
Nenue@1 182 end
Nenue@1 183
Nenue@1 184 elseif watchIndex <= numBlocks then
Nenue@1 185 local used = handler.usedBlocks
Nenue@1 186 local free = handler.freeBlocks
Nenue@1 187 print('clean up dead quest block')
Nenue@1 188 if used[blockIndex] then
Nenue@1 189 used[blockIndex]:Hide()
Nenue@1 190 used[blockIndex]:ClearAllPoints()
Nenue@1 191 free[#free+1]= used[blockIndex]
Nenue@1 192 used[blockIndex] = nil
Nenue@1 193 end
Nenue@1 194 else
Nenue@14 195 print(' |cFFFF9900END|r @', blockIndex)
Nenue@1 196 break -- done with quest stuff
Nenue@1 197 end
Nenue@1 198 end
Nenue@1 199 handler.numWatched = numWatched
Nenue@1 200 handler.numBlocks = numBlocks
Nenue@1 201 handler.actualBlocks = actualBlocks
Nenue@1 202 handler:Report()
Nenue@14 203
Nenue@14 204 if numBlocks >= 1 then
Nenue@14 205 previousBlock = nil
Nenue@1 206 tracker.height = trackerHeight
Nenue@1 207 else
Nenue@1 208 tracker.height = 0
Nenue@1 209 end
Nenue@1 210
Nenue@14 211 return tracker.numWatched, tracker.numAll
Nenue@1 212 end
Nenue@1 213
Nenue@14 214 --- Updates the selected block frame to display the given info batch
Nenue@14 215 -- If `previousBlock` is set, it will attempt to anchor to that
Nenue@14 216 -- @param blockNum the ordered block to be updated, not a watchIndex value
Nenue@14 217 -- @param info the reference returned by the GetXInfo functions
Nenue@14 218 -- REMEMBER: t.info and questData[questID] are the same table
Nenue@14 219 mod.UpdateTrackerBlock = function (handler, blockIndex, info)
Nenue@14 220 local print = B.print('BlockParse')
Nenue@14 221 print(' Read list item |cFF00FFFF'..blockIndex..'|r')
Nenue@14 222 if not blockIndex or not info then
Nenue@14 223 return
Nenue@14 224 end
Nenue@14 225 local tracker = handler.Tracker
Nenue@14 226 local t = handler:GetBlock(blockIndex)
Nenue@14 227 t.handler = handler
Nenue@14 228 t.info = info
Nenue@14 229 t.mainStyle = 'Normal'
Nenue@14 230 t.subStyle = nil
Nenue@14 231
Nenue@14 232 info.blockIndex = blockIndex
Nenue@14 233 if info.questID then handler.QuestBlock[info.questID] = t end
Nenue@14 234 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end
Nenue@14 235 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end
Nenue@14 236 handler.BlockInfo[blockIndex] = info
Nenue@14 237
Nenue@14 238
Nenue@14 239 t.attachmentHeight = 0
Nenue@14 240 --if info.isComplete then
Nenue@14 241 --t.status:Show()
Nenue@14 242 --t.status:SetText(info.completionText)
Nenue@14 243 --end
Nenue@14 244
Nenue@14 245 if info.numObjectives >= 1 then
Nenue@16 246 t.attachmentHeight = 0
Nenue@14 247 t.status:Show()
Nenue@14 248 print(' lines to build:', info.numObjectives)
Nenue@14 249
Nenue@14 250 local text = ''
Nenue@14 251
Nenue@14 252 mod.UpdateObjectives(t, info, text)
Nenue@14 253 elseif info.description then
Nenue@14 254 t.status:SetText(info.description)
Nenue@14 255 else
Nenue@14 256 t.status:SetText(nil)
Nenue@14 257 end
Nenue@14 258 t.title:SetText(info.title)
Nenue@16 259 print(' ', t.status:CanWordWrap(), t.status:GetStringHeight())
Nenue@14 260
Nenue@14 261
Nenue@14 262 if info.specialItem and not info.itemButton then
Nenue@14 263 print(' - |cFF00FFFFgenerating item button for info set')
Nenue@14 264 info.itemButton = mod.SetItemButton(t, info)
Nenue@14 265 else
Nenue@14 266 --info.itemButton = nil
Nenue@14 267 end
Nenue@14 268
Nenue@14 269 handler.SetBlockTags(t, info)
Nenue@14 270
Nenue@14 271 if previousBlock then
Nenue@14 272 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0)
Nenue@14 273 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
Nenue@14 274 print(' anchor to|cFF0088FF', previousBlock:GetName())
Nenue@14 275 end
Nenue@14 276
Nenue@16 277
Nenue@14 278 --- metrics are calculated in SetStyle
Nenue@14 279 t:SetStyle('TrackerBlock', handler.name, t.mainStyle, t.subStyle)
Nenue@14 280 t:Show()
Nenue@14 281
Nenue@14 282 print(' |cFF00FFFF)|r -> ', t, t:GetHeight())
Nenue@14 283
Nenue@16 284 if info.rewardInfo then
Nenue@16 285 print('has immediate reward')
Nenue@16 286 if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then
Nenue@16 287 t.icon:Show()
Nenue@16 288 t.iconLabel:SetText(info.rewardInfo[1].count)
Nenue@16 289 t.icon:SetSize(t.height, t.height)
Nenue@16 290 t.icon:SetTexture(info.rewardInfo[1].texture)
Nenue@16 291 end
Nenue@16 292
Nenue@16 293 else
Nenue@16 294 t.icon:Hide()
Nenue@16 295 end
Nenue@14 296
Nenue@14 297 if Devian and Devian.InWorkspace() then
Nenue@14 298 t.debugText:Show()
Nenue@14 299 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle)))
Nenue@14 300 end
Nenue@14 301 return t
Nenue@14 302 end
Nenue@14 303
Nenue@14 304 mod.UpdateObjectives = function(block, info, text)
Nenue@14 305 local print = B.print('BlockLine')
Nenue@14 306 print(' |cFF00FF00objective updates for', block:GetName())
Nenue@14 307
Nenue@14 308 local attachmentHeight = block.attachmentHeight
Nenue@14 309 if info.description then
Nenue@14 310 print(' -- has description text:', select('#', info.description), info.description)
Nenue@14 311 text = info.description
Nenue@14 312 end
Nenue@14 313 local completionScore, completionMax = 0, 0
Nenue@14 314
Nenue@14 315 for i, line in ipairs(info.objectives) do
Nenue@14 316 print(' |cFF88FF00objective', i)
Nenue@14 317 block.handler.ParseObjective(line, info)
Nenue@14 318
Nenue@14 319 if line.title then
Nenue@14 320 info.title = line.title
Nenue@14 321 line.title = nil
Nenue@14 322 end
Nenue@14 323
Nenue@14 324
Nenue@14 325 if line.widget then
Nenue@16 326 if attachmentHeight == 0 then
Nenue@16 327 attachmentHeight = block.status.spacing
Nenue@16 328 end
Nenue@16 329
Nenue@14 330 line.widget:Show()
Nenue@14 331 line.widget:SetParent(block)
Nenue@14 332 line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight )
Nenue@14 333 print(' has a widget, height is', line.widget.height)
Nenue@14 334 attachmentHeight = attachmentHeight + line.widget.height
Nenue@14 335 completionScore = completionScore + line.progress
Nenue@14 336 completionMax = completionMax + 2
Nenue@14 337 end
Nenue@14 338
Nenue@14 339 if line.displayText then
Nenue@14 340 print(' has text')
Nenue@14 341 text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r'
Nenue@14 342 end
Nenue@14 343
Nenue@14 344 end
Nenue@14 345
Nenue@14 346 block.completionScore = completionScore / completionMax
Nenue@14 347 block.attachmentHeight = attachmentHeight
Nenue@14 348
Nenue@14 349 block.status:SetText(text)
Nenue@16 350 block.status:SetWordWrap(true)
Nenue@14 351 end
Nenue@14 352
Nenue@14 353 --- Objective parsers
Nenue@14 354 -- defines the following variables
Nenue@14 355 -- * height - height of whatever display widget is involved in conveying the task
Nenue@14 356 -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things
Nenue@14 357 -- * money - boolean that determines listening for money events or not
Nenue@14 358 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively
Nenue@14 359 mod.Tracker.ParseObjective = function(line, info)
Nenue@14 360
Nenue@14 361 if line.finished then
Nenue@14 362 line.progress = 2
Nenue@14 363 elseif line.quantity > 0 then
Nenue@14 364 line.progress = 1
Nenue@14 365 else
Nenue@14 366 line.progress = 0
Nenue@14 367 end
Nenue@14 368
Nenue@14 369 end
Nenue@14 370
Nenue@14 371 Bonus.ParseObjective = function(line, info)
Nenue@14 372 local print = B.print('BonusLine')
Nenue@16 373
Nenue@14 374
Nenue@14 375 line.displayColor = 'FFFFFF'
Nenue@14 376 if line.text and not info.title then
Nenue@14 377 line.title = line.text
Nenue@14 378 else
Nenue@14 379 line.displayText = line.text
Nenue@14 380 end
Nenue@14 381
Nenue@15 382 line.progress = 0
Nenue@15 383 print(' ', line.index,'|cFFFF0088-|r', line.objectiveType, line.text)
Nenue@14 384 if line.objectiveType == 'progressbar' then
Nenue@14 385 line.widgetType = 'ProgressBar'
Nenue@14 386 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID)))
Nenue@14 387 line.value = GetQuestProgressBarPercent(info.questID) or 0
Nenue@14 388 line.maxValue = 100
Nenue@14 389 if line.value >= line.maxValue then
Nenue@14 390 line.progress = 1
Nenue@14 391 elseif line.value > 0 then
Nenue@14 392 line.progress = 2
Nenue@14 393 end
Nenue@14 394 line.format = PERCENTAGE_STRING
Nenue@14 395 line.widget = mod.SetWidget(line, info, 'ProgressBar', info.questID..'-'..line.index)
Nenue@15 396 print(' ** text:', line.text, 'value:', line.value, 'max:', line.maxValue)
Nenue@14 397 else
Nenue@14 398 line.widget = nil
Nenue@14 399 end
Nenue@14 400 end
Nenue@14 401
Nenue@14 402 Cheevs.ParseObjective = function(line, info)
Nenue@14 403 local print = B.print('CheevsLine')
Nenue@14 404 line.progress = 0
Nenue@14 405 if line.flags then
Nenue@14 406 if band(line.flags, 0x00000001) > 0 then
Nenue@14 407 line.format = "%d/%d"
Nenue@14 408 line.widget = mod.SetWidget(line, info, 'ProgressBar', line.criteriaID)
Nenue@14 409 elseif band(line.flags, 0x00000002) then
Nenue@14 410 line.widget = nil
Nenue@14 411 else
Nenue@14 412 line.widget = nil
Nenue@14 413 line.displayColor = 'FFFFFF'
Nenue@14 414 line.displayText = line.text
Nenue@14 415
Nenue@14 416 end
Nenue@14 417 end
Nenue@14 418 print('line.type =', line.type)
Nenue@14 419 print(' ** qtyStr:', line.quantityString, 'qty:', line.quantity, 'assetID:', line.assetID)
Nenue@14 420 end
Nenue@14 421
Nenue@14 422 Quest.ParseObjective = function(line)
Nenue@14 423 local print = B.print('QuestLine')
Nenue@14 424 print(' |cFFFF0088', line.type)
Nenue@14 425 local color = '00FFFF'
Nenue@14 426 line.progress = 0
Nenue@14 427 if line.finished then
Nenue@14 428 line.progress = 2
Nenue@14 429 color = 'FFFFFF'
Nenue@14 430 elseif line.type == 'monster' then
Nenue@14 431 color = 'FFFF00'
Nenue@14 432 elseif line.type == 'item' then
Nenue@14 433 color = '44DDFF'
Nenue@14 434 elseif line.type == 'object' then
Nenue@14 435 color = 'FF44DD'
Nenue@14 436 end
Nenue@14 437 line.displayColor = color
Nenue@14 438 line.displayText = line.text
Nenue@14 439 end
Nenue@14 440
Nenue@14 441
Nenue@1 442 mod.Quest.numButtons = 0
Nenue@1 443 local usedButtons = mod.Quest.itemButtons
Nenue@1 444 local freeButtons = mod.Quest.freeButtons
Nenue@16 445 mod.UpdateWrapper = function(reason)
Nenue@16 446 print('|cFF00FFFFUpdateWrapper:|r', reason)
Nenue@13 447 unitLevel = UnitLevel('player')
Nenue@14 448 wrapperWidth = mod.Conf.Wrapper.WrapperWidth
Nenue@14 449 scrollWidth = mod.Conf.Wrapper.WrapperWidth
Nenue@1 450 local wrapperBlocks = 0
Nenue@1 451 -- Update scroll child vertical size
Nenue@1 452 scrollHeight = 0
Nenue@1 453 for i, handler in ipairs(orderedHandlers) do
Nenue@1 454 mod.UpdateTracker(handler)
Nenue@14 455 local tracker = handler.Tracker
Nenue@1 456 if handler.actualBlocks >= 1 then
Nenue@10 457 tracker:SetParent(Scroll)
Nenue@1 458 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight)
Nenue@1 459 tracker:SetSize(wrapperWidth, tracker.height)
Nenue@14 460 print('|cFF00FFFF'..tracker:GetName()..'|r h:|cFF00FF00', tracker.height, '|r y:|cFF00FF00', -scrollHeight)
Nenue@1 461 scrollHeight = scrollHeight + tracker.height
Nenue@14 462 tracker:Show()
Nenue@14 463 else
Nenue@14 464 tracker:Hide()
Nenue@1 465 end
Nenue@1 466 wrapperBlocks = wrapperBlocks + handler.actualBlocks
Nenue@1 467 end
Nenue@1 468 print('final scrollHeight:', scrollHeight)
Nenue@1 469
Nenue@1 470
Nenue@1 471
Nenue@1 472 -- Update frame dimensions
Nenue@1 473 if scrollHeight > wrapperMaxHeight then
Nenue@1 474 print(' is larger than', wrapperMaxHeight)
Nenue@1 475 wrapperHeight = wrapperMaxHeight
Nenue@1 476 else
Nenue@1 477 wrapperHeight = scrollHeight
Nenue@9 478 B.Conf.ObjectiveScroll = 0
Nenue@1 479 end
Nenue@1 480 scrollWidth = floor(scrollWidth+.5)
Nenue@1 481 scrollHeight = floor(scrollHeight+.5)
Nenue@1 482 wrapperWidth = floor(wrapperWidth+.5)
Nenue@1 483 wrapperHeight = floor(wrapperHeight+.5)
Nenue@1 484 headerHeight = floor(headerHeight+.5)
Nenue@1 485
Nenue@1 486 if wrapperBlocks >= 1 then
Nenue@10 487 for i, region in ipairs(Wrapper.headerComplex) do
Nenue@2 488 region:Show()
Nenue@2 489 end
Nenue@1 490 else
Nenue@10 491 for i, region in ipairs(Wrapper.headerComplex) do
Nenue@2 492 region:Hide()
Nenue@2 493 end
Nenue@1 494 return
Nenue@1 495 end
Nenue@14 496 --[[wrapperHeight = scrollHeight
Nenue@1 497
Nenue@14 498 print('|cFFFFFF00params:|r scroller:', scrollWidth .. ',' .. scrollHeight, 'scroll:', scrollWidth .. ',' .. scrollHeight,
Nenue@14 499 'wrapper:', wrapperWidth .. ',' .. wrapperHeight,
Nenue@14 500 'header:', headerHeight)]]
Nenue@1 501
Nenue@14 502 --Scroller:SetSize(wrapperWidth, wrapperHeight)
Nenue@13 503 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, 0)
Nenue@1 504 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT')
Nenue@1 505
Nenue@7 506
Nenue@1 507 Scroll:SetSize(scrollWidth, scrollHeight)
Nenue@7 508 Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, B.Conf.ObjectiveScroll or 0)
Nenue@1 509 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT')
Nenue@1 510
Nenue@1 511 --Scroller:UpdateScrollChildRect()
Nenue@13 512 Wrapper:SetSize(wrapperWidth, wrapperHeight)
Nenue@1 513
Nenue@14 514 --[[ update action buttons
Nenue@6 515 print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(),
Nenue@6 516 '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(),
Nenue@6 517 '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(),
Nenue@6 518 '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5)
Nenue@6 519 )
Nenue@14 520 mod.UpdateActionButtons()
Nenue@14 521 --]]
Nenue@1 522
Nenue@1 523 end
Nenue@1 524
Nenue@1 525 --- Queue any active item buttons for update for that frame
Nenue@6 526 mod.UpdateActionButtons = function(updateReason)
Nenue@6 527 Scroller.snap_upper = 0
Nenue@6 528 Scroller.snap_lower = 0
Nenue@6 529 local print = B.print('ItemButton')
Nenue@6 530 if updateReason then
Nenue@6 531 print = B.print('IB_'..updateReason)
Nenue@6 532 end
Nenue@6 533
Nenue@1 534 local previousItem
Nenue@2 535 for questID, itemButton in pairs(usedButtons) do
Nenue@6 536 local info= mod.Quest.Info[questID]
Nenue@6 537
Nenue@5 538 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
Nenue@5 539 local block = mod.Quest.QuestBlock[questID]
Nenue@1 540 if block then
Nenue@5 541 -- Dispatch the probe
Nenue@6 542 if IsQuestWatched(info.questLogIndex) then
Nenue@6 543 itemButton.previousItem = previousItem
Nenue@5 544 print(' |cFFFFFF00probing', block:GetName())
Nenue@1 545 block:SetScript('OnUpdate', function()
Nenue@5 546 if block:GetBottom() and not InCombatLockdown() then
Nenue@5 547 print(' '..block:GetName()..' |cFF00FF00probe hit!')
Nenue@6 548 mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
Nenue@5 549 block:SetScript('OnUpdate', nil)
Nenue@5 550 end
Nenue@5 551 end)
Nenue@6 552 previousItem = itemButton
Nenue@1 553 else
Nenue@5 554 print('hidden block or unwatched quest')
Nenue@6 555 itemButton.previousItem = nil
Nenue@5 556 itemButton:Hide()
Nenue@1 557 end
Nenue@8 558 elseif itemButton:IsVisible() then
Nenue@8 559 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
Nenue@6 560 itemButton.previousItem = nil
Nenue@6 561 itemButton:Hide()
Nenue@8 562 else
Nenue@8 563 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
Nenue@1 564 end
Nenue@1 565 end
Nenue@1 566 end
Nenue@1 567
Nenue@6 568 mod.UpdateBlockAction = function (block, itemButton)
Nenue@5 569 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
Nenue@5 570 if itemButton.questID ~= block.info.questID then
Nenue@5 571 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
Nenue@6 572 -- something happened between this and last frame, go back and set new probes
Nenue@5 573 return mod.UpdateActionButtons()
Nenue@2 574 end
Nenue@2 575
Nenue@6 576 local previousItem = itemButton.previousItem
Nenue@6 577 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
Nenue@6 578 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
Nenue@6 579 local point, anchor, relative
Nenue@6 580
Nenue@6 581 if block:GetBottom() < lower_bound then
Nenue@6 582 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@1 583 if previousItem then
Nenue@6 584 print('adjusting', previousItem:GetName())
Nenue@1 585 previousItem:ClearAllPoints()
Nenue@6 586 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
Nenue@1 587 end
Nenue@1 588 itemButton:ClearAllPoints()
Nenue@6 589 itemButton.x = Wrapper:GetLeft() -4
Nenue@6 590 itemButton.y = Wrapper:GetBottom()
Nenue@6 591 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@6 592 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
Nenue@6 593
Nenue@6 594 elseif block:GetTop() > upper_bound then
Nenue@6 595 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
Nenue@6 596 itemButton:ClearAllPoints()
Nenue@6 597 if previousItem then
Nenue@6 598 print('latch onto another piece')
Nenue@6 599 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
Nenue@6 600 itemButton.x = 0
Nenue@6 601 itemButton.y = -itemButtonSpacing
Nenue@6 602 else
Nenue@6 603 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
Nenue@6 604 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@6 605 itemButton.x = Scroller:GetLeft() -4
Nenue@6 606 itemButton.y = Scroller:GetTop()
Nenue@6 607 end
Nenue@1 608 itemButton:Show()
Nenue@6 609 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
Nenue@1 610 else
Nenue@6 611 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@1 612 itemButton:ClearAllPoints()
Nenue@6 613 itemButton.x = block:GetLeft() - itemButtonSpacing
Nenue@6 614 itemButton.y = block:GetTop()
Nenue@6 615 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@1 616 end
Nenue@6 617
Nenue@6 618 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
Nenue@6 619 itemButton:Show()
Nenue@1 620 end
Nenue@1 621
Nenue@1 622 mod.UpdateItemButtonCooldown = function(button)
Nenue@1 623
Nenue@1 624 end