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@19: local DefaultTracker, Quest, Bonus, Cheevs = mod.DefaultTracker, mod.Quest, mod.Bonus, mod.Cheevs Nenue@1: local CreateFrame = CreateFrame Nenue@19: local print = B.print('ObjWrapper') Nenue@13: local unitLevel = 1 Nenue@19: local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON 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@19: local band = bit.band Nenue@19: local currentPosition, anchorFrame, anchorPoint Nenue@19: function mod:Update (reason, dataID) Nenue@19: local updateWrapper = 0 Nenue@19: local hasStuff Nenue@19: local insertingStuff Nenue@19: reason = reason or OBJECTIVE_TRACKER_UPDATE_REASON Nenue@19: currentPosition = 0 Nenue@19: anchorPoint = 'TOPLEFT' Nenue@19: anchorFrame = Scroll Nenue@3: Nenue@19: local wrapperHeight = 0 Nenue@19: for id, handler in pairs(mod.orderedHandlers) do Nenue@19: local frame = handler.frame Nenue@2: Nenue@19: print(format('|cFF00FFFFbitcheck (%04X vs %04x+%04x):|r', reason, handler.updateReasonModule, handler.updateReasonEvents), band(reason, handler.updateReasonModule + handler.updateReasonEvents)) Nenue@19: if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then Nenue@19: handler:Update(reason, dataID) Nenue@19: print('|cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) Nenue@19: insertingStuff = true Nenue@19: else Nenue@19: print('|cFFFF0088'..id..'|r', 'no reason') Nenue@19: end Nenue@19: Nenue@19: if handler.numWatched >= 1 then Nenue@19: hasStuff = true Nenue@19: currentPosition = currentPosition + 1 Nenue@19: frame:SetParent(Scroll) Nenue@19: frame:SetPoint('TOPLEFT', anchorFrame, anchorPoint, 0, 0) Nenue@19: print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint) Nenue@19: anchorFrame = handler.frame Nenue@19: anchorPoint = 'BOTTOMLEFT' Nenue@19: Nenue@19: print('current frame height:', frame.height) Nenue@19: wrapperHeight = wrapperHeight + frame.height Nenue@19: print('|cFFFF0088total height:', wrapperHeight) Nenue@19: else Nenue@19: handler.frame:Hide() Nenue@2: end Nenue@2: end Nenue@2: Nenue@14: Nenue@19: if hasStuff or insertingStuff then Nenue@19: Nenue@19: print('updating height to', wrapperHeight) Nenue@19: Wrapper:SetHeight(wrapperHeight) Nenue@19: Scroller:SetHeight(wrapperHeight) Nenue@19: Scroll:SetHeight(wrapperHeight) Nenue@19: print('|cFFFF8800Wrapper:', Wrapper:GetSize()) Nenue@19: for i = 1, Wrapper:GetNumPoints() do Nenue@19: print(' ', Wrapper:GetPoint(i)) Nenue@19: end Nenue@19: print(' |cFF00FFFFScroller:', Scroller:GetSize()) Nenue@19: for i = 1, Scroller:GetNumPoints() do Nenue@19: print(' ', Scroller:GetPoint(i)) Nenue@19: end Nenue@19: print(' |cFF00FFFFScroll:', Scroll:GetSize()) Nenue@19: for i = 1, Scroll:GetNumPoints() do Nenue@19: print(' ', Scroll:GetPoint(i)) Nenue@19: end Nenue@19: Nenue@19: Wrapper:Show() Nenue@19: Scroller:Show() Nenue@19: Scroll:Show() Nenue@13: end Nenue@19: Nenue@2: end Nenue@2: Nenue@19: DefaultTracker.GetBlock = function(handler, blockIndex) Nenue@19: local block = handler.usedBlocks[blockIndex] Nenue@19: if not handler.usedBlocks[blockIndex] then Nenue@19: if #handler.freeBlocks >= 1 then Nenue@19: block = handler.freeBlocks[#handler.freeBlocks] Nenue@19: handler.freeBlocks[#handler.freeBlocks] = nil Nenue@19: else Nenue@19: block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') Nenue@19: block.SetStyle = mod.SetBlockStyle Nenue@19: block.Select = handler.Select Nenue@19: block.Open = handler.Open Nenue@19: block.Remove = handler.Remove Nenue@19: block.Link = handler.Link Nenue@19: block:SetScript('OnMouseUp', handler.OnMouseUp) Nenue@19: block:SetScript('OnMouseDown', handler.OnMouseDown) Nenue@19: block.attachmentHeight = 0 Nenue@19: block:ClearAllPoints() Nenue@19: end Nenue@19: Nenue@19: handler.usedBlocks[blockIndex] = block Nenue@2: end Nenue@19: return handler.usedBlocks[blockIndex] Nenue@2: end Nenue@2: Nenue@19: DefaultTracker.Update = function (self, reason, dataID) Nenue@19: local tracker = self.frame Nenue@14: print('|cFFFF4400'..tracker:GetName().. '|r:Update()') Nenue@1: local blockIndex = 0 Nenue@19: local trackerHeight = 0 Nenue@14: Nenue@1: Nenue@19: self.currentAnchor = tracker.titlebg Nenue@19: local numWatched = self:GetNumWatched() Nenue@19: local numBlocks = self.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@19: local info = self:GetInfo(watchIndex) Nenue@1: if info then Nenue@19: local currentBlock = self:UpdateBlock(blockIndex, info) Nenue@19: self.currentAnchor = currentBlock Nenue@14: print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) Nenue@19: print(currentBlock:IsVisible()) Nenue@19: print(currentBlock:GetPoint(1)) 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@19: local used = self.usedBlocks Nenue@19: local free = self.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@19: self.numWatched = numWatched Nenue@19: self.numBlocks = numBlocks Nenue@19: self.actualBlocks = actualBlocks Nenue@19: self:Report() Nenue@14: Nenue@19: tracker.previousHeight = tracker.height Nenue@14: if numBlocks >= 1 then Nenue@14: previousBlock = nil Nenue@19: Nenue@19: tracker.height = trackerHeight + tracker.titlebg:GetHeight() Nenue@19: tracker:SetHeight(tracker.height) Nenue@19: tracker:Show() Nenue@19: Nenue@19: print(tracker.height) Nenue@19: Nenue@1: else Nenue@1: tracker.height = 0 Nenue@19: tracker:Hide() 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@19: DefaultTracker.UpdateBlock = function (self, 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@19: local frame = self.frame Nenue@19: local t = self:GetBlock(blockIndex) Nenue@19: t.handler = self Nenue@14: t.info = info Nenue@18: t.mainStyle = info.mainStyle or 'Normal' Nenue@18: t.subStyle = info.subStyle Nenue@14: Nenue@14: info.blockIndex = blockIndex Nenue@19: if info.questID then self.QuestBlock[info.questID] = t end Nenue@19: if info.questLogIndex then self.LogBlock[info.questLogIndex] = t end Nenue@19: if info.watchIndex then self.WatchBlock[info.watchIndex] = t end Nenue@19: self.BlockInfo[blockIndex] = info Nenue@14: Nenue@14: t.attachmentHeight = 0 Nenue@19: if info.isComplete then Nenue@19: if mod.AutoQuest.Info[info.questID] then Nenue@18: t.status:SetText('(Click to Complete)') Nenue@19: t.status:Show() Nenue@18: else Nenue@18: t.status:SetText('Ready to turn in') Nenue@19: t.status:Show() Nenue@18: end Nenue@18: elseif info.completed then Nenue@18: t.status:SetText(nil) Nenue@19: t.status:Hide() Nenue@18: elseif info.numObjectives >= 1 then Nenue@16: t.attachmentHeight = 0 Nenue@14: t.status:Show() Nenue@19: print(' lines to parse:', info.numObjectives) Nenue@14: local text = '' Nenue@14: Nenue@14: mod.UpdateObjectives(t, info, text) Nenue@19: print(' |cFF00FF00attachment', t.attachmentHeight) Nenue@14: elseif info.description then Nenue@14: t.status:SetText(info.description) Nenue@19: t.status:Show() Nenue@14: else Nenue@14: t.status:SetText(nil) Nenue@19: t.status:Show() 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@19: if self.currentAnchor then Nenue@19: t:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, 0) Nenue@19: t:SetPoint('RIGHT', frame,'RIGHT', 0, 0) Nenue@19: print(' anchor to|cFF0088FF', self.currentAnchor:GetName()) Nenue@14: end Nenue@14: Nenue@16: Nenue@14: --- metrics are calculated in SetStyle Nenue@19: t:SetStyle('TrackerBlock', self.name, t.mainStyle, t.subStyle) Nenue@19: print(' |cFFFFFF00height|r', t.height) Nenue@14: t:Show() Nenue@14: Nenue@14: print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) Nenue@14: Nenue@18: local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t, 'TOPRIGHT' Nenue@16: if info.rewardInfo then Nenue@16: print('has immediate reward') Nenue@16: if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then Nenue@16: t.icon:Show() Nenue@16: t.iconLabel:SetText(info.rewardInfo[1].count) Nenue@16: t.icon:SetSize(t.height, t.height) Nenue@18: t.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) Nenue@18: tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.icon, 'TOPLEFT' Nenue@16: t.icon:SetTexture(info.rewardInfo[1].texture) Nenue@16: end Nenue@16: else Nenue@16: t.icon:Hide() Nenue@16: end Nenue@14: Nenue@18: if info.selected then Nenue@18: t.SelectionOverlay:Show() Nenue@18: else Nenue@18: t.SelectionOverlay:Hide() Nenue@18: end Nenue@18: Nenue@18: if info.frequencyTag then Nenue@18: t.FrequencyTag:SetTexCoord(unpack(info.frequencyTag)) Nenue@18: t.FrequencyTag:Show() Nenue@18: t.FrequencyTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) Nenue@18: tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.FrequencyTag, 'TOPLEFT' Nenue@18: else Nenue@18: t.FrequencyTag:Hide() Nenue@18: end Nenue@18: if info.typeTag then Nenue@18: t.TypeTag:SetTexCoord(unpack(info.typeTag)) Nenue@18: t.TypeTag:Show() Nenue@18: t.TypeTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) Nenue@18: tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.TypeTag, 'TOPLEFT' Nenue@18: else Nenue@18: t.TypeTag:Hide() Nenue@18: end Nenue@18: if info.completionTag then Nenue@18: t.CompletionTag:SetTexCoord(unpack(info.completionTag)) Nenue@18: t.CompletionTag:Show() Nenue@18: t.CompletionTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) Nenue@18: tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.CompletionTag, 'TOPLEFT' Nenue@18: else Nenue@18: t.CompletionTag:Hide() Nenue@18: end Nenue@18: Nenue@18: --[[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@18: end]] Nenue@14: return t Nenue@14: end Nenue@14: Nenue@19: Nenue@19: 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@19: print(attachmentHeight) Nenue@18: if info.description and not(info.earnedBy or info.isComplete) 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@19: print(attachmentHeight) 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: if line.widget then Nenue@16: if attachmentHeight == 0 then Nenue@19: attachmentHeight = (block.status.spacing or block.status:GetSpacing()) * 2 Nenue@19: --print(attachmentHeight) Nenue@16: end 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: end Nenue@14: Nenue@19: Nenue@19: Nenue@14: block.completionScore = completionScore / completionMax Nenue@14: block.attachmentHeight = attachmentHeight Nenue@14: Nenue@18: if #text >= 1 then Nenue@18: block.status:SetText(text) Nenue@18: block.status:SetWordWrap(true) Nenue@18: else Nenue@18: block.status:SetText(nil) Nenue@18: block.status:Hide() Nenue@18: end Nenue@18: 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@19: DefaultTracker.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@16: 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@15: line.progress = 0 Nenue@15: print(' ', line.index,'|cFFFF0088-|r', line.objectiveType, line.text) Nenue@14: if line.objectiveType == 'progressbar' then 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@15: print(' ** text:', line.text, 'value:', line.value, 'max:', line.maxValue) 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@19: --[=[ Nenue@16: mod.UpdateWrapper = function(reason) Nenue@16: print('|cFF00FFFFUpdateWrapper:|r', reason) 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@19: local frame = handler.frame Nenue@1: if handler.actualBlocks >= 1 then Nenue@19: frame:SetParent(Scroll) Nenue@19: frame:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight) Nenue@19: frame:SetSize(wrapperWidth, frame.height) Nenue@19: print('|cFF00FFFF'..frame:GetName()..'|r h:|cFF00FF00', frame.height, '|r y:|cFF00FF00', -scrollHeight) Nenue@19: scrollHeight = scrollHeight + frame.height Nenue@19: frame:Show() Nenue@14: else Nenue@19: frame: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@18: --]] Nenue@14: mod.UpdateActionButtons() Nenue@1: Nenue@1: end Nenue@19: --]=] 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 Nenue@18: Nenue@18: local unitLevel = UnitLevel('player') Nenue@18: Nenue@18: