Nenue@1: --- ${PACKAGE_NAME} Nenue@1: -- @file-author@ Nenue@1: -- @project-revision@ @project-hash@ Nenue@1: -- @file-revision@ @file-hash@ Nenue@1: -- Created: 3/30/2016 12:49 AM Nenue@1: local B = select(2,...).frame Nenue@10: local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') Nenue@14: local ipairs, max, min, unpack, floor, pairs, tostring, type, band = ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band Nenue@2: local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion Nenue@2: local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent Nenue@14: local Quest, Bonus, Cheevs = mod.Quest, mod.Bonus, mod.Cheevs Nenue@1: local CreateFrame = CreateFrame Nenue@1: local print = B.print('Objectives') Nenue@13: local unitLevel = 1 Nenue@1: -------------------------------------------------------------------- Nenue@1: --- Global frame layout Nenue@1: -------------------------------------------------------------------- Nenue@1: Nenue@1: --- Upvalues Nenue@2: local Wrapper = VeneerObjectiveWrapper Nenue@1: local Scroller = Wrapper.scrollArea Nenue@2: local Scroll = VeneerObjectiveScroll Nenue@1: local orderedHandlers = mod.orderedHandlers Nenue@1: local orderedNames = mod.orderedNames Nenue@1: Nenue@1: --- Temp values set during updates Nenue@1: local wrapperWidth, wrapperHeight Nenue@1: local scrollWidth, scrollHeight Nenue@1: local previousBlock Nenue@1: local currentBlock Nenue@10: --- todo: source these from config Nenue@6: local itemButtonSize, itemButtonSpacing = 36, 1 Nenue@1: local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] Nenue@1: local titleSize, textSize = 15, 15 Nenue@1: local titleOutline, textOutline = "OUTLINE", "OUTLINE" Nenue@1: local titleSpacing, textSpacing = 4, 3 Nenue@1: local textIndent = 5 Nenue@12: local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed Nenue@2: local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' Nenue@1: local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 Nenue@2: local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 Nenue@1: local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} Nenue@1: Nenue@7: Nenue@14: mod.InitializeWrapper = function() Nenue@3: Nenue@14: mod.SetBlockStyle(Scroller, 'Scroller', 'Normal') Nenue@14: mod.SetBlockStyle(Scroller, 'Scroll', 'Normal') Nenue@14: mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal') Nenue@2: Nenue@2: for i, name in ipairs(orderedNames) do Nenue@2: if not mod.orderedHandlers[i] then Nenue@2: if mod.Tracker(name, i) then Nenue@2: local handler = mod[name] Nenue@2: local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate') Nenue@14: tracker.title:SetText(handler.displayName) Nenue@10: mod.SetBlockStyle(tracker, 'Tracker', 'Normal') Nenue@2: handler.Tracker = tracker Nenue@2: mod.orderedTrackers[i] = tracker Nenue@2: mod.namedTrackers[name] = tracker Nenue@2: mod.indexedTrackers[handler] = tracker Nenue@2: print('created new tracker frames for new handler') Nenue@2: end Nenue@2: end Nenue@2: end Nenue@2: Nenue@2: Scroller:SetScrollChild(Scroll) Nenue@14: Nenue@14: mod.InitializeWrapperWidgets() Nenue@13: if B.Conf.ObjectiveTrackerMinimized then Nenue@13: Scroller_OnShow(Scroller) Nenue@13: end Nenue@2: mod.UpdateWrapperStyle() Nenue@2: end Nenue@2: Nenue@2: mod.InitializeXPTracker = function() Nenue@2: local XPBar = Wrapper.XPBar Nenue@2: if UnitLevel('player') == 100 then Nenue@2: XPBar:Hide() Nenue@2: return Nenue@2: end Nenue@2: Nenue@2: --- xp bar Nenue@6: XPBar:SetWidth(wrapperWidth - Wrapper.close:GetWidth()) Nenue@12: XPBar.statusbg:SetAllPoints(XPBar) Nenue@6: XPBar:RegisterEvent('DISABLE_XP_GAIN') Nenue@6: XPBar:RegisterEvent('ENABLE_XP_GAIN') Nenue@2: XPBar:SetScript('OnEvent', mod.UpdateXP) Nenue@6: Nenue@6: if not IsXPUserDisabled() then Nenue@6: mod.EnableXP(XPBar) Nenue@6: else Nenue@6: mod.DisableXP(XPBar) Nenue@6: end Nenue@6: Nenue@6: mod.UpdateXP(XPBar) Nenue@2: end Nenue@2: Nenue@6: mod.EnableXP = function(self) Nenue@6: self:RegisterEvent('PLAYER_XP_UPDATE') Nenue@6: self:RegisterEvent('PLAYER_LEVEL_UP') Nenue@6: self:RegisterEvent('PLAYER_UPDATE_RESTING') Nenue@12: self.statusbg:SetTexture(0,0,0,.25) Nenue@6: self:Show() Nenue@6: end Nenue@2: Nenue@6: mod.DisableXP = function(self) Nenue@6: self:UnregisterEvent('PLAYER_XP_UPDATE') Nenue@6: self:UnregisterEvent('PLAYER_LEVEL_UP') Nenue@6: self:UnregisterEvent('PLAYER_UPDATE_RESTING') Nenue@12: self.statusbg:SetTexture(0.5,0.5,0.5,0.5) Nenue@6: self:Hide() Nenue@6: end Nenue@2: Nenue@6: mod.UpdateXP = function(self, event) Nenue@6: if event == 'DISABLE_XP_GAIN' then Nenue@6: mod.DisableXP(self) Nenue@6: elseif event == 'ENABLE_XP_GAIN' then Nenue@6: mod.EnableXP(self) Nenue@2: end Nenue@2: Nenue@6: if not IsXPUserDisabled() then Nenue@6: Nenue@6: local xp = UnitXP('player') Nenue@6: local xpmax = UnitXPMax('player') Nenue@6: local rest = GetXPExhaustion() Nenue@12: self.foreground:SetWidth((xp/xpmax) * self:GetWidth()) Nenue@6: if rest then Nenue@6: self.rested:ClearAllPoints() Nenue@6: if xp == 0 then Nenue@6: self.rested:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0) Nenue@6: else Nenue@6: self.rested:SetPoint('TOPLEFT', self.fg, 'TOPRIGHT', 0, 0) Nenue@6: end Nenue@6: Nenue@6: if (xp + rest) > xpmax then Nenue@6: self.rested:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, 0) Nenue@6: else Nenue@6: self.rested:SetWidth((rest/xpmax) * self:GetWidth()) Nenue@6: end Nenue@6: self.rested:SetPoint('BOTTOM', self, 'BOTTOM') Nenue@6: self.rested:Show() Nenue@2: else Nenue@6: self.rested:Hide() Nenue@2: end Nenue@2: Nenue@6: if IsResting() then Nenue@12: self.statusbg:SetTexture(.2,.8,.2,.5) Nenue@2: else Nenue@12: self.statusbg:SetTexture(0,0,0,.25) Nenue@2: end Nenue@6: self.xpText:SetText(xp .. '/'.. xpmax .. (rest and (' ('..tostring(rest)..')') or '')) Nenue@2: end Nenue@2: end Nenue@2: Nenue@1: Nenue@2: Nenue@14: mod.UpdateTracker = function(handler) Nenue@1: local tracker = handler.Tracker Nenue@14: print('|cFFFF4400'..tracker:GetName().. '|r:Update()') Nenue@1: local blockIndex = 0 Nenue@1: local trackerHeight = headerHeight Nenue@14: Nenue@1: Nenue@10: previousBlock = tracker.title Nenue@1: local numWatched = handler.GetNumWatched() Nenue@1: local numBlocks = handler.numBlocks Nenue@9: local actualBlocks = 0 Nenue@1: for watchIndex = 1, 25 do Nenue@1: blockIndex = blockIndex + 1 Nenue@1: if watchIndex <= numWatched then Nenue@1: local info = handler:GetInfo(watchIndex) Nenue@1: if info then Nenue@1: local currentBlock = mod.UpdateTrackerBlock(handler, blockIndex, info) Nenue@1: previousBlock = currentBlock Nenue@14: print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) Nenue@1: trackerHeight = trackerHeight + currentBlock.height Nenue@1: numBlocks = max(numBlocks, watchIndex) Nenue@1: actualBlocks = actualBlocks + 1 Nenue@1: else Nenue@14: print(' |cFFFF0000Failed to draw info for index #'..watchIndex) Nenue@1: end Nenue@1: Nenue@1: elseif watchIndex <= numBlocks then Nenue@1: local used = handler.usedBlocks Nenue@1: local free = handler.freeBlocks Nenue@1: print('clean up dead quest block') Nenue@1: if used[blockIndex] then Nenue@1: used[blockIndex]:Hide() Nenue@1: used[blockIndex]:ClearAllPoints() Nenue@1: free[#free+1]= used[blockIndex] Nenue@1: used[blockIndex] = nil Nenue@1: end Nenue@1: else Nenue@14: print(' |cFFFF9900END|r @', blockIndex) Nenue@1: break -- done with quest stuff Nenue@1: end Nenue@1: end Nenue@1: handler.numWatched = numWatched Nenue@1: handler.numBlocks = numBlocks Nenue@1: handler.actualBlocks = actualBlocks Nenue@1: handler:Report() Nenue@14: Nenue@14: if numBlocks >= 1 then Nenue@14: previousBlock = nil Nenue@1: tracker.height = trackerHeight Nenue@1: else Nenue@1: tracker.height = 0 Nenue@1: end Nenue@1: Nenue@14: return tracker.numWatched, tracker.numAll Nenue@1: end Nenue@1: Nenue@14: --- Updates the selected block frame to display the given info batch Nenue@14: -- If `previousBlock` is set, it will attempt to anchor to that Nenue@14: -- @param blockNum the ordered block to be updated, not a watchIndex value Nenue@14: -- @param info the reference returned by the GetXInfo functions Nenue@14: -- REMEMBER: t.info and questData[questID] are the same table Nenue@14: mod.UpdateTrackerBlock = function (handler, blockIndex, info) Nenue@14: local print = B.print('BlockParse') Nenue@14: print(' Read list item |cFF00FFFF'..blockIndex..'|r') Nenue@14: if not blockIndex or not info then Nenue@14: return Nenue@14: end Nenue@14: local tracker = handler.Tracker Nenue@14: local t = handler:GetBlock(blockIndex) Nenue@14: t.handler = handler Nenue@14: t.info = info Nenue@14: t.mainStyle = 'Normal' Nenue@14: t.subStyle = nil Nenue@14: Nenue@14: info.blockIndex = blockIndex Nenue@14: if info.questID then handler.QuestBlock[info.questID] = t end Nenue@14: if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end Nenue@14: if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end Nenue@14: handler.BlockInfo[blockIndex] = info Nenue@14: Nenue@14: Nenue@14: t.attachmentHeight = 0 Nenue@14: --if info.isComplete then Nenue@14: --t.status:Show() Nenue@14: --t.status:SetText(info.completionText) Nenue@14: --end Nenue@14: Nenue@14: if info.numObjectives >= 1 then Nenue@14: t.attachmentHeight = textSpacing Nenue@14: t.status:Show() Nenue@14: print(' lines to build:', info.numObjectives) Nenue@14: Nenue@14: local text = '' Nenue@14: Nenue@14: mod.UpdateObjectives(t, info, text) Nenue@14: elseif info.description then Nenue@14: t.status:SetText(info.description) Nenue@14: else Nenue@14: t.status:SetText(nil) Nenue@14: end Nenue@14: t.title:SetText(info.title) Nenue@14: Nenue@14: Nenue@14: if info.specialItem and not info.itemButton then Nenue@14: print(' - |cFF00FFFFgenerating item button for info set') Nenue@14: info.itemButton = mod.SetItemButton(t, info) Nenue@14: else Nenue@14: --info.itemButton = nil Nenue@14: end Nenue@14: Nenue@14: handler.SetBlockTags(t, info) Nenue@14: Nenue@14: if previousBlock then Nenue@14: t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0) Nenue@14: t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) Nenue@14: print(' anchor to|cFF0088FF', previousBlock:GetName()) Nenue@14: end Nenue@14: Nenue@14: --- metrics are calculated in SetStyle Nenue@14: t:SetStyle('TrackerBlock', handler.name, t.mainStyle, t.subStyle) Nenue@14: t:Show() Nenue@14: Nenue@14: print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) Nenue@14: Nenue@14: Nenue@14: if Devian and Devian.InWorkspace() then Nenue@14: t.debugText:Show() Nenue@14: t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle))) Nenue@14: end Nenue@14: return t Nenue@14: end Nenue@14: Nenue@14: mod.UpdateObjectives = function(block, info, text) Nenue@14: local print = B.print('BlockLine') Nenue@14: print(' |cFF00FF00objective updates for', block:GetName()) Nenue@14: Nenue@14: local attachmentHeight = block.attachmentHeight Nenue@14: if info.description then Nenue@14: print(' -- has description text:', select('#', info.description), info.description) Nenue@14: text = info.description Nenue@14: end Nenue@14: local completionScore, completionMax = 0, 0 Nenue@14: Nenue@14: for i, line in ipairs(info.objectives) do Nenue@14: print(' |cFF88FF00objective', i) Nenue@14: block.handler.ParseObjective(line, info) Nenue@14: Nenue@14: if line.title then Nenue@14: info.title = line.title Nenue@14: line.title = nil Nenue@14: end Nenue@14: Nenue@14: Nenue@14: if line.widget then Nenue@14: line.widget:Show() Nenue@14: line.widget:SetParent(block) Nenue@14: line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight ) Nenue@14: print(' has a widget, height is', line.widget.height) Nenue@14: attachmentHeight = attachmentHeight + line.widget.height Nenue@14: completionScore = completionScore + line.progress Nenue@14: completionMax = completionMax + 2 Nenue@14: end Nenue@14: Nenue@14: if line.displayText then Nenue@14: print(' has text') Nenue@14: text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r' Nenue@14: end Nenue@14: Nenue@14: end Nenue@14: Nenue@14: block.completionScore = completionScore / completionMax Nenue@14: block.attachmentHeight = attachmentHeight Nenue@14: Nenue@14: block.status:SetText(text) Nenue@14: end Nenue@14: Nenue@14: --- Objective parsers Nenue@14: -- defines the following variables Nenue@14: -- * height - height of whatever display widget is involved in conveying the task Nenue@14: -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things Nenue@14: -- * money - boolean that determines listening for money events or not Nenue@14: -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively Nenue@14: mod.Tracker.ParseObjective = function(line, info) Nenue@14: Nenue@14: if line.finished then Nenue@14: line.progress = 2 Nenue@14: elseif line.quantity > 0 then Nenue@14: line.progress = 1 Nenue@14: else Nenue@14: line.progress = 0 Nenue@14: end Nenue@14: Nenue@14: end Nenue@14: Nenue@14: Bonus.ParseObjective = function(line, info) Nenue@14: local print = B.print('BonusLine') Nenue@14: for k,v in pairs(line) do Nenue@14: print(k, v) Nenue@14: end Nenue@14: Nenue@14: line.displayColor = 'FFFFFF' Nenue@14: if line.text and not info.title then Nenue@14: line.title = line.text Nenue@14: else Nenue@14: line.displayText = line.text Nenue@14: end Nenue@14: Nenue@14: line.progess = 0 Nenue@14: if line.objectiveType == 'progressbar' then Nenue@14: print(' |cFFFF0088==|r', line.type, line.text) Nenue@14: line.widgetType = 'ProgressBar' Nenue@14: print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) Nenue@14: line.value = GetQuestProgressBarPercent(info.questID) or 0 Nenue@14: line.maxValue = 100 Nenue@14: if line.value >= line.maxValue then Nenue@14: line.progress = 1 Nenue@14: elseif line.value > 0 then Nenue@14: line.progress = 2 Nenue@14: end Nenue@14: line.format = PERCENTAGE_STRING Nenue@14: line.widget = mod.SetWidget(line, info, 'ProgressBar', info.questID..'-'..line.index) Nenue@14: print('line.type =', line.type) Nenue@14: print(' ** qtyStr:', line.quantityString, 'qty:', line.value, 'assetID:', line.questID) Nenue@14: else Nenue@14: line.widget = nil Nenue@14: end Nenue@14: end Nenue@14: Nenue@14: Cheevs.ParseObjective = function(line, info) Nenue@14: local print = B.print('CheevsLine') Nenue@14: line.progress = 0 Nenue@14: if line.flags then Nenue@14: if band(line.flags, 0x00000001) > 0 then Nenue@14: line.format = "%d/%d" Nenue@14: line.widget = mod.SetWidget(line, info, 'ProgressBar', line.criteriaID) Nenue@14: elseif band(line.flags, 0x00000002) then Nenue@14: line.widget = nil Nenue@14: else Nenue@14: line.widget = nil Nenue@14: line.displayColor = 'FFFFFF' Nenue@14: line.displayText = line.text Nenue@14: Nenue@14: end Nenue@14: end Nenue@14: print('line.type =', line.type) Nenue@14: print(' ** qtyStr:', line.quantityString, 'qty:', line.quantity, 'assetID:', line.assetID) Nenue@14: end Nenue@14: Nenue@14: Quest.ParseObjective = function(line) Nenue@14: local print = B.print('QuestLine') Nenue@14: print(' |cFFFF0088', line.type) Nenue@14: local color = '00FFFF' Nenue@14: line.progress = 0 Nenue@14: if line.finished then Nenue@14: line.progress = 2 Nenue@14: color = 'FFFFFF' Nenue@14: elseif line.type == 'monster' then Nenue@14: color = 'FFFF00' Nenue@14: elseif line.type == 'item' then Nenue@14: color = '44DDFF' Nenue@14: elseif line.type == 'object' then Nenue@14: color = 'FF44DD' Nenue@14: end Nenue@14: line.displayColor = color Nenue@14: line.displayText = line.text Nenue@14: end Nenue@14: Nenue@14: Nenue@1: mod.Quest.numButtons = 0 Nenue@1: local usedButtons = mod.Quest.itemButtons Nenue@1: local freeButtons = mod.Quest.freeButtons Nenue@1: mod.UpdateWrapper = function() Nenue@13: unitLevel = UnitLevel('player') Nenue@14: wrapperWidth = mod.Conf.Wrapper.WrapperWidth Nenue@14: scrollWidth = mod.Conf.Wrapper.WrapperWidth Nenue@1: local wrapperBlocks = 0 Nenue@1: -- Update scroll child vertical size Nenue@1: scrollHeight = 0 Nenue@1: for i, handler in ipairs(orderedHandlers) do Nenue@1: mod.UpdateTracker(handler) Nenue@14: local tracker = handler.Tracker Nenue@1: if handler.actualBlocks >= 1 then Nenue@10: tracker:SetParent(Scroll) Nenue@1: tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight) Nenue@1: tracker:SetSize(wrapperWidth, tracker.height) Nenue@14: print('|cFF00FFFF'..tracker:GetName()..'|r h:|cFF00FF00', tracker.height, '|r y:|cFF00FF00', -scrollHeight) Nenue@1: scrollHeight = scrollHeight + tracker.height Nenue@14: tracker:Show() Nenue@14: else Nenue@14: tracker:Hide() Nenue@1: end Nenue@1: wrapperBlocks = wrapperBlocks + handler.actualBlocks Nenue@1: end Nenue@1: print('final scrollHeight:', scrollHeight) Nenue@1: Nenue@1: Nenue@1: Nenue@1: -- Update frame dimensions Nenue@1: if scrollHeight > wrapperMaxHeight then Nenue@1: print(' is larger than', wrapperMaxHeight) Nenue@1: wrapperHeight = wrapperMaxHeight Nenue@1: else Nenue@1: wrapperHeight = scrollHeight Nenue@9: B.Conf.ObjectiveScroll = 0 Nenue@1: end Nenue@1: scrollWidth = floor(scrollWidth+.5) Nenue@1: scrollHeight = floor(scrollHeight+.5) Nenue@1: wrapperWidth = floor(wrapperWidth+.5) Nenue@1: wrapperHeight = floor(wrapperHeight+.5) Nenue@1: headerHeight = floor(headerHeight+.5) Nenue@1: Nenue@1: if wrapperBlocks >= 1 then Nenue@10: for i, region in ipairs(Wrapper.headerComplex) do Nenue@2: region:Show() Nenue@2: end Nenue@1: else Nenue@10: for i, region in ipairs(Wrapper.headerComplex) do Nenue@2: region:Hide() Nenue@2: end Nenue@1: return Nenue@1: end Nenue@14: --[[wrapperHeight = scrollHeight Nenue@1: Nenue@14: print('|cFFFFFF00params:|r scroller:', scrollWidth .. ',' .. scrollHeight, 'scroll:', scrollWidth .. ',' .. scrollHeight, Nenue@14: 'wrapper:', wrapperWidth .. ',' .. wrapperHeight, Nenue@14: 'header:', headerHeight)]] Nenue@1: Nenue@14: --Scroller:SetSize(wrapperWidth, wrapperHeight) Nenue@13: Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, 0) Nenue@1: Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT') Nenue@1: Nenue@7: Nenue@1: Scroll:SetSize(scrollWidth, scrollHeight) Nenue@7: Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, B.Conf.ObjectiveScroll or 0) Nenue@1: Scroll:SetPoint('RIGHT', Scroller, 'RIGHT') Nenue@1: Nenue@1: --Scroller:UpdateScrollChildRect() Nenue@13: Wrapper:SetSize(wrapperWidth, wrapperHeight) Nenue@1: Nenue@14: --[[ update action buttons Nenue@6: print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(), Nenue@6: '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(), Nenue@6: '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(), Nenue@6: '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5) Nenue@6: ) Nenue@14: mod.UpdateActionButtons() Nenue@14: --]] Nenue@1: Nenue@1: end Nenue@1: Nenue@1: --- Queue any active item buttons for update for that frame Nenue@6: mod.UpdateActionButtons = function(updateReason) Nenue@6: Scroller.snap_upper = 0 Nenue@6: Scroller.snap_lower = 0 Nenue@6: local print = B.print('ItemButton') Nenue@6: if updateReason then Nenue@6: print = B.print('IB_'..updateReason) Nenue@6: end Nenue@6: Nenue@1: local previousItem Nenue@2: for questID, itemButton in pairs(usedButtons) do Nenue@6: local info= mod.Quest.Info[questID] Nenue@6: Nenue@5: print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) Nenue@5: local block = mod.Quest.QuestBlock[questID] Nenue@1: if block then Nenue@5: -- Dispatch the probe Nenue@6: if IsQuestWatched(info.questLogIndex) then Nenue@6: itemButton.previousItem = previousItem Nenue@5: print(' |cFFFFFF00probing', block:GetName()) Nenue@1: block:SetScript('OnUpdate', function() Nenue@5: if block:GetBottom() and not InCombatLockdown() then Nenue@5: print(' '..block:GetName()..' |cFF00FF00probe hit!') Nenue@6: mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope Nenue@5: block:SetScript('OnUpdate', nil) Nenue@5: end Nenue@5: end) Nenue@6: previousItem = itemButton Nenue@1: else Nenue@5: print('hidden block or unwatched quest') Nenue@6: itemButton.previousItem = nil Nenue@5: itemButton:Hide() Nenue@1: end Nenue@8: elseif itemButton:IsVisible() then Nenue@8: print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName()) Nenue@6: itemButton.previousItem = nil Nenue@6: itemButton:Hide() Nenue@8: else Nenue@8: print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName()) Nenue@1: end Nenue@1: end Nenue@1: end Nenue@1: Nenue@6: mod.UpdateBlockAction = function (block, itemButton) Nenue@5: print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') Nenue@5: if itemButton.questID ~= block.info.questID then Nenue@5: print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID) Nenue@6: -- something happened between this and last frame, go back and set new probes Nenue@5: return mod.UpdateActionButtons() Nenue@2: end Nenue@2: Nenue@6: local previousItem = itemButton.previousItem Nenue@6: local upper_bound = Scroller:GetTop() + Scroller.snap_upper Nenue@6: local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize Nenue@6: local point, anchor, relative Nenue@6: Nenue@6: if block:GetBottom() < lower_bound then Nenue@6: print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5)) Nenue@1: if previousItem then Nenue@6: print('adjusting', previousItem:GetName()) Nenue@1: previousItem:ClearAllPoints() Nenue@6: previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing) Nenue@1: end Nenue@1: itemButton:ClearAllPoints() Nenue@6: itemButton.x = Wrapper:GetLeft() -4 Nenue@6: itemButton.y = Wrapper:GetBottom() Nenue@6: point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT' Nenue@6: Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing Nenue@6: Nenue@6: elseif block:GetTop() > upper_bound then Nenue@6: print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5)) Nenue@6: itemButton:ClearAllPoints() Nenue@6: if previousItem then Nenue@6: print('latch onto another piece') Nenue@6: point, anchor, relative ='TOP', previousItem, 'BOTTOM' Nenue@6: itemButton.x = 0 Nenue@6: itemButton.y = -itemButtonSpacing Nenue@6: else Nenue@6: print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop()) Nenue@6: point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' Nenue@6: itemButton.x = Scroller:GetLeft() -4 Nenue@6: itemButton.y = Scroller:GetTop() Nenue@6: end Nenue@1: itemButton:Show() Nenue@6: Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing) Nenue@1: else Nenue@6: print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5)) Nenue@1: itemButton:ClearAllPoints() Nenue@6: itemButton.x = block:GetLeft() - itemButtonSpacing Nenue@6: itemButton.y = block:GetTop() Nenue@6: point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' Nenue@1: end Nenue@6: Nenue@6: itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y) Nenue@6: itemButton:Show() Nenue@1: end Nenue@1: Nenue@1: mod.UpdateItemButtonCooldown = function(button) Nenue@1: Nenue@1: end