annotate ObjectiveFrame.lua @ 2:a2396b03ce63

- identify action buttons by the associated QuestID instead of QuestLogIndex - deferred button placement in general to a self-destructing OnUpdate -- and defer self-destruct to a end of combat event if InCombatLockdown - tracker wrapper has an experience/reputation bar; the two elements "feel" related and it's a very simple info display
author Nenue
date Thu, 31 Mar 2016 01:38:47 -0400
parents b0447b382f36
children 3397aae1f44d
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@2 7 local ipairs, max, min, unpack, floor, pairs, tostring, type = ipairs, max, min, unpack, floor, pairs, tostring, type
Nenue@2 8 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion
Nenue@2 9 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
Nenue@1 10 local CreateFrame = CreateFrame
Nenue@1 11 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@1 12 local print = B.print('Objectives')
Nenue@1 13 --------------------------------------------------------------------
Nenue@1 14 --- Global frame layout
Nenue@1 15 --------------------------------------------------------------------
Nenue@1 16
Nenue@1 17 --- Upvalues
Nenue@2 18 local Wrapper = VeneerObjectiveWrapper
Nenue@1 19 local Scroller = Wrapper.scrollArea
Nenue@2 20 local Scroll = VeneerObjectiveScroll
Nenue@1 21 local orderedHandlers = mod.orderedHandlers
Nenue@1 22 local orderedNames = mod.orderedNames
Nenue@1 23
Nenue@1 24 --- Temp values set during updates
Nenue@1 25 local wrapperWidth, wrapperHeight
Nenue@1 26 local scrollWidth, scrollHeight
Nenue@1 27 local previousBlock
Nenue@1 28 local currentBlock
Nenue@1 29 --- todo: map these into config table when its sorted out
Nenue@1 30 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]]
Nenue@1 31 local titleSize, textSize = 15, 15
Nenue@1 32 local titleOutline, textOutline = "OUTLINE", "OUTLINE"
Nenue@1 33 local titleSpacing, textSpacing = 4, 3
Nenue@1 34 local textIndent = 5
Nenue@1 35 local wrapperMaxWidth, wrapperMaxHeight = 280, 490 -- these are the hard bounds, actual *Height variables are changed
Nenue@2 36 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
Nenue@1 37 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24
Nenue@2 38 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2
Nenue@1 39 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0}
Nenue@1 40
Nenue@2 41 --- These are mostly aesthetic choices so it lives here
Nenue@1 42 mod.defaults = {
Nenue@1 43 ObjectiveTrackerAnchor = {'BOTTOM', 'RIGHT'},
Nenue@1 44 ObjectiveTrackerParent = 'DebuffButton',
Nenue@1 45 ObjectiveTrackerSize = {250, 600},
Nenue@1 46 ObjectiveWrapperParent = '',
Nenue@2 47 WrapperStyle = {
Nenue@2 48 Header = {
Nenue@2 49 Background = {Left = [[Objective-Header]], Right = [[Objective-Header]], Tile = [[Objective-Header]]},
Nenue@2 50 BackgroundCrop = {Left = {0, 0.4, 0,1}, Right={0.6,1,0,1}, Tile = {0.4,.6,0,1,}},
Nenue@2 51 BackgroundScale = {Left = 100, Right = 100},
Nenue@2 52 Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline}
Nenue@2 53 }
Nenue@2 54 },
Nenue@2 55 ObjectiveHeaderStyle = {
Nenue@2 56 Normal = {
Nenue@2 57 Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,1}},
Nenue@2 58 Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing,
Nenue@2 59 }
Nenue@2 60 },
Nenue@1 61 ObjectiveTrackerStyle = {
Nenue@1 62 Normal = {
Nenue@1 63 Title = {
Nenue@1 64 Gradient = { MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, 0}},
Nenue@1 65 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing,
Nenue@1 66 },
Nenue@1 67 Text = {
Nenue@1 68 Gradient = { MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, 0}},
Nenue@1 69 Font = {textFont, textSize, textOutline}, Spacing = textSpacing,
Nenue@1 70 },
Nenue@1 71 },
Nenue@1 72 Super = {
Nenue@1 73 Title = {
Nenue@1 74 Gradient = { MinColor = {0, .7, .6, .8}, MaxColor = {0, .7, .6, 0.2}},
Nenue@1 75 Font = {titleFont, titleSize, titleOutline},
Nenue@1 76 Spacing = titleSpacing, BackgroundFullWidth = true
Nenue@1 77 },
Nenue@1 78 Text = {
Nenue@1 79 Gradient = { MinColor = {0, .7, .6, 0.5}, MaxColor = {0, .7, .6, 0.1} },
Nenue@1 80 Font = {textFont, textSize, textOutline}, Spacing = textSpacing,
Nenue@1 81 },
Nenue@1 82 },
Nenue@1 83 Active = {
Nenue@1 84 Title = {
Nenue@1 85 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, 1}, },
Nenue@1 86 Font = {titleFont, titleSize, titleOutline},
Nenue@1 87 Spacing = titleSpacing,
Nenue@1 88 BackgroundFullWidth = true
Nenue@1 89 },
Nenue@1 90 Text = {
Nenue@1 91 Gradient = { MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, 1}, },
Nenue@1 92 Font = {textFont, textSize, textOutline},
Nenue@1 93 Spacing = textSpacing,
Nenue@1 94 BackgroundFullWidth = true
Nenue@1 95 }
Nenue@1 96 },
Nenue@1 97 Complete = {
Nenue@1 98 Title = {
Nenue@1 99 Gradient = { MinColor = {0, 1, 0, 0.34}, MaxColor = {0, 1, 0, .17}, },
Nenue@1 100 Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing,
Nenue@1 101 BackgroundFullWidth = true
Nenue@1 102 },
Nenue@1 103 Text = {
Nenue@1 104 Gradient = { MinColor = {0, 1, 0, .25}, MaxColor = {0, 1, 0, 0.12}, },
Nenue@1 105 Font = {textFont, textSize, textOutline}, Spacing = textSpacing,
Nenue@1 106 BackgroundFullWidth = true
Nenue@1 107 }
Nenue@1 108 },
Nenue@1 109 }
Nenue@1 110 }
Nenue@1 111
Nenue@2 112 local Scroller_OnShow = function()
Nenue@2 113 Wrapper.watchMoneyReasons = 0;
Nenue@2 114 mod.UpdateWrapper()
Nenue@2 115 mod.SetEvents()
Nenue@2 116 for i, region in ipairs(Wrapper.header) do
Nenue@2 117 region:Show()
Nenue@2 118 end
Nenue@2 119 end
Nenue@2 120
Nenue@2 121 local Scroller_OnHide = function()
Nenue@2 122 local self = Wrapper
Nenue@2 123 Wrapper:UnregisterAllEvents()
Nenue@2 124 Wrapper:SetScript('OnEvent', nil)
Nenue@2 125 for i, region in ipairs(Wrapper.header) do
Nenue@2 126 region:Hide()
Nenue@2 127 end
Nenue@2 128 end
Nenue@2 129
Nenue@2 130 local Scroller_OnMouseWheel = function(self, delta)
Nenue@2 131 local r = Scroll:GetHeight() - Scroller:GetHeight()
Nenue@2 132 local s = self:GetVerticalScroll() - delta * floor(r/5+.5)
Nenue@2 133 if r == 0 then return end
Nenue@2 134 if s >= r then
Nenue@2 135 s = r
Nenue@2 136 elseif s < 1 then
Nenue@2 137 s = 0
Nenue@2 138 end
Nenue@2 139 self:SetVerticalScroll(s)
Nenue@2 140 print(s, r, self:GetVerticalScroll())
Nenue@2 141
Nenue@2 142 mod.UpdateActionButtons()
Nenue@2 143 end
Nenue@2 144
Nenue@2 145 local WrapperCloseButton_OnClick = function(self)
Nenue@2 146 if Scroller:IsVisible() then
Nenue@2 147 Scroller:Hide()
Nenue@2 148 else
Nenue@2 149 Scroller:Show()
Nenue@2 150 end
Nenue@2 151 end
Nenue@2 152
Nenue@2 153 mod.InitializeTrackers = function()
Nenue@2 154
Nenue@2 155 local c = mod.defaults.ObjectiveHeaderStyle.Normal
Nenue@2 156 local g1, g2, g3, g4 = unpack(c.Gradient.MinColor)
Nenue@2 157 local h1, h2, h3, h4 = unpack(c.Gradient.MaxColor)
Nenue@2 158
Nenue@2 159 for i, name in ipairs(orderedNames) do
Nenue@2 160 if not mod.orderedHandlers[i] then
Nenue@2 161 if mod.Tracker(name, i) then
Nenue@2 162 local handler = mod[name]
Nenue@2 163
Nenue@2 164 local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate')
Nenue@2 165 tracker.header:SetText(handler.name)
Nenue@2 166 tracker.header:SetHeight(headerHeight)
Nenue@2 167 tracker.header:SetFont(unpack(c.Font))
Nenue@2 168 tracker.header:SetTextColor(unpack(headerColor))
Nenue@2 169
Nenue@2 170 tracker.headerbg:SetGradientAlpha('HORIZONTAL', g1, g2 ,g3, g4, h1, h2, h3, h4)
Nenue@2 171 tracker.headerbg:SetHeight(headerHeight)
Nenue@2 172
Nenue@2 173 handler.Tracker = tracker
Nenue@2 174 mod.orderedTrackers[i] = tracker
Nenue@2 175 mod.namedTrackers[name] = tracker
Nenue@2 176 mod.indexedTrackers[handler] = tracker
Nenue@2 177 print('created new tracker frames for new handler')
Nenue@2 178 end
Nenue@2 179 end
Nenue@2 180 end
Nenue@2 181
Nenue@2 182 Scroller:SetScrollChild(Scroll)
Nenue@2 183 Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel)
Nenue@2 184 Scroller:SetScript('OnShow', Scroller_OnShow)
Nenue@2 185 Scroller:SetScript('OnHide', Scroller_OnHide)
Nenue@2 186 Wrapper.close:SetScript('OnClick', WrapperCloseButton_OnClick)
Nenue@2 187 Wrapper:SetPoint(unpack(wrapperPosition))
Nenue@2 188 Scroller_OnShow(Scroller)
Nenue@2 189
Nenue@2 190 mod.UpdateWrapperStyle()
Nenue@2 191 end
Nenue@2 192
Nenue@2 193 mod.InitializeXPTracker = function()
Nenue@2 194 local XPBar = Wrapper.XPBar
Nenue@2 195 if UnitLevel('player') == 100 then
Nenue@2 196 XPBar:Hide()
Nenue@2 197 return
Nenue@2 198 end
Nenue@2 199
Nenue@2 200 --- xp bar
Nenue@2 201 XPBar:Show()
Nenue@2 202 XPBar.rested:SetTexture(2,.6,1,1)
Nenue@2 203 XPBar.fg:SetTexture(.3,.1,.95,1)
Nenue@2 204 XPBar.bg:SetTexture(0,0,0,.25)
Nenue@2 205 XPBar:RegisterEvent('PLAYER_XP_UPDATE')
Nenue@2 206 XPBar:RegisterEvent('PLAYER_LEVEL_UP')
Nenue@2 207 XPBar:RegisterEvent('PLAYER_UPDATE_RESTING')
Nenue@2 208 XPBar:SetScript('OnEvent', mod.UpdateXP)
Nenue@2 209 mod.UpdateXP(Wrapper.xpBar)
Nenue@2 210 end
Nenue@2 211
Nenue@2 212 mod.UpdateXP = function()
Nenue@2 213 local XPBar = Wrapper.XPBar
Nenue@2 214 local xp = UnitXP('player')
Nenue@2 215 local xpmax = UnitXPMax('player')
Nenue@2 216 local rest = GetXPExhaustion()
Nenue@2 217
Nenue@2 218 XPBar.bg:SetAllPoints(XPBar)
Nenue@2 219 XPBar.fg:SetWidth((xp/xpmax) * XPBar:GetWidth())
Nenue@2 220
Nenue@2 221 if IsResting() then
Nenue@2 222 XPBar.bg:SetTexture(.2,.8,.2,.5)
Nenue@2 223 else
Nenue@2 224 XPBar.bg:SetTexture(0,0,0,.25)
Nenue@2 225 end
Nenue@2 226
Nenue@2 227 if rest then
Nenue@2 228 XPBar.rested:ClearAllPoints()
Nenue@2 229 if xp == 0 then
Nenue@2 230 XPBar.rested:SetPoint('LEFT', XPBar, 'LEFT', 0, 0)
Nenue@2 231 else
Nenue@2 232 XPBar.rested:SetPoint('LEFT', XPBar.fg, 'RIGHT', 0, 0)
Nenue@2 233 end
Nenue@2 234
Nenue@2 235 if (xp + rest) > xpmax then
Nenue@2 236 XPBar.rested:SetPoint('RIGHT', XPBar, 'RIGHT', 0, 0)
Nenue@2 237 else
Nenue@2 238 XPBar.rested:SetWidth((xp/xpmax) * XPBar:GetWidth())
Nenue@2 239 end
Nenue@2 240 XPBar.rested:Show()
Nenue@2 241 else
Nenue@2 242 XPBar.rested:Hide()
Nenue@2 243 end
Nenue@2 244
Nenue@2 245 XPBar.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or ''))
Nenue@2 246 end
Nenue@2 247
Nenue@2 248 mod.UpdateReputation = function(self)
Nenue@2 249 end
Nenue@1 250
Nenue@1 251 --- Argument containers
Nenue@1 252 local a1, a2, a3, a4, b1, b2, b3, b4, f1, f2, f3, w1, w2
Nenue@1 253 mod.SetBlockStyle = function(block, name)
Nenue@1 254 -- var names intended to reflect argument order
Nenue@2 255 --@debug@
Nenue@1 256 local c = mod.defaults.ObjectiveTrackerStyle[name]
Nenue@2 257 --@end-debug@
Nenue@2 258 --[===[@non-debug
Nenue@2 259 local c = mod.Conf
Nenue@2 260 --@end-non-debug]===]
Nenue@1 261 a1, a2, a3, a4 = unpack(c.Title.Gradient.MinColor)
Nenue@1 262 b1, b2, b3, b4 = unpack(c.Title.Gradient.MaxColor)
Nenue@1 263 block.titlebg:SetGradientAlpha('HORIZONTAL', a1, a2, a3, a4, b1, b2, b3, b4)
Nenue@1 264
Nenue@1 265 a1, a2, a3, a4 = unpack(c.Text.Gradient.MinColor)
Nenue@1 266 b1, b2, b3, b4 = unpack(c.Text.Gradient.MaxColor)
Nenue@1 267 block.bg:SetGradientAlpha('HORIZONTAL', a1, a2, a3, a4, b1, b2, b3, b4)
Nenue@1 268
Nenue@1 269 f1, f2, f3 = unpack(c.Title.Font)
Nenue@1 270 block.title:SetFont(f1, f2, f3)
Nenue@1 271
Nenue@1 272 f1, f2 ,f3 = unpack(c.Text.Font)
Nenue@1 273 block.objectives:SetFont(f1,f2,f3)
Nenue@1 274
Nenue@1 275 w1 = Wrapper:GetWidth()
Nenue@1 276 w2 = (c.Title.BackgroundFullWidth and w1 or block.title:GetStringWidth())
Nenue@1 277
Nenue@1 278 local titleSpacing, titleSpacing2 = c.Title.Spacing, (c.Title.Spacing * 2)
Nenue@1 279 local textSpacing, textSpacing2 = c.Text.Spacing, (c.Text.Spacing * 2)
Nenue@1 280
Nenue@1 281 if block.info.isTrivial then
Nenue@1 282 block.title:SetTextColor(0.7, 0.7, 0.7, 1)
Nenue@1 283 elseif block.info.isComplete then
Nenue@1 284 block.title:SetTextColor(1,1,1,1)
Nenue@1 285 else
Nenue@1 286 block.title:SetTextColor(0,.7,1,1)
Nenue@1 287 end
Nenue@1 288 block.title:SetSpacing(titleSpacing)
Nenue@1 289 block.objectives:SetSpacing(textSpacing)
Nenue@1 290 block.objectives:SetWordWrap(true)
Nenue@1 291
Nenue@1 292 local titleHeight, textHeight = block.title:GetStringHeight(), block.objectives:GetStringHeight()
Nenue@1 293 local blockHeight = titleHeight + titleSpacing2 + textHeight + textSpacing2
Nenue@1 294 local blockWidth = wrapperMaxWidth
Nenue@1 295
Nenue@1 296 block.titlebg:SetSize(min(w1, w2), titleHeight + titleSpacing2)
Nenue@1 297 block.bg:SetSize(w1, textHeight + textSpacing2)
Nenue@1 298 block:SetSize(blockWidth, blockHeight)
Nenue@1 299
Nenue@1 300 block.title:SetPoint('TOPLEFT', block.titlebg, 'TOPLEFT', 0, -titleSpacing)
Nenue@1 301 block.objectives:SetPoint('TOPLEFT', block.titlebg, 'BOTTOMLEFT', textIndent, -textSpacing)
Nenue@1 302
Nenue@1 303 -- store
Nenue@1 304 block.titleHeight = titleHeight
Nenue@1 305 block.textHeight = textHeight
Nenue@1 306 block.width = blockWidth
Nenue@1 307 block.height = blockHeight
Nenue@1 308
Nenue@2 309 print(' |cFF00FFFF'..block:GetName()..'|r:|cFF0088FFSetStyle|r(', blockWidth, 'x', blockHeight, '(textH', textHeight,', titleH', titleHeight, ')')
Nenue@2 310 end
Nenue@2 311
Nenue@2 312 local segments = {'Left', 'Right', 'Tile'}
Nenue@2 313 mod.UpdateWrapperStyle = function()
Nenue@2 314 local c = mod.defaults.WrapperStyle
Nenue@2 315 for _, segment in ipairs(segments) do
Nenue@2 316 Wrapper['Background'..segment]:SetAtlas(c.Header.Background[segment])
Nenue@2 317 Wrapper['Background'..segment]:SetTexCoord(unpack(c.Header.BackgroundCrop[segment]))
Nenue@2 318 if c.Header.BackgroundScale[segment] then
Nenue@2 319 Wrapper['Background'..segment]:SetWidth(c.Header.BackgroundScale[segment])
Nenue@2 320 end
Nenue@2 321 end
Nenue@1 322 end
Nenue@1 323
Nenue@1 324 --- Updates the selected block frame to display the given info batch
Nenue@1 325 -- If `previousBlock` is set, it will attempt to anchor to that
Nenue@1 326 -- @param blockNum the ordered block to be updated, not a watchIndex value
Nenue@1 327 -- @param info the reference returned by the GetXInfo functions
Nenue@1 328 -- REMEMBER: t.info and questData[questID] are the same table
Nenue@1 329 mod.UpdateTrackerBlock = function (handler, blockIndex, info)
Nenue@2 330 print(' |cFF00FFFFUpdateTrackerBlock('..blockIndex..'|r')
Nenue@1 331 if not blockIndex or not info then
Nenue@1 332 return
Nenue@1 333 end
Nenue@1 334
Nenue@1 335 local tracker = handler.Tracker
Nenue@1 336
Nenue@1 337 local t = handler:GetBlock(blockIndex)
Nenue@1 338 if previousBlock then
Nenue@1 339 if blockIndex == 1 then
Nenue@1 340 t:SetPoint('TOPLEFT', previousBlock, 'TOPLEFT', 0, -headerHeight)
Nenue@1 341 else
Nenue@1 342 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0)
Nenue@1 343 end
Nenue@1 344 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
Nenue@1 345 end
Nenue@2 346 --print(t:GetName(), t:GetSize())
Nenue@2 347 --print(t:GetPoint(1))
Nenue@1 348
Nenue@1 349 t.info = info
Nenue@1 350
Nenue@1 351 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end
Nenue@1 352 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end
Nenue@1 353
Nenue@1 354 info.blockIndex = blockIndex
Nenue@1 355 handler.BlockInfo[blockIndex] = info
Nenue@1 356 t.Select = handler.Select
Nenue@1 357 t.Open = handler.Open
Nenue@1 358 t.Remove = handler.Remove
Nenue@1 359 t.Link = handler.Link
Nenue@1 360 t:SetScript('OnMouseUp', handler.OnMouseUp)
Nenue@1 361 t:SetScript('OnMouseDown', handler.OnMouseDown)
Nenue@1 362 t.title:SetText(info.title)
Nenue@1 363
Nenue@1 364 if info.isComplete then
Nenue@1 365 t.objectives:Show()
Nenue@1 366 t.objectives:SetText(info.completionText)
Nenue@1 367 elseif info.numObjectives >= 1 then
Nenue@1 368 t.objectives:Show()
Nenue@2 369 print(' - objective lines:', info.numObjectives, 'can wrap:', t.objectives:CanWordWrap())
Nenue@1 370 local text = ''
Nenue@1 371 for o, obj in ipairs(t.info.objectives) do
Nenue@1 372 local line = obj.text
Nenue@1 373 if obj.type == 'monster' then
Nenue@1 374 line = '|cFFFFFF00' .. line .. '|r'
Nenue@1 375 elseif obj.type == 'item' then
Nenue@1 376 line = '|cFF44BBFF' .. line .. '|r'
Nenue@1 377 elseif obj.type == 'object' then
Nenue@1 378 line = '|cFFFFFFFF' .. line .. '|r'
Nenue@1 379 end
Nenue@1 380 text = text .. ((text == '') and "" or "\n") .. line
Nenue@1 381 end
Nenue@1 382 t.objectives:SetText(text)
Nenue@1 383
Nenue@1 384
Nenue@1 385 -- todo: set up a SecureActionButton template
Nenue@2 386 if info.specialItem and not info.itemButton then
Nenue@2 387 print(' - |cFF00FFFFupdate item button')
Nenue@1 388 mod.SetItemButton(t, info)
Nenue@1 389 end
Nenue@1 390
Nenue@1 391
Nenue@1 392 elseif info.description then
Nenue@1 393 t.objectives:SetText(info.description)
Nenue@1 394 t.objectives:SetWordWrap(true)
Nenue@1 395 else
Nenue@1 396 t.objectives:SetText(nil)
Nenue@1 397 end
Nenue@1 398 local style = 'Normal'
Nenue@1 399 if info.isComplete then
Nenue@1 400 style = 'Complete'
Nenue@1 401 elseif info.superTracked then
Nenue@1 402 style = 'Super'
Nenue@1 403 end
Nenue@1 404
Nenue@1 405 t:SetStyle(style)
Nenue@1 406
Nenue@1 407
Nenue@1 408 local fullheight = t:GetHeight()
Nenue@1 409 t:Show()
Nenue@2 410 print(' |cFF00FFFF)|r -> ', t, t:GetHeight(), fullheight)
Nenue@1 411 return t
Nenue@1 412 end
Nenue@1 413
Nenue@1 414 mod.UpdateTracker = function(handler)
Nenue@1 415 print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r')
Nenue@1 416 local tracker = handler.Tracker
Nenue@1 417 local blockIndex = 0
Nenue@1 418 local trackerHeight = headerHeight
Nenue@1 419 local w = 300
Nenue@1 420
Nenue@1 421 previousBlock = handler.Tracker
Nenue@1 422 local numWatched = handler.GetNumWatched()
Nenue@1 423 local numBlocks = handler.numBlocks
Nenue@1 424 local actualBlocks = handler.actualBlocks
Nenue@1 425 for watchIndex = 1, 25 do
Nenue@1 426 blockIndex = blockIndex + 1
Nenue@1 427 if watchIndex <= numWatched then
Nenue@1 428 local info = handler:GetInfo(watchIndex)
Nenue@1 429 if info then
Nenue@1 430 local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info)
Nenue@1 431 previousBlock = currentBlock
Nenue@1 432 trackerHeight = trackerHeight + currentBlock.height
Nenue@1 433 numBlocks = max(numBlocks, watchIndex)
Nenue@1 434 actualBlocks = actualBlocks + 1
Nenue@1 435 else
Nenue@1 436 print('|cFFFF0000Failed to draw info for index #'..watchIndex)
Nenue@1 437 end
Nenue@1 438
Nenue@1 439 elseif watchIndex <= numBlocks then
Nenue@1 440 local used = handler.usedBlocks
Nenue@1 441 local free = handler.freeBlocks
Nenue@1 442 print('clean up dead quest block')
Nenue@1 443 if used[blockIndex] then
Nenue@1 444 used[blockIndex]:Hide()
Nenue@1 445 used[blockIndex]:ClearAllPoints()
Nenue@1 446 free[#free+1]= used[blockIndex]
Nenue@1 447 used[blockIndex] = nil
Nenue@1 448 end
Nenue@1 449 else
Nenue@1 450 print('Stopping scan at', blockIndex)
Nenue@1 451 break -- done with quest stuff
Nenue@1 452 end
Nenue@1 453 end
Nenue@1 454 handler.numWatched = numWatched
Nenue@1 455 handler.numBlocks = numBlocks
Nenue@1 456 handler.actualBlocks = actualBlocks
Nenue@1 457 handler:Report()
Nenue@1 458 previousBlock = nil
Nenue@1 459 if numBlocks > 0 then
Nenue@1 460 tracker.height = trackerHeight
Nenue@1 461 else
Nenue@1 462 tracker.height = 0
Nenue@1 463 end
Nenue@1 464
Nenue@1 465 print('|cFF00FF88)|r ->', numBlocks, 'blocks; height', tracker.height, 'last block: ')
Nenue@1 466 end
Nenue@1 467
Nenue@1 468 mod.Quest.numButtons = 0
Nenue@1 469 local usedButtons = mod.Quest.itemButtons
Nenue@1 470 local freeButtons = mod.Quest.freeButtons
Nenue@1 471 mod.UpdateWrapper = function()
Nenue@1 472 wrapperWidth = wrapperMaxWidth
Nenue@1 473 scrollWidth = wrapperWidth
Nenue@1 474 local wrapperBlocks = 0
Nenue@1 475 -- Update scroll child vertical size
Nenue@1 476 scrollHeight = 0
Nenue@1 477 for i, handler in ipairs(orderedHandlers) do
Nenue@1 478 mod.UpdateTracker(handler)
Nenue@1 479 if handler.actualBlocks >= 1 then
Nenue@1 480 local tracker = handler.Tracker
Nenue@1 481 print('setting', handler.Tracker, 'to anchor to offset', -scrollHeight)
Nenue@1 482 tracker:SetParent(Scroll) -- this doesn't do anything that relativeTo doesn't
Nenue@1 483 tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight)
Nenue@1 484 tracker:SetSize(wrapperWidth, tracker.height)
Nenue@1 485 print('adding ', tracker.height)
Nenue@1 486 scrollHeight = scrollHeight + tracker.height
Nenue@1 487 end
Nenue@1 488 wrapperBlocks = wrapperBlocks + handler.actualBlocks
Nenue@1 489 end
Nenue@1 490 print('final scrollHeight:', scrollHeight)
Nenue@1 491
Nenue@1 492
Nenue@1 493
Nenue@1 494 -- Update frame dimensions
Nenue@1 495 if scrollHeight > wrapperMaxHeight then
Nenue@1 496 print(' is larger than', wrapperMaxHeight)
Nenue@1 497 --ScrollBar:Show()
Nenue@1 498 --scrollWidth = wrapperMaxWidth - scrollBarWidth
Nenue@1 499 wrapperHeight = wrapperMaxHeight
Nenue@1 500 -- Make ThumbTexture reflect the viewing scale (smaller for longer scroll, bigger for shorter)
Nenue@1 501 --ScrollBar:GetThumbTexture():SetHeight((wrapperMaxHeight/scrollHeight) * (wrapperMaxHeight))
Nenue@1 502 --ScrollBar:SetWidth(scrollBarWidth)
Nenue@1 503 --ScrollBar:SetPoint('TOPRIGHT', Scroller, 'TOPRIGHT', 0, 0)
Nenue@1 504 --ScrollBar:SetPoint('BOTTOMLEFT', Scroller, 'BOTTOMRIGHT', -scrollBarWidth, 0)
Nenue@1 505 --ScrollBar:SetMinMaxValues(1, scrollHeight - wrapperMaxHeight)
Nenue@1 506 else
Nenue@1 507 --ScrollBar:Hide()
Nenue@1 508 wrapperHeight = scrollHeight
Nenue@1 509 end
Nenue@1 510 scrollWidth = floor(scrollWidth+.5)
Nenue@1 511 scrollHeight = floor(scrollHeight+.5)
Nenue@1 512 wrapperWidth = floor(wrapperWidth+.5)
Nenue@1 513 wrapperHeight = floor(wrapperHeight+.5)
Nenue@1 514 headerHeight = floor(headerHeight+.5)
Nenue@1 515
Nenue@1 516 if wrapperBlocks >= 1 then
Nenue@2 517 for i, region in ipairs(Wrapper.header) do
Nenue@2 518 region:Show()
Nenue@2 519 end
Nenue@1 520 else
Nenue@2 521 for i, region in ipairs(Wrapper.header) do
Nenue@2 522 region:Hide()
Nenue@2 523 end
Nenue@1 524 return
Nenue@1 525 end
Nenue@1 526 --wrapperHeight = scrollHeight
Nenue@1 527
Nenue@1 528 print('|cFFFFFF00params:|r scroller:', scrollWidth, 'x', scrollHeight)
Nenue@1 529 print('|cFFFFFF00params:|r scroll:', scrollWidth, 'x', scrollHeight)
Nenue@1 530 print('|cFFFFFF00params:|r wrapper:', wrapperWidth, 'x', wrapperHeight)
Nenue@1 531 print('|cFFFFFF00params:|r header:', headerHeight)
Nenue@1 532
Nenue@1 533 Scroller:SetSize(wrapperWidth, wrapperHeight)
Nenue@1 534 Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, -headerHeight)
Nenue@1 535 Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT')
Nenue@1 536
Nenue@1 537 Scroll:SetSize(scrollWidth, scrollHeight)
Nenue@1 538 Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, 0)
Nenue@1 539 Scroll:SetPoint('RIGHT', Scroller, 'RIGHT')
Nenue@1 540
Nenue@1 541 --Scroller:UpdateScrollChildRect()
Nenue@1 542 Wrapper:SetSize(wrapperWidth, wrapperHeight + headerHeight)
Nenue@1 543
Nenue@1 544 -- update action buttons
Nenue@1 545
Nenue@1 546
Nenue@1 547 print('scroll size:', Scroll:GetSize())
Nenue@1 548 print('scroller size:',Scroller:GetSize())
Nenue@1 549 print('wrapper size:', Wrapper:GetSize())
Nenue@1 550 print('scroll range :', floor(Scroller:GetVerticalScrollRange()+.5))
Nenue@1 551
Nenue@1 552
Nenue@1 553 mod.UpdateActionButtons()
Nenue@1 554 end
Nenue@1 555
Nenue@1 556 --- Queue any active item buttons for update for that frame
Nenue@1 557 mod.UpdateActionButtons = function()
Nenue@1 558 local previousItem
Nenue@2 559 for questID, itemButton in pairs(usedButtons) do
Nenue@2 560 local questIndex = mod.Quest.Info[questID].questLogIndex
Nenue@1 561 print('|cFF00FFFF', questIndex, itemButton:GetName())
Nenue@1 562 local block = mod.Quest.LogBlock[questIndex]
Nenue@1 563 print(block:GetTop())
Nenue@1 564 if block then
Nenue@1 565 if IsQuestWatched(questIndex) then
Nenue@1 566 -- Dispatch the probe
Nenue@1 567 block:SetScript('OnUpdate', function()
Nenue@1 568 print('|cFFFFFF00probing', block:GetName())
Nenue@1 569 if block:GetBottom() then
Nenue@1 570 print('|cFF00FF00ding ding ding!')
Nenue@1 571 mod.UpdateBlockAction(block, itemButton, previousItem)
Nenue@1 572 block:SetScript('OnUpdate', nil)
Nenue@1 573 end
Nenue@1 574 end)
Nenue@1 575 return
Nenue@1 576 else
Nenue@2 577 mod.FreeItemButtons(block)
Nenue@1 578 end
Nenue@1 579 end
Nenue@1 580 end
Nenue@1 581 end
Nenue@1 582
Nenue@1 583 mod.UpdateBlockAction = function (block, itemButton, previousItem)
Nenue@2 584 if block.itemButton ~= itemButton then
Nenue@2 585 block.itemButton = itemButton
Nenue@2 586 end
Nenue@2 587 if itemButton.block ~= block then
Nenue@2 588 itemButton.block = block
Nenue@2 589 end
Nenue@2 590
Nenue@1 591 if block:GetBottom() < Scroller:GetBottom() then
Nenue@1 592 print('|cFFFFFF00bottom not fully visible')
Nenue@1 593 if previousItem then
Nenue@1 594 previousItem:ClearAllPoints()
Nenue@1 595 previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, 4)
Nenue@1 596 end
Nenue@1 597 itemButton:ClearAllPoints()
Nenue@1 598 itemButton:SetPoint('BOTTOMRIGHT', UIParent, 'BOTTOMLEFT', Wrapper:GetLeft(), Wrapper:GetBottom())
Nenue@1 599 itemButton:Show()
Nenue@1 600 else
Nenue@1 601 print('|cFF00FF00visible positions')
Nenue@1 602 itemButton:ClearAllPoints()
Nenue@1 603 itemButton:SetPoint('TOPRIGHT', UIParent, 'BOTTOMLEFT', block:GetLeft(), block:GetTop())
Nenue@1 604 itemButton:Show()
Nenue@1 605 end
Nenue@1 606 end
Nenue@1 607
Nenue@1 608 mod.UpdateItemButtonCooldown = function(button)
Nenue@1 609
Nenue@1 610 end