# HG changeset patch # User Nenue # Date 1460277332 14400 # Node ID e837384ac3635da9f29106a47d6e5bfe96a71166 # Parent 9b3fa734abff0c6ed91ebb62432863190462fae9 Separating objective tracker module diff -r 9b3fa734abff -r e837384ac363 ObjectiveCore.lua --- a/ObjectiveCore.lua Sat Apr 09 07:32:45 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,436 +0,0 @@ ---- ${PACKAGE_NAME} --- @file-author@ --- @project-revision@ @project-hash@ --- @file-revision@ @file-hash@ --- Created: 3/26/2016 1:51 AM -local B, _G = select(2,...).frame, _G -local pairs, setmetatable, type, tostring, band, format = _G.pairs, _G.setmetatable, _G.type, _G.tostring, bit.band, string.format -local ipairs, tinsert, hooksecurefunc = _G.ipairs, _G.tinsert, _G.hooksecurefunc -local PlaySoundFile, IsQuestTask, SortQuestWatches, GetCurrentMapAreaID, GetZoneText, GetMinimapZoneText = PlaySoundFile, IsQuestTask, SortQuestWatches, GetCurrentMapAreaID, GetZoneText, GetMinimapZoneText -local AddQuestWatch, SetSuperTrackedQuestID, GetNumQuestWatches, AUTO_QUEST_WATCH, MAX_WATCHABLE_QUESTS = AddQuestWatch, SetSuperTrackedQuestID, GetNumQuestWatches, AUTO_QUEST_WATCH, MAX_WATCHABLE_QUESTS -local QuestPOIUpdateIcons, GetCVar, IsPlayerInMicroDungeon, WorldMapFrame, GetCVarBool, SetMapToCurrentZone = QuestPOIUpdateIcons, GetCVar, IsPlayerInMicroDungeon, WorldMapFrame, GetCVarBool, SetMapToCurrentZone -local AddAutoQuestPopUp = AddAutoQuestPopUp -local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') -local print = B.print('Objectives') -local ObjectiveTrackerFrame, VeneerObjectiveScroll, CreateFrame = _G.ObjectiveTrackerFrame, _G.VeneerObjectiveScroll, _G.CreateFrame -local Wrapper = _G.VeneerObjectiveWrapper -local Scroller = VeneerObjectiveWrapper.scrollArea -local Scroll = _G.VeneerObjectiveScroll - ---- Performance values ---[[ - self:RegisterEvent("QUEST_LOG_UPDATE"); - self:RegisterEvent("TRACKED_ACHIEVEMENT_LIST_CHANGED"); - self:RegisterEvent("QUEST_WATCH_LIST_CHANGED"); - self:RegisterEvent("QUEST_AUTOCOMPLETE"); - self:RegisterEvent("QUEST_ACCEPTED"); - self:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED"); - self:RegisterEvent("SCENARIO_UPDATE"); - self:RegisterEvent("SCENARIO_CRITERIA_UPDATE"); - self:RegisterEvent("TRACKED_ACHIEVEMENT_UPDATE"); - self:RegisterEvent("ZONE_CHANGED_NEW_AREA"); - self:RegisterEvent("ZONE_CHANGED"); - self:RegisterEvent("QUEST_POI_UPDATE"); - self:RegisterEvent("VARIABLES_LOADED"); - self:RegisterEvent("QUEST_TURNED_IN"); - self:RegisterEvent("PLAYER_MONEY"); - ]] - - ---- These are the bitfields used by Blizzard_ObjectiveTracker to determine which segments get parsed. ---- They are replicated here so that plugins can make use of any securehook args involving this info. -local OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST -- 0x0100 -local OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP = OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP -- 0x0200 -local OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE = OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE -- 0x0400 -local OBJECTIVE_TRACKER_UPDATE_MODULE_SCENARIO = OBJECTIVE_TRACKER_UPDATE_MODULE_SCENARIO -- 0x0800 -local OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT = OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT -- 0x1000 - - -local OBJECTIVE_TRACKER_UPDATE_STATIC = OBJECTIVE_TRACKER_UPDATE_STATIC -- 0x0000 -local OBJECTIVE_TRACKER_UPDATE_ALL = OBJECTIVE_TRACKER_UPDATE_ALL -- 0xFFFF -local OBJECTIVE_TRACKER_UPDATE_ID = OBJECTIVE_TRACKER_UPDATE_ID -- 0 - -local OBJECTIVE_TRACKER_UPDATE_QUEST = OBJECTIVE_TRACKER_UPDATE_QUEST -- 0x0001 -local OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED = OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED -- 0x0002 -local OBJECTIVE_TRACKER_UPDATE_TASK_ADDED = OBJECTIVE_TRACKER_UPDATE_TASK_ADDED -- 0x0004 -local OBJECTIVE_TRACKER_UPDATE_SCENARIO = OBJECTIVE_TRACKER_UPDATE_SCENARIO -- 0x0008 -local OBJECTIVE_TRACKER_UPDATE_SCENARIO_NEW_STAGE = OBJECTIVE_TRACKER_UPDATE_SCENARIO_NEW_STAGE -- 0x0010 -local OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT = OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT -- 0x0020 -local OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED = OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED -- 0x0040 -local OBJECTIVE_TRACKER_UPDATE_SCENARIO_BONUS_DELAYED = OBJECTIVE_TRACKER_UPDATE_SCENARIO_BONUS_DELAYED -- 0x0080 - -local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_ALL -- default ---- Used to determine which trackers are listening for money events -mod.watchMoneyReasons = 0 - ---- Baseline defaults table; values defined in the files that they pertain to -mod.defaults = {} - ---- Tracker display order -mod.orderedNames = {'Bonus', 'AutoQuest', 'Quest', 'Cheevs'} - ---- ipairs() argument tables -mod.orderedHandlers = setmetatable({}, {__mode = "k"}) -mod.orderedTrackers = setmetatable({}, {__mode = "k"}) -mod.indexedTrackers = setmetatable({}, {__mode = "k"}) - ---- pairs() argument tables -mod.namedTrackers = setmetatable({}, {__mode = "k"}) - -local WRAPPER_ANCHOR_POINT = 'TOPRIGHT' -local WRAPPER_OFFSET_X = 0 -local WRAPPER_OFFSET_Y = -200 -local WRAPPER_MAX_HEIGHT = 670 -local WRAPPER_WIDTH = 280 -local WRAPPER_HEADER_HEIGHT = 24 - -mod.defaults.Wrapper = { - AnchorPoint = WRAPPER_ANCHOR_POINT, - OffsetX = WRAPPER_OFFSET_X, - OffsetY = WRAPPER_OFFSET_Y, - Height = WRAPPER_MAX_HEIGHT, - Width = WRAPPER_WIDTH, - 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.DefaultHandler = { - previousHeight = 0, - - name = "temp", - displayName = "temp", - updateReasonModule = 0xFF00, - updateReasonEvent = 0x00FF, - - numWatched = 0, --- number of entries being handled - numBlocks = 0, --- number of blocks created - actualBlocks = 0, --- number of blocks in use - - freeBlocks = {}, --- block heap - usedBlocks = {}, - - Info = {}, -- find data by ID - BlockInfo = {}, -- find data by block ID - Watched = {}, -- find watchIndex by data ID - WatchInfo = {}, -- find data by watch index - WatchBlock = {}, -- find block by watch index -} - -mod.AutoQuest = { - name = "AutoQuest", - displayName = "Notice", - updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, - updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + - OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, -} -mod.Quest = { - name = "Quest", - displayName = "Quests", - updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, - updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + - OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, -} -mod.Cheevs = { - name = "Cheevs", - displayName = "Achievements", - updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT, - updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT + - OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED, -} -mod.Bonus = { - name = "Bonus", - displayName = "Bonus Objectives", - updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE, - updateReasonEvents = OBJECTIVE_TRACKER_UPDATE_QUEST + OBJECTIVE_TRACKER_UPDATE_TASK_ADDED -} - -local Tracker_string = function (self) - return self.name -end -local Tracker_call = function (self, reason) - self:Update(reason) -end -local Handler_Initialize = function (self, name, index) - print('Initializing |cFF00FFFF'..name..'|r module...') - - local handler = setmetatable(mod[name] or {}, { - __tostring = Tracker_string, - __call = Tracker_call - }) - if type(mod.orderedHandlers[index]) == 'table' then - return mod.orderedHandlers[index] - end - - print('|cFFFFFF00Acquiring locals') - local preset = {} - for k, _ in pairs(handler) do - preset[k] = true - end - - - print('|cFFFF8800Inheriting') - for k, v in pairs(self) do - if not handler[k] then - if type(v) == 'table' then - -- assume all tables to be local data; don't inherit or ref - handler[k] = {} - else - handler[k] = self[k] - end - print('copying', k) - end - end - print('|cFFFF4400'..tostring(name)..'|r:') - for k, v in pairs(handler) do - print(format("%32s %8s %s", (preset[k] and '|cFFFFFFFF' or '|cFFFFFF00') .. k .. '|r', type(v), tostring(v))) - end - - mod[name] = handler - - local trackerName = 'Veneer'..name..'Tracker' - local handler = mod[name] - local frame = CreateFrame('Frame', trackerName, _G.VeneerObjectiveScroll, 'VeneerTrackerTemplate') - frame.title:SetText(handler.displayName) - 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 - print('|cFFFF0088' .. trackerName .. '|r created for |cFF00FFFF' .. handler.displayName .. '|r module') - - mod.orderedHandlers[index] = handler - return true -end - -local Event = {} -Event.QUEST_LOG_UPDATE = function() - return OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST + OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE -end -Event.QUEST_ACCEPTED = function(questLogIndex, questID) - if ( IsQuestTask(questID) ) then - return OBJECTIVE_TRACKER_UPDATE_TASK_ADDED, questID - else - if ( AUTO_QUEST_WATCH == "1" and GetNumQuestWatches() < MAX_WATCHABLE_QUESTS ) then - AddQuestWatch(questLogIndex); - SetSuperTrackedQuestID(questID); - end - return OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST - end -end -Event.QUEST_WATCH_LIST_CHANGED = function(questID, added) - if ( added ) then - if ( not IsQuestTask(questID) ) then - return OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID, added - end - else - return OBJECTIVE_TRACKER_UPDATE_QUEST, questID, added - end -end -Event.QUEST_POI_UPDATE = function() - - QuestPOIUpdateIcons(); - if ( GetCVar("trackQuestSorting") == "proximity" ) then - SortQuestWatches(); - end - - return OBJECTIVE_TRACKER_UPDATE_ALL - -end -Event.SUPER_TRACKED_QUEST_CHANGED = function() - return OBJECTIVE_TRACKER_UPDATE_QUEST -end -Event.ZONE_CHANGED = function() - - local inMicroDungeon = IsPlayerInMicroDungeon(); - if ( inMicroDungeon ~= mod.inMicroDungeon ) then - if ( not WorldMapFrame:IsShown() and GetCVarBool("questPOI") ) then - SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker - end - --SortQuestWatches(); - mod.inMicroDungeon = inMicroDungeon; - end -end -Event.QUEST_AUTOCOMPLETE = function(questId) - AddAutoQuestPopUp(questId, "COMPLETE"); - return OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST + OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP -end -Event.SCENARIO_CRITERIA_UPDATE = function() - return OBJECTIVE_TRACKER_UPDATE_SCENARIO -end -Event.SCENARIO_UPDATE = function(newStage) - if ( newStage ) then - return OBJECTIVE_TRACKER_UPDATE_SCENARIO_NEW_STAGE - else - return OBJECTIVE_TRACKER_UPDATE_SCENARIO - end -end -Event.TRACKED_ACHIEVEMENT_UPDATE = function() - return OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT -end -Event.TRACKED_ACHIEVEMENT_LIST_CHANGED = function(achievementID, added) - if ( added ) then - return OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT_ADDED, achievementID - else - return OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT - end -end -Event.ZONE_CHANGED_NEW_AREA = function () - if ( not WorldMapFrame:IsShown() and GetCVarBool("questPOI") ) then - SetMapToCurrentZone(); -- update the zone to get the right POI numbers for the tracker - end - SortQuestWatches(); - mod.currentZoneArea = GetCurrentMapAreaID() - print('Updating zone ID to', mod.currentZoneArea, '=', GetZoneText(), GetMinimapZoneText()) - - - return OBJECTIVE_TRACKER_UPDATE_TASK_ADDED -end - - -Event.PLAYER_MONEY = function() - if mod.watchMoneyReasons > 0 then - return mod.watchMoneyReasons - end -end -Event.CRITERIA_COMPLETE = function() - return OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE -end -Event.QUEST_TURN_IN = function(questID, xp, money) - if ( IsQuestTask(questID) ) then - mod.Bonus:OnTurnIn(questID, xp, money) - print('updating bonus modules (code', OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE, ',', questID, xp, money) - return OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE, questID, xp, money - else - return OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST, questID, xp, money - end -end -mod.Event = Event - ---- Done once per ui load -local BlizzHooks = { - ['AddQuestWatch'] = 'AddQuestWatch', - ['RemoveQuestWatch'] = 'RemoveQuestWatch', - ['AbandonQuest'] = 'AbandonQuest', - ['AcknowledgeAutoAcceptQuest'] = 'AcknowledgeAutoAcceptQuest', - ['AddAutoQuestPopUp'] = 'AddAutoQuestPopUp', - ['RemoveAutoQuestPopUp'] = 'RemoveAutoQuestPopUp', - ['AddTrackedAchievement'] = 'AddTrackedAchievement', - ['RemoveTrackedAchievement'] = 'RemoveTrackedAchievement', - ['SetSuperTrackedQuestID'] = 'SetSuperTrackedQuestID' -} -local VeneerData - -mod.SetWatchMoney = function(watchMoney, reason) - if watchMoney then - if band(mod.watchMoneyReasons, reason) == 0 then - mod.watchMoneyReasons = mod.watchMoneyReasons + reason; - end - else - if band(mod.watchMoneyReasons, reason) > 0 then - mod.watchMoneyReasons = mod.watchMoneyReasons - reason; - end - end -end - - -function mod:OnInitialize() - local c = mod.Conf.Wrapper - VeneerData = _G.VeneerData - VeneerData.CallLog = VeneerData.CallLog or {} - if not mod.isHooked then - mod.isHooked = true - for blizzFunc, veneerFunc in pairs(BlizzHooks) do - if mod[veneerFunc] then - hooksecurefunc(blizzFunc, mod[veneerFunc]) - else - hooksecurefunc(blizzFunc, function(...) - print('|cFFFF0088securehook('..tostring(blizzFunc)..')|r args:', ...) - tinsert(VeneerData.CallLog, {blizzFunc, ...}) - end) - end - end - end - - mod.Conf.TasksLog = mod.Conf.TasksLog or {} - - Scroller:SetScrollChild(Scroll) - Scroller:SetWidth(c.Width) - Scroll:SetWidth(c.Width) - Scroll:ClearAllPoints() - Scroll:SetPoint('TOP', Scroller, 'TOP') - ObjectiveTrackerFrame:UnregisterAllEvents() - ObjectiveTrackerFrame:Hide() -end - -function mod:OnEvent (event, ...) - local isHandled - print('OnEvent(|cFF00FF00'.. event ..'|r):', ...) - local reason, arg1, arg2, arg3 - if Event[event] then - if type(Event[event]) == 'function' then - PlaySoundFile([[Interface\Addons\SharedMedia_MyMedia\sound\Info.ogg]]) - reason, arg1, arg2, arg3 = Event[event](...) - elseif type(Event[event]) == 'table' then - PlaySoundFile([[Interface\Addons\SharedMedia_MyMedia\sound\Link.ogg]]) - for i, action in ipairs(Event[event]) do - if type(action) == 'function' then - reason, arg1, arg2, arg3 = action(event, ...) - else - reason = action - end - - if reason then - mod:Update(reason, arg1, arg2, arg3) - end - end - else - PlaySoundFile([[Interface\Addons\SharedMedia_MyMedia\sound\Heart.ogg]]) - reason = Event[event] - end - else - PlaySoundFile([[Interface\Addons\SharedMedia_MyMedia\sound\Quack.ogg]]) - end - if reason then - mod:Update(reason, arg1, arg2, arg3) - else - print('no reason value returned') - PlaySoundFile([[Interface\Addons\SharedMedia_MyMedia\sound\Quack.ogg]]) - end -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 - Handler_Initialize(mod.DefaultHandler, name, id) - end - end - - for event, action in pairs(Event) do - print('|cFFFF0088listen to', event, 'for action|r', tostring(action)) - Wrapper:RegisterEvent(event) - end - - 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:SetWidth(c.Width) - - - mod.InitializeWidgets() - mod:Update() -end - -function mod:OnDisable() - Wrapper:UnregisterAllEvents() -end - - diff -r 9b3fa734abff -r e837384ac363 ObjectiveEvents.lua --- a/ObjectiveEvents.lua Sat Apr 09 07:32:45 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ ---- ${PACKAGE_NAME} --- @file-author@ --- @project-revision@ @project-hash@ --- @file-revision@ @file-hash@ --- Created: 3/30/2016 1:23 AM -local B = select(2,...).frame -local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') -local print = B.print('Objectives') - --------------------------------------------------------------------- ---- Events that are handled by Blizzard_ObjectiveTracker --------------------------------------------------------------------- - -------------------------------------------------------------------- ---- Function hooks for BlizzUI compatibility -------------------------------------------------------------------- -mod.AddQuestWatch = function(questID) - mod:Update(0x00000003) -end - -local Quest = mod.Quest -mod.RemoveQuestWatch = function(questIndex, ...) - print('|cFFFF8800RemoveQuestWatch', questIndex, ...) - - local info = mod.Quest.LogInfo[questIndex] - - -- remove quest refs - local block = Quest.QuestBlock[info.questID] - Quest.QuestBlock[info.questID] = nil - Quest.LogBlock[questIndex] = nil - - -- remove if they still match - if Quest.WatchInfo[info.watchIndex] == info then - print('cleaning dead WatchInfo entry') - 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 - -mod.AddTrackedAchievement = function(cheevID) - mod.CleanWidgets() - mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT) -end - - -mod.RemoveTrackedAchievement = function(cheevID) - print('|cFFFF8800UntrackAchievement', cheevID) - mod.CleanWidgets() - mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_ACHIEVEMENT) -end - -mod.AcceptQuest = function() - mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST_ADDED) -end - -mod.AbandonQuest = function() - QuestPOIUpdateIcons() - mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) -end -mod.TurnInQuest = function() - QuestPOIUpdateIcons() - mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST) -end -mod.AddAutoQuestPopUp = function(...) - mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP) -end -mod.RemoveAutoQuestPopUp = function(...) - mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_AUTO_QUEST_POPUP) -end - - - -mod.SetSuperTrackedQuestID = function(questID) - --mod:Update() -end \ No newline at end of file diff -r 9b3fa734abff -r e837384ac363 ObjectiveFrame.lua --- a/ObjectiveFrame.lua Sat Apr 09 07:32:45 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,825 +0,0 @@ ---- ${PACKAGE_NAME} --- @file-author@ --- @project-revision@ @project-hash@ --- @file-revision@ @file-hash@ --- Created: 3/30/2016 12:49 AM -local B = select(2,...).frame -local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') -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 Default, AutoQuest, Quest, Bonus, Cheevs = mod.DefaultHandler, mod.AutoQuest, mod.Quest, mod.Bonus, mod.Cheevs -local CreateFrame = CreateFrame -local print = B.print('Tracker') -local unitLevel = 1 -local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON -local debug = false --------------------------------------------------------------------- ---- Global frame layout --------------------------------------------------------------------- - ---- Upvalues -local Wrapper = VeneerObjectiveWrapper -local Scroller = Wrapper.scrollArea -local Scroll = VeneerObjectiveScroll -local orderedHandlers = mod.orderedHandlers -local orderedNames = mod.orderedNames - ---- Temp values set during updates -local wrapperWidth, wrapperHeight -local scrollWidth, scrollHeight -local previousBlock -local currentBlock ---- 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 = 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 = 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 rewardSize = 32 -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 - -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) - - if lines[lineIndex+1] then - lines[lineIndex+1]:ClearAllPoints() - end - - if debug then - for _, region in ipairs(lines[lineIndex].debug) do - region:Show() - end - end - - end - return lines[lineIndex] -end - -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') - - block.icon:SetSize(rewardSize, rewardSize) - block.icon:SetPoint('TOPRIGHT', block, 'TOPRIGHT', -2, -2) - - - --- methods for event handlers - - block.Select = handler.Select - block.Open = handler.Open - block.Remove = handler.Remove - block.Link = handler.Link - block:SetScript('OnMouseUp', handler.OnMouseUp) - 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 - -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 - - 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 - attachmentHeight = textSpacing * 2 - 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.widget then - local widgetPosition = 0 - line.widget:SetPoint('TOP', line, 'TOP', 0, -widgetPosition) - line.widget:Show() - line.height = line.widget:GetHeight() + textSpacing - - if line.displayText and #line.displayText >= 1 then - widgetPosition = line.status:GetHeight() + textSpacing - line.status:SetText(line.displayText) - line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + line.widget.height - print(' - progressbar has text, adjust') - end - elseif line.displayText then - line.status:SetText(line.displayText) - line.height = floor(line.status:GetStringHeight()+.5) + textSpacing - - end - attachmentHeight = attachmentHeight + line.height - - line:Show() - - 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) - - - print(' sz', line:GetSize()) - print(' pt', line:GetPoint(1)) - print(' |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg) - - block.endPoint = line - end - - if attachmentHeight > 0 then - block.attachmentHeight = attachmentHeight - print(' |cFF00FF00attachment:', block.attachmentHeight) - end - - local lines = handler.lines[block.blockIndex] - local numObjectives = #info.objectives - local numLines = #lines - if lines and 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 -end - -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 - -Quest.UpdateObjectives = function(handler, block) - local print = lprint - print('|cFF00FFFFUpdateObjectives()') - 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 info.isComplete then - if not completionText then - completionText = GetQuestLogCompletionText(info.questLogIndex) - end - else - Default.UpdateObjectives(handler, block) - end -end - ---- Module-specific display variables --- * height - height of whatever display widget is involved in conveying the task --- * money - boolean that determines listening for money events or not --- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively - -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' - line.displayText = data.text - 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('TOP', line, 'TOP', 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 - line.progress = 1 - else - line.progress = 0 - end - return line -end - - -mod.Quest.numButtons = 0 -local usedButtons = mod.Quest.itemButtons -local freeButtons = mod.Quest.freeButtons ---[=[ -mod.UpdateWrapper = function(reason) - print('|cFF00FFFFUpdateWrapper:|r', reason) - unitLevel = UnitLevel('player') - wrapperWidth = mod.Conf.Wrapper.WrapperWidth - scrollWidth = mod.Conf.Wrapper.WrapperWidth - local wrapperBlocks = 0 - -- Update scroll child vertical size - scrollHeight = 0 - for i, handler in ipairs(orderedHandlers) do - mod.UpdateTracker(handler) - local frame = handler.frame - if handler.actualBlocks >= 1 then - frame:SetParent(Scroll) - frame:SetPoint('TOPLEFT', Scroll, 'TOPLEFT', 0, - scrollHeight) - frame:SetSize(wrapperWidth, frame.height) - print('|cFF00FFFF'..frame:GetName()..'|r h:|cFF00FF00', frame.height, '|r y:|cFF00FF00', -scrollHeight) - scrollHeight = scrollHeight + frame.height - frame:Show() - else - frame:Hide() - end - wrapperBlocks = wrapperBlocks + handler.actualBlocks - end - print('final scrollHeight:', scrollHeight) - - - - -- Update frame dimensions - if scrollHeight > wrapperMaxHeight then - print(' is larger than', wrapperMaxHeight) - wrapperHeight = wrapperMaxHeight - else - wrapperHeight = scrollHeight - B.Conf.ObjectiveScroll = 0 - end - scrollWidth = floor(scrollWidth+.5) - scrollHeight = floor(scrollHeight+.5) - wrapperWidth = floor(wrapperWidth+.5) - wrapperHeight = floor(wrapperHeight+.5) - headerHeight = floor(headerHeight+.5) - - if wrapperBlocks >= 1 then - for i, region in ipairs(Wrapper.headerComplex) do - region:Show() - end - else - for i, region in ipairs(Wrapper.headerComplex) do - region:Hide() - end - return - end - --[[wrapperHeight = scrollHeight - - print('|cFFFFFF00params:|r scroller:', scrollWidth .. ',' .. scrollHeight, 'scroll:', scrollWidth .. ',' .. scrollHeight, - 'wrapper:', wrapperWidth .. ',' .. wrapperHeight, - 'header:', headerHeight)]] - - --Scroller:SetSize(wrapperWidth, wrapperHeight) - Scroller:SetPoint('TOPLEFT', Wrapper, 'TOPLEFT', 0, 0) - Scroller:SetPoint('BOTTOMRIGHT', Wrapper, 'BOTTOMRIGHT') - - - Scroll:SetSize(scrollWidth, scrollHeight) - Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT', 0, B.Conf.ObjectiveScroll or 0) - Scroll:SetPoint('RIGHT', Scroller, 'RIGHT') - - --Scroller:UpdateScrollChildRect() - Wrapper:SetSize(wrapperWidth, wrapperHeight) - - --[[ update action buttons - print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(), - '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(), - '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(), - '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5) - ) - --]] - mod.UpdateActionButtons() - -end ---]=] - - -Default.Update = function (self, reason, ...) - local print = tprint - local tracker = self.frame - 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, 0) - currentBlock:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) - self.currentAnchor = currentBlock - print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height, trackerHeight) - 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: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:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2) - 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('|cFF00FFFF%s and(%04X vs %04x+%04x) = %04X|r', handler.name, 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 - Scroller.snap_lower = 0 - local print = B.print('ItemButton') - if updateReason then - print = B.print('IB_'..updateReason) - end - - local previousItem - for questID, itemButton in pairs(usedButtons) do - local info= mod.Quest.Info[questID] - - print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) - local block = mod.Quest.QuestBlock[questID] - if block then - -- Dispatch the probe - if IsQuestWatched(info.questLogIndex) then - itemButton.previousItem = previousItem - print(' |cFFFFFF00probing', block:GetName()) - block:SetScript('OnUpdate', function() - if block:GetBottom() and not InCombatLockdown() then - print(' '..block:GetName()..' |cFF00FF00probe hit!') - mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope - block:SetScript('OnUpdate', nil) - - end - end) - previousItem = itemButton - else - print('hidden block or unwatched quest') - itemButton.previousItem = nil - itemButton:Hide() - end - elseif itemButton:IsVisible() then - print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName()) - itemButton.previousItem = nil - itemButton:Hide() - else - print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName()) - end - end -end - -mod.UpdateBlockAction = function (block, itemButton) - print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') - if itemButton.questID ~= block.info.questID then - print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID) - -- something happened between this and last frame, go back and set new probes - return mod.UpdateActionButtons() - end - - local previousItem = itemButton.previousItem - local upper_bound = Scroller:GetTop() + Scroller.snap_upper - local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize - local point, anchor, relative - - if block:GetBottom() < lower_bound then - print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5)) - if previousItem then - print('adjusting', previousItem:GetName()) - previousItem:ClearAllPoints() - previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing) - end - itemButton:ClearAllPoints() - itemButton.x = Wrapper:GetLeft() -4 - itemButton.y = Wrapper:GetBottom() - point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT' - Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing - - elseif block:GetTop() > upper_bound then - print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5)) - itemButton:ClearAllPoints() - if previousItem then - print('latch onto another piece') - point, anchor, relative ='TOP', previousItem, 'BOTTOM' - itemButton.x = 0 - itemButton.y = -itemButtonSpacing - else - print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop()) - point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' - itemButton.x = Scroller:GetLeft() -4 - itemButton.y = Scroller:GetTop() - end - itemButton:Show() - Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing) - else - print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5)) - itemButton:ClearAllPoints() - itemButton.x = block:GetLeft() - itemButtonSpacing - itemButton.y = block:GetTop() - point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT' - end - - itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y) - itemButton:Show() -end - -mod.UpdateItemButtonCooldown = function(button) - -end - -local unitLevel = UnitLevel('player') - - diff -r 9b3fa734abff -r e837384ac363 ObjectiveInfo.lua --- a/ObjectiveInfo.lua Sat Apr 09 07:32:45 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,573 +0,0 @@ -local B = select(2,...).frame -local wipe, pairs, ipairs, min, max, unpack, format, mod = table.wipe, pairs, ipairs, min, max, unpack, format, mod -local tinsert, tostring = tinsert, tostring -local GetQuestTagInfo, GetQuestLogTitle = GetQuestTagInfo, GetQuestLogTitle -local GetNumQuestLogEntries, GetNumQuestWatches, GetQuestLogCompletionText, IsQuestWatched, IsQuestHardWatched, GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown = GetNumQuestLogEntries, GetNumQuestWatches, GetQuestLogCompletionText, IsQuestWatched, IsQuestHardWatched, GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown -local GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetTasksTable, GetNumQuestLogTasks, GetTaskInfo, GetQuestObjectiveInfo = GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetTasksTable, GetNumQuestLogTasks, GetTaskInfo, GetQuestObjectiveInfo -local GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo, GetNumQuestLogRewards, GetQuestLogRewardInfo, GetQuestLogRewardMoney, GetMoneyString = GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo, GetNumQuestLogRewards, GetQuestLogRewardInfo, GetQuestLogRewardMoney, GetMoneyString -local GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo = GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo -local GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo = GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo -local QuestHasPOIInfo, GetDistanceSqToQuest, GetQuestFactionGroup = QuestHasPOIInfo, GetDistanceSqToQuest, GetQuestFactionGroup -local GetTrackedAchievements, GetNumTrackedAchievements, GetAchievementInfo = GetTrackedAchievements, GetNumTrackedAchievements, GetAchievementInfo -local GetMoney, floor = GetMoney, floor -local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') -local print = B.print('Info') -local QUEST_TAG_DUNGEON = QUEST_TAG_DUNGEON -local QUEST_TAG_GROUP = QUEST_TAG_GROUP -local QUEST_TAG_ACCOUNT = QUEST_TAG_ACCOUNT -local QUEST_TAG_TCOORDS = QUEST_TAG_TCOORDS -local LE_QUEST_FREQUENCY_DAILY = LE_QUEST_FREQUENCY_DAILY -local LE_QUEST_FREQUENCY_WEEKLY = LE_QUEST_FREQUENCY_WEEKLY -local FACTION_ALLIANCE, LE_QUEST_FACTION_HORDE, FACTION_HORDE, LE_QUEST_FACTION_HORDE = FACTION_ALLIANCE, LE_QUEST_FACTION_HORDE, FACTION_HORDE, LE_QUEST_FACTION_HORDE - -local Tracker, Bonus, AutoQuest, Quest, Cheevs = T.DefaultTracker, T.Bonus, T.AutoQuest, T.Quest, T.Cheevs --------------------------------------------------------------------- ---- Tracker-specific data retrieval functions --------------------------------------------------------------------- - - -local DoQuestRewards= function(t, questID) - local rewards = {} - t.numCurrencies = GetNumQuestLogRewardCurrencies(questID) - for i = 1, t.numCurrencies do - local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID) - tinsert(rewards,{ - type = 'currency', - index = i, - name = name, - texture = texture, - count = count - }); - end - -- items - t.numItems = GetNumQuestLogRewards(questID) - for i = 1, t.numItems do - local name, texture, count, quality, isUsable = GetQuestLogRewardInfo(i, questID) - tinsert(rewards, { - type = 'item', - index = i , - name = name, - texture = texture, - count = count, - quality = quality, - isUsable = isUsable - }); - end - -- money - - local money = GetQuestLogRewardMoney(questID) - if ( money > 0 ) then - tinsert(rewards, { - type = 'money', - name = GetMoneyString(money), - texture = "Interface\\Icons\\inv_misc_coin_01", - count = 0, - }); - end - - if #rewards >= 1 then - t.rewardInfo = rewards - end -end - - ------------------------------ ---- AUTO_QUEST -AutoQuest.LogInfo = {} -AutoQuest.LogBlock = {} -AutoQuest.QuestBlock = {} -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 title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex) - - self.Info[questID] = self.Info[questID] or {} - local popup = self.Info[questID] - popup.title = title - popup.description = type - popup.popupType = type - popup.questID = questID - popup.questIndex = questIndex - popup.popupIndex = popupIndex - - self.Info[questID] = popup - self.WatchInfo[popupIndex] = popup - - - return self.Info[questID] -end - ------------------------------ ---- BONUS OBJECTIVE --- 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(). - ------------------------------------------------------------------------------------------- ---- 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 UnitName, GetRealmName = UnitName, GetRealmName -local InternalGetTasksTable = function() - local completedTasks = T.Conf.TasksLog - local char = UnitName("player") - local realm = GetRealmName() - local tasks = GetTasksTable() - - for questID, data in pairs(Bonus.Info) do - - print(' -- questID:', questID, #data.objectives) - for i, o in ipairs(data.objectives) do - print(' --', i, o.text) - end - - end - - - 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) - local completedTasks = T.Conf.TasksLog - 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) - local completedTasks = T.Conf.TasksLog - if ( completedTasks[questID] ) then - print('using internal data') - 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.WatchInfo = {} -function Bonus:GetNumWatched () - print(self.name, self) - - local tasks = InternalGetTasksTable() - local numWatched = 0 - local numAll = 0 - self.WatchInfo = {} - print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks) - print(' TasksTable pull:') - for i, questID in ipairs(tasks) do - local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID) - local existingTask = self.QuestBlock[questID] - local displayObjectiveHeader = false; - local test = (isInArea or (isOnMap and existingTask)) - --local test = true - if test then - self.Info[questID] = self.Info[questID] or {} - - local t = self.Info[questID] - self.WatchInfo[i] = t - t.isInArea = isInArea - t.isOnMap = isOnMap - t.existingTask = existingTask - t.questID = questID - t.objectives = {} - t.taskIndex = i - - - DoQuestRewards(t, questID) - - local taskTitle - local taskFinished = true; - for objectiveIndex = 1, numObjectives do - local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false); - displayObjectiveHeader = displayObjectiveHeader or displayAsObjective; - if not taskTitle then - if objectiveType == 'progressbar' and not text:match('^%d%+\\%d+') then - taskTitle = text - text = '' - end - end - - - 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 - - -- didn't get a name from progress bar? what about area name - if not taskTitle then - if isInArea then - taskTitle = GetMapNameByID(GetCurrentMapAreaID()) - end - end - t.title = taskTitle - end - - print (' |cFF00FF88#', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N'), (test and '|cFF00FF00show|r' or '|cFFFF0088hide|r')) - end - - - self.numAll = #tasks - self.numWatched = #self.WatchInfo - print(' stats:', self.numAll, 'active tasks,', self.numWatched, 'nearby or animating') - --return #tasks - return #self.WatchInfo -end - ---- info cleanup done when turn-ins are detected -Bonus.OnTurnIn = function(self, questID, xp, money) - print('|cFFFF8800'..self.name..':OnTurnIn call', questID, xp, money) - - - -end - -Bonus.GetInfo = function(self, taskIndex) - print(self.name, self) - return self.WatchInfo[taskIndex] -end - -Bonus.Store = function(questID) - - if not questID then - print('|cFFFF4400invalid quest ID', questID) - return - end - - Bonus.Info[questID] = Bonus.Info[questID] or {} - local t = Bonus.Info[questID] - local isInArea, isOnMap, numObjectives = GetTaskInfo(questID) - t.questID = questID - t.numObjectives = numObjectives - t.isInArea = isInArea - t.isOnMap = isOnMap - - print(' isInArea', isInArea, 'isOnMap', isOnMap, 'numObj', numObjectives) - local displayObjectives = false - local isComplete = true - if numObjectives >= 1 then - print(' ', numObjectives,'objective rows') - t.objectives = {} - for i = 1, t.numObjectives do - t.objectives[i] = {} - local o = t.objectives[i] - o.index = i - --local text, objectiveType, finished, displayAsObjective = - o.text, o.objectiveType, o.finished, o.displayAsObjective = GetQuestObjectiveInfo(questID, i, false) - - print(i, '==>', o.text, o.objectiveType, o.finished, o.displayAsObjective) - t.displayObjectives = t.displayObjectives or o.displayAsObjective - t.isComplete = t.isComplete and o.finished - - end - end - - t.displayObjectives = displayObjectives - - DoQuestRewards(t, questID) - - Bonus.TasksTable[questID] = t - - return t -end - ------------------------------ ---- QUEST -Quest.itemButtons = {} -Quest.freeButtons = {} -Quest.POI = {} -Quest.QuestBlock = {} -Quest.LogBlock = {} -Quest.LogInfo = {} - -function Quest:GetNumWatched () - print(self.name, self) - self.numAll = GetNumQuestLogEntries() - self.numWatched = GetNumQuestWatches() - return self.numWatched, self.numAll -end -Quest.GetInfo = function (self, watchIndex) - print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)') - local questID, title, questIndex, numObjectives, requiredMoney, isComplete, - startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex) - - if not questIndex then - return - end - - local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex) - - - if not questID then - return - end - Quest.Info[questID] = Quest.Info[questID] or {} - - local q = Quest.Info[questID] - q.watchIndex = watchIndex - q.type = 'Quest' - q.questID = questID - q.title = title - q.level = level - q.displayQuestID = displayQuestID - q.suggestedGroup = suggestedGroup - q.questLogIndex = questIndex - q.numObjectives = numObjectives - q.requiredMoney = requiredMoney - q.isComplete = isComplete - q.startEvent = startEvent - q.isAutoComplete = isAutoComplete - q.failureTime = failureTime - q.timeElapsed = timeElapsed - q.questType = questType - q.isTask = isTask - q.isStory = isStory - q.isOnMap = isOnMap - q.hasLocalPOI = hasLocalPOI - q.frequency = frequency - q.isComplete = isComplete - q.isStory = isStory - q.isTask = isTask - - --- resolve icon type and template - local tagID, tagName = GetQuestTagInfo(questID) - if ( tagName ) then - local factionGroup = GetQuestFactionGroup(questID); - -- Faction-specific account quests have additional info in the tooltip - if ( tagID == QUEST_TAG_ACCOUNT and factionGroup ) then - local factionString = FACTION_ALLIANCE; - if ( factionGroup == LE_QUEST_FACTION_HORDE ) then - factionString = FACTION_HORDE; - end - tagName = format("%s (%s)", tagName, factionString); - end - if ( QUEST_TAG_TCOORDS[tagID] ) then - local questTypeIcon; - if ( tagID == QUEST_TAG_ACCOUNT and factionGroup ) then - q.typeTag = QUEST_TAG_TCOORDS["ALLIANCE"]; - if ( factionGroup == LE_QUEST_FACTION_HORDE ) then - q.typeTag= QUEST_TAG_TCOORDS["HORDE"]; - end - else - q.typeTag = QUEST_TAG_TCOORDS[tagID]; - end - end - end - - if ( frequency == LE_QUEST_FREQUENCY_DAILY ) then - q.frequencyTag = QUEST_TAG_TCOORDS["DAILY"] - q.mainStyle = 'Daily' - elseif ( frequency == LE_QUEST_FREQUENCY_WEEKLY ) then - q.frequencyTag = QUEST_TAG_TCOORDS["WEEKLY"] - q.mainStyle = 'Daily' - end - if ( isComplete and isComplete < 0 ) then - q.completionTag = QUEST_TAG_TCOORDS["FAILED"] - q.subStyle = 'Failed' - elseif isComplete then - q.completionTag = QUEST_TAG_TCOORDS["COMPLETED"] - q.subStyle = 'Complete' - end - q.tagID = tagID - q.tagName = tagName - - - - --q.isBreadCrumb = isBreadCrumb - q.completionText= GetQuestLogCompletionText(questIndex) - q.numObjectives = GetNumQuestLeaderBoards(questIndex) - q.objectives = {} - for i = 1, q.numObjectives do - local text, type, finished = GetQuestLogLeaderBoard(i, questIndex) - print(format(' #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished))) - q.objectives[i] = { - index = i, - type = type, - text = text, - finished = finished - } - if type == 'event' then - elseif type == 'monster' then - elseif type == 'object' then - elseif type == 'reputation' then - elseif type == 'item' then - end - end - - if requiredMoney >= 1 then - local money = GetMoney() - local moneyText = money - local requiredSilver, requiredCopper - local requiredGold = (requiredMoney > 10000) and (floor(requiredMoney/10000)) or nil - if mod(requiredMoney, 10000) ~= 0 then - requiredSilver = (requiredMoney > 100) and (mod(requiredMoney, 10000) / 100) or nil - if mod(requiredMoney, 100) ~= 0 then - requiredCopper = mod(requiredMoney, 100) - end - end - - -- round the money value down - if requiredMoney > 9999 and not (requiredSilver or requiredCopper) then - moneyText = floor(money/10000) - elseif requiredMoney < 10000 and mod(requiredMoney,100) == 0 then - moneyText = floor(money/100) - end - - local text = moneyText - local index = #q.objectives + 1 - local finished = (GetMoney() >= requiredMoney) - - if not finished then - text = text .. ' / ' .. GetCoinTextureString(requiredMoney, 15) - else - text = '' .. GetCoinTextureString(requiredMoney, 15) - end - q.objectives[index] = { - index = index, - type = 'progressbar', - quantity = money, - requiredQuantity = requiredMoney, - text = text, - finished = finished - } - print(format(' #%d %s %s %s', index, 'money', text, tostring(finished))) - end - - - local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex) - local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex) - if link or icon or charges then - q.specialItem = { - questID = questID, - questIndex = questIndex, - link = link, - charges = charges, - icon = icon, - start = start, - duration = duration, - enable = enable, - } - end - - if QuestHasPOIInfo(questID) then - local distance, onContinent = GetDistanceSqToQuest(questIndex) - if distance ~= nil and distance > 0 then - self.POI[questIndex] = { - questIndex = questIndex, - questID = questID, - distance = distance, - onContinent = onContinent - } - end - end - - - q.selected = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue - self.WatchInfo[watchIndex] = q - self.LogInfo[questIndex] = q - print('- logIndex =', questIndex, 'title =', title) - return q -end - -Quest.GetClosest = function() - local minID - local minDist = math.huge - for i = 1, Quest.GetNumWatched() do - local info = Quest.GetInfo(i) - if info.hasLocalPOI then - local distance, onContinent = GetDistanceSqToQuest(info.questIndex) - end - end -end - - -Cheevs.GetNumWatched = function(self) - print('|cFF00FF00' .. GetTime()) - Cheevs.trackedCheevs = {GetTrackedAchievements()} - return GetNumTrackedAchievements() -end -Cheevs.GetInfo = function(self, index) - local cheevID = Cheevs.trackedCheevs[index] - local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) - - self.Info[cheevID] = {} - local c = self.Info[cheevID] - c.type = 'Cheevs' - c.watchIndex = index - c.cheevID = cheevID - c.title = name - c.points, c.completed, c.month, c.day, c.year, c.description, c.flags, c.icon, c.rewardText, c.isGuildAch, c.wasEarnedByMe, c.earnedBy = - points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy - c.numObjectives = GetAchievementNumCriteria(cheevID) - c.objectives = {} - for i = 1, c.numObjectives do - local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i) - c.objectives[i] = { - objectiveIndex = i, - cheevID = cheevID, - text = description, - type = type, - finished = completed, - value = quantity, - maxValue = requiredQuantity, - characterName = characterName, - flags = flags, - assetID = assetID, - quantityString = quantityString, - criteriaID = criteriaID, - } - end - print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description) - - self.WatchInfo[index] = c - return self.Info[cheevID] -end diff -r 9b3fa734abff -r e837384ac363 ObjectiveSecure.xml --- a/ObjectiveSecure.xml Sat Apr 09 07:32:45 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ - - - - \ No newline at end of file diff -r 9b3fa734abff -r e837384ac363 ObjectiveStyle.lua --- a/ObjectiveStyle.lua Sat Apr 09 07:32:45 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,506 +0,0 @@ -local B = select(2,...).frame -local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') -local print = B.print('SetStyle') -------------------------------------------------------------- ---- Deals with swapping between different color palettes ---- - -local titleFont, textFont = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]] -local titleSize, textSize = 16, 15 -local titleOutline, textOutline = "OUTLINE", "OUTLINE" -local titleSpacing, textSpacing = 3, 3 -local unpack, type, pairs, tconcat = unpack, type, pairs, table.concat -local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' -local headerFont, headerSize = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 24 -local headerOutline, headerSpacing = 'OUTLINE', 2 - - -mod.defaults.Style = { - Format = { - Frame = { - Width = 270, - }, - title = { - Indent = 0, - Spacing = 0, - }, - status = { - Indent = 5, - Spacing = 0, - } - }, - FontBank = { - ['Normal'] = _G.VeneerCriteriaFontNormal, - ['Progress'] = _G.VeneerCriteriaFontProgress, - ['Complete'] = _G.VeneerCriteriaFontComplete, - ['Failed'] = _G.VeneerCriteriaFontFailed, - }, - Normal = { - title = { - TextColor = {1, 1, 1, 1}, - Width = 270, - Spacing = 0, - Indent = 2, - }, - titlebg = { - }, - status = { - Width = 270, - Spacing = 0, - }, - statusbg = { - }, - Frame = { - } - }, - Tracker = { - Normal = { - title = { - Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing, - Indent = 2, - TextColor = {1, .9, .2, 1}, - }, - titlebg = { - Gradient = {'VERTICAL', MinColor = {0,0,0,0.25}, MaxColor = {0,0,0,.15}}, - } - } - }, - TrackerBlock = { - Normal = { - titlebg = { - Indent = 2, - Gradient = { 'HORIZONTAL', MinColor = {0.7, 0, 0.9, 1}, MaxColor = {.7, 0, 0.9, .1}}, - }, - title = { - TextColor = {1,1,1,1}, - Font = {titleFont, titleSize, titleOutline}, - Spacing = titleSpacing, - }, - status = { - TextColor = {1,1,1,1}, - Font = {textFont, textSize, textOutline}, - Spacing = textSpacing, - }, - statusbg = { - Gradient = { 'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, .1}}, - } - }, - Daily = { - titlebg = { - Gradient = {'HORIZONTAL', MinColor = {0, .4, 1, 1}, MaxColor = {0, 0.4, 1, .1}, }, - }, - statusbg = { - Gradient = {'HORIZONTAL', MinColor = {0, .4, 1, 1}, MaxColor = {0, 0.35, .90, .1}, }, - }, - title = { - TextColor = {0.7,1,1,1}, - Font = {titleFont, titleSize, titleOutline}, - Spacing = titleSpacing, - }, - status = { - TextColor = {1,1,1,1}, - Font = {textFont, textSize, textOutline}, - Spacing = textSpacing, - }, - }, - Super = { - title = { - TextColor = {1,1,1,1}, - Font = {titleFont, titleSize, titleOutline}, - Spacing = titleSpacing, BackgroundFullWidth = true - }, - titlebg = { - Gradient = { 'HORIZONTAL', MinColor = {0, .7, .6, 1}, MaxColor = {0, .7, .6, 1}}, - }, - status = { - TextColor = {1,1,1,1}, - Font = {textFont, textSize, textOutline}, - Spacing = textSpacing, - }, - statusbg = { - Gradient = { 'HORIZONTAL', MinColor = {0, .7, .6, 1}, MaxColor = {0, .7, .6, 1} }, - }, - }, - MouseDown = { - title = { - Font = {titleFont, titleSize, titleOutline}, - Spacing = titleSpacing, - }, - titlebg = { - 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, 1}, }, - } - }, - Complete = { - title = { - TextColor = {1,1,1,1}, - Font = {titleFont, titleSize, titleOutline}, Spacing = titleSpacing, - }, - titlebg = { - 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, 1}, MaxColor = {0, 1, 0, 1}, }, - } - }, - AutoQuest = { - Normal = { - titlebg = { - Indent = 2, - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, 1}}, - }, - title = { - TextColor = {1,1,1,1}, - Font = {titleFont, titleSize, titleOutline}, - Spacing = titleSpacing, - }, - status = { - TextColor = {0,1,0,1}, - Font = {textFont, textSize, textOutline}, - Spacing = textSpacing, - }, - statusbg = { - Gradient = {'HORIZONTAL', MinColor = {0.2, .4, 1, 1}, MaxColor = {.7, 0, 0.9, 1}}, - } - }, - }, - Cheevs = { - Normal = { - - title = { - Font = {titleFont, titleSize, titleOutline}, - Spacing = titleSpacing, - }, - titlebg = { - 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, 1}, MaxColor = {.7, 0, 0.9, 1}}, - }, - }, - Complete = { - title = { - Font = {titleFont, titleSize, titleOutline}, - Spacing = titleSpacing, - }, - titlebg = { - 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, 1}, MaxColor = {.7, 0, 0.9, 1}}, - }, - }, - } - } -} - -local style_cache_func = {} -local block_vars = { - ['titleSize'] = {'titleWidth', 'titleHeight'}, - ['FrameSize'] = {'width', 'height'} -} -local attrib_vars = { - ['Font'] = {'height'}, -} - -mod.BlockStyleCache = {} -local style_cache = mod.BlockStyleCache -mod.regions = {} -mod.regionStyles = {} -mod.SetBlockStyle = function(frame, frameType, ...) - -- var names intended to reflect argument order - print('|cFFFFFF00'..frame:GetName()..'|r', frameType, ...) - --@debug@ - local c = mod.defaults.Normal - local style_list = {... } - local styleName = frameType .. '-' .. table.concat(style_list,'') - local previousClass = {mod.Conf.Style[frameType] } - local previousClassString = {'frame' } - local parentName - - if not style_cache[styleName] then - local style = {} - - --[[ - if mod.defaults.Style[frameType] then - print(' setting style class |cFF00FFFF'..frameType) - else - print(' resorting to class Normal (missing |cFFFF8800'.. frameType..'|r)') - end - --]] - local normal = mod.defaults.Style.Normal - local root = mod.defaults.Style[frameType] or normal - for i, className in ipairs(style_list) do - print('|cFF00FF00'..i..'|r', className) - local class = normal - local childClass - if previousClass then - for i = #previousClass, 1, -1 do - print('checking if '..className..' child of '.. previousClassString[i]) - if previousClass[i][className] then - print(' it is!') - childClass = previousClass[i][className] - parentName = previousClassString[i] - break - end - end - end - if childClass then - class = childClass - print(' ChildClass '..parentName..'.|cFFFF0088'.. className .. '|r') - elseif root[className] then - class = root[className] - print(' SubClass |cFF0088FF'.. className .. '|r') - elseif normal[className] then - class = normal[className] - print(' SubClass Normal.|cFFFF0088'..className..'|r') - else - --print(' SubClass not found '..className..'') - end - tinsert(previousClass, class) - tinsert(previousClassString, className) - - for elementName, element in pairs(class) do - if not elementName:match('^%u') then - --print(' scanning Element |cFF8800FF'.. elementName ..'|r') - if not style[elementName] then - style[elementName] = {} - end - for key, value in pairs(element) do - if mod.SetBlockAttribute[key] then - --print(' |cFF00FF00'..elementName..'|r.|cFF00FFFF'..key..' =', (type(value) == 'table' and ('{'..table.concat(value,', ')..'}') or tostring(value))) - style[elementName][key] = value - end - - end - end - - end - end - - for k, elements in pairs(mod.defaults.Style.Normal) do - if not style[k] and type(elements) ~= 'table' then - style[k] = elements - end - end - - - --[[print('result for: ', frame:GetName()) - for k,v in pairs(style) do - if type(v) == 'table' and not k:match('^%u') then - for kk, vv in pairs(v) do - --print(' |cFFFFFF00'..k..'|r.|cFF00FF00'..kk..'|r =', (type(vv) == 'table' and ('{'..table.concat(vv,', ')..'}') or tostring(vv))) - end - else - --print(' |cFFFFFFFF' .. k ..'|r =', tostring(v)) - end - end - --]] - print('saving |cFFFFFF00'..styleName) - style_cache[styleName] = style - else - - print('using |cFFFF00FF'..styleName) - end - - local style = style_cache[styleName] - - if not style_cache_func[styleName] then - local code = - "return function (frame)\n".. - " local func = Veneer.ObjectiveTracker.SetBlockAttribute\n".. - " local cache = Veneer.ObjectiveTracker.BlockStyleCache" - --.. " print('CacheFunc', '|cFFFFFF00SET|r "..styleName.." |cFFFFFF00ON|r', frame:GetName()) " - - for elementName, styleset in pairs(style) do - code = code .. - "\n if frame['"..elementName.."'] then" - - for attributeName, value in pairs(styleset) do - if mod.SetBlockAttribute[attributeName] then - --print(' add function '..elementName..':'.. attributeName ..'(', (type(value) == 'table' and ('{'..table.concat(value,', ')..'}') or tostring(value)), ')') - - - --mod.SetBlockAttribute[attributeName](region, value) - code = code - --.. "\n print('CacheFunc', ' applying', '|cFF00FFFF" .. attributeName .. "|r to', '|cFF0088FF"..elementName.."|r', cache['"..styleName.."']['"..elementName.."']['".. attributeName .."'])" - .. "\n\n func['" .. attributeName .. "'](frame['"..elementName.."'],".. - " cache['"..styleName.."']['"..elementName.."']['".. attributeName .."'])" - - --- Set any frame.blah variables used in Updates - if block_vars[elementName .. attributeName] then - --print('|cFF008800BVar|r', elementName..attributeName) - for i, blockKey in ipairs(block_vars[elementName .. attributeName]) do - --print(' assigning |cFF008800'..blockKey..'|r') - frame[blockKey] = (type(value) == 'table') and value[i] or value - end - end - - end - end - code = code .. - "\n else".. - --"\n print('CacheFunc', ' |cFFFF4400missing', frame:GetName()..'."..elementName.."')".. - "\n end" - end - code = code .. "\nend" - local result = assert(loadstring(code)) - --print('storing style func', styleName, result()) - style_cache_func[styleName] = result() - - end - style_cache_func[styleName](frame) - - --- Hardcoding the sizing vars for sanity - local defaultWidth = mod.Conf.Wrapper.Width - local normalSettings = mod.defaults.Style.Format - 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 - - frame.title.spacing = frame.title.spacing or frame.title:GetSpacing() - frame.title:SetPoint('LEFT', frame, 'LEFT', normalSettings.title.Indent) - frame.title:SetPoint('TOP', frame, 'TOP', 0, -frame.title.spacing) - frame.title:SetWidth(frame.width) - if frame.titlebg then - frame.titlebg:SetHeight(frame.titleHeight) - 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 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) - if frame.statusbg then - - --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 - - frame.height = frame.titleHeight + frame.statusHeight + (frame.attachmentHeight or 0) - frame:SetSize(frame.width, frame.height) - print(' |cFF0088FFsizing frame', frame.width, frame.height) -end - ---- Argument containers -local o -- text flag -local a1, a2, a3, a4, b1, b2, b3, b4 -- color1, color2 -local f1, f2, f3 -- font -local w1, w2 -- size -local p1, p2, p3, x, y -- path/point args -mod.SetBlockAttribute = {} -local sb = mod.SetBlockAttribute -local print = B.print('Attribute') -sb.Gradient = function(region, value) - print('|cFF8844FFGradient|r', region:GetName(), unpack(value)) - o = value[1] - a1, a2, a3, a4 = unpack(value.MinColor) - b1, b2, b3, b4 = unpack(value.MaxColor) - region:SetVertexColor(1,1,1) - region:SetTexture(1,1,1,1) - region:SetGradientAlpha(o, a1, a2, a3, a4, b1, b2, b3, b4) -end - -sb.Background = function(region, value) - print('|cFF0088FFBackground|r', unpack(value)) - region:SetVertexColor(1,1,1) -- reset - region:SetTexture(unpack(value)) -end -sb.BackgroundComplex = function (region, value) - local left, tile, right = value.Left, value.Tile, value.Right - -end -sb.Font = function(region, value) - f1, f2, f3 = unpack(value) - print('|cFFFFFF00Font|r', f1, f2, f3) - region:SetFont(f1, f2, f3) -end - -sb.Spacing = function(region, value) - print('FontSpacing', region:GetName(), value) - region:SetSpacing(value) - region.spacing = value -end - -sb.TextColor = function(region, value) - a1, a2, a3, a4 = unpack(value) - print('TextColor', a1, a2, a3, a4) - region:SetTextColor(a1, a2, a3, a4) -end -sb.Texture = function(region, value) - - p1, a1, a2, a3, a4 = unpack(value) - print('Texture', p1, a1, a2, a3, a4) - region:SetTexture(p1) - if a1 then - region:SetTexCoord(a1, a2, a3, a4) - end -end -sb.Width = function(region, value) - w1 = value - region:SetWidth(w1) -end - -sb.Height = function(region, value) - w2 = value - region:SetHeight(w2) -end -sb.Size = function(region, value) - w1, w2 = unpack(value) - region:SetSize(w1, w2) -end - diff -r 9b3fa734abff -r e837384ac363 ObjectiveTracker.xml --- a/ObjectiveTracker.xml Sat Apr 09 07:32:45 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,475 +0,0 @@ - - - - - - - - - - - - - self.toggle = true - --self.drag = true - Veneer.OnLoad(self) - - - - - Veneer.OnDragStart(self) - - - Veneer.OnDragStop(self) - Veneer.ObjectiveTracker.UpdateActionButtons() - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -