annotate ObjectiveInfo.lua @ 13:9455693fc290

Init - recall XML display state on reload ObjectiveFrame - quest coloring by relative level - quest coloring by daily/weekly/complete status - remember starting scroll value between reload - limit anchor points to edges for regions affected by style attributes ObjectiveInfo - AutoQuest outline definitions - Pull Quest title and tag data in addition to WatchInfo ObjectiveStyle - ensure consistent style table - hardcode certain attributes for sanity XML - ensure consistent naming conventions for heading and content elements - ensure hardcore anchors are based on edges - expansion of file structure to deal with complexities of dynamic widgets and style caching ObjectiveUI - determine primary style by block handler when restoring original style - moved framescript to 'ObjectiveWidgets' lua
author Nenue
date Sat, 02 Apr 2016 17:46:52 -0400
parents 7923243ae972
children ed642234f017
rev   line source
Nenue@0 1 local B = select(2,...).frame
Nenue@0 2 local wipe, pairs, ipairs, min, max, unpack = table.wipe, pairs, ipairs, min, max, unpack
Nenue@0 3 local GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo = GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo
Nenue@0 4 local GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo = GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo
Nenue@0 5 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@0 6 local print = B.print('Objectives')
Nenue@0 7
Nenue@0 8 local Tracker, AutoQuest, Quest, Cheevs = mod.Tracker, mod.AutoQuest, mod.Quest, mod.Cheevs
Nenue@0 9 --------------------------------------------------------------------
Nenue@0 10 --- Tracker-specific data retrieval functions
Nenue@0 11 --------------------------------------------------------------------
Nenue@13 12
Nenue@13 13
Nenue@13 14 -----------------------------
Nenue@13 15 --- AUTO_QUEST
Nenue@13 16 AutoQuest.name = "Remote Quests"
Nenue@13 17 AutoQuest.GetNumWatched = GetNumAutoQuestPopUps
Nenue@13 18 AutoQuest.GetInfo = function(watchIndex)
Nenue@13 19 return Quest.GetInfo(watchIndex)
Nenue@13 20 end
Nenue@13 21
Nenue@13 22 -----------------------------
Nenue@13 23 --- QUEST
Nenue@13 24 Quest.name = "Quests"
Nenue@1 25 Quest.itemButtons = {}
Nenue@1 26 Quest.freeButtons = {}
Nenue@1 27 Quest.POI = {}
Nenue@5 28 Quest.QuestBlock = {}
Nenue@0 29 Quest.GetNumWatched = function()
Nenue@0 30 return GetNumQuestWatches ()
Nenue@0 31 end
Nenue@0 32 Quest.GetInfo = function (self, watchIndex)
Nenue@0 33 print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)')
Nenue@1 34 local questID, title, questIndex, numObjectives, requiredMoney, isComplete,
Nenue@0 35 startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
Nenue@13 36
Nenue@13 37 local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex)
Nenue@13 38 local questTagID, tagName = GetQuestTagInfo(questID);
Nenue@13 39
Nenue@0 40 if not questID then
Nenue@0 41 return
Nenue@0 42 end
Nenue@0 43 self.Info[questID] = self.Info[questID] or {}
Nenue@0 44
Nenue@0 45 local q = self.Info[questID]
Nenue@0 46 q.watchIndex = watchIndex
Nenue@0 47 q.type = 'Quest'
Nenue@0 48 q.questID = questID
Nenue@0 49 q.title = title
Nenue@13 50 q.level = level
Nenue@1 51 q.questLogIndex = questIndex
Nenue@0 52 q.numObjectives = numObjectives
Nenue@0 53 q.requiredMoney = requiredMoney
Nenue@0 54 q.isComplete = isComplete
Nenue@0 55 q.startEvent = startEvent
Nenue@0 56 q.isAutoComplete = isAutoComplete
Nenue@0 57 q.failureTime = failureTime
Nenue@0 58 q.timeElapsed = timeElapsed
Nenue@0 59 q.questType = questType
Nenue@0 60 q.isTask = isTask
Nenue@0 61 q.isStory = isStory
Nenue@0 62 q.isOnMap = isOnMap
Nenue@0 63 q.hasLocalPOI = hasLocalPOI
Nenue@0 64
Nenue@13 65 q.isDaily = ( frequency == LE_QUEST_FREQUENCY_DAILY and (not isComplete or isComplete == 0) )
Nenue@13 66 q.isWeekly = ( frequency == LE_QUEST_FREQUENCY_WEEKLY and (not isComplete or isComplete == 0) )
Nenue@13 67 q.isComplete = isComplete
Nenue@13 68 q.isStory = isStory
Nenue@13 69 q.isTask = isTask
Nenue@13 70 --q.isBreadCrumb = isBreadCrumb
Nenue@1 71 q.completionText= GetQuestLogCompletionText(questIndex)
Nenue@1 72 q.numObjectives = GetNumQuestLeaderBoards(questIndex)
Nenue@1 73 q.isWatched = IsQuestWatched(questIndex)
Nenue@13 74 q.isHardWatched = IsQuestHardWatched(questIndex)
Nenue@0 75 q.objectives = {}
Nenue@0 76 for i = 1, q.numObjectives do
Nenue@1 77 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex)
Nenue@0 78 q.objectives[i] = {
Nenue@0 79 type = type,
Nenue@0 80 text = text,
Nenue@0 81 finished = finished
Nenue@0 82 }
Nenue@0 83 if type == 'event' then
Nenue@0 84 elseif type == 'monster' then
Nenue@0 85 elseif type == 'object' then
Nenue@0 86 elseif type == 'reputation' then
Nenue@0 87 elseif type == 'item' then
Nenue@0 88 end
Nenue@0 89 end
Nenue@0 90
Nenue@1 91 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex)
Nenue@1 92 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex)
Nenue@0 93 if link or icon or charges then
Nenue@0 94 q.specialItem = {
Nenue@1 95 questID = questID,
Nenue@1 96 questIndex = questIndex,
Nenue@0 97 link = link,
Nenue@0 98 charges = charges,
Nenue@0 99 icon = icon,
Nenue@0 100 start = start,
Nenue@0 101 duration = duration,
Nenue@0 102 enable = enable,
Nenue@0 103 }
Nenue@0 104 end
Nenue@0 105
Nenue@1 106
Nenue@1 107 if QuestHasPOIInfo(questID) then
Nenue@1 108 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@1 109 if distance ~= nil and distance > 0 then
Nenue@1 110 self.POI[questIndex] = {
Nenue@1 111 questIndex = questIndex,
Nenue@1 112 questID = questID,
Nenue@1 113 distance = distance,
Nenue@1 114 onContinent = onContinent
Nenue@1 115 }
Nenue@1 116 end
Nenue@1 117 end
Nenue@1 118
Nenue@8 119 q.superTracked = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue
Nenue@8 120 self.WatchInfo[watchIndex] = q
Nenue@1 121 self.LogInfo[questIndex] = q
Nenue@2 122 print('- logIndex =', questIndex, 'title =', title)
Nenue@0 123 return q
Nenue@0 124 end
Nenue@0 125
Nenue@1 126 Quest.GetClosest = function()
Nenue@1 127 local minID
Nenue@1 128 local minDist = math.huge
Nenue@1 129 for i = 1, Quest.GetNumWatched() do
Nenue@1 130 local info = Quest.GetInfo(i)
Nenue@1 131 if info.hasLocalPOI then
Nenue@1 132 local distance, onContinent = GetDistanceSqToQuest(info.questIndex)
Nenue@1 133 end
Nenue@1 134 end
Nenue@1 135 end
Nenue@1 136
Nenue@6 137
Nenue@0 138 Cheevs.GetNumWatched = function(self)
Nenue@0 139 Cheevs.trackedCheevs = {GetTrackedAchievements()}
Nenue@0 140 return GetNumTrackedAchievements()
Nenue@0 141 end
Nenue@0 142 Cheevs.GetInfo = function(self, index)
Nenue@0 143 local cheevID = Cheevs.trackedCheevs[index]
Nenue@0 144 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
Nenue@0 145
Nenue@0 146 self.Info[cheevID] = {}
Nenue@0 147 local c = self.Info[cheevID]
Nenue@0 148 c.type = 'Cheevs'
Nenue@0 149 c.watchIndex = index
Nenue@0 150 c.cheevID = cheevID
Nenue@0 151 c.title = name
Nenue@0 152 c.points, c.completed, c.month, c.day, c.year, c.description, c.flags, c.icon, c.rewardText, c.isGuildAch, c.wasEarnedByMe, c.earnedBy =
Nenue@0 153 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy
Nenue@0 154 c.numObjectives = GetAchievementNumCriteria(cheevID)
Nenue@0 155 c.objectives = {}
Nenue@0 156 for i = 1, c.numObjectives do
Nenue@0 157 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i)
Nenue@0 158 c.objectives[i] = {
Nenue@8 159 cheevID = cheevID,
Nenue@0 160 text = description,
Nenue@0 161 type = type,
Nenue@0 162 finished = completed,
Nenue@0 163 quantity = quantity,
Nenue@0 164 requiredQuantity = requiredQuantity,
Nenue@0 165 characterName = characterName,
Nenue@0 166 flags = flags,
Nenue@0 167 assetID = assetID,
Nenue@0 168 quantityString = quantityString,
Nenue@0 169 criteriaID = criteriaID,
Nenue@0 170 }
Nenue@0 171 end
Nenue@3 172 print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description)
Nenue@0 173
Nenue@0 174 self.WatchInfo[index] = c
Nenue@0 175 return self.Info[cheevID]
Nenue@0 176 end