Nenue@28: --- ${PACKAGE_NAME} Nenue@28: -- @file-author@ Nenue@28: -- @project-revision@ @project-hash@ Nenue@28: -- @file-revision@ @file-hash@ Nenue@28: -- Created: 3/30/2016 12:49 AM Nenue@28: local B = select(2,...).frame Nenue@28: local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') Nenue@28: local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band Nenue@28: local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion Nenue@28: local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent Nenue@28: local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText Nenue@28: local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent Nenue@28: local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs Nenue@28: local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame Nenue@29: local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow Nenue@28: local print = B.print('Tracker') Nenue@28: local unitLevel = 1 Nenue@28: local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON Nenue@28: local debug = false Nenue@28: -------------------------------------------------------------------- Nenue@28: --- Global frame layout Nenue@28: -------------------------------------------------------------------- Nenue@28: Nenue@28: --- Upvalues Nenue@28: local Wrapper = _G.VeneerObjectiveWrapper Nenue@28: local Scroller = Wrapper.scrollArea Nenue@28: local Scroll = _G.VeneerObjectiveScroll Nenue@28: local orderedHandlers = T.orderedHandlers Nenue@28: local orderedNames = T.orderedNames Nenue@28: Nenue@28: --- Temp values set during updates Nenue@28: local wrapperWidth, wrapperHeight Nenue@28: local scrollWidth, scrollHeight Nenue@28: local previousBlock Nenue@28: local currentBlock Nenue@28: --- todo: source these from config Nenue@28: local itemButtonSize, itemButtonSpacing = 36, 1 Nenue@28: Nenue@28: local headerHeight, headerColor, headerSpacing = 16, {1,1,1,1}, 2 Nenue@28: local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0} Nenue@28: local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE' Nenue@28: Nenue@28: local titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125} Nenue@28: local titlebg_daily = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125 } Nenue@28: local titlebg_account = {'HORIZONTAL', 0, .45, 1, .25, 0, .45, 1, .125} Nenue@28: local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE' Nenue@28: Nenue@28: local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 } Nenue@28: local textbg_daily = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 } Nenue@28: local textbg_account = {'HORIZONTAL', 0, .45, 1, 0.4, 0, .41, 1, .085 } Nenue@28: local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE' Nenue@28: Nenue@28: Nenue@28: local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225} Nenue@28: local titleSpacing, textSpacing, blockSpacing = 3, 3, 1 Nenue@28: local titleIndent, textIndent,selectionIndent = 2, 5, 50 Nenue@28: Nenue@28: local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed Nenue@28: local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' Nenue@28: local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 } Nenue@28: local rewardSize = 32 Nenue@28: local oprint = B.print('Objectives') Nenue@28: local bprint = B.print('Block') Nenue@28: local tprint = B.print('Tracker') Nenue@28: local lprint = B.print('Line') Nenue@28: Nenue@28: local currentPosition, anchorFrame, anchorPoint Nenue@28: Nenue@28: --- Positioning and stuff Nenue@28: local tick = 0 Nenue@28: function T:Update (reason, ...) Nenue@28: tick = tick + 1 Nenue@28: local print = tprint Nenue@28: reason = reason or OBJECTIVE_TRACKER_UPDATE_REASON Nenue@28: local updateWrapper = 0 Nenue@28: local hasStuff Nenue@28: local insertingStuff Nenue@28: Nenue@28: print(format('%d |cFFFF%04X Update()', tick, lshift(reason, 4)), reason, ...) Nenue@28: currentPosition = 0 Nenue@28: anchorPoint = 'TOP' Nenue@28: anchorFrame = Scroll Nenue@28: Nenue@28: local wrapperHeight = 0 Nenue@28: for id, handler in pairs(T.orderedHandlers) do Nenue@28: local frame = handler.frame Nenue@28: Nenue@28: print(format('|cFF00FFFF%s and(%04X vs %04x+%04x) = %04X|r', handler.name, reason, handler.updateReasonModule, handler.updateReasonEvents, band(reason, handler.updateReasonModule + handler.updateReasonEvents))) Nenue@28: if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then Nenue@28: handler:Update(reason, ...) Nenue@28: print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) Nenue@28: insertingStuff = true Nenue@28: else Nenue@28: print(' |cFFFF0088'..id..'|r', 'no reason to update') Nenue@28: end Nenue@28: Nenue@28: if handler.numWatched >= 1 then Nenue@28: hasStuff = true Nenue@28: currentPosition = currentPosition + 1 Nenue@28: frame:SetParent(Scroll) Nenue@28: frame:SetPoint('TOP', anchorFrame, anchorPoint, 0, 0) Nenue@28: print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint) Nenue@28: anchorFrame = handler.frame Nenue@28: anchorPoint = 'BOTTOM' Nenue@28: Nenue@28: print('current frame height:', frame.height) Nenue@28: wrapperHeight = wrapperHeight + frame.height Nenue@28: print('|cFFFF0088total height:', wrapperHeight) Nenue@28: else Nenue@28: handler.frame:Hide() Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: Nenue@28: if hasStuff or insertingStuff then Nenue@28: print('updating height to', wrapperHeight) Nenue@28: Wrapper:SetHeight(wrapperHeight) Nenue@28: Scroller:SetHeight(wrapperHeight) Nenue@28: Scroll:SetHeight(wrapperHeight) Nenue@28: Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0) Nenue@28: print('|cFFFF8800Wrapper:', Wrapper:GetSize()) Nenue@28: for i = 1, Wrapper:GetNumPoints() do Nenue@28: print(' ', Wrapper:GetPoint(i)) Nenue@28: end Nenue@28: print(' |cFF00FFFFScroller:', Scroller:GetSize()) Nenue@28: for i = 1, Scroller:GetNumPoints() do Nenue@28: print(' ', Scroller:GetPoint(i)) Nenue@28: end Nenue@28: print(' |cFF00FFFFScroll:', Scroll:GetSize()) Nenue@28: for i = 1, Scroll:GetNumPoints() do Nenue@28: print(' ', Scroll:GetPoint(i)) Nenue@28: end Nenue@28: Nenue@28: Wrapper:Show() Nenue@28: Scroller:Show() Nenue@28: Scroll:Show() Nenue@28: end Nenue@28: Quest.GetClosest() Nenue@28: --T.UpdateActionButtons(reason) Nenue@28: end Nenue@28: Nenue@28: T.AddBlock = function(self, block) Nenue@28: local print = bprint Nenue@28: local tracker = self.frame Nenue@28: local info = block.info Nenue@29: block:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, 0) Nenue@29: block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) Nenue@29: self.currentAnchor = block Nenue@29: print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height) Nenue@29: tracker.height = tracker.height + block.height Nenue@29: self.numBlocks = max(self.numBlocks, info.blockIndex) Nenue@29: self.actualBlocks = self.actualBlocks + 1 Nenue@28: end Nenue@28: Nenue@28: --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons) Nenue@28: T.AddTag = function (block, tagName, tagPoint, tagAnchor, tagRelative) Nenue@28: local print = bprint Nenue@28: local tag = block[tagName] Nenue@28: if block.info[tagName] and tag then Nenue@28: tag:SetTexCoord(unpack(block.info[tagName])) Nenue@28: tag:Show() Nenue@28: tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) Nenue@28: tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT' Nenue@28: else Nenue@28: block[tagName]:Hide() Nenue@28: end Nenue@28: return tagPoint, tagAnchor, tagRelative Nenue@28: end Nenue@28: Nenue@28: --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call. Nenue@28: T.AddLine = function(block, line) Nenue@28: local print = lprint Nenue@28: line:ClearAllPoints() Nenue@28: line:SetPoint('LEFT', block, 'LEFT', 0, 0) Nenue@28: line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing) Nenue@28: line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) Nenue@28: line:SetHeight(line.height) Nenue@28: line:Show() Nenue@28: Nenue@28: block.endIndex = line.index Nenue@28: block.numLines = block.numLines + 1 Nenue@28: block.attachmentHeight = block.attachmentHeight + (line.height + textSpacing) Nenue@28: print(' |cFF0088FFsetting line #'..block.numLines..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height, Nenue@28: "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N')) Nenue@28: block.endPoint = line Nenue@28: end Nenue@28: Nenue@28: --- Creates or retrieves a complete line data object Nenue@28: T.GetLine = function(handler, block, lineIndex) Nenue@28: local print = lprint Nenue@28: local blockIndex = block.index Nenue@28: if not block.lines then Nenue@28: block.lines = {} Nenue@28: end Nenue@28: local lines = block.lines Nenue@28: if not lines[lineIndex] then Nenue@28: print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex) Nenue@28: lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective') Nenue@28: local line = lines[lineIndex] Nenue@28: line.index = lineIndex Nenue@28: line.height = 0 Nenue@28: line.status:SetSpacing(textSpacing) Nenue@28: line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0) Nenue@28: B.SetConfigLayers(line) Nenue@28: Nenue@28: if lines[lineIndex+1] then Nenue@28: lines[lineIndex+1]:ClearAllPoints() Nenue@28: end Nenue@28: Nenue@28: if debug then Nenue@28: for _, region in ipairs(lines[lineIndex].debug) do Nenue@28: region:Show() Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: end Nenue@28: return lines[lineIndex] Nenue@28: end Nenue@28: Nenue@29: Nenue@29: Nenue@28: --- Creates or retrieves a complete block frame object Nenue@28: T.GetBlock = function(handler, blockIndex) Nenue@28: local print = bprint Nenue@28: local block = handler.usedBlocks[blockIndex] Nenue@28: Nenue@28: if not handler.usedBlocks[blockIndex] then Nenue@28: if #handler.freeBlocks >= 1 then Nenue@28: block = handler.freeBlocks[#handler.freeBlocks] Nenue@28: handler.freeBlocks[#handler.freeBlocks] = nil Nenue@28: else Nenue@28: block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') Nenue@28: Nenue@28: Nenue@28: Nenue@28: local c = T.Conf.Wrapper Nenue@28: block.index = blockIndex Nenue@28: block:SetWidth(c.Width) Nenue@28: Nenue@28: block.title:SetSpacing(c.TitleSpacing) Nenue@28: block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) Nenue@28: Nenue@28: block.titlebg:SetTexture(1,1,1,1) Nenue@28: block.titlebg:SetGradientAlpha(unpack(T.colors.default.titlebg)) Nenue@28: block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) Nenue@28: block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) Nenue@28: Nenue@28: block.status:SetSpacing(c.TextSpacing) Nenue@28: block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing) Nenue@28: block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0) Nenue@28: Nenue@28: block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) Nenue@28: block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) Nenue@28: block.statusbg:SetTexture(1,1,1,1) Nenue@28: block.statusbg:SetGradientAlpha(unpack(T.colors.default.textbg)) Nenue@28: Nenue@28: block.SelectionOverlay:SetGradientAlpha(unpack(T.colors.default.selectionbg)) Nenue@28: block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0) Nenue@28: block.SelectionOverlay:SetPoint('BOTTOMRIGHT') Nenue@28: Nenue@28: block.icon:SetSize(rewardSize, rewardSize) Nenue@28: block.icon:SetPoint('TOPRIGHT', block, 'TOPRIGHT', -2, -2) Nenue@28: Nenue@28: Nenue@28: --- methods for event handlers Nenue@28: Nenue@28: block.Select = handler.Select Nenue@28: block.Open = handler.Open Nenue@28: block.Remove = handler.Remove Nenue@28: block.Link = handler.Link Nenue@28: block.clickZone:SetScript('OnMouseUp', function(self, ...) handler.OnMouseUp(block, ...) end) Nenue@28: block.clickZone:SetScript('OnMouseDown', function(self, ...) handler.OnMouseDown(block, ...) end) Nenue@28: block.attachmentHeight = 0 Nenue@28: block:ClearAllPoints() Nenue@28: Nenue@28: B.SetConfigLayers(block) Nenue@28: Nenue@28: if debug then Nenue@28: for _, region in ipairs(block.debug) do Nenue@28: region:Show() Nenue@28: end Nenue@28: end Nenue@28: end Nenue@28: handler.usedBlocks[blockIndex] = block Nenue@28: end Nenue@28: return handler.usedBlocks[blockIndex] Nenue@28: end Nenue@28: Nenue@28: --- Content generator base Nenue@28: Default.Update = function (self, reason, ...) Nenue@28: local print = tprint Nenue@28: local tracker = self.frame Nenue@28: local blockIndex = 0 Nenue@28: tracker.previousHeight = tracker.height Nenue@28: tracker.height = 0 Nenue@28: Nenue@28: tracker.title:SetFont(headerFont, headerSize, headerOutline) Nenue@28: tracker.titlebg:SetHeight(headerHeight) Nenue@28: tracker.title:SetTextColor(unpack(headerColor)) Nenue@28: Nenue@28: self.currentAnchor = tracker.titlebg Nenue@29: self.numWatched = self:GetNumWatched() Nenue@29: self.actualBlocks = 0 Nenue@28: for watchIndex = 1, 25 do Nenue@28: blockIndex = blockIndex + 1 Nenue@29: if watchIndex <= self.numWatched then Nenue@28: local info = self:GetInfo(watchIndex) Nenue@28: if info then Nenue@28: local currentBlock = self:UpdateBlock(blockIndex, info) Nenue@29: T.AddBlock(self, currentBlock) Nenue@28: else Nenue@28: print(' |cFFFF0000bad GetInfo data for #'..watchIndex) Nenue@28: end Nenue@29: elseif watchIndex <= self.actualBlocks then Nenue@28: local used = self.usedBlocks Nenue@28: local free = self.freeBlocks Nenue@28: print('clean up dead quest block') Nenue@28: if used[blockIndex] then Nenue@28: used[blockIndex]:Hide() Nenue@28: used[blockIndex]:ClearAllPoints() Nenue@28: free[#free+1]= used[blockIndex] Nenue@28: used[blockIndex] = nil Nenue@28: end Nenue@28: else Nenue@28: print(' |cFFFF9900END|r @', blockIndex) Nenue@28: break -- done with quest stuff Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: Nenue@29: if self.actualBlocks >= 1 then Nenue@28: tracker.height = tracker.height + headerHeight Nenue@28: tracker:Show() Nenue@28: Nenue@28: if tracker.wasEmpty then Nenue@28: tracker.headerFade:Play() Nenue@28: tracker.wasEmpty = nil Nenue@28: end Nenue@28: if tracker.height ~= tracker.previousHeight then Nenue@28: tracker:SetHeight(tracker.height) Nenue@28: end Nenue@29: print(' |cFFFFFF00', tracker.height, tracker:GetWidth()) Nenue@28: else Nenue@28: tracker:Hide() Nenue@28: tracker.wasEmpty = true Nenue@28: end Nenue@28: Nenue@28: return tracker.numWatched, tracker.numAll Nenue@28: end Nenue@28: Nenue@28: --- Updates the selected block frame to display the given info batch Nenue@28: -- If `previousBlock` is set, it will attempt to anchor to that Nenue@28: -- @param blockNum the ordered block to be updated, not a watchIndex value Nenue@28: -- @param info the reference returned by the GetXInfo functions Nenue@28: -- REMEMBER: t.info and questData[questID] are the same table Nenue@28: Default.UpdateBlock = function (handler, blockIndex, info) Nenue@28: local print = bprint Nenue@28: print(' Read list item |cFF00FFFF'..blockIndex..'|r') Nenue@28: if not blockIndex or not info then Nenue@28: return Nenue@28: end Nenue@28: local frame = handler.frame Nenue@28: local block = T.GetBlock(handler, blockIndex) Nenue@28: block.handler = handler Nenue@28: block.info = info Nenue@28: block.mainStyle = info.mainStyle or 'Normal' Nenue@28: block.subStyle = info.subStyle Nenue@28: Nenue@28: info.blockIndex = blockIndex Nenue@28: if info.questID then handler.QuestBlock[info.questID] = block end Nenue@28: if info.questLogIndex then handler.LogBlock[info.questLogIndex] = block end Nenue@28: if info.watchIndex then handler.WatchBlock[info.watchIndex] = block end Nenue@28: handler.BlockInfo[blockIndex] = info Nenue@28: Nenue@28: block.endPoint = block.titlebg Nenue@28: block.attachmentHeight = 0 Nenue@28: handler:UpdateObjectives(block) Nenue@28: Nenue@28: block.title:SetText(info.title) Nenue@28: local titleHeight = floor(block.title:GetHeight()+.5) Nenue@28: local statusHeight = floor(block.status:GetHeight()+.5) Nenue@28: local attachmentHeight =floor(block.attachmentHeight + .5) Nenue@28: local titlebgHeight = titleHeight + titleSpacing*2 Nenue@28: local statusbgHeight = statusHeight + textSpacing*2 Nenue@28: Nenue@28: block.titlebg:SetHeight(titlebgHeight) Nenue@28: Nenue@28: Nenue@28: print(' |cFF0088FFanchor to', handler.currentAnchor:GetName()) Nenue@28: Nenue@28: print(' |cFF00FF00total sizes:') Nenue@28: print(' attachment:', attachmentHeight) Nenue@28: print(' title:', titlebgHeight, '('.. titleHeight..')') Nenue@28: --block.titlebg:SetHeight(block.title:GetHeight() + T.Conf.Wrapper.TitleSpacing) Nenue@28: block.height = titlebgHeight + attachmentHeight Nenue@28: if statusHeight > 1 then Nenue@28: block.height = block.height + statusbgHeight Nenue@28: print(' status:', statusbgHeight, '('.. statusHeight..')') Nenue@28: else Nenue@28: print(' |cFFFF0088 skipped') Nenue@28: end Nenue@28: block:SetHeight(block.height) Nenue@28: Nenue@28: print(' |cFFFFFF00height|r:', block.height) Nenue@28: print(' |cFF00FFFF)|r -> ', block, block:GetHeight()) Nenue@28: Nenue@28: block:Show() Nenue@28: Nenue@28: if info.specialItem and not info.itemButton then Nenue@28: print(' - |cFF00FFFFgenerating item button for info set') Nenue@28: info.itemButton = T.SetItemButton(block, info) Nenue@28: else Nenue@28: --info.itemButton = nil Nenue@28: end Nenue@28: Nenue@28: local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block, 'TOPRIGHT' Nenue@28: Nenue@28: if info.rewardInfo then Nenue@28: print('has immediate reward') Nenue@28: if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then Nenue@28: block.icon:Show() Nenue@28: block.iconLabel:SetText(info.rewardInfo[1].count) Nenue@28: block.icon:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2) Nenue@28: tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block.icon, 'TOPLEFT' Nenue@28: block.icon:SetTexture(info.rewardInfo[1].texture) Nenue@28: end Nenue@28: else Nenue@28: block.icon:Hide() Nenue@28: end Nenue@28: Nenue@28: if info.selected then Nenue@28: block.SelectionOverlay:Show() Nenue@28: else Nenue@28: block.SelectionOverlay:Hide() Nenue@28: end Nenue@28: -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel Nenue@28: --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1) Nenue@28: --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1) Nenue@28: Nenue@28: tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative) Nenue@28: tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative) Nenue@28: tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative) Nenue@28: Nenue@28: return block Nenue@28: end Nenue@28: Nenue@28: Nenue@28: Nenue@28: Nenue@28: --- Does the main iterations for populating block content. Nenue@28: -- Hooked by corresponding handler functions where additional details need to be sorted. Nenue@28: Default.UpdateObjectives = function(handler, block) Nenue@28: local print = lprint Nenue@28: local info = block.info Nenue@28: print(' |cFF00FF00default objectives routine', block:GetName()) Nenue@28: Nenue@28: -- reset the starting positions Nenue@28: block.attachmentHeight = 0 Nenue@28: block.endPoint = block.titlebg Nenue@28: local completionScore, completionMax = 0, 0 Nenue@28: local displayObjectiveHeader = false Nenue@28: Nenue@28: Nenue@28: --- The first line is going to be used no matter what, so it is hard-pulled. Nenue@28: -- It also ensures that we're in the right position for cleaning up the leftover lines. Nenue@28: local lineIndex = 1 Nenue@28: local line = T.GetLine(handler, block, lineIndex) Nenue@28: Nenue@28: block.numLines = 0 Nenue@28: block.attachmentHeight = 0 Nenue@28: Nenue@28: if info.description and #info.description >= 1 then Nenue@28: print(' |cFF00FFFF header line:|r', info.description) Nenue@28: line.status:SetText(info.description) Nenue@28: line.height = floor(line.status:GetStringHeight()+.5) + textSpacing Nenue@28: if line.widget then Nenue@28: line.widget:Hide() Nenue@28: end Nenue@28: T.AddLine(block, line) Nenue@28: Nenue@28: lineIndex = lineIndex + 1 Nenue@28: line = T.GetLine(handler, block, lineIndex) Nenue@28: end Nenue@28: Nenue@28: if (info.isComplete or info.numObjectives == 0) and info.completionText then Nenue@28: print(' overriding line #1 for completion text:', info.completionText) Nenue@28: line.status:SetText(info.completionText) Nenue@28: line.height = floor(line.status:GetStringHeight()+.5) + textSpacing Nenue@28: if line.widget then Nenue@28: line.widget:Hide() Nenue@28: end Nenue@28: T.AddLine(block, line) Nenue@28: else Nenue@28: if info.objectives then Nenue@28: for i, data in ipairs(info.objectives) do Nenue@28: print(' |cFF88FF00#', i, data.type, data.text) Nenue@28: displayObjectiveHeader = true Nenue@28: line.height = 0 Nenue@28: handler:UpdateLine(block, line, data) Nenue@28: Nenue@28: -- For progressbar and timer lines, status text may be used as the title heading Nenue@28: if line.widget then Nenue@28: local widgetPosition = 0 Nenue@28: --- WIDGET POSITION ------------------------------------------------- Nenue@28: line.widget:SetPoint('TOP', line, 'TOP', 0, -widgetPosition) Nenue@28: line.widget:Show() Nenue@28: line.height = line.widget:GetHeight() + textSpacing Nenue@28: --------------------------------------------------------------------- Nenue@28: if line.displayText and #line.displayText >= 1 then Nenue@28: widgetPosition = line.status:GetHeight() + textSpacing Nenue@28: line.status:SetText(line.displayText) Nenue@28: line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + line.widget.height Nenue@28: print(' - progressbar has text, adjust') Nenue@28: end Nenue@28: elseif line.displayText then Nenue@28: line.status:SetText(line.displayText) Nenue@28: line.height = floor(line.status:GetStringHeight()+.5) Nenue@28: end Nenue@28: Nenue@28: T.AddLine(block, line) Nenue@28: Nenue@28: --print(' sz', line:GetWidth(), line:GetHeight(), 'pt', line:GetPoint(1)) Nenue@28: --print(' |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg) Nenue@28: Nenue@28: lineIndex = lineIndex + 1 Nenue@28: line = T.GetLine(handler, block, lineIndex) Nenue@28: end Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: while (block.lines[lineIndex+1]) do Nenue@28: print(' - hide |cFFFF0088'..lineIndex..'|r') Nenue@28: block.lines[lineIndex]:Hide() Nenue@28: lineIndex = lineIndex +1 Nenue@28: end Nenue@28: Nenue@28: Nenue@28: Nenue@28: if lineIndex > 0 then Nenue@28: block.attachmentHeight = block.attachmentHeight + textSpacing * 2 Nenue@28: print(' |cFF00FF00attachment:', block.attachmentHeight) Nenue@28: end Nenue@28: Nenue@28: Nenue@28: --[[ Nenue@28: local lines = handler.lines[block.index] Nenue@28: if lines and #lines > block.numLines then Nenue@28: print(' |cFFFF008' .. (#lines - block.numLines) .. ' extra lines to hide.') Nenue@28: for i = block.numLines + 1, #lines do Nenue@28: print(' hide', i, lines[i]:GetName()) Nenue@28: lines[i]:Hide() Nenue@28: end Nenue@28: end Nenue@28: ]] Nenue@28: Nenue@28: Nenue@28: if debug then Nenue@28: for i, region in ipairs(block.debug) do Nenue@28: for j = 1, region:GetNumPoints() do Nenue@28: local _, target = region:GetPoint(j) Nenue@28: if target:IsVisible() then Nenue@28: region:Hide() Nenue@28: else Nenue@28: region:Show() Nenue@28: end Nenue@28: end Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: block.completionScore = completionScore / completionMax Nenue@28: end Nenue@28: Nenue@28: Nenue@28: --- Module-specific display variables Nenue@28: -- * height - height of whatever display widget is involved in conveying the task Nenue@28: -- * money - boolean that determines listening for money events or not Nenue@28: -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively Nenue@28: Nenue@28: Nenue@28: Default.UpdateLine = function(block, line) Nenue@28: if line.finished then Nenue@28: line.progress = 2 Nenue@28: elseif line.quantity > 0 then Nenue@28: line.progress = 1 Nenue@28: else Nenue@28: line.progress = 0 Nenue@28: end Nenue@28: return line Nenue@28: end Nenue@28: ---------- Nenue@28: --- Top level methods Nenue@28: Nenue@28: --- Queue any active item buttons for update for that frame Nenue@28: local iprint = B.print('ItemButton') Nenue@28: T.UpdateActionButtons = function(updateReason) Nenue@28: local print = iprint Nenue@28: Scroller.snap_upper = 0 Nenue@28: Scroller.snap_lower = 0 Nenue@28: local print = B.print('ItemButton') Nenue@28: if updateReason then Nenue@28: print = B.print('IB_'..updateReason) Nenue@28: end Nenue@28: Nenue@28: local previousItem Nenue@28: for questID, itemButton in pairs(Quest.itemButtons) do Nenue@28: local info= T.Quest.Info[questID] Nenue@28: Nenue@28: print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) Nenue@28: local block = T.Quest.QuestBlock[questID] Nenue@28: if block then Nenue@28: -- Dispatch the probe Nenue@28: if IsQuestWatched(info.questLogIndex) then Nenue@28: itemButton.previousItem = previousItem Nenue@28: print(' |cFFFFFF00probing', block:GetName()) Nenue@28: block:SetScript('OnUpdate', function() Nenue@28: if block:GetBottom() and not InCombatLockdown() then Nenue@28: print(' '..block:GetName()..' |cFF00FF00probe hit!') Nenue@28: T.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope Nenue@28: block:SetScript('OnUpdate', nil) Nenue@28: Nenue@28: end Nenue@28: end) Nenue@28: previousItem = itemButton Nenue@28: else Nenue@28: print('hidden block or unwatched quest') Nenue@28: itemButton.previousItem = nil Nenue@28: itemButton:Hide() Nenue@28: end Nenue@28: elseif itemButton:IsVisible() then Nenue@28: print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName()) Nenue@28: itemButton.previousItem = nil Nenue@28: itemButton:Hide() Nenue@28: else Nenue@28: print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName()) Nenue@28: end Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: T.UpdateBlockAction = function (block, itemButton) Nenue@28: local print = iprint Nenue@28: print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') Nenue@28: if itemButton.questID ~= block.info.questID then Nenue@28: print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID) Nenue@28: -- something happened between this and last frame, go back and set new probes Nenue@28: return T.UpdateActionButtons() Nenue@28: end Nenue@28: Nenue@28: local previousItem = itemButton.previousItem Nenue@28: local upper_bound = Scroller:GetTop() + Scroller.snap_upper Nenue@28: local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize Nenue@28: local point, anchor, relative Nenue@28: Nenue@28: if block:GetBottom() < lower_bound then Nenue@28: print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5)) Nenue@28: if previousItem then Nenue@28: print('adjusting', previousItem:GetName()) Nenue@28: previousItem:ClearAllPoints() Nenue@28: previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing) Nenue@28: end Nenue@28: itemButton:ClearAllPoints() Nenue@28: itemButton.x = Wrapper:GetLeft() -4 Nenue@28: itemButton.y = Wrapper:GetBottom() Nenue@28: point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT' Nenue@28: Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing Nenue@28: Nenue@28: elseif block:GetTop() > upper_bound then Nenue@28: print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5)) Nenue@28: itemButton:ClearAllPoints() Nenue@28: if previousItem then Nenue@28: print('latch onto another piece') Nenue@28: point, anchor, relative ='TOP', previousItem, 'BOTTOM' Nenue@28: itemButton.x = 0 Nenue@28: itemButton.y = -itemButtonSpacing Nenue@28: else Nenue@28: print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop()) Nenue@28: point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' Nenue@28: itemButton.x = Scroller:GetLeft() -4 Nenue@28: itemButton.y = Scroller:GetTop() Nenue@28: end Nenue@28: itemButton:Show() Nenue@28: Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing) Nenue@28: else Nenue@28: print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5)) Nenue@28: itemButton:ClearAllPoints() Nenue@28: itemButton.x = block:GetLeft() - itemButtonSpacing Nenue@28: itemButton.y = block:GetTop() Nenue@28: point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' Nenue@28: end Nenue@28: Nenue@28: itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y) Nenue@28: itemButton:Show() Nenue@28: end Nenue@28: Nenue@28: T.UpdateItemButtonCooldown = function(button) Nenue@28: Nenue@28: end Nenue@28: Nenue@29: Default.Select = function(handler, block) Nenue@29: T:Update(handler.watchReasonModule) Nenue@28: end Nenue@29: Default.Open = function(handler, block) Nenue@29: T:Update(handler.watchReasonModule) Nenue@28: end Nenue@29: Default.Remove = function(handler, block) Nenue@29: T:Update(handler.watchReasonModule) Nenue@28: end Nenue@29: Default.Report = function(handler, block) Nenue@29: print('Stats:', handler.numWatched,'items tracked,', handler.numBlocks,'blocks assigned.') Nenue@28: end Nenue@28: Nenue@28: Default.OnMouseUp = function(self, button) Nenue@28: print(self.handler.name, self.mainStyle, self.subStyle) Nenue@28: if button == 'LeftButton' then Nenue@28: if IsModifiedClick("CHATLINK") and ChatEdit_GetActiveWindow() then Nenue@29: self.Link(self.handler, self) Nenue@28: elseif IsModifiedClick("QUESTWATCHTOGGLE") then Nenue@29: self.Remove(self.handler, self) Nenue@28: else Nenue@29: self.Select(self.handler, self) Nenue@28: end Nenue@28: elseif button == 'RightButton' then Nenue@29: self.Open(self.handler, self) Nenue@28: end Nenue@28: self.initialButton = nil Nenue@28: self.modChatLink = nil Nenue@28: self.modQuestWatch = nil Nenue@29: T:Update(self.handler.updateReasonModule) Nenue@28: print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r') Nenue@28: end Nenue@28: Default.OnMouseDown = function(self, button) Nenue@28: print(self.info.title) Nenue@28: end