annotate ObjectiveInfo.lua @ 17:c33497b116d6

ObjectiveStyle - statusbg and titlebg will respect the spacing value
author Nenue
date Tue, 05 Apr 2016 00:44:25 -0400
parents 880828018bf4
children d1812fb10ae6
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@16 4 local GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo = GetQuestWatchIndex, 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@16 16 AutoQuest.LogInfo = {}
Nenue@16 17 AutoQuest.LogBlock = {}
Nenue@16 18 AutoQuest.QuestBlock = {}
Nenue@16 19 AutoQuest.WatchBlock = {}
Nenue@16 20 AutoQuest.GetNumWatched = function()
Nenue@16 21 AutoQuest.numWatched = GetNumAutoQuestPopUps()
Nenue@16 22 return AutoQuest.numWatched
Nenue@16 23 end
Nenue@16 24 AutoQuest.GetInfo = function(self, popupIndex)
Nenue@16 25
Nenue@16 26 local questID, type = GetAutoQuestPopUp(popupIndex)
Nenue@16 27 local questIndex = GetQuestLogIndexByID(questID)
Nenue@16 28 local questWatchIndex = GetQuestWatchIndex(questIndex)
Nenue@16 29
Nenue@16 30 local questInfo = Quest:GetInfo(questWatchIndex)
Nenue@16 31 self.Info[questID] = {
Nenue@16 32 title = questInfo.title,
Nenue@16 33 description = type,
Nenue@16 34 popupType = type,
Nenue@16 35 questID = questID,
Nenue@16 36 questIndex = questIndex,
Nenue@16 37 popupIndex = popupIndex,
Nenue@16 38 watchIndex = questWatchIndex,
Nenue@16 39 numObjectives = 0
Nenue@16 40 }
Nenue@16 41
Nenue@16 42
Nenue@16 43 return self.Info[questID]
Nenue@13 44 end
Nenue@13 45
Nenue@13 46 -----------------------------
Nenue@14 47 --- BONUS OBJECTIVE
Nenue@14 48 Bonus.TasksTable = {}
Nenue@14 49 Bonus.TasksPOI = {}
Nenue@14 50 Bonus.TaskScenario = {}
Nenue@14 51
Nenue@14 52 local taskData = {}
Nenue@14 53 Bonus.QuestBlock = {}
Nenue@16 54 Bonus.TaskWatch = {}
Nenue@14 55 Bonus.GetNumWatched = function()
Nenue@16 56 local tasks = GetTasksTable()
Nenue@14 57 local numTasks = 0
Nenue@16 58 Bonus.TaskWatch = {}
Nenue@16 59 print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks)
Nenue@16 60 for i, questID in ipairs(tasks) do
Nenue@16 61 local t = Bonus.StoreTask(questID)
Nenue@16 62 print (' taskIndex', i, 'questID', questID)
Nenue@16 63 print(' isComplete', t.isComplete)
Nenue@16 64 if (t.inInArea or t.isOnMap) and not t.isComplete then
Nenue@14 65 numTasks = numTasks + 1
Nenue@16 66 Bonus.TaskWatch[numTasks] = t
Nenue@14 67 end
Nenue@14 68 end
Nenue@14 69 Bonus.numAll = #Bonus.TasksTable
Nenue@14 70 Bonus.numWatched = numTasks
Nenue@14 71 return GetNumQuestLogTasks()
Nenue@14 72 end
Nenue@16 73
Nenue@16 74 Bonus.GetInfo = function(self, taskIndex)
Nenue@16 75 return Bonus.TaskWatch[taskIndex]
Nenue@16 76 end
Nenue@16 77
Nenue@16 78 Bonus.StoreTask = function(questID)
Nenue@16 79
Nenue@14 80 if not questID then
Nenue@16 81 print('|cFFFF4400invalid quest ID', questID)
Nenue@14 82 return
Nenue@14 83 end
Nenue@14 84
Nenue@16 85 Bonus.Info[questID] = Bonus.Info[questID] or {}
Nenue@16 86 local t = Bonus.Info[questID]
Nenue@16 87 local isInArea, isOnMap, numObjectives = GetTaskInfo(questID)
Nenue@16 88 t.questID = questID
Nenue@16 89 t.numObjectives = numObjectives
Nenue@16 90 t.isInArea = isInArea
Nenue@16 91 t.isOnMap = isOnMap
Nenue@14 92
Nenue@16 93 print(' isInArea', isInArea, 'isOnMap', isOnMap, 'numObj', numObjectives)
Nenue@16 94 local displayObjectives = false
Nenue@16 95 local isComplete = true
Nenue@16 96 if numObjectives >= 1 then
Nenue@16 97 print(' ', numObjectives,'objective rows')
Nenue@14 98 t.objectives = {}
Nenue@14 99 for i = 1, t.numObjectives do
Nenue@14 100 t.objectives[i] = {}
Nenue@14 101 local o = t.objectives[i]
Nenue@14 102 o.index = i
Nenue@16 103 --local text, objectiveType, finished, displayAsObjective =
Nenue@16 104 o.text, o.objectiveType, o.finished, o.displayAsObjective = GetQuestObjectiveInfo(questID, i, false)
Nenue@14 105
Nenue@14 106 print(i, '==>', o.text, o.objectiveType, o.finished, o.displayAsObjective)
Nenue@14 107 t.displayObjectives = t.displayObjectives or o.displayAsObjective
Nenue@14 108 t.isComplete = t.isComplete and o.finished
Nenue@14 109
Nenue@14 110 end
Nenue@14 111 end
Nenue@16 112
Nenue@16 113 t.displayObjectives = displayObjectives
Nenue@16 114
Nenue@16 115
Nenue@16 116 local rewards = {}
Nenue@16 117 t.numCurrencies = GetNumQuestLogRewardCurrencies(questID)
Nenue@16 118 for i = 1, t.numCurrencies do
Nenue@16 119 local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID)
Nenue@16 120 tinsert(rewards,{
Nenue@16 121 type = 'currency',
Nenue@16 122 index = i,
Nenue@16 123 name = name,
Nenue@16 124 texture = texture,
Nenue@16 125 count = count
Nenue@16 126 });
Nenue@16 127 end
Nenue@16 128 -- items
Nenue@16 129 t.numItems = GetNumQuestLogRewards(questID)
Nenue@16 130 for i = 1, t.numItems do
Nenue@16 131 local name, texture, count, quality, isUsable = GetQuestLogRewardInfo(i, questID)
Nenue@16 132 tinsert(rewards, {
Nenue@16 133 type = 'item',
Nenue@16 134 index = i ,
Nenue@16 135 name = name,
Nenue@16 136 texture = texture,
Nenue@16 137 count = count,
Nenue@16 138 quality = quality,
Nenue@16 139 isUsable = isUsable
Nenue@16 140 });
Nenue@16 141 end
Nenue@16 142 -- money
Nenue@16 143
Nenue@16 144 local money = GetQuestLogRewardMoney(questID)
Nenue@16 145 if ( money > 0 ) then
Nenue@16 146 tinsert(rewards, {
Nenue@16 147 type = 'money',
Nenue@16 148 name = GetMoneyString(money),
Nenue@16 149 texture = "Interface\\Icons\\inv_misc_coin_01",
Nenue@16 150 count = 0,
Nenue@16 151 });
Nenue@16 152 end
Nenue@16 153
Nenue@16 154 if #rewards >= 1 then
Nenue@16 155 t.rewardInfo = rewards
Nenue@16 156 end
Nenue@16 157
Nenue@14 158 Bonus.TasksTable[questID] = t
Nenue@14 159
Nenue@14 160 return t
Nenue@14 161 end
Nenue@14 162
Nenue@14 163 -----------------------------
Nenue@13 164 --- QUEST
Nenue@1 165 Quest.itemButtons = {}
Nenue@1 166 Quest.freeButtons = {}
Nenue@1 167 Quest.POI = {}
Nenue@5 168 Quest.QuestBlock = {}
Nenue@16 169 Quest.LogBlock = {}
Nenue@16 170 Quest.LogInfo = {}
Nenue@0 171 Quest.GetNumWatched = function()
Nenue@14 172 Quest.numAll = GetNumQuestLogEntries()
Nenue@14 173 Quest.numWatched = GetNumQuestWatches()
Nenue@14 174 return Quest.numWatched
Nenue@0 175 end
Nenue@0 176 Quest.GetInfo = function (self, watchIndex)
Nenue@0 177 print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)')
Nenue@1 178 local questID, title, questIndex, numObjectives, requiredMoney, isComplete,
Nenue@0 179 startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
Nenue@13 180
Nenue@14 181 local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex)
Nenue@13 182 local questTagID, tagName = GetQuestTagInfo(questID);
Nenue@13 183
Nenue@0 184 if not questID then
Nenue@0 185 return
Nenue@0 186 end
Nenue@16 187 Quest.Info[questID] = Quest.Info[questID] or {}
Nenue@0 188
Nenue@16 189 local q = Quest.Info[questID]
Nenue@0 190 q.watchIndex = watchIndex
Nenue@0 191 q.type = 'Quest'
Nenue@0 192 q.questID = questID
Nenue@0 193 q.title = title
Nenue@13 194 q.level = level
Nenue@1 195 q.questLogIndex = questIndex
Nenue@0 196 q.numObjectives = numObjectives
Nenue@0 197 q.requiredMoney = requiredMoney
Nenue@0 198 q.isComplete = isComplete
Nenue@0 199 q.startEvent = startEvent
Nenue@0 200 q.isAutoComplete = isAutoComplete
Nenue@0 201 q.failureTime = failureTime
Nenue@0 202 q.timeElapsed = timeElapsed
Nenue@0 203 q.questType = questType
Nenue@0 204 q.isTask = isTask
Nenue@0 205 q.isStory = isStory
Nenue@0 206 q.isOnMap = isOnMap
Nenue@0 207 q.hasLocalPOI = hasLocalPOI
Nenue@0 208
Nenue@13 209 q.isDaily = ( frequency == LE_QUEST_FREQUENCY_DAILY and (not isComplete or isComplete == 0) )
Nenue@13 210 q.isWeekly = ( frequency == LE_QUEST_FREQUENCY_WEEKLY and (not isComplete or isComplete == 0) )
Nenue@13 211 q.isComplete = isComplete
Nenue@13 212 q.isStory = isStory
Nenue@13 213 q.isTask = isTask
Nenue@14 214
Nenue@14 215 if isTask then
Nenue@14 216 --q.task = Bonus.GetInfo(questID)
Nenue@14 217 end
Nenue@14 218
Nenue@13 219 --q.isBreadCrumb = isBreadCrumb
Nenue@1 220 q.completionText= GetQuestLogCompletionText(questIndex)
Nenue@1 221 q.numObjectives = GetNumQuestLeaderBoards(questIndex)
Nenue@1 222 q.isWatched = IsQuestWatched(questIndex)
Nenue@13 223 q.isHardWatched = IsQuestHardWatched(questIndex)
Nenue@0 224 q.objectives = {}
Nenue@0 225 for i = 1, q.numObjectives do
Nenue@1 226 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex)
Nenue@0 227 q.objectives[i] = {
Nenue@14 228 index = i,
Nenue@0 229 type = type,
Nenue@0 230 text = text,
Nenue@0 231 finished = finished
Nenue@0 232 }
Nenue@0 233 if type == 'event' then
Nenue@0 234 elseif type == 'monster' then
Nenue@0 235 elseif type == 'object' then
Nenue@0 236 elseif type == 'reputation' then
Nenue@0 237 elseif type == 'item' then
Nenue@0 238 end
Nenue@0 239 end
Nenue@0 240
Nenue@1 241 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex)
Nenue@1 242 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex)
Nenue@0 243 if link or icon or charges then
Nenue@0 244 q.specialItem = {
Nenue@1 245 questID = questID,
Nenue@1 246 questIndex = questIndex,
Nenue@0 247 link = link,
Nenue@0 248 charges = charges,
Nenue@0 249 icon = icon,
Nenue@0 250 start = start,
Nenue@0 251 duration = duration,
Nenue@0 252 enable = enable,
Nenue@0 253 }
Nenue@0 254 end
Nenue@0 255
Nenue@1 256
Nenue@1 257 if QuestHasPOIInfo(questID) then
Nenue@1 258 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@1 259 if distance ~= nil and distance > 0 then
Nenue@1 260 self.POI[questIndex] = {
Nenue@1 261 questIndex = questIndex,
Nenue@1 262 questID = questID,
Nenue@1 263 distance = distance,
Nenue@1 264 onContinent = onContinent
Nenue@1 265 }
Nenue@1 266 end
Nenue@1 267 end
Nenue@1 268
Nenue@8 269 q.superTracked = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue
Nenue@8 270 self.WatchInfo[watchIndex] = q
Nenue@1 271 self.LogInfo[questIndex] = q
Nenue@2 272 print('- logIndex =', questIndex, 'title =', title)
Nenue@0 273 return q
Nenue@0 274 end
Nenue@0 275
Nenue@1 276 Quest.GetClosest = function()
Nenue@1 277 local minID
Nenue@1 278 local minDist = math.huge
Nenue@1 279 for i = 1, Quest.GetNumWatched() do
Nenue@1 280 local info = Quest.GetInfo(i)
Nenue@1 281 if info.hasLocalPOI then
Nenue@1 282 local distance, onContinent = GetDistanceSqToQuest(info.questIndex)
Nenue@1 283 end
Nenue@1 284 end
Nenue@1 285 end
Nenue@1 286
Nenue@6 287
Nenue@0 288 Cheevs.GetNumWatched = function(self)
Nenue@0 289 Cheevs.trackedCheevs = {GetTrackedAchievements()}
Nenue@0 290 return GetNumTrackedAchievements()
Nenue@0 291 end
Nenue@0 292 Cheevs.GetInfo = function(self, index)
Nenue@0 293 local cheevID = Cheevs.trackedCheevs[index]
Nenue@0 294 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
Nenue@0 295
Nenue@0 296 self.Info[cheevID] = {}
Nenue@0 297 local c = self.Info[cheevID]
Nenue@0 298 c.type = 'Cheevs'
Nenue@0 299 c.watchIndex = index
Nenue@0 300 c.cheevID = cheevID
Nenue@0 301 c.title = name
Nenue@0 302 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 303 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy
Nenue@0 304 c.numObjectives = GetAchievementNumCriteria(cheevID)
Nenue@0 305 c.objectives = {}
Nenue@0 306 for i = 1, c.numObjectives do
Nenue@0 307 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i)
Nenue@0 308 c.objectives[i] = {
Nenue@14 309 index = i,
Nenue@8 310 cheevID = cheevID,
Nenue@0 311 text = description,
Nenue@0 312 type = type,
Nenue@0 313 finished = completed,
Nenue@14 314 value = quantity,
Nenue@14 315 maxValue = requiredQuantity,
Nenue@0 316 characterName = characterName,
Nenue@0 317 flags = flags,
Nenue@0 318 assetID = assetID,
Nenue@0 319 quantityString = quantityString,
Nenue@0 320 criteriaID = criteriaID,
Nenue@0 321 }
Nenue@0 322 end
Nenue@3 323 print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description)
Nenue@0 324
Nenue@0 325 self.WatchInfo[index] = c
Nenue@0 326 return self.Info[cheevID]
Nenue@0 327 end