annotate ObjectiveFrame.lua @ 1:b0447b382f36

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