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@2: local ipairs, max, min, unpack, floor, pairs, tostring, type = ipairs, max, min, unpack, floor, pairs, tostring, type Nenue@2: local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion Nenue@2: local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent 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@2: --- These are mostly aesthetic choices so it lives here Nenue@7: Nenue@3: Nenue@2: local Scroller_OnShow = function() Nenue@2: Wrapper.watchMoneyReasons = 0; Nenue@2: mod.UpdateWrapper() Nenue@2: mod.SetEvents() Nenue@10: for i, region in ipairs(Wrapper.headerComplex) do Nenue@2: region:Show() Nenue@2: end Nenue@2: end Nenue@2: Nenue@2: local Scroller_OnHide = function() Nenue@2: local self = Wrapper Nenue@2: Wrapper:UnregisterAllEvents() Nenue@2: Wrapper:SetScript('OnEvent', nil) Nenue@10: for i, region in ipairs(Wrapper.headerComplex) do Nenue@2: region:Hide() Nenue@2: end Nenue@2: end Nenue@2: Nenue@2: local Scroller_OnMouseWheel = function(self, delta) Nenue@2: local r = Scroll:GetHeight() - Scroller:GetHeight() Nenue@7: local s = B.Conf.ObjectiveScroll - delta * floor(r/5+.5) Nenue@7: local from = self:GetVerticalScroll() Nenue@2: if s >= r then Nenue@2: s = r Nenue@2: elseif s < 1 then Nenue@2: s = 0 Nenue@2: end Nenue@2: self:SetVerticalScroll(s) Nenue@7: B.Conf.ObjectiveScroll = s Nenue@7: print('|cFF00FF00OnMouseWheel', 'from = ', from, 'scroll =', s, ' range =', r, 'current =', self:GetVerticalScroll()) Nenue@2: Nenue@6: mod.UpdateActionButtons('SCROLLING') Nenue@2: end Nenue@2: Nenue@2: local WrapperCloseButton_OnClick = function(self) Nenue@13: Wrapper:Minimize() Nenue@13: if B.Conf.FrameState[Wrapper:GetName()] == 1 then Nenue@13: self:GetNormalTexture():SetTexture([[Interface\PaperDollInfoFrame\UI-Character-SkillsPageDown-Up]]) Nenue@13: self:GetPushedTexture():SetTexture([[Interface\PaperDollInfoFrame\UI-Character-SkillsPageDown-Down]]) Nenue@2: else Nenue@13: self:GetNormalTexture():SetTexture([[Interface\PaperDollInfoFrame\UI-Character-SkillsPageUp-Up]]) Nenue@13: self:GetPushedTexture():SetTexture([[Interface\PaperDollInfoFrame\UI-Character-SkillsPageUp-Down]]) Nenue@2: end Nenue@2: end Nenue@13: local WrapperCloseButton_OnMouseWheel = function(self, delta) Nenue@13: end Nenue@2: Nenue@2: mod.InitializeTrackers = function() Nenue@2: 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: Nenue@2: local tracker = CreateFrame('Frame', 'Veneer'..name..'Tracker', Scroll, 'VeneerTrackerTemplate') Nenue@10: tracker.title:SetText(name) Nenue@10: mod.SetBlockStyle(tracker, 'Tracker', 'Normal') Nenue@2: 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@10: Nenue@10: Nenue@2: end Nenue@2: end Nenue@2: end Nenue@2: Nenue@2: Scroller:SetScrollChild(Scroll) Nenue@2: Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel) Nenue@2: Scroller:SetScript('OnShow', Scroller_OnShow) Nenue@2: Scroller:SetScript('OnHide', Scroller_OnHide) Nenue@2: Wrapper.close:SetScript('OnClick', WrapperCloseButton_OnClick) Nenue@13: Wrapper.close:SetScript('OnMouseWheel', WrapperCloseButton_OnMouseWheel) Nenue@2: Wrapper:SetPoint(unpack(wrapperPosition)) 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@2: local segments = {'Left', 'Right', 'Tile'} Nenue@2: mod.UpdateWrapperStyle = function() Nenue@10: --[[for _, segment in ipairs(segments) do Nenue@10: local texture, a1, a2, a3, a4, width = unpack(mod.defaults.Style.Wrapper.BackgroundComplex[segment]) Nenue@10: Wrapper['Background'..segment]:SetAtlas(texture) Nenue@10: Wrapper['Background'..segment]:SetTexCoord(a1, a2, a3, a4) Nenue@10: if width then Nenue@10: Wrapper['Background'..segment]:SetWidth(width) Nenue@2: end Nenue@10: end]] Nenue@1: end Nenue@1: Nenue@1: --- Updates the selected block frame to display the given info batch Nenue@1: -- If `previousBlock` is set, it will attempt to anchor to that Nenue@1: -- @param blockNum the ordered block to be updated, not a watchIndex value Nenue@1: -- @param info the reference returned by the GetXInfo functions Nenue@1: -- REMEMBER: t.info and questData[questID] are the same table Nenue@1: mod.UpdateTrackerBlock = function (handler, blockIndex, info) Nenue@10: local print = B.print('ObjectiveBlockParse') Nenue@2: print(' |cFF00FFFFUpdateTrackerBlock('..blockIndex..'|r') Nenue@1: if not blockIndex or not info then Nenue@1: return Nenue@1: end Nenue@1: Nenue@10: local mainStyle = 'Normal' Nenue@10: local subStyle Nenue@1: local tracker = handler.Tracker Nenue@1: Nenue@1: local t = handler:GetBlock(blockIndex) Nenue@1: if previousBlock then Nenue@10: t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0) Nenue@1: t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) Nenue@1: end Nenue@2: --print(t:GetName(), t:GetSize()) Nenue@2: --print(t:GetPoint(1)) Nenue@1: Nenue@1: t.info = info Nenue@1: Nenue@5: if info.questID then handler.QuestBlock[info.questID] = t end Nenue@1: if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end Nenue@1: if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end Nenue@1: Nenue@1: info.blockIndex = blockIndex Nenue@1: handler.BlockInfo[blockIndex] = info Nenue@7: Nenue@1: t.Select = handler.Select Nenue@1: t.Open = handler.Open Nenue@1: t.Remove = handler.Remove Nenue@1: t.Link = handler.Link Nenue@1: t:SetScript('OnMouseUp', handler.OnMouseUp) Nenue@1: t:SetScript('OnMouseDown', handler.OnMouseDown) Nenue@1: t.title:SetText(info.title) Nenue@1: Nenue@7: t.attachmentHeight = 0 Nenue@1: if info.isComplete then Nenue@10: t.status:Show() Nenue@10: t.status:SetText(info.completionText) Nenue@1: elseif info.numObjectives >= 1 then Nenue@7: t.attachmentHeight = textSpacing Nenue@10: t.status:Show() Nenue@10: print(' - objective lines:', info.numObjectives, 'can wrap:', t.status:CanWordWrap()) Nenue@3: Nenue@1: local text = '' Nenue@3: Nenue@3: --- todo: implement objective displays Nenue@3: -- in an accumulator loop, call upon handler for the appropriate display frame, each defining: Nenue@10: -- * height - height of whatever display widget is involved in conveying the task Nenue@10: -- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things Nenue@10: -- * money - boolean that determines listening for money events or not Nenue@10: -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively Nenue@10: text = mod.UpdateObjectives(t, info, text) Nenue@3: Nenue@10: t.status:SetText(text) Nenue@10: t.status:SetWordWrap(true) Nenue@1: Nenue@1: elseif info.description then Nenue@10: t.status:SetText(info.description) Nenue@10: t.status:SetWordWrap(true) Nenue@1: else Nenue@10: t.status:SetText(nil) Nenue@1: end Nenue@10: Nenue@1: if info.isComplete then Nenue@10: mainStyle = 'Complete' Nenue@10: end Nenue@10: if info.superTracked then Nenue@10: subStyle = 'Super' Nenue@13: elseif info.isDaily then Nenue@13: subStyle = 'Daily' Nenue@1: end Nenue@1: Nenue@5: if info.specialItem and not info.itemButton then Nenue@5: print(' - |cFF00FFFFgenerating item button for info set') Nenue@4: info.itemButton = mod.SetItemButton(t, info) Nenue@4: else Nenue@4: --info.itemButton = nil Nenue@4: end Nenue@4: Nenue@13: if info.level then Nenue@13: local levelDiff = unitLevel - info.level Nenue@13: if levelDiff > 9 then Nenue@13: t.title:SetTextColor(0.7, 0.7, 0.7, 1) Nenue@13: elseif levelDiff > 1 then Nenue@13: t.title:SetTextColor(0.5, 1, 0.5, 1) Nenue@13: elseif levelDiff < -1 then Nenue@13: t.title:SetTextColor(1, 0.4, 0.25, 1) Nenue@13: elseif levelDiff < -4 then Nenue@13: t.title:SetTextColor(1, 0, 0, 1) Nenue@13: else Nenue@13: t.title:SetTextColor(1,1,1,1) Nenue@13: end Nenue@13: end Nenue@13: Nenue@13: Nenue@6: if Devian and Devian.InWorkspace() then Nenue@6: t.debugText:Show() Nenue@13: t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (info.level and info.level or '-')) Nenue@6: end Nenue@6: Nenue@3: --- metrics are calculated in SetStyle Nenue@10: t:SetStyle('TrackerBlock', handler.name, mainStyle, subStyle) Nenue@3: t:Show() Nenue@1: Nenue@3: print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) Nenue@1: return t Nenue@1: end Nenue@1: Nenue@4: mod.UpdateObjectives = function(block, info, text) Nenue@10: local print = B.print('ObjectiveBlockParse') Nenue@10: Nenue@7: local attachmentHeight = block.attachmentHeight Nenue@7: if info.description then Nenue@7: print(' -- has description text:', select('#', info.description), info.description) Nenue@7: text = info.description Nenue@7: end Nenue@10: local completionScore, completionMax = 0, 0 Nenue@4: for o, obj in ipairs(info.objectives) do Nenue@4: --- achievement criteria Nenue@4: if obj.flags then Nenue@4: Nenue@4: Nenue@4: if bit.band(obj.flags, 0x00000001) > 0 then Nenue@4: obj.type = 'ProgressBar' Nenue@4: elseif bit.band(obj.flags, 0x00000002) then Nenue@4: obj.type = 'Hidden' Nenue@4: obj.widget = nil Nenue@4: else Nenue@4: obj.type = 'Text' Nenue@4: obj.widget = nil Nenue@4: text = text .. ((text == '') and "" or "\n") .. obj.text Nenue@4: end Nenue@4: Nenue@7: print('obj.type =', obj.type) Nenue@7: print(' ** qtyStr:', obj.quantityString, 'qty:', obj.quantity, 'assetID:', obj.assetID) Nenue@7: obj.widget = mod.SetWidget(obj, info) Nenue@10: if obj.finished then Nenue@10: obj.progress = 2 Nenue@10: elseif obj.quantity > 0 then Nenue@10: obj.progress = 1 Nenue@10: else Nenue@10: obj.progress = 0 Nenue@10: end Nenue@10: Nenue@10: Nenue@4: --- none of the above (most quests) Nenue@4: else Nenue@4: local line = obj.text Nenue@4: local color = '00FFFF' Nenue@4: if obj.finished then Nenue@10: obj.progress = 2 Nenue@4: color = 'FFFFFF' Nenue@4: elseif obj.type == 'monster' then Nenue@4: color = 'FFFF00' Nenue@4: elseif obj.type == 'item' then Nenue@4: color = '44DDFF' Nenue@4: elseif obj.type == 'object' then Nenue@4: color = 'FF44DD' Nenue@4: end Nenue@4: text = text .. ((text == '') and "" or "\n") .. '|cFF'..color.. line .. '|r' Nenue@4: end Nenue@4: Nenue@4: if obj.widget then Nenue@7: Nenue@7: obj.widget:Show() Nenue@7: obj.widget:SetPoint('TOPLEFT', block.objectives, 'BOTTOMLEFT', 0, -attachmentHeight) Nenue@7: print('have a widget, height is', obj.widget.height) Nenue@4: attachmentHeight = attachmentHeight + obj.widget.height Nenue@10: completionScore = completionScore + obj.progress Nenue@10: completionMax = completionMax + 2 Nenue@4: end Nenue@4: Nenue@4: end Nenue@10: Nenue@10: block.completionScore = completionScore / completionMax Nenue@10: block.attachmentHeight = attachmentHeight Nenue@10: Nenue@10: return text Nenue@4: end Nenue@4: Nenue@1: mod.UpdateTracker = function(handler) Nenue@1: print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r') Nenue@1: local tracker = handler.Tracker Nenue@1: local blockIndex = 0 Nenue@1: local trackerHeight = headerHeight Nenue@1: local w = 300 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@10: print('|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@1: 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@1: print('Stopping scan at', 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@1: previousBlock = nil Nenue@1: if numBlocks > 0 then Nenue@1: tracker.height = trackerHeight Nenue@1: else Nenue@1: tracker.height = 0 Nenue@1: end Nenue@1: Nenue@1: print('|cFF00FF88)|r ->', numBlocks, 'blocks; height', tracker.height, 'last block: ') Nenue@1: end Nenue@1: 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@1: wrapperWidth = wrapperMaxWidth Nenue@1: scrollWidth = 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@1: if handler.actualBlocks >= 1 then Nenue@1: local tracker = handler.Tracker Nenue@1: print('setting', handler.Tracker, 'to anchor to offset', -scrollHeight) Nenue@10: tracker:SetParent(Scroll) Nenue@1: tracker:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight) Nenue@1: tracker:SetSize(wrapperWidth, tracker.height) Nenue@1: print('adding ', tracker.height) Nenue@1: scrollHeight = scrollHeight + tracker.height 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@1: --wrapperHeight = scrollHeight Nenue@1: Nenue@1: print('|cFFFFFF00params:|r scroller:', scrollWidth, 'x', scrollHeight) Nenue@1: print('|cFFFFFF00params:|r scroll:', scrollWidth, 'x', scrollHeight) Nenue@1: print('|cFFFFFF00params:|r wrapper:', wrapperWidth, 'x', wrapperHeight) Nenue@1: print('|cFFFFFF00params:|r header:', headerHeight) Nenue@1: Nenue@10: mod.SetBlockStyle(Scroller, 'Scroller', 'Normal') Nenue@10: mod.SetBlockStyle(Scroller, 'Scroll', 'Normal') Nenue@10: mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal') Nenue@10: Nenue@1: 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@1: -- 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@6: mod.UpdateActionButtons('FULL_UPDATE') 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