annotate ObjectiveTracker/Widgets.lua @ 37:e84d645c8ab8

- revised the tracker update function to build its complete data list up front and use the values as points of comparison for determining possible out of place blocks, which will be iterated over afterward to remove what wasn't re-used - also entailed revising the exact role of global event handlers and function hooks, limiting their directions of communication so one doesn't end up calling the other multiple or inifinity times - schema handling polish
author Nenue
date Mon, 18 Apr 2016 07:56:23 -0400
parents 69d03f8e293e
children 1f8f9cc3d956
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@28 104 T:SetEnabled()
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@28 278 T.SetWidget = function(line, 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@28 286 widget = CreateFrame('Frame', 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType)
Nenue@28 287
Nenue@28 288 print('|cFFFF0088Creating `'..widget:GetName()..'` id', wr[widgetType].lastn)
Nenue@28 289 else
Nenue@28 290 widget = tremove(wr[widgetType].free)
Nenue@28 291 print('|cFFFFFF00Acquiring released widget', widget:GetName())
Nenue@28 292 end
Nenue@28 293
Nenue@28 294
Nenue@28 295 wr[widgetType].used[objectiveKey] = widget
Nenue@28 296 widget.line = line
Nenue@28 297 widget.objective = data
Nenue@28 298 widget.key = objectiveKey
Nenue@28 299 T.InitializeWidget(widget)
Nenue@28 300 return widget
Nenue@28 301 end
Nenue@28 302
Nenue@28 303 --- WidgetTemplate 'OnLoad'
Nenue@28 304 T.RegisterWidget = function(frame)
Nenue@28 305 local print = B.print('ObjectiveWidgets')
Nenue@28 306 local widgetType = frame.widgetType
Nenue@28 307 if not wr[frame.widgetType] then
Nenue@28 308 print('|cFFFF4400[[WidgetTemplate]]|r', widgetType)
Nenue@28 309 wr[widgetType] = { lastn = 1, free = {}, used = {}, usedIndex = {}, freeIndex = {} }
Nenue@28 310 else
Nenue@28 311 print('|cFF0088FF+ [[WidgetTemplate]]r', widgetType, wr[widgetType].lastn)
Nenue@28 312 wr[widgetType].lastn = wr[widgetType].lastn + 1
Nenue@28 313 end
Nenue@28 314 end
Nenue@28 315 --- WidgetTemplate 'OnShow'
Nenue@33 316 local wrapperWidth, textIndent
Nenue@28 317 T.InitializeWidget = setmetatable({}, {
Nenue@28 318 __call = function(t, frame)
Nenue@28 319 -- todo: config pull
Nenue@33 320 if not wrapperWidth then
Nenue@33 321 wrapperWidth = T.Conf.Wrapper.Width
Nenue@33 322 textIndent = T.Conf.Wrapper.TextIndent
Nenue@33 323 end
Nenue@28 324
Nenue@33 325 frame:SetWidth(wrapperWidth - textIndent * 2)
Nenue@28 326 frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType])
Nenue@34 327 frame:RegisterEvent('QUEST_LOG_UPDATE')
Nenue@28 328 frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE')
Nenue@28 329 frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED')
Nenue@28 330 frame:RegisterEvent('CRITERIA_UPDATE')
Nenue@28 331 frame:RegisterEvent('CRITERIA_COMPLETE')
Nenue@28 332 frame:RegisterEvent('CRITERIA_EARNED')
Nenue@28 333 t[frame.widgetType](frame)
Nenue@28 334 T.UpdateWidget[frame.widgetType](frame)
Nenue@28 335 end,
Nenue@28 336 })
Nenue@28 337
Nenue@28 338 --- WidgetTemplate 'OnEvent'
Nenue@28 339 T.UpdateWidget = setmetatable({}, {
Nenue@28 340 __call = function(t, frame)
Nenue@28 341 if not frame.widgetType then
Nenue@28 342 error('Invalid widget template, needs .widgetType')
Nenue@28 343 return
Nenue@28 344 end
Nenue@28 345
Nenue@28 346 return t[frame.widgetType](frame)
Nenue@28 347 end
Nenue@28 348 })
Nenue@28 349
Nenue@28 350 --- WidgetTemplate 'OnHide'
Nenue@28 351 T.ReleaseWidget = function(frame)
Nenue@28 352 --[[
Nenue@28 353 local print = B.print('ObjectiveWidgets')
Nenue@28 354 local reg = wr[frame.widgetType]
Nenue@28 355 if reg and reg.used[frame.key] then
Nenue@28 356 reg.used[frame.key] = nil
Nenue@28 357 frame.line = nil
Nenue@28 358 frame.info = nil
Nenue@28 359 frame:UnregisterAllEvents()
Nenue@28 360 tinsert(reg.free, frame)
Nenue@28 361 print('|cFFBBBBBBreleased from service', frame:GetName())
Nenue@28 362 end
Nenue@28 363 ]]
Nenue@28 364 end
Nenue@28 365
Nenue@28 366 --- RemoveTrackedAchievement post-hook
Nenue@28 367 T.CleanWidgets = function()
Nenue@28 368 local print = B.print('ObjectiveWidgets')
Nenue@28 369 local tracked = {GetTrackedAchievements() }
Nenue@28 370 local tasks = GetTasksTable()
Nenue@28 371 for type, reg in pairs(T.WidgetRegistry) do
Nenue@28 372 print('collecting', type)
Nenue@28 373 for key, frame in pairs(reg.used) do
Nenue@28 374 if frame.objective.cheevID then
Nenue@28 375 local id = frame.objective.cheevID
Nenue@28 376
Nenue@28 377 if id and not tContains(tracked, id) then
Nenue@28 378
Nenue@28 379 print(' untracked achievement', id, 'associated with', key, frame:GetName())
Nenue@28 380 frame:Hide()
Nenue@28 381 end
Nenue@28 382 elseif frame.objective.questID then
Nenue@28 383 -- do something for quest task
Nenue@28 384 end
Nenue@28 385 end
Nenue@28 386 end
Nenue@28 387 end
Nenue@28 388
Nenue@28 389
Nenue@28 390
Nenue@28 391 T.defaults.WidgetStyle = {
Nenue@28 392
Nenue@28 393 }
Nenue@28 394
Nenue@37 395 local progressHeight = 17
Nenue@28 396 local progressBorder = 1
Nenue@28 397 local progressFont = _G.VeneerCriteriaFontNormal
Nenue@28 398
Nenue@34 399 local lprint = B.print('Line')
Nenue@28 400 T.InitializeWidget.ProgressBar = function(self)
Nenue@34 401 local print = lprint
Nenue@28 402 local c = T.Conf.Wrapper
Nenue@28 403 self.height = progressHeight + c.TextSpacing
Nenue@28 404 self.width = c.Width - c.TextSpacing
Nenue@34 405 self.value = self.value or 1
Nenue@34 406 self.maxValue = self.maxValue or 1
Nenue@28 407
Nenue@28 408 self:SetHeight(progressHeight)
Nenue@28 409 self.bg:SetHeight(progressHeight)
Nenue@28 410 self.bg:SetWidth(self.width)
Nenue@28 411 self.fg:ClearAllPoints()
Nenue@28 412 self.fg:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', progressBorder, progressBorder)
Nenue@28 413 self.fg:SetHeight(progressHeight - progressBorder * 2)
Nenue@34 414
Nenue@37 415 --self.status:SetFontObject(progressFont)
Nenue@28 416 self.status:SetText(self.objective.quantityString)
Nenue@28 417 end
Nenue@28 418
Nenue@28 419 T.UpdateWidget.ProgressBar = function (self)
Nenue@33 420 local quantity, requiredQuantity = self.value, self.maxValue
Nenue@28 421 print('update vals:')
Nenue@28 422 for k,v in pairs(self.line) do
Nenue@28 423 print(k, v)
Nenue@28 424 end
Nenue@28 425
Nenue@28 426 local progress = (quantity / requiredQuantity)
Nenue@28 427 if progress >= 1 then
Nenue@28 428 self.fg:Show()
Nenue@28 429 self.fg:SetWidth(self.width - progressBorder * 2)
Nenue@28 430 elseif progress > 0 then
Nenue@28 431 self.fg:Show()
Nenue@28 432 print('color:', 1-progress*2 , progress*2 - 1,0,1)
Nenue@28 433 print('width:', (self.width -progressBorder * 2) * progress)
Nenue@28 434 self.fg:SetTexture(1-progress*2 , progress*2,0,1)
Nenue@28 435 self.fg:SetWidth((self.width -progressBorder * 2) * progress)
Nenue@28 436 else
Nenue@28 437 self.fg:Hide()
Nenue@28 438 end
Nenue@28 439 end
Nenue@28 440
Nenue@28 441
Nenue@28 442 T.InitializeWidget.Hidden = function (self)
Nenue@28 443 self.height = 0
Nenue@28 444 end
Nenue@28 445 T.UpdateWidget.Hidden = function (self)
Nenue@28 446 self.height= 0
Nenue@35 447 end
Nenue@35 448
Nenue@35 449
Nenue@35 450 --- Queue any active item buttons for update for that frame
Nenue@35 451 local iprint = B.print('ItemButton')
Nenue@35 452 local Quest = T.Quest
Nenue@35 453 local IsQuestWatched, InCombatLockdown = IsQuestWatched, InCombatLockdown
Nenue@35 454 T.UpdateActionButtons = function(updateReason)
Nenue@35 455 local print = iprint
Nenue@35 456 Scroller.snap_upper = 0
Nenue@35 457 Scroller.snap_lower = 0
Nenue@35 458 local print = B.print('ItemButton')
Nenue@35 459 if updateReason then
Nenue@35 460 print = B.print('IB_'..updateReason)
Nenue@35 461 end
Nenue@35 462
Nenue@35 463 local previousItem
Nenue@35 464 for questID, itemButton in pairs(Quest.itemButtons) do
Nenue@35 465 local info= T.Quest.Info[questID]
Nenue@35 466
Nenue@35 467 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
Nenue@35 468 local block = T.Quest.QuestBlock[questID]
Nenue@35 469 if block then
Nenue@35 470 -- Dispatch the probe
Nenue@35 471 if IsQuestWatched(info.logIndex) then
Nenue@35 472 itemButton.previousItem = previousItem
Nenue@35 473 print(' |cFFFFFF00probing', block:GetName())
Nenue@35 474 block:SetScript('OnUpdate', function()
Nenue@35 475 if block:GetBottom() and not InCombatLockdown() then
Nenue@35 476 print(' '..block:GetName()..' |cFF00FF00probe hit!')
Nenue@35 477 T.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
Nenue@35 478 block:SetScript('OnUpdate', nil)
Nenue@35 479
Nenue@35 480 end
Nenue@35 481 end)
Nenue@35 482 previousItem = itemButton
Nenue@35 483 else
Nenue@35 484 print('hidden block or unwatched quest')
Nenue@35 485 itemButton.previousItem = nil
Nenue@35 486 itemButton:Hide()
Nenue@35 487 end
Nenue@35 488 elseif itemButton:IsVisible() then
Nenue@35 489 print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
Nenue@35 490 itemButton.previousItem = nil
Nenue@35 491 itemButton:Hide()
Nenue@35 492 else
Nenue@35 493 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
Nenue@35 494 end
Nenue@35 495 end
Nenue@28 496 end