annotate ObjectiveInfo.lua @ 14:ed642234f017

ObjectiveFrame - implement proper tracker name text - expanded tracker prototypes to cover "objective lines" formatting and accommodation of widget variables - implement the progress bars for bonus objectives ObjectiveStyle - moved `UpdateWrapperStyle` over and renamed it to fit semantics - change the formula for block.`height` to measure non-widget content only - allows widgets to position relative to text - size FontString `status` to match block.`height` - full block height is acquired by adding block.`height` and block.`attachmentHeight` which is calculated during objective parsing ObjectiveWidgets - use string keys for generated widgets to deal with multiple objectives under the same questID, and maybe dungeon objectives - wrapper buttons use a common code path - specialized handlers for wheel scrolling moved over to fit semantics
author Nenue
date Mon, 04 Apr 2016 03:16:22 -0400
parents 9455693fc290
children 880828018bf4
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@14 6 local print = B.print('TrackerInfo')
Nenue@0 7
Nenue@14 8 local Tracker, Bonus, AutoQuest, Quest, Cheevs = mod.Tracker, mod.Bonus, 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.GetNumWatched = GetNumAutoQuestPopUps
Nenue@13 17 AutoQuest.GetInfo = function(watchIndex)
Nenue@13 18 return Quest.GetInfo(watchIndex)
Nenue@13 19 end
Nenue@13 20
Nenue@13 21 -----------------------------
Nenue@14 22 --- BONUS OBJECTIVE
Nenue@14 23 Bonus.TasksTable = {}
Nenue@14 24 Bonus.TasksPOI = {}
Nenue@14 25 Bonus.TaskScenario = {}
Nenue@14 26
Nenue@14 27 local taskData = {}
Nenue@14 28 Bonus.QuestBlock = {}
Nenue@14 29 Bonus.GetNumWatched = function()
Nenue@14 30 Bonus.TasksTable = GetTasksTable()
Nenue@14 31 local numTasks = 0
Nenue@14 32 for i, questID in ipairs(Bonus.TasksTable) do
Nenue@14 33 local isInArea, isOnMap, numObjectives = GetTaskInfo(questID)
Nenue@14 34 if isInArea and isOnMap then
Nenue@14 35 numTasks = numTasks + 1
Nenue@14 36 end
Nenue@14 37 end
Nenue@14 38 Bonus.numAll = #Bonus.TasksTable
Nenue@14 39 Bonus.numWatched = numTasks
Nenue@14 40 return GetNumQuestLogTasks()
Nenue@14 41 end
Nenue@14 42 Bonus.GetInfo = function(self, watchIndex)
Nenue@14 43 local questID = Bonus.TasksTable[watchIndex]
Nenue@14 44 if not questID then
Nenue@14 45 print('|cFFFF4400no quest ID for row', watchIndex)
Nenue@14 46 return
Nenue@14 47 end
Nenue@14 48
Nenue@14 49
Nenue@14 50 local t= {}
Nenue@14 51 t.isInArea, t.isOnMap, t.numObjectives = GetTaskInfo(questID)
Nenue@14 52
Nenue@14 53 print('isInArea', t.isInArea, 'isOnMap', t.isOnMap, 'numObj', t.numObjectives)
Nenue@14 54 t.displayObjectives = false
Nenue@14 55 t.isComplete = true
Nenue@14 56 t.questID = questID
Nenue@14 57 if t.numObjectives >= 1 then
Nenue@14 58 print(t.numObjectives,'objective rows')
Nenue@14 59 t.objectives = {}
Nenue@14 60 for i = 1, t.numObjectives do
Nenue@14 61 t.objectives[i] = {}
Nenue@14 62 local o = t.objectives[i]
Nenue@14 63 o.index = i
Nenue@14 64 o.text, o.objectiveType, o.finished, o.displayAsObjective = GetQuestObjectiveInfo(questID, i, true)
Nenue@14 65
Nenue@14 66 print(i, '==>', o.text, o.objectiveType, o.finished, o.displayAsObjective)
Nenue@14 67 t.displayObjectives = t.displayObjectives or o.displayAsObjective
Nenue@14 68 t.isComplete = t.isComplete and o.finished
Nenue@14 69
Nenue@14 70 end
Nenue@14 71 end
Nenue@14 72 Bonus.TasksTable[questID] = t
Nenue@14 73
Nenue@14 74 return t
Nenue@14 75 end
Nenue@14 76
Nenue@14 77 -----------------------------
Nenue@13 78 --- QUEST
Nenue@1 79 Quest.itemButtons = {}
Nenue@1 80 Quest.freeButtons = {}
Nenue@1 81 Quest.POI = {}
Nenue@5 82 Quest.QuestBlock = {}
Nenue@0 83 Quest.GetNumWatched = function()
Nenue@14 84 Quest.numAll = GetNumQuestLogEntries()
Nenue@14 85 Quest.numWatched = GetNumQuestWatches()
Nenue@14 86 return Quest.numWatched
Nenue@0 87 end
Nenue@0 88 Quest.GetInfo = function (self, watchIndex)
Nenue@0 89 print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)')
Nenue@1 90 local questID, title, questIndex, numObjectives, requiredMoney, isComplete,
Nenue@0 91 startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
Nenue@13 92
Nenue@14 93 local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex)
Nenue@13 94 local questTagID, tagName = GetQuestTagInfo(questID);
Nenue@13 95
Nenue@0 96 if not questID then
Nenue@0 97 return
Nenue@0 98 end
Nenue@0 99 self.Info[questID] = self.Info[questID] or {}
Nenue@0 100
Nenue@0 101 local q = self.Info[questID]
Nenue@0 102 q.watchIndex = watchIndex
Nenue@0 103 q.type = 'Quest'
Nenue@0 104 q.questID = questID
Nenue@0 105 q.title = title
Nenue@13 106 q.level = level
Nenue@1 107 q.questLogIndex = questIndex
Nenue@0 108 q.numObjectives = numObjectives
Nenue@0 109 q.requiredMoney = requiredMoney
Nenue@0 110 q.isComplete = isComplete
Nenue@0 111 q.startEvent = startEvent
Nenue@0 112 q.isAutoComplete = isAutoComplete
Nenue@0 113 q.failureTime = failureTime
Nenue@0 114 q.timeElapsed = timeElapsed
Nenue@0 115 q.questType = questType
Nenue@0 116 q.isTask = isTask
Nenue@0 117 q.isStory = isStory
Nenue@0 118 q.isOnMap = isOnMap
Nenue@0 119 q.hasLocalPOI = hasLocalPOI
Nenue@0 120
Nenue@13 121 q.isDaily = ( frequency == LE_QUEST_FREQUENCY_DAILY and (not isComplete or isComplete == 0) )
Nenue@13 122 q.isWeekly = ( frequency == LE_QUEST_FREQUENCY_WEEKLY and (not isComplete or isComplete == 0) )
Nenue@13 123 q.isComplete = isComplete
Nenue@13 124 q.isStory = isStory
Nenue@13 125 q.isTask = isTask
Nenue@14 126
Nenue@14 127 if isTask then
Nenue@14 128 --q.task = Bonus.GetInfo(questID)
Nenue@14 129 end
Nenue@14 130
Nenue@13 131 --q.isBreadCrumb = isBreadCrumb
Nenue@1 132 q.completionText= GetQuestLogCompletionText(questIndex)
Nenue@1 133 q.numObjectives = GetNumQuestLeaderBoards(questIndex)
Nenue@1 134 q.isWatched = IsQuestWatched(questIndex)
Nenue@13 135 q.isHardWatched = IsQuestHardWatched(questIndex)
Nenue@0 136 q.objectives = {}
Nenue@0 137 for i = 1, q.numObjectives do
Nenue@1 138 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex)
Nenue@0 139 q.objectives[i] = {
Nenue@14 140 index = i,
Nenue@0 141 type = type,
Nenue@0 142 text = text,
Nenue@0 143 finished = finished
Nenue@0 144 }
Nenue@0 145 if type == 'event' then
Nenue@0 146 elseif type == 'monster' then
Nenue@0 147 elseif type == 'object' then
Nenue@0 148 elseif type == 'reputation' then
Nenue@0 149 elseif type == 'item' then
Nenue@0 150 end
Nenue@0 151 end
Nenue@0 152
Nenue@1 153 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex)
Nenue@1 154 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex)
Nenue@0 155 if link or icon or charges then
Nenue@0 156 q.specialItem = {
Nenue@1 157 questID = questID,
Nenue@1 158 questIndex = questIndex,
Nenue@0 159 link = link,
Nenue@0 160 charges = charges,
Nenue@0 161 icon = icon,
Nenue@0 162 start = start,
Nenue@0 163 duration = duration,
Nenue@0 164 enable = enable,
Nenue@0 165 }
Nenue@0 166 end
Nenue@0 167
Nenue@1 168
Nenue@1 169 if QuestHasPOIInfo(questID) then
Nenue@1 170 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@1 171 if distance ~= nil and distance > 0 then
Nenue@1 172 self.POI[questIndex] = {
Nenue@1 173 questIndex = questIndex,
Nenue@1 174 questID = questID,
Nenue@1 175 distance = distance,
Nenue@1 176 onContinent = onContinent
Nenue@1 177 }
Nenue@1 178 end
Nenue@1 179 end
Nenue@1 180
Nenue@8 181 q.superTracked = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue
Nenue@8 182 self.WatchInfo[watchIndex] = q
Nenue@1 183 self.LogInfo[questIndex] = q
Nenue@2 184 print('- logIndex =', questIndex, 'title =', title)
Nenue@0 185 return q
Nenue@0 186 end
Nenue@0 187
Nenue@1 188 Quest.GetClosest = function()
Nenue@1 189 local minID
Nenue@1 190 local minDist = math.huge
Nenue@1 191 for i = 1, Quest.GetNumWatched() do
Nenue@1 192 local info = Quest.GetInfo(i)
Nenue@1 193 if info.hasLocalPOI then
Nenue@1 194 local distance, onContinent = GetDistanceSqToQuest(info.questIndex)
Nenue@1 195 end
Nenue@1 196 end
Nenue@1 197 end
Nenue@1 198
Nenue@6 199
Nenue@0 200 Cheevs.GetNumWatched = function(self)
Nenue@0 201 Cheevs.trackedCheevs = {GetTrackedAchievements()}
Nenue@0 202 return GetNumTrackedAchievements()
Nenue@0 203 end
Nenue@0 204 Cheevs.GetInfo = function(self, index)
Nenue@0 205 local cheevID = Cheevs.trackedCheevs[index]
Nenue@0 206 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
Nenue@0 207
Nenue@0 208 self.Info[cheevID] = {}
Nenue@0 209 local c = self.Info[cheevID]
Nenue@0 210 c.type = 'Cheevs'
Nenue@0 211 c.watchIndex = index
Nenue@0 212 c.cheevID = cheevID
Nenue@0 213 c.title = name
Nenue@0 214 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 215 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy
Nenue@0 216 c.numObjectives = GetAchievementNumCriteria(cheevID)
Nenue@0 217 c.objectives = {}
Nenue@0 218 for i = 1, c.numObjectives do
Nenue@0 219 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i)
Nenue@0 220 c.objectives[i] = {
Nenue@14 221 index = i,
Nenue@8 222 cheevID = cheevID,
Nenue@0 223 text = description,
Nenue@0 224 type = type,
Nenue@0 225 finished = completed,
Nenue@14 226 value = quantity,
Nenue@14 227 maxValue = requiredQuantity,
Nenue@0 228 characterName = characterName,
Nenue@0 229 flags = flags,
Nenue@0 230 assetID = assetID,
Nenue@0 231 quantityString = quantityString,
Nenue@0 232 criteriaID = criteriaID,
Nenue@0 233 }
Nenue@0 234 end
Nenue@3 235 print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description)
Nenue@0 236
Nenue@0 237 self.WatchInfo[index] = c
Nenue@0 238 return self.Info[cheevID]
Nenue@0 239 end