annotate ObjectiveFrame.lua @ 20:6bd2102d340b

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