annotate ObjectiveTracker/Widgets.lua @ 38:1f8f9cc3d956

- module integration brought up to speed with current frame management structure
author Nenue
date Thu, 21 Apr 2016 11:36:41 -0400
parents e84d645c8ab8
children 92534dc793f2
rev   line source
Nenue@28 1 local B = select(2,...).frame
Nenue@28 2 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@28 3 local print = B.print('WidgetFactory')
Nenue@28 4 local _G, UIParent = _G, UIParent
Nenue@28 5 local GetQuestLogSpecialItemInfo, IsQuestLogSpecialItemInRange, GetQuestLogSpecialItemCooldown = GetQuestLogSpecialItemInfo, IsQuestLogSpecialItemInRange, GetQuestLogSpecialItemCooldown
Nenue@28 6 local CooldownFrame_SetTimer, SetItemButtonTextureVertexColor, CreateFrame, VeneerObjectiveScroll = CooldownFrame_SetTimer, SetItemButtonTextureVertexColor, CreateFrame, VeneerObjectiveScroll
Nenue@28 7 local tremove, tContains, pairs, ipairs, setmetatable, floor = tremove, tContains, pairs, ipairs, setmetatable, floor
Nenue@28 8 local SetItemButtonTexture, SetItemButtonCount = SetItemButtonTexture, SetItemButtonCount
Nenue@28 9 local ToggleWorldMap, GetTrackedAchievements, GetTasksTable = ToggleWorldMap, GetTrackedAchievements, GetTasksTable
Nenue@28 10 -- GLOBALS: Veneer_QuestObjectiveItem_UpdateCooldown, Veneer_QuestObjectiveItem_OnUpdate
Nenue@28 11 --- frame refs
Nenue@28 12 local Wrapper = _G.VeneerObjectiveWrapper
Nenue@28 13 local Scroller = Wrapper.scrollArea
Nenue@28 14 local CloseButton = Wrapper.CloseButton
Nenue@28 15 local QuestMapButton = Wrapper.QuestMapButton
Nenue@28 16 local Scroll = _G.VeneerObjectiveScroll
Nenue@28 17 local usedButtons = T.Quest.itemButtons
Nenue@28 18 local freeButtons = T.Quest.freeButtons
Nenue@28 19
Nenue@28 20 T.buttons = {
Nenue@28 21 CloseButton = {
Nenue@28 22 closedSwatch = {
Nenue@28 23 [[Interface\Buttons\UI-Panel-QuestHideButton]],
Nenue@28 24 [[Interface\Buttons\UI-Panel-QuestHideButton]],
Nenue@28 25 0, 0.5, 0.5, 1,
Nenue@28 26 0.5, 1, 0.5, 1,
Nenue@28 27 },
Nenue@28 28 openSwatch = {
Nenue@28 29 [[Interface\Buttons\UI-Panel-QuestHideButton]],
Nenue@28 30 [[Interface\Buttons\UI-Panel-QuestHideButton]],
Nenue@28 31 0.5, 1, 0.5, 1,
Nenue@28 32 0, 0.5, 0.5, 1,
Nenue@28 33 },
Nenue@28 34 parent = 'VeneerObjectiveWrapper'
Nenue@28 35 },
Nenue@28 36 QuestMapButton = {
Nenue@28 37 closedSwatch = {
Nenue@28 38 [[Interface\QUESTFRAME\UI-QUESTMAP_BUTTON]],
Nenue@28 39 [[Interface\QUESTFRAME\UI-QUESTMAP_BUTTON]],
Nenue@28 40 0, 1, 0.5, 1,
Nenue@28 41 0, 1, 0, 0.5,
Nenue@28 42 },
Nenue@28 43 openSwatch = {
Nenue@28 44 [[Interface\QUESTFRAME\UI-QUESTMAP_BUTTON]],
Nenue@28 45 [[Interface\QUESTFRAME\UI-QUESTMAP_BUTTON]],
Nenue@28 46 0, 1, 0, 0.5,
Nenue@28 47 0, 1, 0.5, 1,
Nenue@28 48 }
Nenue@28 49 }
Nenue@28 50 }
Nenue@28 51
Nenue@28 52 local Scroller_OnShow = function()
Nenue@28 53 Wrapper.watchMoneyReasons = 0;
Nenue@28 54 --T:Update()
Nenue@28 55 --T:OnInitialize()
Nenue@28 56 for i, region in ipairs(Wrapper.headerComplex) do
Nenue@28 57 region:Show()
Nenue@28 58 end
Nenue@28 59 end
Nenue@28 60
Nenue@28 61 local Scroller_OnHide = function()
Nenue@28 62 local self = Wrapper
Nenue@28 63 Wrapper:UnregisterAllEvents()
Nenue@28 64 Wrapper:SetScript('OnEvent', nil)
Nenue@28 65 for i, region in ipairs(Wrapper.headerComplex) do
Nenue@28 66 region:Hide()
Nenue@28 67 end
Nenue@28 68 end
Nenue@28 69
Nenue@28 70 local Scroller_OnMouseWheel = function(self, delta)
Nenue@28 71 local r = Scroll:GetHeight() - Scroller:GetHeight()
Nenue@28 72 local s = B.Conf.ObjectiveScroll - delta * floor(r/5+.5)
Nenue@28 73 local from = self:GetVerticalScroll()
Nenue@28 74 print('|cFF00FF00OnMouseWheel', 'scroll =', s)
Nenue@28 75 if s >= r then
Nenue@28 76 s = r
Nenue@28 77 elseif s < 1 then
Nenue@28 78 s = 0
Nenue@28 79 end
Nenue@28 80 self:SetVerticalScroll(s)
Nenue@28 81 B.Conf.ObjectiveScroll = s
Nenue@28 82 print('|cFF00FF00OnMouseWheel', 'from = ', from, 'scroll =', s, ' range =', r, 'current =', self:GetVerticalScroll())
Nenue@28 83
Nenue@28 84 T.UpdateActionButtons('SCROLLING')
Nenue@28 85 end
Nenue@28 86
Nenue@28 87 local UpdatePanelButton = function (self, state)
Nenue@28 88 state = state or true
Nenue@28 89 local swatch = (state == true) and self.openSwatch or self.closedSwatch
Nenue@28 90 print((state ~= true) and 'closedSwatch' or 'openSwatch')
Nenue@28 91 self:SetNormalTexture(swatch[1])
Nenue@28 92 self:SetPushedTexture(swatch[2])
Nenue@28 93 if #swatch >= 6 then
Nenue@28 94 self:GetNormalTexture():SetTexCoord(swatch[3], swatch[4], swatch[5], swatch[6])
Nenue@28 95 end
Nenue@28 96 if #swatch == 10 then
Nenue@28 97 self:GetPushedTexture():SetTexCoord(swatch[7], swatch[8], swatch[9], swatch[10])
Nenue@28 98 end
Nenue@28 99
Nenue@28 100 end
Nenue@28 101
Nenue@28 102 local OnClick = {}
Nenue@28 103 OnClick.CloseButton = function(self)
Nenue@38 104 T:Enable()
Nenue@34 105 if T.Conf.enabled then
Nenue@34 106 T:Update()
Nenue@34 107 end
Nenue@34 108
Nenue@28 109 UpdatePanelButton(self, T.Conf.enabled)
Nenue@28 110 end
Nenue@28 111
Nenue@28 112 OnClick.QuestMapButton = function()
Nenue@28 113 ToggleWorldMap()
Nenue@28 114 end
Nenue@28 115
Nenue@28 116
Nenue@28 117 T.InitializeWidgets = function()
Nenue@28 118 local panelButtons = T.buttons
Nenue@28 119 --- tracker scroll
Nenue@28 120 Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel)
Nenue@28 121 Scroller:SetScript('OnShow', Scroller_OnShow)
Nenue@28 122 Scroller:SetScript('OnHide', Scroller_OnHide)
Nenue@28 123 for name, swatch in pairs(panelButtons) do
Nenue@28 124 local source = swatch and swatch or panelButtons.CloseButton
Nenue@28 125 local button = Wrapper[name]
Nenue@28 126 button.parent = swatch.parent
Nenue@28 127 button.openSwatch = source.openSwatch
Nenue@28 128 button.closedSwatch = source.closedSwatch
Nenue@28 129 if OnClick[name] then
Nenue@28 130 button:SetScript('OnClick', OnClick[name])
Nenue@28 131 end
Nenue@28 132 UpdatePanelButton(button, T.Conf.enabled)
Nenue@28 133 end
Nenue@28 134 end
Nenue@28 135
Nenue@28 136 ----------------------------------------------------------------------------------------
Nenue@28 137 --- modified version of the itemButton initializer used by Barjack's 'QuestKing 2' addon,
Nenue@28 138 --- url: http://mods.curse.com/addons/wow/questking
Nenue@28 139 ----------------------------------------------------------------------------------------
Nenue@28 140 T.SetItemButton = function(block, info)
Nenue@28 141 local itemInfo = info.specialItem
Nenue@28 142 if not itemInfo then
Nenue@28 143 return
Nenue@28 144 end
Nenue@28 145
Nenue@28 146 local itemButton
Nenue@28 147 if not info.itemButton then
Nenue@28 148 if #freeButtons >= 1 then
Nenue@28 149 print(' |cFF00FFFFfound a free button')
Nenue@28 150 itemButton = freeButtons[#freeButtons]
Nenue@28 151 freeButtons[#freeButtons] = nil
Nenue@28 152 if itemButton.block then
Nenue@28 153 itemButton.block.itemButton = nil
Nenue@28 154 itemButton.block = nil
Nenue@28 155 end
Nenue@28 156 else
Nenue@28 157 local buttonIndex = T.Quest.numButtons + #freeButtons + 1
Nenue@28 158 itemButton = CreateFrame('Button', 'VeneerQuestItemButton' .. buttonIndex, UIParent, 'VeneerItemButtonTemplate')
Nenue@28 159 itemButton.buttonIndex = buttonIndex
Nenue@28 160 itemButton:SetSize(36, 36)
Nenue@28 161 itemButton:GetNormalTexture():SetSize(36 * (5/3), 36 * (5/3))
Nenue@28 162 print(' |cFFFF4400starting new button', itemButton:GetName())
Nenue@28 163 end
Nenue@28 164 T.Quest.numButtons = T.Quest.numButtons + 1
Nenue@28 165 else
Nenue@28 166 itemButton = info.itemButton
Nenue@28 167 print(' |cFF00FF00found assigned button', itemButton:GetName())
Nenue@28 168
Nenue@28 169 end
Nenue@28 170 -- set values
Nenue@28 171
Nenue@28 172 info.itemButton = itemButton
Nenue@28 173 usedButtons[info.questID] = itemButton
Nenue@28 174 print(' |cFF8800FFassigning|r', itemButton:GetName(), 'to quest|cFF00FF00', info.questID, '|rat|cFFFFFF00', block:GetName(),'|r')
Nenue@28 175
Nenue@28 176 for k,v in pairs(usedButtons) do
Nenue@28 177 print('|cFFFF44DD'..k..'|r', v:GetName())
Nenue@28 178 end
Nenue@28 179
Nenue@28 180 itemButton:SetAttribute("type", "item")
Nenue@28 181 itemButton:SetAttribute("item", itemInfo.link)
Nenue@28 182
Nenue@28 183 itemButton.questID = info.questID
Nenue@34 184 itemButton.logIndex = info.logIndex
Nenue@28 185 itemButton.charges = itemInfo.charges
Nenue@28 186 itemButton.rangeTimer = -1
Nenue@28 187 itemButton.block = block
Nenue@28 188
Nenue@28 189 SetItemButtonTexture(itemButton, itemInfo.icon)
Nenue@28 190 SetItemButtonCount(itemButton, itemInfo.charges)
Nenue@28 191 Veneer_QuestObjectiveItem_UpdateCooldown(itemButton);
Nenue@28 192
Nenue@28 193 return itemButton
Nenue@28 194 end
Nenue@28 195 --- Clear an itemButton from the given block
Nenue@28 196 T.FreeItemButtons = function(block)
Nenue@28 197
Nenue@28 198 if block.itemButton then
Nenue@28 199 local itemButton = block.itemButton
Nenue@28 200 if itemButton.questID ~= block.info.questID then
Nenue@28 201 block.itemButton = nil
Nenue@28 202 itemButton.block = T.Quest.InfoBlock[itemButton.questID]
Nenue@28 203 else
Nenue@28 204 itemButton.block = nil
Nenue@28 205 itemButton:Hide()
Nenue@28 206
Nenue@28 207 usedButtons[itemButton.questID] = nil
Nenue@28 208 freeButtons[#freeButtons + 1] = itemButton
Nenue@28 209 T.Quest.numButtons = T.Quest.numButtons - 1
Nenue@28 210 print('|cFFFF0088released', itemButton:GetName(),'and', block:GetName())
Nenue@28 211 end
Nenue@28 212 end
Nenue@28 213 end
Nenue@28 214
Nenue@28 215 function Veneer_QuestObjectiveItem_OnUpdate (self, elapsed)
Nenue@28 216 -- Handle range indicator
Nenue@28 217 local rangeTimer = self.rangeTimer
Nenue@28 218 if (rangeTimer) then
Nenue@28 219 rangeTimer = rangeTimer - elapsed
Nenue@28 220 if (rangeTimer <= 0) then
Nenue@34 221 local link, item, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.logIndex)
Nenue@28 222 if ((not charges) or (charges ~= self.charges)) then
Nenue@28 223 T:Update()
Nenue@28 224 return
Nenue@28 225 end
Nenue@28 226
Nenue@28 227 local count = self.HotKey
Nenue@34 228 local valid = IsQuestLogSpecialItemInRange(self.logIndex)
Nenue@28 229 if (valid == 0) then
Nenue@28 230 count:Show()
Nenue@28 231 count:SetVertexColor(1.0, 0.1, 0.1)
Nenue@28 232 elseif (valid == 1) then
Nenue@28 233 count:Show()
Nenue@28 234 count:SetVertexColor(0.6, 0.6, 0.6)
Nenue@28 235 else
Nenue@28 236 count:Hide()
Nenue@28 237 end
Nenue@28 238 rangeTimer = TOOLTIP_UPDATE_TIME
Nenue@28 239 end
Nenue@28 240
Nenue@28 241 self.rangeTimer = rangeTimer
Nenue@28 242 end
Nenue@28 243 end
Nenue@28 244
Nenue@28 245 function Veneer_QuestObjectiveItem_UpdateCooldown (itemButton)
Nenue@34 246 local start, duration, enable = GetQuestLogSpecialItemCooldown(itemButton.logIndex)
Nenue@28 247 if (start) then
Nenue@28 248 CooldownFrame_SetTimer(itemButton.Cooldown, start, duration, enable)
Nenue@28 249 if (duration > 0 and enable == 0) then
Nenue@28 250 SetItemButtonTextureVertexColor(itemButton, 0.4, 0.4, 0.4)
Nenue@28 251 else
Nenue@28 252 SetItemButtonTextureVertexColor(itemButton, 1, 1, 1)
Nenue@28 253 end
Nenue@28 254 end
Nenue@28 255 end
Nenue@28 256
Nenue@28 257 -----------------------------------------
Nenue@28 258 -- Criteria frames
Nenue@28 259
Nenue@28 260 --[[
Nenue@28 261 text = description,
Nenue@28 262 type = type,
Nenue@28 263 finished = completed,
Nenue@28 264 quantity = quantity,
Nenue@28 265 requiredQuantity = requiredQuantity,
Nenue@28 266 characterName = characterName,
Nenue@28 267 flags = flags,
Nenue@28 268 assetID = assetID,
Nenue@28 269 quantityString = quantityString,
Nenue@28 270 criteriaID = criteriaID,
Nenue@28 271 ]]
Nenue@28 272 local newWidgetID = 0
Nenue@28 273 T.WidgetRegistry = {}
Nenue@28 274 local wr = T.WidgetRegistry
Nenue@28 275
Nenue@28 276 --- Get a usable widget for the given achievement criteria set.
Nenue@28 277 -- Returns a frame object with dimensioning parameters needed to size the receiving tracker block
Nenue@38 278 T.GetWidget = function(data, objectiveType, objectiveKey)
Nenue@28 279 local print = B.print('ObjectiveWidgets')
Nenue@28 280 local widgetType = objectiveType
Nenue@28 281 local widget
Nenue@28 282 if wr[widgetType] and wr[widgetType].used[objectiveKey] then
Nenue@28 283 widget = wr[widgetType].used[objectiveKey]
Nenue@28 284 print('|cFF00FF00Updating ('..objectiveKey..')', widget)
Nenue@28 285 elseif not wr[widgetType] or #wr[widgetType].free == 0 then
Nenue@38 286 widget = CreateFrame(widgetType, 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType)
Nenue@28 287 print('|cFFFF0088Creating `'..widget:GetName()..'` id', wr[widgetType].lastn)
Nenue@28 288 else
Nenue@28 289 widget = tremove(wr[widgetType].free)
Nenue@28 290 print('|cFFFFFF00Acquiring released widget', widget:GetName())
Nenue@28 291 end
Nenue@28 292
Nenue@28 293
Nenue@28 294 wr[widgetType].used[objectiveKey] = widget
Nenue@28 295 widget.objective = data
Nenue@28 296 widget.key = objectiveKey
Nenue@28 297 T.InitializeWidget(widget)
Nenue@28 298 return widget
Nenue@28 299 end
Nenue@28 300
Nenue@28 301 --- WidgetTemplate 'OnLoad'
Nenue@28 302 T.RegisterWidget = function(frame)
Nenue@28 303 local print = B.print('ObjectiveWidgets')
Nenue@28 304 local widgetType = frame.widgetType
Nenue@28 305 if not wr[frame.widgetType] then
Nenue@28 306 print('|cFFFF4400[[WidgetTemplate]]|r', widgetType)
Nenue@28 307 wr[widgetType] = { lastn = 1, free = {}, used = {}, usedIndex = {}, freeIndex = {} }
Nenue@28 308 else
Nenue@28 309 print('|cFF0088FF+ [[WidgetTemplate]]r', widgetType, wr[widgetType].lastn)
Nenue@28 310 wr[widgetType].lastn = wr[widgetType].lastn + 1
Nenue@28 311 end
Nenue@28 312 end
Nenue@28 313 --- WidgetTemplate 'OnShow'
Nenue@33 314 local wrapperWidth, textIndent
Nenue@28 315 T.InitializeWidget = setmetatable({}, {
Nenue@28 316 __call = function(t, frame)
Nenue@28 317 -- todo: config pull
Nenue@33 318 if not wrapperWidth then
Nenue@33 319 wrapperWidth = T.Conf.Wrapper.Width
Nenue@33 320 textIndent = T.Conf.Wrapper.TextIndent
Nenue@33 321 end
Nenue@28 322
Nenue@33 323 frame:SetWidth(wrapperWidth - textIndent * 2)
Nenue@28 324 frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType])
Nenue@34 325 frame:RegisterEvent('QUEST_LOG_UPDATE')
Nenue@28 326 frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE')
Nenue@28 327 frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED')
Nenue@28 328 frame:RegisterEvent('CRITERIA_UPDATE')
Nenue@28 329 frame:RegisterEvent('CRITERIA_COMPLETE')
Nenue@28 330 frame:RegisterEvent('CRITERIA_EARNED')
Nenue@28 331 t[frame.widgetType](frame)
Nenue@28 332 T.UpdateWidget[frame.widgetType](frame)
Nenue@28 333 end,
Nenue@28 334 })
Nenue@28 335
Nenue@28 336 --- WidgetTemplate 'OnEvent'
Nenue@28 337 T.UpdateWidget = setmetatable({}, {
Nenue@28 338 __call = function(t, frame)
Nenue@28 339 if not frame.widgetType then
Nenue@28 340 error('Invalid widget template, needs .widgetType')
Nenue@28 341 return
Nenue@28 342 end
Nenue@28 343
Nenue@28 344 return t[frame.widgetType](frame)
Nenue@28 345 end
Nenue@28 346 })
Nenue@28 347
Nenue@28 348 --- WidgetTemplate 'OnHide'
Nenue@28 349 T.ReleaseWidget = function(frame)
Nenue@28 350 --[[
Nenue@28 351 local print = B.print('ObjectiveWidgets')
Nenue@28 352 local reg = wr[frame.widgetType]
Nenue@28 353 if reg and reg.used[frame.key] then
Nenue@28 354 reg.used[frame.key] = nil
Nenue@28 355 frame.line = nil
Nenue@28 356 frame.info = nil
Nenue@28 357 frame:UnregisterAllEvents()
Nenue@28 358 tinsert(reg.free, frame)
Nenue@28 359 print('|cFFBBBBBBreleased from service', frame:GetName())
Nenue@28 360 end
Nenue@28 361 ]]
Nenue@28 362 end
Nenue@28 363
Nenue@28 364 --- RemoveTrackedAchievement post-hook
Nenue@28 365 T.CleanWidgets = function()
Nenue@28 366 local print = B.print('ObjectiveWidgets')
Nenue@28 367 local tracked = {GetTrackedAchievements() }
Nenue@28 368 local tasks = GetTasksTable()
Nenue@28 369 for type, reg in pairs(T.WidgetRegistry) do
Nenue@28 370 print('collecting', type)
Nenue@28 371 for key, frame in pairs(reg.used) do
Nenue@28 372 if frame.objective.cheevID then
Nenue@28 373 local id = frame.objective.cheevID
Nenue@28 374
Nenue@28 375 if id and not tContains(tracked, id) then
Nenue@28 376
Nenue@28 377 print(' untracked achievement', id, 'associated with', key, frame:GetName())
Nenue@28 378 frame:Hide()
Nenue@28 379 end
Nenue@28 380 elseif frame.objective.questID then
Nenue@28 381 -- do something for quest task
Nenue@28 382 end
Nenue@28 383 end
Nenue@28 384 end
Nenue@28 385 end
Nenue@28 386
Nenue@28 387
Nenue@28 388
Nenue@28 389 T.defaults.WidgetStyle = {
Nenue@28 390
Nenue@28 391 }
Nenue@28 392
Nenue@37 393 local progressHeight = 17
Nenue@28 394 local progressBorder = 1
Nenue@28 395 local progressFont = _G.VeneerCriteriaFontNormal
Nenue@28 396
Nenue@34 397 local lprint = B.print('Line')
Nenue@38 398 T.InitializeWidget.StatusBar = function(self)
Nenue@34 399 local print = lprint
Nenue@28 400 local c = T.Conf.Wrapper
Nenue@28 401 self.height = progressHeight + c.TextSpacing
Nenue@28 402 self.width = c.Width - c.TextSpacing
Nenue@34 403 self.value = self.value or 1
Nenue@34 404 self.maxValue = self.maxValue or 1
Nenue@28 405
Nenue@28 406 self:SetHeight(progressHeight)
Nenue@38 407 self:SetMinMaxValues(0, self.maxValue)
Nenue@38 408 self:SetValue(self.value)
Nenue@34 409
Nenue@37 410 --self.status:SetFontObject(progressFont)
Nenue@28 411 self.status:SetText(self.objective.quantityString)
Nenue@28 412 end
Nenue@28 413
Nenue@38 414 T.UpdateWidget.StatusBar = function (self)
Nenue@38 415 local value, maxValue = self.value, self.maxValue
Nenue@28 416 print('update vals:')
Nenue@38 417 for k,v in pairs(self) do
Nenue@28 418 print(k, v)
Nenue@28 419 end
Nenue@38 420 self:SetValue(self.value)
Nenue@38 421 local format = self.format or '%d/%d'
Nenue@38 422 self.status:SetFormattedText(format, value, maxValue)
Nenue@38 423 local progress = (value / maxValue)
Nenue@38 424 if progress > 0 then
Nenue@28 425 print('color:', 1-progress*2 , progress*2 - 1,0,1)
Nenue@28 426 print('width:', (self.width -progressBorder * 2) * progress)
Nenue@38 427 self:SetStatusBarColor(1-progress*2 , progress*2,0,1)
Nenue@28 428 end
Nenue@28 429 end
Nenue@28 430
Nenue@28 431
Nenue@28 432 T.InitializeWidget.Hidden = function (self)
Nenue@28 433 self.height = 0
Nenue@28 434 end
Nenue@28 435 T.UpdateWidget.Hidden = function (self)
Nenue@28 436 self.height= 0
Nenue@35 437 end
Nenue@35 438
Nenue@35 439
Nenue@35 440 --- Queue any active item buttons for update for that frame
Nenue@35 441 local iprint = B.print('ItemButton')
Nenue@35 442 local Quest = T.Quest
Nenue@35 443 local IsQuestWatched, InCombatLockdown = IsQuestWatched, InCombatLockdown
Nenue@35 444 T.UpdateActionButtons = function(updateReason)
Nenue@35 445 local print = iprint
Nenue@35 446 Scroller.snap_upper = 0
Nenue@35 447 Scroller.snap_lower = 0
Nenue@35 448 local print = B.print('ItemButton')
Nenue@35 449 if updateReason then
Nenue@35 450 print = B.print('IB_'..updateReason)
Nenue@35 451 end
Nenue@35 452
Nenue@35 453 local previousItem
Nenue@35 454 for questID, itemButton in pairs(Quest.itemButtons) do
Nenue@35 455 local info= T.Quest.Info[questID]
Nenue@35 456
Nenue@35 457 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
Nenue@35 458 local block = T.Quest.QuestBlock[questID]
Nenue@35 459 if block then
Nenue@35 460 -- Dispatch the probe
Nenue@35 461 if IsQuestWatched(info.logIndex) then
Nenue@35 462 itemButton.previousItem = previousItem
Nenue@35 463 print(' |cFFFFFF00probing', block:GetName())
Nenue@35 464 block:SetScript('OnUpdate', function()
Nenue@35 465 if block:GetBottom() and not InCombatLockdown() then
Nenue@35 466 print(' '..block:GetName()..' |cFF00FF00probe hit!')
Nenue@35 467 T.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
Nenue@35 468 block:SetScript('OnUpdate', nil)
Nenue@35 469
Nenue@35 470 end
Nenue@35 471 end)
Nenue@35 472 previousItem = itemButton
Nenue@35 473 else
Nenue@35 474 print('hidden block or unwatched quest')
Nenue@35 475 itemButton.previousItem = nil
Nenue@35 476 itemButton:Hide()
Nenue@35 477 end
Nenue@35 478 elseif itemButton:IsVisible() then
Nenue@35 479 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
Nenue@35 480 itemButton.previousItem = nil
Nenue@35 481 itemButton:Hide()
Nenue@35 482 else
Nenue@35 483 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
Nenue@35 484 end
Nenue@35 485 end
Nenue@28 486 end