annotate ObjectiveFrame.lua @ 18:d1812fb10ae6

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