annotate ObjectiveFrame.lua @ 15:f660f1c1e0aa

Objective Widgets - determine completion by fractional value
author Nenue
date Mon, 04 Apr 2016 03:41:28 -0400
parents ed642234f017
children 880828018bf4
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@6 84 XPBar:SetWidth(wrapperWidth - Wrapper.close: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@14 246 t.attachmentHeight = textSpacing
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@14 259
Nenue@14 260
Nenue@14 261 if info.specialItem and not info.itemButton then
Nenue@14 262 print(' - |cFF00FFFFgenerating item button for info set')
Nenue@14 263 info.itemButton = mod.SetItemButton(t, info)
Nenue@14 264 else
Nenue@14 265 --info.itemButton = nil
Nenue@14 266 end
Nenue@14 267
Nenue@14 268 handler.SetBlockTags(t, info)
Nenue@14 269
Nenue@14 270 if previousBlock then
Nenue@14 271 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0)
Nenue@14 272 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
Nenue@14 273 print(' anchor to|cFF0088FF', previousBlock:GetName())
Nenue@14 274 end
Nenue@14 275
Nenue@14 276 --- metrics are calculated in SetStyle
Nenue@14 277 t:SetStyle('TrackerBlock', handler.name, t.mainStyle, t.subStyle)
Nenue@14 278 t:Show()
Nenue@14 279
Nenue@14 280 print(' |cFF00FFFF)|r -> ', t, t:GetHeight())
Nenue@14 281
Nenue@14 282
Nenue@14 283 if Devian and Devian.InWorkspace() then
Nenue@14 284 t.debugText:Show()
Nenue@14 285 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle)))
Nenue@14 286 end
Nenue@14 287 return t
Nenue@14 288 end
Nenue@14 289
Nenue@14 290 mod.UpdateObjectives = function(block, info, text)
Nenue@14 291 local print = B.print('BlockLine')
Nenue@14 292 print(' |cFF00FF00objective updates for', block:GetName())
Nenue@14 293
Nenue@14 294 local attachmentHeight = block.attachmentHeight
Nenue@14 295 if info.description then
Nenue@14 296 print(' -- has description text:', select('#', info.description), info.description)
Nenue@14 297 text = info.description
Nenue@14 298 end
Nenue@14 299 local completionScore, completionMax = 0, 0
Nenue@14 300
Nenue@14 301 for i, line in ipairs(info.objectives) do
Nenue@14 302 print(' |cFF88FF00objective', i)
Nenue@14 303 block.handler.ParseObjective(line, info)
Nenue@14 304
Nenue@14 305 if line.title then
Nenue@14 306 info.title = line.title
Nenue@14 307 line.title = nil
Nenue@14 308 end
Nenue@14 309
Nenue@14 310
Nenue@14 311 if line.widget then
Nenue@14 312 line.widget:Show()
Nenue@14 313 line.widget:SetParent(block)
Nenue@14 314 line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight )
Nenue@14 315 print(' has a widget, height is', line.widget.height)
Nenue@14 316 attachmentHeight = attachmentHeight + line.widget.height
Nenue@14 317 completionScore = completionScore + line.progress
Nenue@14 318 completionMax = completionMax + 2
Nenue@14 319 end
Nenue@14 320
Nenue@14 321 if line.displayText then
Nenue@14 322 print(' has text')
Nenue@14 323 text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r'
Nenue@14 324 end
Nenue@14 325
Nenue@14 326 end
Nenue@14 327
Nenue@14 328 block.completionScore = completionScore / completionMax
Nenue@14 329 block.attachmentHeight = attachmentHeight
Nenue@14 330
Nenue@14 331 block.status:SetText(text)
Nenue@14 332 end
Nenue@14 333
Nenue@14 334 --- Objective parsers
Nenue@14 335 -- defines the following variables
Nenue@14 336 -- * height - height of whatever display widget is involved in conveying the task
Nenue@14 337 -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things
Nenue@14 338 -- * money - boolean that determines listening for money events or not
Nenue@14 339 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively
Nenue@14 340 mod.Tracker.ParseObjective = function(line, info)
Nenue@14 341
Nenue@14 342 if line.finished then
Nenue@14 343 line.progress = 2
Nenue@14 344 elseif line.quantity > 0 then
Nenue@14 345 line.progress = 1
Nenue@14 346 else
Nenue@14 347 line.progress = 0
Nenue@14 348 end
Nenue@14 349
Nenue@14 350 end
Nenue@14 351
Nenue@14 352 Bonus.ParseObjective = function(line, info)
Nenue@14 353 local print = B.print('BonusLine')
Nenue@14 354 for k,v in pairs(line) do
Nenue@14 355 print(k, v)
Nenue@14 356 end
Nenue@14 357
Nenue@14 358 line.displayColor = 'FFFFFF'
Nenue@14 359 if line.text and not info.title then
Nenue@14 360 line.title = line.text
Nenue@14 361 else
Nenue@14 362 line.displayText = line.text
Nenue@14 363 end
Nenue@14 364
Nenue@15 365 line.progress = 0
Nenue@15 366 print(' ', line.index,'|cFFFF0088-|r', line.objectiveType, line.text)
Nenue@14 367 if line.objectiveType == 'progressbar' then
Nenue@14 368 line.widgetType = 'ProgressBar'
Nenue@14 369 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID)))
Nenue@14 370 line.value = GetQuestProgressBarPercent(info.questID) or 0
Nenue@14 371 line.maxValue = 100
Nenue@14 372 if line.value >= line.maxValue then
Nenue@14 373 line.progress = 1
Nenue@14 374 elseif line.value > 0 then
Nenue@14 375 line.progress = 2
Nenue@14 376 end
Nenue@14 377 line.format = PERCENTAGE_STRING
Nenue@14 378 line.widget = mod.SetWidget(line, info, 'ProgressBar', info.questID..'-'..line.index)
Nenue@15 379 print(' ** text:', line.text, 'value:', line.value, 'max:', line.maxValue)
Nenue@14 380 else
Nenue@14 381 line.widget = nil
Nenue@14 382 end
Nenue@14 383 end
Nenue@14 384
Nenue@14 385 Cheevs.ParseObjective = function(line, info)
Nenue@14 386 local print = B.print('CheevsLine')
Nenue@14 387 line.progress = 0
Nenue@14 388 if line.flags then
Nenue@14 389 if band(line.flags, 0x00000001) > 0 then
Nenue@14 390 line.format = "%d/%d"
Nenue@14 391 line.widget = mod.SetWidget(line, info, 'ProgressBar', line.criteriaID)
Nenue@14 392 elseif band(line.flags, 0x00000002) then
Nenue@14 393 line.widget = nil
Nenue@14 394 else
Nenue@14 395 line.widget = nil
Nenue@14 396 line.displayColor = 'FFFFFF'
Nenue@14 397 line.displayText = line.text
Nenue@14 398
Nenue@14 399 end
Nenue@14 400 end
Nenue@14 401 print('line.type =', line.type)
Nenue@14 402 print(' ** qtyStr:', line.quantityString, 'qty:', line.quantity, 'assetID:', line.assetID)
Nenue@14 403 end
Nenue@14 404
Nenue@14 405 Quest.ParseObjective = function(line)
Nenue@14 406 local print = B.print('QuestLine')
Nenue@14 407 print(' |cFFFF0088', line.type)
Nenue@14 408 local color = '00FFFF'
Nenue@14 409 line.progress = 0
Nenue@14 410 if line.finished then
Nenue@14 411 line.progress = 2
Nenue@14 412 color = 'FFFFFF'
Nenue@14 413 elseif line.type == 'monster' then
Nenue@14 414 color = 'FFFF00'
Nenue@14 415 elseif line.type == 'item' then
Nenue@14 416 color = '44DDFF'
Nenue@14 417 elseif line.type == 'object' then
Nenue@14 418 color = 'FF44DD'
Nenue@14 419 end
Nenue@14 420 line.displayColor = color
Nenue@14 421 line.displayText = line.text
Nenue@14 422 end
Nenue@14 423
Nenue@14 424
Nenue@1 425 mod.Quest.numButtons = 0
Nenue@1 426 local usedButtons = mod.Quest.itemButtons
Nenue@1 427 local freeButtons = mod.Quest.freeButtons
Nenue@1 428 mod.UpdateWrapper = function()
Nenue@13 429 unitLevel = UnitLevel('player')
Nenue@14 430 wrapperWidth = mod.Conf.Wrapper.WrapperWidth
Nenue@14 431 scrollWidth = mod.Conf.Wrapper.WrapperWidth
Nenue@1 432 local wrapperBlocks = 0
Nenue@1 433 -- Update scroll child vertical size
Nenue@1 434 scrollHeight = 0
Nenue@1 435 for i, handler in ipairs(orderedHandlers) do
Nenue@1 436 mod.UpdateTracker(handler)
Nenue@14 437 local tracker = handler.Tracker
Nenue@1 438 if handler.actualBlocks >= 1 then
Nenue@10 439 tracker:SetParent(Scroll)
Nenue@1 440 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight)
Nenue@1 441 tracker:SetSize(wrapperWidth, tracker.height)
Nenue@14 442 print('|cFF00FFFF'..tracker:GetName()..'|r h:|cFF00FF00', tracker.height, '|r y:|cFF00FF00', -scrollHeight)
Nenue@1 443 scrollHeight = scrollHeight + tracker.height
Nenue@14 444 tracker:Show()
Nenue@14 445 else
Nenue@14 446 tracker:Hide()
Nenue@1 447 end
Nenue@1 448 wrapperBlocks = wrapperBlocks + handler.actualBlocks
Nenue@1 449 end
Nenue@1 450 print('final scrollHeight:', scrollHeight)
Nenue@1 451
Nenue@1 452
Nenue@1 453
Nenue@1 454 -- Update frame dimensions
Nenue@1 455 if scrollHeight > wrapperMaxHeight then
Nenue@1 456 print(' is larger than', wrapperMaxHeight)
Nenue@1 457 wrapperHeight = wrapperMaxHeight
Nenue@1 458 else
Nenue@1 459 wrapperHeight = scrollHeight
Nenue@9 460 B.Conf.ObjectiveScroll = 0
Nenue@1 461 end
Nenue@1 462 scrollWidth = floor(scrollWidth+.5)
Nenue@1 463 scrollHeight = floor(scrollHeight+.5)
Nenue@1 464 wrapperWidth = floor(wrapperWidth+.5)
Nenue@1 465 wrapperHeight = floor(wrapperHeight+.5)
Nenue@1 466 headerHeight = floor(headerHeight+.5)
Nenue@1 467
Nenue@1 468 if wrapperBlocks >= 1 then
Nenue@10 469 for i, region in ipairs(Wrapper.headerComplex) do
Nenue@2 470 region:Show()
Nenue@2 471 end
Nenue@1 472 else
Nenue@10 473 for i, region in ipairs(Wrapper.headerComplex) do
Nenue@2 474 region:Hide()
Nenue@2 475 end
Nenue@1 476 return
Nenue@1 477 end
Nenue@14 478 --[[wrapperHeight = scrollHeight
Nenue@1 479
Nenue@14 480 print('|cFFFFFF00params:|r scroller:', scrollWidth .. ',' .. scrollHeight, 'scroll:', scrollWidth .. ',' .. scrollHeight,
Nenue@14 481 'wrapper:', wrapperWidth .. ',' .. wrapperHeight,
Nenue@14 482 'header:', headerHeight)]]
Nenue@1 483
Nenue@14 484 --Scroller:SetSize(wrapperWidth, wrapperHeight)
Nenue@13 485 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, 0)
Nenue@1 486 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT')
Nenue@1 487
Nenue@7 488
Nenue@1 489 Scroll:SetSize(scrollWidth, scrollHeight)
Nenue@7 490 Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, B.Conf.ObjectiveScroll or 0)
Nenue@1 491 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT')
Nenue@1 492
Nenue@1 493 --Scroller:UpdateScrollChildRect()
Nenue@13 494 Wrapper:SetSize(wrapperWidth, wrapperHeight)
Nenue@1 495
Nenue@14 496 --[[ update action buttons
Nenue@6 497 print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(),
Nenue@6 498 '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(),
Nenue@6 499 '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(),
Nenue@6 500 '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5)
Nenue@6 501 )
Nenue@14 502 mod.UpdateActionButtons()
Nenue@14 503 --]]
Nenue@1 504
Nenue@1 505 end
Nenue@1 506
Nenue@1 507 --- Queue any active item buttons for update for that frame
Nenue@6 508 mod.UpdateActionButtons = function(updateReason)
Nenue@6 509 Scroller.snap_upper = 0
Nenue@6 510 Scroller.snap_lower = 0
Nenue@6 511 local print = B.print('ItemButton')
Nenue@6 512 if updateReason then
Nenue@6 513 print = B.print('IB_'..updateReason)
Nenue@6 514 end
Nenue@6 515
Nenue@1 516 local previousItem
Nenue@2 517 for questID, itemButton in pairs(usedButtons) do
Nenue@6 518 local info= mod.Quest.Info[questID]
Nenue@6 519
Nenue@5 520 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
Nenue@5 521 local block = mod.Quest.QuestBlock[questID]
Nenue@1 522 if block then
Nenue@5 523 -- Dispatch the probe
Nenue@6 524 if IsQuestWatched(info.questLogIndex) then
Nenue@6 525 itemButton.previousItem = previousItem
Nenue@5 526 print(' |cFFFFFF00probing', block:GetName())
Nenue@1 527 block:SetScript('OnUpdate', function()
Nenue@5 528 if block:GetBottom() and not InCombatLockdown() then
Nenue@5 529 print(' '..block:GetName()..' |cFF00FF00probe hit!')
Nenue@6 530 mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
Nenue@5 531 block:SetScript('OnUpdate', nil)
Nenue@5 532 end
Nenue@5 533 end)
Nenue@6 534 previousItem = itemButton
Nenue@1 535 else
Nenue@5 536 print('hidden block or unwatched quest')
Nenue@6 537 itemButton.previousItem = nil
Nenue@5 538 itemButton:Hide()
Nenue@1 539 end
Nenue@8 540 elseif itemButton:IsVisible() then
Nenue@8 541 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
Nenue@6 542 itemButton.previousItem = nil
Nenue@6 543 itemButton:Hide()
Nenue@8 544 else
Nenue@8 545 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
Nenue@1 546 end
Nenue@1 547 end
Nenue@1 548 end
Nenue@1 549
Nenue@6 550 mod.UpdateBlockAction = function (block, itemButton)
Nenue@5 551 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
Nenue@5 552 if itemButton.questID ~= block.info.questID then
Nenue@5 553 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
Nenue@6 554 -- something happened between this and last frame, go back and set new probes
Nenue@5 555 return mod.UpdateActionButtons()
Nenue@2 556 end
Nenue@2 557
Nenue@6 558 local previousItem = itemButton.previousItem
Nenue@6 559 local upper_bound = Scroller:GetTop() + Scroller.snap_upper
Nenue@6 560 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
Nenue@6 561 local point, anchor, relative
Nenue@6 562
Nenue@6 563 if block:GetBottom() < lower_bound then
Nenue@6 564 print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@1 565 if previousItem then
Nenue@6 566 print('adjusting', previousItem:GetName())
Nenue@1 567 previousItem:ClearAllPoints()
Nenue@6 568 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
Nenue@1 569 end
Nenue@1 570 itemButton:ClearAllPoints()
Nenue@6 571 itemButton.x = Wrapper:GetLeft() -4
Nenue@6 572 itemButton.y = Wrapper:GetBottom()
Nenue@6 573 point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@6 574 Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
Nenue@6 575
Nenue@6 576 elseif block:GetTop() > upper_bound then
Nenue@6 577 print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
Nenue@6 578 itemButton:ClearAllPoints()
Nenue@6 579 if previousItem then
Nenue@6 580 print('latch onto another piece')
Nenue@6 581 point, anchor, relative ='TOP', previousItem, 'BOTTOM'
Nenue@6 582 itemButton.x = 0
Nenue@6 583 itemButton.y = -itemButtonSpacing
Nenue@6 584 else
Nenue@6 585 print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
Nenue@6 586 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@6 587 itemButton.x = Scroller:GetLeft() -4
Nenue@6 588 itemButton.y = Scroller:GetTop()
Nenue@6 589 end
Nenue@1 590 itemButton:Show()
Nenue@6 591 Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
Nenue@1 592 else
Nenue@6 593 print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
Nenue@1 594 itemButton:ClearAllPoints()
Nenue@6 595 itemButton.x = block:GetLeft() - itemButtonSpacing
Nenue@6 596 itemButton.y = block:GetTop()
Nenue@6 597 point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
Nenue@1 598 end
Nenue@6 599
Nenue@6 600 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
Nenue@6 601 itemButton:Show()
Nenue@1 602 end
Nenue@1 603
Nenue@1 604 mod.UpdateItemButtonCooldown = function(button)
Nenue@1 605
Nenue@1 606 end