# HG changeset patch # User Nenue # Date 1460110325 14400 # Node ID d5ee940de27374cd635b7b4457a02a2a223b844c # Parent 6bd2102d340b4e0b8729db60a894fcb8432f6ca6 use hardcoded aesthetic manipulations over loadstring cramming diff -r 6bd2102d340b -r d5ee940de273 Core.xml --- a/Core.xml Wed Apr 06 07:54:19 2016 -0400 +++ b/Core.xml Fri Apr 08 06:12:05 2016 -0400 @@ -27,25 +27,25 @@ - - + + - + - + - + - + - + diff -r 6bd2102d340b -r d5ee940de273 Init.lua --- a/Init.lua Wed Apr 06 07:54:19 2016 -0400 +++ b/Init.lua Fri Apr 08 06:12:05 2016 -0400 @@ -409,7 +409,12 @@ B.InitXMLFrame = function(self) print('|cFF00FF00hello from '..self:GetName()) - self:RegisterForDrag('LeftButton') + if self.drag then + self:RegisterForDrag('LeftButton') + else + self:EnableMouse(false) + end + if not B.Conf.FramePosition then B.Conf.FramePosition = {} end diff -r 6bd2102d340b -r d5ee940de273 ObjectiveCore.lua --- a/ObjectiveCore.lua Wed Apr 06 07:54:19 2016 -0400 +++ b/ObjectiveCore.lua Fri Apr 08 06:12:05 2016 -0400 @@ -58,7 +58,7 @@ local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_ALL -- default --- Used to determine which trackers are listening for money events -mod.MoneyReasons = 0 +mod.watchMoneyReasons = 0 --- Baseline defaults table; values defined in the files that they pertain to mod.defaults = {} @@ -87,10 +87,15 @@ OffsetY = WRAPPER_OFFSET_Y, Height = WRAPPER_MAX_HEIGHT, Width = WRAPPER_WIDTH, - HeaderHeight = WRAPPER_HEADER_HEIGHT + HeaderHeight = WRAPPER_HEADER_HEIGHT, + TextSpacing = 3, + TitleSpacing = 3, } + + + --- Tracker module definitions begin here; innards dealing with data retreival and output are defined further in -mod.DefaultTracker = { +mod.DefaultHandler = { previousHeight = 0, name = "temp", @@ -150,8 +155,7 @@ local Tracker_call = function (self, reason) self:Update(reason) end - -local Tracker_Initialize = function (self, name, index) +local Handler_Initialize = function (self, name, index) print('Initializing |cFF00FFFF'..name..'|r module...') local handler = setmetatable(mod[name] or {}, { @@ -195,6 +199,7 @@ mod.SetBlockStyle(frame, 'Tracker', 'Normal') handler.frame = frame handler.trackerName = trackerName + handler.lines = {} mod.orderedTrackers[index] = frame mod.namedTrackers[name] = frame mod.indexedTrackers[handler] = frame @@ -204,14 +209,17 @@ return true end + function mod:OnEvent (event, ...) local isHandled - print('|cFF00FF00'.. event ..'|r', ...) + print('OnEvent(|cFF00FF00'.. event ..'|r):', ...) if ( event == "QUEST_LOG_UPDATE" ) then - mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST); + mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST); + elseif ( event == "TRACKED_ACHIEVEMENT_UPDATE" ) then --AchievementObjectiveTracker_OnAchievementUpdate(...); mod.Cheevs:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT) + elseif ( event == "QUEST_ACCEPTED" ) then local questLogIndex, questID = ...; if ( IsQuestTask(questID) ) then @@ -221,7 +229,9 @@ AddQuestWatch(questLogIndex); SetSuperTrackedQuestID(questID); end + mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) end + elseif ( event == "TRACKED_ACHIEVEMENT_LIST_CHANGED" ) then local achievementID, added = ...; if ( added ) then @@ -229,27 +239,29 @@ else mod:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT); end + elseif ( event == "QUEST_WATCH_LIST_CHANGED" ) then local questID, added = ...; if ( added ) then if ( not IsQuestTask(questID) ) then - mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID); + mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID, added); end else - mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST); + mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST, questID, added); end + elseif ( event == "QUEST_POI_UPDATE" ) then QuestPOIUpdateIcons(); if ( GetCVar("trackQuestSorting") == "proximity" ) then SortQuestWatches(); end - mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST); + mod:Update(OBJECTIVE_TRACKER_UPDATE_ALL); elseif ( event == "SCENARIO_CRITERIA_UPDATE" ) then mod:Update(OBJECTIVE_TRACKER_UPDATE_SCENARIO); elseif ( event == "SUPER_TRACKED_QUEST_CHANGED" ) then - mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST) + --mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST) elseif ( event == "ZONE_CHANGED" ) then local inMicroDungeon = IsPlayerInMicroDungeon(); if ( inMicroDungeon ~= self.inMicroDungeon ) then @@ -262,7 +274,7 @@ elseif ( event == "QUEST_AUTOCOMPLETE" ) then local questId = ...; AddAutoQuestPopUp(questId, "COMPLETE"); - mod:Update(OBJECTIVE_TRACKER_UPDATE_STATIC) + mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) elseif ( event == "SCENARIO_UPDATE" ) then local newStage = ...; if ( newStage ) then @@ -275,12 +287,20 @@ SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker end SortQuestWatches(); + mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE) + elseif (event == 'CRITERIA_COMPLETE') then + mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE) + elseif ( event == "QUEST_TURNED_IN" ) then local questID, xp, money = ...; if ( IsQuestTask(questID) ) then mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE) + else + + mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) end elseif ( event == "PLAYER_MONEY" and self.watchMoneyReasons > 0 ) then + -- only update trackers that have money counters mod:Update(self.watchMoneyReasons); end end @@ -317,31 +337,44 @@ end Scroller:SetScrollChild(Scroll) Scroller:SetWidth(c.Width) - Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT') Scroll:SetWidth(c.Width) + Scroll:ClearAllPoints() + Scroll:SetPoint('TOP', Scroller, 'TOP') ObjectiveTrackerFrame:UnregisterAllEvents() ObjectiveTrackerFrame:Hide() end --- Done any time the the minimize button is toggled up + function mod:OnEnable() for id, name in ipairs(mod.orderedNames) do if not mod.orderedHandlers[id] then - Tracker_Initialize(mod.DefaultTracker, name, id) + Handler_Initialize(mod.DefaultHandler, name, id) end end - for event, func in pairs(mod) do - if type(func) == 'function' and event:match('^[A-Z_]+$') then - print('|cFFFF44FFlistening to', event) - Wrapper:RegisterEvent(event) - end - end + Wrapper:RegisterEvent("CRITERIA_COMPLETE"); + Wrapper:RegisterEvent("SCENARIO_UPDATE"); + Wrapper:RegisterEvent("SCENARIO_CRITERIA_UPDATE"); + Wrapper:RegisterEvent("PLAYER_MONEY"); + Wrapper:RegisterEvent("QUEST_ACCEPTED"); + Wrapper:RegisterEvent("QUEST_AUTOCOMPLETE"); + Wrapper:RegisterEvent("QUEST_LOG_UPDATE"); + Wrapper:RegisterEvent("QUEST_POI_UPDATE"); + Wrapper:RegisterEvent("QUEST_TURNED_IN"); + Wrapper:RegisterEvent("QUEST_WATCH_LIST_CHANGED"); + Wrapper:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED"); + Wrapper:RegisterEvent("TRACKED_ACHIEVEMENT_LIST_CHANGED"); + Wrapper:RegisterEvent("TRACKED_ACHIEVEMENT_UPDATE"); + Wrapper:RegisterEvent("VARIABLES_LOADED"); + Wrapper:RegisterEvent("ZONE_CHANGED_NEW_AREA"); + Wrapper:RegisterEvent("ZONE_CHANGED"); + Wrapper:SetScript('OnEvent', mod.OnEvent) local c = mod.Conf.Wrapper - Wrapper:SetPoint(c.AnchorPoint, UIParent, c.AnchorPoint, c.OffsetX, c.OffsetY) - B.Conf.FramePosition[Wrapper:GetName()] = {c.AnchorPoint, c.AnchorPoint, c.OffsetX, c.OffsetY} + --Wrapper:SetPoint(c.AnchorPoint, UIParent, c.AnchorPoint, c.OffsetX, c.OffsetY) + --B.Conf.FramePosition[Wrapper:GetName()] = {c.AnchorPoint, c.AnchorPoint, c.OffsetX, c.OffsetY} Wrapper:SetWidth(c.Width) diff -r 6bd2102d340b -r d5ee940de273 ObjectiveEvents.lua --- a/ObjectiveEvents.lua Wed Apr 06 07:54:19 2016 -0400 +++ b/ObjectiveEvents.lua Fri Apr 08 06:12:05 2016 -0400 @@ -18,19 +18,26 @@ mod:Update(0x00000003) end +local Quest = mod.Quest mod.RemoveQuestWatch = function(questIndex, ...) print('|cFFFF8800RemoveQuestWatch', questIndex, ...) + local info = mod.Quest.LogInfo[questIndex] -- remove quest refs - mod.Quest.LogBlock[questIndex] = nil - mod.Quest.QuestBlock[info.questID] = nil + local block = Quest.QuestBlock[info.questID] + Quest.QuestBlock[info.questID] = nil + Quest.LogBlock[questIndex] = nil -- remove if they still match - if mod.Quest.WatchInfo[info.watchIndex] == info then + if Quest.WatchInfo[info.watchIndex] == info then print('cleaning dead WatchInfo entry') - mod.Quest.WatchInfo[info.watchIndex] = nil + Quest.WatchInfo[info.watchIndex] = nil end + for i = 1, #info.objectives do + Quest.lines[block.blockIndex][i]:Hide() + end + mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) end @@ -68,5 +75,5 @@ mod.SetSuperTrackedQuestID = function(questID) - mod:Update() + --mod:Update() end \ No newline at end of file diff -r 6bd2102d340b -r d5ee940de273 ObjectiveFrame.lua --- a/ObjectiveFrame.lua Wed Apr 06 07:54:19 2016 -0400 +++ b/ObjectiveFrame.lua Fri Apr 08 06:12:05 2016 -0400 @@ -8,11 +8,12 @@ local ipairs, max, min, unpack, floor, pairs, tostring, type, band = ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent -local DefaultTracker, Quest, Bonus, Cheevs = mod.DefaultTracker, mod.Quest, mod.Bonus, mod.Cheevs +local Default, AutoQuest, Quest, Bonus, Cheevs = mod.DefaultHandler, mod.AutoQuest, mod.Quest, mod.Bonus, mod.Cheevs local CreateFrame = CreateFrame -local print = B.print('ObjWrapper') +local print = B.print('Tracker') local unitLevel = 1 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON +local debug = false -------------------------------------------------------------------- --- Global frame layout -------------------------------------------------------------------- @@ -32,93 +33,99 @@ --- todo: source these from config local itemButtonSize, itemButtonSpacing = 36, 1 local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] -local titleSize, textSize = 15, 15 +local titleSize, textSize = 16, 16 +local titlebg, textbg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125}, {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0} local titleOutline, textOutline = "OUTLINE", "OUTLINE" -local titleSpacing, textSpacing = 4, 3 -local textIndent = 5 +local titleSpacing, textSpacing = 3, 3 +local titleIndent, textIndent = 2, 5 +local blockSpacing = 1 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} +local oprint = B.print('Objectives') +local bprint = B.print('Block') +local tprint = B.print('Tracker') +local lprint = B.print('Line') local band = bit.band local currentPosition, anchorFrame, anchorPoint -function mod:Update (reason, dataID) - local updateWrapper = 0 - local hasStuff - local insertingStuff - reason = reason or OBJECTIVE_TRACKER_UPDATE_REASON - currentPosition = 0 - anchorPoint = 'TOPLEFT' - anchorFrame = Scroll - local wrapperHeight = 0 - for id, handler in pairs(mod.orderedHandlers) do - local frame = handler.frame +Default.GetLine = function(handler, blockIndex, lineIndex) + local print = lprint + if not handler.lines[blockIndex] then + handler.lines[blockIndex] = {} + end + local lines = handler.lines[blockIndex] + if not lines[lineIndex] then + print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex) + lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, handler:GetBlock(blockIndex), 'VeneerTrackerObjective') + local line = lines[lineIndex] + line.index = lineIndex + line.height = 0 + line.status:SetSpacing(textSpacing) + line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0) + B.SetConfigLayers(line) - print(format('|cFF00FFFFbitcheck (%04X vs %04x+%04x):|r', reason, handler.updateReasonModule, handler.updateReasonEvents), band(reason, handler.updateReasonModule + handler.updateReasonEvents)) - if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then - handler:Update(reason, dataID) - print('|cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) - insertingStuff = true - else - print('|cFFFF0088'..id..'|r', 'no reason') + if lines[lineIndex+1] then + lines[lineIndex+1]:ClearAllPoints() end - if handler.numWatched >= 1 then - hasStuff = true - currentPosition = currentPosition + 1 - frame:SetParent(Scroll) - frame:SetPoint('TOPLEFT', anchorFrame, anchorPoint, 0, 0) - print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint) - anchorFrame = handler.frame - anchorPoint = 'BOTTOMLEFT' - - print('current frame height:', frame.height) - wrapperHeight = wrapperHeight + frame.height - print('|cFFFF0088total height:', wrapperHeight) - else - handler.frame:Hide() - end - end - - - if hasStuff or insertingStuff then - - print('updating height to', wrapperHeight) - Wrapper:SetHeight(wrapperHeight) - Scroller:SetHeight(wrapperHeight) - Scroll:SetHeight(wrapperHeight) - print('|cFFFF8800Wrapper:', Wrapper:GetSize()) - for i = 1, Wrapper:GetNumPoints() do - print(' ', Wrapper:GetPoint(i)) - end - print(' |cFF00FFFFScroller:', Scroller:GetSize()) - for i = 1, Scroller:GetNumPoints() do - print(' ', Scroller:GetPoint(i)) - end - print(' |cFF00FFFFScroll:', Scroll:GetSize()) - for i = 1, Scroll:GetNumPoints() do - print(' ', Scroll:GetPoint(i)) + if debug then + for _, region in ipairs(lines[lineIndex].debug) do + region:Show() + end end - Wrapper:Show() - Scroller:Show() - Scroll:Show() end - + return lines[lineIndex] end -DefaultTracker.GetBlock = function(handler, blockIndex) +Default.GetBlock = function(handler, blockIndex) + local print = bprint local block = handler.usedBlocks[blockIndex] + if not handler.usedBlocks[blockIndex] then if #handler.freeBlocks >= 1 then block = handler.freeBlocks[#handler.freeBlocks] handler.freeBlocks[#handler.freeBlocks] = nil else block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') + block.GetLine = function(block, lineIndex, data) return handler:GetLine(blockIndex, lineIndex, data) end + block.UpdateLine = function(block, lineIndex, data) return handler:UpdateLine(block, lineIndex, data) end + block.UpdateObjectives = function(block) return handler:UpdateObjectives(block) end + block.SetTag = function(block, ...) return handler.SetTag(block, ...) end + + local c = mod.Conf.Wrapper + block.blockIndex = blockIndex block.SetStyle = mod.SetBlockStyle + block:SetWidth(c.Width) + + block.title:SetSpacing(c.TitleSpacing) + block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) + + block.titlebg:SetTexture(1,1,1,1) + block.titlebg:SetGradientAlpha(unpack(titlebg)) + block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) + block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) + + block.status:SetSpacing(c.TextSpacing) + block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing) + block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0) + + block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) + block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) + block.statusbg:SetTexture(1,1,1,1) + block.statusbg:SetGradientAlpha(unpack(textbg)) + + block.SelectionOverlay:SetPoint('TOPLEFT') + block.SelectionOverlay:SetPoint('BOTTOMRIGHT') + + + + --- methods for event handlers + block.Select = handler.Select block.Open = handler.Open block.Remove = handler.Remove @@ -127,274 +134,252 @@ block:SetScript('OnMouseDown', handler.OnMouseDown) block.attachmentHeight = 0 block:ClearAllPoints() + + B.SetConfigLayers(block) + + if debug then + for _, region in ipairs(block.debug) do + region:Show() + end + end end - handler.usedBlocks[blockIndex] = block end return handler.usedBlocks[blockIndex] end -DefaultTracker.Update = function (self, reason, dataID) - local tracker = self.frame - print('|cFFFF4400'..tracker:GetName().. '|r:Update()') - local blockIndex = 0 - local trackerHeight = 0 +Default.SetTag = function (block, tagName, tagPoint, tagAnchor, tagRelative) + local print = bprint + local tag = block[tagName] + if block.info[tagName] and tag then + tag:SetTexCoord(unpack(block.info[tagName])) + tag:Show() + tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) + tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT' + else + block[tagName]:Hide() + end + return tagPoint, tagAnchor, tagRelative +end +Default.UpdateObjectives = function(handler, block) + local print = lprint + local info = block.info - self.currentAnchor = tracker.titlebg - local numWatched = self:GetNumWatched() - local numBlocks = self.numBlocks - local actualBlocks = 0 - for watchIndex = 1, 25 do - blockIndex = blockIndex + 1 - if watchIndex <= numWatched then - local info = self:GetInfo(watchIndex) - if info then - local currentBlock = self:UpdateBlock(blockIndex, info) - self.currentAnchor = currentBlock - print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) - print(currentBlock:IsVisible()) - print(currentBlock:GetPoint(1)) - trackerHeight = trackerHeight + currentBlock.height - numBlocks = max(numBlocks, watchIndex) - actualBlocks = actualBlocks + 1 - else - print(' |cFFFF0000Failed to draw info for index #'..watchIndex) + print(' |cFF00FF00doing objectives', block:GetName()) + + -- set the starting positions + block.endPoint = block.status + local completionScore, completionMax = 0, 0 + local displayObjectiveHeader = false + + if info.description and #info.description >= 1 then + print(' |cFF00FFFF header line:|r', info.description) + block.status:SetText(info.description) + displayObjectiveHeader = true + end + + local attachmentHeight = 0 + if info.objectives then + for i, data in ipairs(info.objectives) do + print(' |cFF88FF00#', i, data.type, data.text) + displayObjectiveHeader = true + local line = block:GetLine(i) + line.height = 0 + block:UpdateLine(line, data) + + line:ClearAllPoints() + if line.displayText then + line.status:SetText(line.displayText) + line.height = floor(line.status:GetStringHeight()+.5) end - elseif watchIndex <= numBlocks then - local used = self.usedBlocks - local free = self.freeBlocks - print('clean up dead quest block') - if used[blockIndex] then - used[blockIndex]:Hide() - used[blockIndex]:ClearAllPoints() - free[#free+1]= used[blockIndex] - used[blockIndex] = nil + if line.widget then + line.widget:SetPoint('TOP', line, 'TOP', 0, 0) + line.widget:Show() end - else - print(' |cFFFF9900END|r @', blockIndex) - break -- done with quest stuff - end - end - self.numWatched = numWatched - self.numBlocks = numBlocks - self.actualBlocks = actualBlocks - self:Report() - tracker.previousHeight = tracker.height - if numBlocks >= 1 then - previousBlock = nil - tracker.height = trackerHeight + tracker.titlebg:GetHeight() - tracker:SetHeight(tracker.height) - tracker:Show() + line:Show() - print(tracker.height) + line:SetPoint('LEFT', block, 'LEFT', 0, 0) + line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, 0) + line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) + line:SetHeight(line.height) - else - tracker.height = 0 - tracker:Hide() - end + attachmentHeight = attachmentHeight + line.height + print(' sz', line:GetSize()) + print(' pt', line:GetPoint(1)) + print(' |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg) - return tracker.numWatched, tracker.numAll -end - ---- Updates the selected block frame to display the given info batch --- If `previousBlock` is set, it will attempt to anchor to that --- @param blockNum the ordered block to be updated, not a watchIndex value --- @param info the reference returned by the GetXInfo functions --- REMEMBER: t.info and questData[questID] are the same table -DefaultTracker.UpdateBlock = function (self, blockIndex, info) - local print = B.print('BlockParse') - print(' Read list item |cFF00FFFF'..blockIndex..'|r') - if not blockIndex or not info then - return - end - local frame = self.frame - local t = self:GetBlock(blockIndex) - t.handler = self - t.info = info - t.mainStyle = info.mainStyle or 'Normal' - t.subStyle = info.subStyle - - info.blockIndex = blockIndex - if info.questID then self.QuestBlock[info.questID] = t end - if info.questLogIndex then self.LogBlock[info.questLogIndex] = t end - if info.watchIndex then self.WatchBlock[info.watchIndex] = t end - self.BlockInfo[blockIndex] = info - - t.attachmentHeight = 0 - if info.isComplete then - if mod.AutoQuest.Info[info.questID] then - t.status:SetText('(Click to Complete)') - t.status:Show() - else - t.status:SetText('Ready to turn in') - t.status:Show() - end - elseif info.completed then - t.status:SetText(nil) - t.status:Hide() - elseif info.numObjectives >= 1 then - t.attachmentHeight = 0 - t.status:Show() - print(' lines to parse:', info.numObjectives) - local text = '' - - mod.UpdateObjectives(t, info, text) - print(' |cFF00FF00attachment', t.attachmentHeight) - elseif info.description then - t.status:SetText(info.description) - t.status:Show() - else - t.status:SetText(nil) - t.status:Show() - end - t.title:SetText(info.title) - - - if info.specialItem and not info.itemButton then - print(' - |cFF00FFFFgenerating item button for info set') - info.itemButton = mod.SetItemButton(t, info) - else - --info.itemButton = nil - end - - if self.currentAnchor then - t:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, 0) - t:SetPoint('RIGHT', frame,'RIGHT', 0, 0) - print(' anchor to|cFF0088FF', self.currentAnchor:GetName()) - end - - - --- metrics are calculated in SetStyle - t:SetStyle('TrackerBlock', self.name, t.mainStyle, t.subStyle) - print(' |cFFFFFF00height|r', t.height) - t:Show() - - print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) - - local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t, 'TOPRIGHT' - if info.rewardInfo then - print('has immediate reward') - if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then - t.icon:Show() - t.iconLabel:SetText(info.rewardInfo[1].count) - t.icon:SetSize(t.height, t.height) - t.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) - tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.icon, 'TOPLEFT' - t.icon:SetTexture(info.rewardInfo[1].texture) - end - else - t.icon:Hide() - end - - if info.selected then - t.SelectionOverlay:Show() - else - t.SelectionOverlay:Hide() - end - - if info.frequencyTag then - t.FrequencyTag:SetTexCoord(unpack(info.frequencyTag)) - t.FrequencyTag:Show() - t.FrequencyTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) - tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.FrequencyTag, 'TOPLEFT' - else - t.FrequencyTag:Hide() - end - if info.typeTag then - t.TypeTag:SetTexCoord(unpack(info.typeTag)) - t.TypeTag:Show() - t.TypeTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) - tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.TypeTag, 'TOPLEFT' - else - t.TypeTag:Hide() - end - if info.completionTag then - t.CompletionTag:SetTexCoord(unpack(info.completionTag)) - t.CompletionTag:Show() - t.CompletionTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) - tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.CompletionTag, 'TOPLEFT' - else - t.CompletionTag:Hide() - end - - --[[if Devian and Devian.InWorkspace() then - t.debugText:Show() - t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle))) - end]] - return t -end - - - -mod.UpdateObjectives = function(block, info, text) - local print = B.print('BlockLine') - print(' |cFF00FF00objective updates for', block:GetName()) - - local attachmentHeight = block.attachmentHeight - print(attachmentHeight) - if info.description and not(info.earnedBy or info.isComplete) then - print(' -- has description text:', select('#', info.description), info.description) - text = info.description - end - local completionScore, completionMax = 0, 0 - - for i, line in ipairs(info.objectives) do - print(attachmentHeight) - print(' |cFF88FF00objective', i) - block.handler.ParseObjective(line, info) - - if line.title then - info.title = line.title - line.title = nil + block.endPoint = line end - if line.widget then - if attachmentHeight == 0 then - attachmentHeight = (block.status.spacing or block.status:GetSpacing()) * 2 - --print(attachmentHeight) - end - line.widget:Show() - line.widget:SetParent(block) - line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight ) - print(' has a widget, height is', line.widget.height) - attachmentHeight = attachmentHeight + line.widget.height - completionScore = completionScore + line.progress - completionMax = completionMax + 2 + if attachmentHeight > 0 then + block.attachmentHeight = attachmentHeight + textSpacing * 2 + print(' |cFF00FF00attachment:', block.attachmentHeight) end - if line.displayText then - print(' has text') - text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r' + local lines = handler.lines[block.blockIndex] + local numObjectives = info.numObjectives + local numLines = #lines + if numLines > numObjectives then + print(' has extra lines, need to clean up;', numLines, numObjectives) + for i = numObjectives+1, numLines do + print(' hide', i, lines[i]:GetName()) + lines[i]:Hide() + end end end + print(' displayHeader:', displayObjectiveHeader) + + if debug then + for i, region in ipairs(block.debug) do + for j = 1, region:GetNumPoints() do + local _, target = region:GetPoint(j) + if target:IsVisible() then + region:Hide() + else + region:Show() + end + end + end + end + block.completionScore = completionScore / completionMax - block.attachmentHeight = attachmentHeight +end - if #text >= 1 then - block.status:SetText(text) - block.status:SetWordWrap(true) - else - block.status:SetText(nil) - block.status:Hide() +Bonus.UpdateObjectives = function(handler, block) + Default.UpdateObjectives(handler, block) +end + +local CLICK_TO_COMPLETE = 'Click to Complete' +local CLICK_TO_ACCEPT = 'Click to Accept' + +AutoQuest.UpdateObjectives = function(handler, block) + local print = lprint + if block.info.type == 'OFFER' then + block.status:SetText(CLICK_TO_ACCEPT) end end ---- Objective parsers --- defines the following variables +Quest.UpdateObjectives = function(handler, block) + local print = lprint + print('|cFF00FFFFUpdateObjectives()') + Default.UpdateObjectives(handler, block) + local info = block.info + local completionText + if info.isAutoComplete then + local questID, popupType = GetAutoQuestPopUp(info.questLogIndex) + if popupType == 'COMPLETE' then + completionText = CLICK_TO_COMPLETE + end + end + if not completionText then + completionText = GetQuestLogCompletionText(info.questLogIndex) + end + + block.status:SetText() +end + +--- Module-specific display variables -- * height - height of whatever display widget is involved in conveying the task --- * lines - number of non-wrapped text lines to account for line space; may be discarded depending on things -- * money - boolean that determines listening for money events or not -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively -DefaultTracker.ParseObjective = function(line, info) +Quest.UpdateLine = function(handler, block, line, data) + local print = lprint + print(' |cFFFF0088', block:GetName(), line.index, data.type) + local objectiveType = data.type + local r, g, b, a = 0, 1, 1, 1 + line.progress = 0 + if data.finished then + line.progress = 2 + r, g, b, a = 0, 1, 0, 1 + elseif objectiveType == 'monster' then + r, g, b, a = 1, 0, .45, 1 + elseif objectiveType == 'item' then + r, g, b, a = .8, .8, .8, 1 + elseif objectiveType == 'object' then + r, g, b, a = 1, 1, 1, 1 + elseif objectiveType == 'player' then + r, g, b, a = 0, 0.8, 1, 1 + end + + line.displayColor = {r, g, b, a} + line.status:SetTextColor(r, g, b, a) + line.displayText = data.text + return line +end + +Bonus.UpdateLine = function(handler, block, line, data) + local info = block.info + local print = lprint + + + line.displayColor = 'FFFFFF' + if data.text and not info.title then + print('using first text item as title') + info.title = data.text + else + line.displayText = data.text + end + + line.progress = 0 + print(' ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text) + if data.objectiveType == 'progressbar' then + line.widgetType = 'ProgressBar' + print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) + data.value = GetQuestProgressBarPercent(info.questID) or 0 + data.maxValue = 100 + if data.value >= data.maxValue then + line.progress = 1 + elseif data.value > 0 then + line.progress = 2 + end + line.format = PERCENTAGE_STRING + local widget = mod.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex) + print(' |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue) + widget:SetPoint('CENTER', line, 'CENTER', 0, 0) + + line.widget = widget + line.height = widget.height + else + line.displayText = data.text + line.widget = nil + end + return line +end + +Cheevs.UpdateLine = function(handler, block, line, data) + local print = B.print('CheevsLine') + line.progress = 0 + print(' ', data.objectiveIndex,'|cFF0088FF-|r', data.objectiveType, data.text) + if data.flags then + if band(data.flags, 0x00000001) > 0 then + line.format = "%d/%d" + line.widget = mod.SetWidget(line, data, 'ProgressBar', data.criteriaID) + line.height = line.widget.height + elseif band(data.flags, 0x00000002) then + line.widget = nil + else + line.widget = nil + line.displayColor = 'FFFFFF' + line.displayText = line.text + + end + else + + line.displayText = data.text + end + print('line.type =', data.type) + print(' ** qtyStr:', data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID) +end +Default.UpdateLine = function(block, line) if line.finished then line.progress = 2 elseif line.quantity > 0 then @@ -402,77 +387,7 @@ else line.progress = 0 end - -end - -Bonus.ParseObjective = function(line, info) - local print = B.print('BonusLine') - - - line.displayColor = 'FFFFFF' - if line.text and not info.title then - line.title = line.text - else - line.displayText = line.text - end - - line.progress = 0 - print(' ', line.index,'|cFFFF0088-|r', line.objectiveType, line.text) - if line.objectiveType == 'progressbar' then - line.widgetType = 'ProgressBar' - print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) - line.value = GetQuestProgressBarPercent(info.questID) or 0 - line.maxValue = 100 - if line.value >= line.maxValue then - line.progress = 1 - elseif line.value > 0 then - line.progress = 2 - end - line.format = PERCENTAGE_STRING - line.widget = mod.SetWidget(line, info, 'ProgressBar', info.questID..'-'..line.index) - print(' ** text:', line.text, 'value:', line.value, 'max:', line.maxValue) - else - line.widget = nil - end -end - -Cheevs.ParseObjective = function(line, info) - local print = B.print('CheevsLine') - line.progress = 0 - if line.flags then - if band(line.flags, 0x00000001) > 0 then - line.format = "%d/%d" - line.widget = mod.SetWidget(line, info, 'ProgressBar', line.criteriaID) - elseif band(line.flags, 0x00000002) then - line.widget = nil - else - line.widget = nil - line.displayColor = 'FFFFFF' - line.displayText = line.text - - end - end - print('line.type =', line.type) - print(' ** qtyStr:', line.quantityString, 'qty:', line.quantity, 'assetID:', line.assetID) -end - -Quest.ParseObjective = function(line) - local print = B.print('QuestLine') - print(' |cFFFF0088', line.type) - local color = '00FFFF' - line.progress = 0 - if line.finished then - line.progress = 2 - color = 'FFFFFF' - elseif line.type == 'monster' then - color = 'FFFF00' - elseif line.type == 'item' then - color = '44DDFF' - elseif line.type == 'object' then - color = 'FF44DD' - end - line.displayColor = color - line.displayText = line.text + return line end @@ -561,6 +476,242 @@ end --]=] + +Default.Update = function (self, reason, ...) + local print = tprint + local tracker = self.frame + print('|cFFFF4400'..tracker:GetName().. '|r:Update()', reason, ...) + local blockIndex = 0 + local trackerHeight = floor(tracker.titlebg:GetHeight()+.5) + + self.currentAnchor = tracker.titlebg + local numWatched = self:GetNumWatched() + local numBlocks = self.numBlocks + local actualBlocks = 0 + for watchIndex = 1, 25 do + blockIndex = blockIndex + 1 + if watchIndex <= numWatched then + local info = self:GetInfo(watchIndex) + if info then + local currentBlock = self:UpdateBlock(blockIndex, info) + currentBlock:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, -1) + currentBlock:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) + self.currentAnchor = currentBlock + print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) + trackerHeight = trackerHeight + currentBlock.height + numBlocks = max(numBlocks, watchIndex) + actualBlocks = actualBlocks + 1 + else + print(' |cFFFF0000bad GetInfo data for #'..watchIndex) + end + + elseif watchIndex <= numBlocks then + local used = self.usedBlocks + local free = self.freeBlocks + print('clean up dead quest block') + if used[blockIndex] then + used[blockIndex]:Hide() + used[blockIndex]:ClearAllPoints() + free[#free+1]= used[blockIndex] + used[blockIndex] = nil + end + else + print(' |cFFFF9900END|r @', blockIndex) + break -- done with quest stuff + end + end + self.numWatched = numWatched + self.numBlocks = numBlocks + self.actualBlocks = actualBlocks + + tracker.previousHeight = tracker.height + if numBlocks >= 1 then + previousBlock = nil + + tracker.height = trackerHeight + tracker.titlebg:GetHeight() + tracker:SetHeight(tracker.height) + tracker:Show() + + + else + tracker.height = 0 + tracker:Hide() + end + + return tracker.numWatched, tracker.numAll +end + +--- Updates the selected block frame to display the given info batch +-- If `previousBlock` is set, it will attempt to anchor to that +-- @param blockNum the ordered block to be updated, not a watchIndex value +-- @param info the reference returned by the GetXInfo functions +-- REMEMBER: t.info and questData[questID] are the same table +Default.UpdateBlock = function (self, blockIndex, info) + local print = bprint + print(' Read list item |cFF00FFFF'..blockIndex..'|r') + if not blockIndex or not info then + return + end + local frame = self.frame + local block = self:GetBlock(blockIndex) + block.handler = self + block.info = info + block.mainStyle = info.mainStyle or 'Normal' + block.subStyle = info.subStyle + + info.blockIndex = blockIndex + if info.questID then self.QuestBlock[info.questID] = block end + if info.questLogIndex then self.LogBlock[info.questLogIndex] = block end + if info.watchIndex then self.WatchBlock[info.watchIndex] = block end + self.BlockInfo[blockIndex] = info + + block.endPoint = block.titlebg + block.attachmentHeight = 0 + block:UpdateObjectives() + + block.title:SetText(info.title) + local titleHeight = floor(block.title:GetHeight()+.5) + local statusHeight = floor(block.status:GetHeight()+.5) + local attachmentHeight =floor(block.attachmentHeight + .5) + local titlebgHeight = titleHeight + titleSpacing*2 + local statusbgHeight = statusHeight + textSpacing*2 + + block.titlebg:SetHeight(titlebgHeight) + + + print(' |cFF0088FFanchor to', self.currentAnchor:GetName()) + + print(' |cFF00FF00total sizes:') + print(' attachment:', attachmentHeight) + print(' title:', titlebgHeight, '('.. titleHeight..')') + --block.titlebg:SetHeight(block.title:GetHeight() + mod.Conf.Wrapper.TitleSpacing) + block.height = titlebgHeight + attachmentHeight + if statusHeight > 1 then + block.height = block.height + statusbgHeight + print(' status:', statusbgHeight, '('.. statusHeight..')') + else + print(' |cFFFF0088 skipped') + end + block:SetHeight(block.height) + + print(' |cFFFFFF00height|r:', block.height) + print(' |cFF00FFFF)|r -> ', block, block:GetHeight()) + + block:Show() + + + if info.specialItem and not info.itemButton then + print(' - |cFF00FFFFgenerating item button for info set') + info.itemButton = mod.SetItemButton(block, info) + else + --info.itemButton = nil + end + + local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block, 'TOPRIGHT' + if info.rewardInfo then + print('has immediate reward') + if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then + block.icon:Show() + block.iconLabel:SetText(info.rewardInfo[1].count) + block.icon:SetSize(block.height, block.height) + block.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) + tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block.icon, 'TOPLEFT' + block.icon:SetTexture(info.rewardInfo[1].texture) + end + else + block.icon:Hide() + end + + if info.selected then + block.SelectionOverlay:Show() + else + block.SelectionOverlay:Hide() + end + + -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel + block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1) + block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1) + + tagPoint, tagAnchor, tagRelative = block:SetTag('frequencyTag', tagPoint, tagAnchor, tagRelative) + tagPoint, tagAnchor, tagRelative = block:SetTag('typeTag', tagPoint, tagAnchor, tagRelative) + tagPoint, tagAnchor, tagRelative = block:SetTag('completionTag', tagPoint, tagAnchor, tagRelative) + + return block +end +---------- +--- Top level methods + +local tick = 0 +function mod:Update (reason, ...) + tick = tick + 1 + local print = tprint + reason = reason or OBJECTIVE_TRACKER_UPDATE_REASON + local updateWrapper = 0 + local hasStuff + local insertingStuff + + print(format('%d |cFFFF%04X Update()', tick, bit.lshift(reason, 4)), reason, ...) + currentPosition = 0 + anchorPoint = 'TOP' + anchorFrame = Scroll + + local wrapperHeight = 0 + for id, handler in pairs(mod.orderedHandlers) do + local frame = handler.frame + + print(format(' |cFF00FFFFbitcheck (%04X vs %04x+%04x):|r', reason, handler.updateReasonModule, handler.updateReasonEvents), band(reason, handler.updateReasonModule + handler.updateReasonEvents)) + if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then + handler:Update(reason, ...) + print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) + insertingStuff = true + else + print(' |cFFFF0088'..id..'|r', 'no reason to update') + end + + if handler.numWatched >= 1 then + hasStuff = true + currentPosition = currentPosition + 1 + frame:SetParent(Scroll) + frame:SetPoint('TOP', anchorFrame, anchorPoint, 0, 0) + print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint) + anchorFrame = handler.frame + anchorPoint = 'BOTTOM' + + print('current frame height:', frame.height) + wrapperHeight = wrapperHeight + frame.height + print('|cFFFF0088total height:', wrapperHeight) + else + handler.frame:Hide() + end + end + + + if hasStuff or insertingStuff then + print('updating height to', wrapperHeight) + Wrapper:SetHeight(wrapperHeight) + Scroller:SetHeight(wrapperHeight) + Scroll:SetHeight(wrapperHeight) + Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0) + print('|cFFFF8800Wrapper:', Wrapper:GetSize()) + for i = 1, Wrapper:GetNumPoints() do + print(' ', Wrapper:GetPoint(i)) + end + print(' |cFF00FFFFScroller:', Scroller:GetSize()) + for i = 1, Scroller:GetNumPoints() do + print(' ', Scroller:GetPoint(i)) + end + print(' |cFF00FFFFScroll:', Scroll:GetSize()) + for i = 1, Scroll:GetNumPoints() do + print(' ', Scroll:GetPoint(i)) + end + + Wrapper:Show() + Scroller:Show() + Scroll:Show() + end + +end + --- Queue any active item buttons for update for that frame mod.UpdateActionButtons = function(updateReason) Scroller.snap_upper = 0 diff -r 6bd2102d340b -r d5ee940de273 ObjectiveInfo.lua --- a/ObjectiveInfo.lua Wed Apr 06 07:54:19 2016 -0400 +++ b/ObjectiveInfo.lua Fri Apr 08 06:12:05 2016 -0400 @@ -33,26 +33,26 @@ AutoQuest.WatchBlock = {} function AutoQuest:GetNumWatched () print(self.name, self) + Quest:GetNumWatched() self.numWatched = GetNumAutoQuestPopUps() + return self.numWatched end AutoQuest.GetInfo = function(self, popupIndex) local questID, type = GetAutoQuestPopUp(popupIndex) local questIndex = GetQuestLogIndexByID(questID) - local questWatchIndex = GetQuestWatchIndex(questIndex) + local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex) - local questInfo = Quest:GetInfo(questWatchIndex) self.Info[questID] = { - title = questInfo.title, + title = title, description = type, popupType = type, questID = questID, questIndex = questIndex, popupIndex = popupIndex, - watchIndex = questWatchIndex, - numObjectives = 0 } + self.WatchInfo[popupIndex] = self.Info[questID] return self.Info[questID] @@ -60,39 +60,125 @@ ----------------------------- --- BONUS OBJECTIVE -Bonus.TasksTable = {} -Bonus.TasksPOI = {} -Bonus.TaskScenario = {} +-- The default UI pops them up as you enter their relevant areas, but the data is actually available at all times. +-- The only requirement is that you've been to said area and progressed any of the objectives. +-- Blizzard deal with this fact by caching any task data collected during session and masking out whatever gets completed. +-- For the addon's module structure to work, GetNumWatched method also invokes a tasks table scan. +-- That composes the table searched by GetInfo(). -local taskData = {} +------------------------------------------------------------------------------------------ +--- These functions are copied from Blizzard_BonusObjectiveTracker.lua; +-- It's kind of dumb, but this avoids the risk of code taint. + +--- Returns a tasks table modified to include recently completed objectives +local completedTasks = {} +local InternalGetTasksTable = function() + local tasks = GetTasksTable() + for questID, data in pairs(completedTasks) do + if questID > 0 then + local found = false + for i = 1, #tasks do + if tasks[i] == questID then + found = true + break + end + end + -- if it's not part of the current table, then try to insert it where it was last found + if not found then + if data.watchIndex < #tasks then + tinsert(tasks, data.watchIndex, data) + else + tinsert(tasks, data) + end + end + end + end + return tasks +end + +--- Returns an entry from the composed tasks table if possible, otherwise makes an API pull +local InternalGetTaskInfo = function(questID) + if completedTasks[questID] then + return true, true, #completedTasks[questID].objectives + else + return GetTaskInfo(questID) + end +end + +--- Same as above but for the objective entries +local InternalGetQuestObjectiveInfo = function(questID, objectiveIndex) + if ( completedTasks[questID] ) then + return completedTasks[questID].objectives[objectiveIndex], completedTasks[questID].objectiveType, true; + else + return GetQuestObjectiveInfo(questID, objectiveIndex, false); + end +end + +--- end redundant copy of silliness +------------------------------------------------------------------------------------------ + +Bonus.Completed = {} +Bonus.POI = {} +Bonus.Scenario = {} Bonus.QuestBlock = {} -Bonus.TaskWatch = {} function Bonus:GetNumWatched () print(self.name, self) - local tasks = GetTasksTable() - local numTasks = 0 - Bonus.TaskWatch = {} + local tasks = InternalGetTasksTable() + local numWatched = 0 + local numAll = 0 + self.WatchInfo = {} print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks) for i, questID in ipairs(tasks) do - local t = Bonus.StoreTask(questID) - print (' taskIndex', i, 'questID', questID) - print(' isComplete', t.isComplete) - if (t.inInArea or t.isOnMap) and not t.isComplete then - numTasks = numTasks + 1 - Bonus.TaskWatch[numTasks] = t + local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID) + local existingTask = self.QuestBlock[questID] + local displayObjectiveHeader = false; + print (' |cFF00FF00taskIndex', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N')) + if isInArea or isOnMap then + self.Info[questID] = self.Info[questID] or {} + + local t = self.Info[questID] + local title = GetQuestLogTitle(questID) + self.WatchInfo[i] = t + t.title = title + t.isInArea = isInArea + t.isOnMap = isOnMap + t.existingTask = existingTask + t.questID = questID + t.objectives = {} + t.taskIndex = i + + local taskFinished = true; + for objectiveIndex = 1, numObjectives do + local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false); + displayObjectiveHeader = displayObjectiveHeader or displayAsObjective; + print(' --', text, objectiveType, finished, displayAsObjective) + t.objectives[objectiveIndex] = t.objectives[objectiveIndex] or {} + local o = t.objectives[objectiveIndex] + + o.objectiveIndex = objectiveIndex + o.text = text + o.objectiveType = objectiveType + o.finished = finished + o.displayAsObjective = displayAsObjective + print(' |cFF00FF88*', objectiveIndex, text) + end end end - Bonus.numAll = #Bonus.TasksTable - Bonus.numWatched = numTasks + + + self.numAll = #tasks + self.numWatched = #self.WatchInfo + print(' stats:', self.numAll, 'active tasks,', self.numWatched, 'nearby or animating') + --return #tasks return GetNumQuestLogTasks() end Bonus.GetInfo = function(self, taskIndex) print(self.name, self) - return Bonus.TaskWatch[taskIndex] + return self.WatchInfo[taskIndex] end -Bonus.StoreTask = function(questID) +Bonus.Store = function(questID) if not questID then print('|cFFFF4400invalid quest ID', questID) @@ -347,6 +433,7 @@ Cheevs.GetNumWatched = function(self) + print('|cFF00FF00' .. GetTime()) Cheevs.trackedCheevs = {GetTrackedAchievements()} return GetNumTrackedAchievements() end @@ -367,7 +454,7 @@ for i = 1, c.numObjectives do local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i) c.objectives[i] = { - index = i, + objectiveIndex = i, cheevID = cheevID, text = description, type = type, diff -r 6bd2102d340b -r d5ee940de273 ObjectiveStyle.lua --- a/ObjectiveStyle.lua Wed Apr 06 07:54:19 2016 -0400 +++ b/ObjectiveStyle.lua Fri Apr 08 06:12:05 2016 -0400 @@ -53,11 +53,6 @@ Frame = { } }, - Wrapper = { - title = { - Font = {wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline}, - Spacing = 4,} - }, Tracker = { Normal = { title = { @@ -74,7 +69,7 @@ Normal = { titlebg = { Indent = 2, - Gradient = { 'HORIZONTAL', MinColor = {0.7, 0, 0.9, 0}, MaxColor = {.7, 0, 0.9, .25}}, + Gradient = { 'HORIZONTAL', MinColor = {0.7, 0, 0.9, 1}, MaxColor = {.7, 0, 0.9, .1}}, }, title = { TextColor = {1,1,1,1}, @@ -87,15 +82,15 @@ Spacing = textSpacing, }, statusbg = { - Gradient = { 'HORIZONTAL', MinColor = {0.2, .4, 1, 0}, MaxColor = {.7, 0, 0.9, .11}}, + Gradient = { 'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, .1}}, } }, Daily = { titlebg = { - Gradient = {'HORIZONTAL', MinColor = {0, .4, 1, 0}, MaxColor = {0, 0.4, 1, .35}, }, + Gradient = {'HORIZONTAL', MinColor = {0, .4, 1, 1}, MaxColor = {0, 0.4, 1, .1}, }, }, statusbg = { - Gradient = {'HORIZONTAL', MinColor = {0, .4, 1, 0}, MaxColor = {0, 0.35, .90, .31}, }, + Gradient = {'HORIZONTAL', MinColor = {0, .4, 1, 1}, MaxColor = {0, 0.35, .90, .1}, }, }, title = { TextColor = {0.7,1,1,1}, @@ -115,7 +110,7 @@ Spacing = titleSpacing, BackgroundFullWidth = true }, titlebg = { - Gradient = { 'HORIZONTAL', MinColor = {0, .7, .6, 0}, MaxColor = {0, .7, .6, 0.23}}, + Gradient = { 'HORIZONTAL', MinColor = {0, .7, .6, 1}, MaxColor = {0, .7, .6, 1}}, }, status = { TextColor = {1,1,1,1}, @@ -123,7 +118,7 @@ Spacing = textSpacing, }, statusbg = { - Gradient = { 'HORIZONTAL', MinColor = {0, .7, .6, 0}, MaxColor = {0, .7, .6, 0.23} }, + Gradient = { 'HORIZONTAL', MinColor = {0, .7, .6, 1}, MaxColor = {0, .7, .6, 1} }, }, }, MouseDown = { @@ -132,14 +127,14 @@ Spacing = titleSpacing, }, titlebg = { - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .4}, }, + Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, 1}, }, }, status = { Font = {textFont, textSize, textOutline}, Spacing = textSpacing, }, statusbg = { - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, .2}, }, + Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {0.2, .4, 1, 1}, }, } }, Complete = { @@ -148,21 +143,21 @@ Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, }, titlebg = { - Gradient = {'HORIZONTAL', MinColor = {0, 1, 0, 0}, MaxColor = {0, 1, 0, 0.34}, }, + Gradient = {'HORIZONTAL', MinColor = {0, 1, 0, 1}, MaxColor = {0, 1, 0, 1}, }, }, status = { TextColor = {1,1,1,1}, Font = {textFont, textSize, textOutline}, Spacing = textSpacing, }, statusbg = { - Gradient = {'HORIZONTAL', MinColor = {0, 1, 0, 0}, MaxColor = {0, 1, 0, .25}, }, + Gradient = {'HORIZONTAL', MinColor = {0, 1, 0, 1}, MaxColor = {0, 1, 0, 1}, }, } }, AutoQuest = { Normal = { titlebg = { Indent = 2, - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 0}, MaxColor = {.7, 0, 0.9, .14}}, + Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, 1}}, }, title = { TextColor = {1,1,1,1}, @@ -175,7 +170,7 @@ Spacing = textSpacing, }, statusbg = { - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 0}, MaxColor = {.7, 0, 0.9, .11}}, + Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, 1}}, } }, }, @@ -187,7 +182,7 @@ Spacing = titleSpacing, }, titlebg = { - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, + Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, 1}}, }, status = { @@ -195,7 +190,7 @@ Spacing = textSpacing, }, statusbg = { - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, + Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, 1}}, }, }, Complete = { @@ -204,14 +199,14 @@ Spacing = titleSpacing, }, titlebg = { - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 0.45}, MaxColor = {.7, 0, 0.9, .19}}, + Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, 1}}, }, status = { Font = {textFont, textSize, textOutline}, Spacing = textSpacing, }, statusbg = { - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 0.25}, MaxColor = {.7, 0, 0.9, .12}}, + Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, 1}}, }, }, } @@ -381,10 +376,12 @@ frame.width = defaultWidth frame.statusWidth = defaultWidth - normalSettings.status.Indent frame.titleWidth = defaultWidth - normalSettings.title.Indent + frame.attachmentHeight = frame.attachmentHeight or 0 if frame.title then frame.titleHeight = frame.title and frame.title:GetStringHeight() or 0 if frame.titleHeight > 0 then + print('add spacing to', frame.titleHeight) frame.titleHeight = frame.titleHeight + (frame.title.spacing or 0)*2 end @@ -397,28 +394,40 @@ frame.titlebg:SetWidth(frame.width) end print(' titleHeight', frame.titleHeight, 'indent', normalSettings.title.Indent, 'spacing', frame.title.spacing) + print(' -- text:', frame.title:GetSize()) + print(' -- bg:', frame.titlebg:GetSize()) + else frame.titleHeight = 0 end - if frame.status then + + if frame.status and (frame.status:GetText() or frame.attachmentHeight > 0) then frame.statusHeight = frame.status and frame.status:GetStringHeight() or 0 if frame.statusHeight > 0 then frame.statusHeight = frame.statusHeight + (frame.status.spacing or 0)*2 end frame.status.spacing = frame.status.spacing or frame.status:GetSpacing() + frame.status:SetWidth(frame.width) frame.status:SetPoint('LEFT', frame, 'LEFT', normalSettings.status.Indent, 0) frame.status:SetPoint('TOP', frame.titlebg, 'BOTTOM', 0, 0) - frame.status:SetHeight(frame.statusHeight) + --frame.status:SetHeight(frame.statusHeight) if frame.statusbg then - frame.statusbg:SetHeight(frame.statusHeight + (frame.attachmentHeight or 0)) + --frame.statusbg:SetHeight(frame.statusHeight + (frame.attachmentHeight or 0)) + --frame.statusbg:SetPoint('BOTTOM', frame, 'BOTTOM', 0, 0) frame.statusbg:SetWidth(frame.width) end print(' status tHeight', frame.statusHeight, 'indent', normalSettings.status.Indent, 'spacing', frame.status.spacing) else + if frame.status then + frame.status:Hide() + end + if frame.statusbg then + frame.statusbg:Hide() + end frame.statusHeight = 0 end diff -r 6bd2102d340b -r d5ee940de273 ObjectiveTracker.xml --- a/ObjectiveTracker.xml Wed Apr 06 07:54:19 2016 -0400 +++ b/ObjectiveTracker.xml Fri Apr 08 06:12:05 2016 -0400 @@ -1,10 +1,17 @@ - + + + + + + + + self.toggle = true - self.drag = true + --self.drag = true Veneer.OnLoad(self) @@ -16,8 +23,8 @@ Veneer.OnDragStop(self) Veneer.ObjectiveTracker.UpdateActionButtons() - - + + @@ -81,7 +88,7 @@ - + @@ -95,7 +102,7 @@ - + @@ -223,17 +230,19 @@ - - - + + - + + + + @@ -241,6 +250,8 @@ + + -