annotate ObjectiveInfo.lua @ 18:d1812fb10ae6

ObjectiveStyle - move tag/template logic into the corresponding GetInfo
author Nenue
date Tue, 05 Apr 2016 02:38:01 -0400
parents 880828018bf4
children 605e8f0e46db
rev   line source
Nenue@0 1 local B = select(2,...).frame
Nenue@18 2 local wipe, pairs, ipairs, min, max, unpack, format = table.wipe, pairs, ipairs, min, max, unpack, format
Nenue@18 3 local tinsert, tostring = tinsert, tostring
Nenue@18 4 local GetQuestTagInfo, GetQuestLogTitle = GetQuestTagInfo, GetQuestLogTitle
Nenue@18 5 local GetNumQuestLogEntries, GetNumQuestWatches, GetQuestLogCompletionText, IsQuestWatched, IsQuestHardWatched, GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown = GetNumQuestLogEntries, GetNumQuestWatches, GetQuestLogCompletionText, IsQuestWatched, IsQuestHardWatched, GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown
Nenue@18 6 local GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetTasksTable, GetNumQuestLogTasks, GetTaskInfo, GetQuestObjectiveInfo = GetNumAutoQuestPopUps, GetAutoQuestPopUp, GetTasksTable, GetNumQuestLogTasks, GetTaskInfo, GetQuestObjectiveInfo
Nenue@18 7 local GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo, GetNumQuestLogRewards, GetQuestLogRewardInfo, GetQuestLogRewardMoney, GetMoneyString = GetNumQuestLogRewardCurrencies, GetQuestLogRewardCurrencyInfo, GetNumQuestLogRewards, GetQuestLogRewardInfo, GetQuestLogRewardMoney, GetMoneyString
Nenue@0 8 local GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo = GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo
Nenue@16 9 local GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo = GetQuestWatchIndex, GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo
Nenue@18 10 local QuestHasPOIInfo, GetDistanceSqToQuest, GetQuestFactionGroup = QuestHasPOIInfo, GetDistanceSqToQuest, GetQuestFactionGroup
Nenue@18 11 local GetTrackedAchievements, GetNumTrackedAchievements, GetAchievementInfo = GetTrackedAchievements, GetNumTrackedAchievements, GetAchievementInfo
Nenue@0 12 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@14 13 local print = B.print('TrackerInfo')
Nenue@18 14 local QUEST_TAG_DUNGEON = QUEST_TAG_DUNGEON
Nenue@18 15 local QUEST_TAG_GROUP = QUEST_TAG_GROUP
Nenue@18 16 local QUEST_TAG_ACCOUNT = QUEST_TAG_ACCOUNT
Nenue@18 17 local QUEST_TAG_TCOORDS = QUEST_TAG_TCOORDS
Nenue@18 18 local LE_QUEST_FREQUENCY_DAILY = LE_QUEST_FREQUENCY_DAILY
Nenue@18 19 local LE_QUEST_FREQUENCY_WEEKLY = LE_QUEST_FREQUENCY_WEEKLY
Nenue@18 20 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
Nenue@0 21
Nenue@14 22 local Tracker, Bonus, AutoQuest, Quest, Cheevs = mod.Tracker, mod.Bonus, mod.AutoQuest, mod.Quest, mod.Cheevs
Nenue@0 23 --------------------------------------------------------------------
Nenue@0 24 --- Tracker-specific data retrieval functions
Nenue@0 25 --------------------------------------------------------------------
Nenue@13 26
Nenue@13 27
Nenue@13 28 -----------------------------
Nenue@13 29 --- AUTO_QUEST
Nenue@16 30 AutoQuest.LogInfo = {}
Nenue@16 31 AutoQuest.LogBlock = {}
Nenue@16 32 AutoQuest.QuestBlock = {}
Nenue@16 33 AutoQuest.WatchBlock = {}
Nenue@16 34 AutoQuest.GetNumWatched = function()
Nenue@16 35 AutoQuest.numWatched = GetNumAutoQuestPopUps()
Nenue@16 36 return AutoQuest.numWatched
Nenue@16 37 end
Nenue@16 38 AutoQuest.GetInfo = function(self, popupIndex)
Nenue@16 39
Nenue@16 40 local questID, type = GetAutoQuestPopUp(popupIndex)
Nenue@16 41 local questIndex = GetQuestLogIndexByID(questID)
Nenue@16 42 local questWatchIndex = GetQuestWatchIndex(questIndex)
Nenue@16 43
Nenue@16 44 local questInfo = Quest:GetInfo(questWatchIndex)
Nenue@16 45 self.Info[questID] = {
Nenue@16 46 title = questInfo.title,
Nenue@16 47 description = type,
Nenue@16 48 popupType = type,
Nenue@16 49 questID = questID,
Nenue@16 50 questIndex = questIndex,
Nenue@16 51 popupIndex = popupIndex,
Nenue@16 52 watchIndex = questWatchIndex,
Nenue@16 53 numObjectives = 0
Nenue@16 54 }
Nenue@16 55
Nenue@16 56
Nenue@16 57 return self.Info[questID]
Nenue@13 58 end
Nenue@13 59
Nenue@13 60 -----------------------------
Nenue@14 61 --- BONUS OBJECTIVE
Nenue@14 62 Bonus.TasksTable = {}
Nenue@14 63 Bonus.TasksPOI = {}
Nenue@14 64 Bonus.TaskScenario = {}
Nenue@14 65
Nenue@14 66 local taskData = {}
Nenue@14 67 Bonus.QuestBlock = {}
Nenue@16 68 Bonus.TaskWatch = {}
Nenue@14 69 Bonus.GetNumWatched = function()
Nenue@16 70 local tasks = GetTasksTable()
Nenue@14 71 local numTasks = 0
Nenue@16 72 Bonus.TaskWatch = {}
Nenue@16 73 print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks)
Nenue@16 74 for i, questID in ipairs(tasks) do
Nenue@16 75 local t = Bonus.StoreTask(questID)
Nenue@16 76 print (' taskIndex', i, 'questID', questID)
Nenue@16 77 print(' isComplete', t.isComplete)
Nenue@16 78 if (t.inInArea or t.isOnMap) and not t.isComplete then
Nenue@14 79 numTasks = numTasks + 1
Nenue@16 80 Bonus.TaskWatch[numTasks] = t
Nenue@14 81 end
Nenue@14 82 end
Nenue@14 83 Bonus.numAll = #Bonus.TasksTable
Nenue@14 84 Bonus.numWatched = numTasks
Nenue@14 85 return GetNumQuestLogTasks()
Nenue@14 86 end
Nenue@16 87
Nenue@16 88 Bonus.GetInfo = function(self, taskIndex)
Nenue@16 89 return Bonus.TaskWatch[taskIndex]
Nenue@16 90 end
Nenue@16 91
Nenue@16 92 Bonus.StoreTask = function(questID)
Nenue@16 93
Nenue@14 94 if not questID then
Nenue@16 95 print('|cFFFF4400invalid quest ID', questID)
Nenue@14 96 return
Nenue@14 97 end
Nenue@14 98
Nenue@16 99 Bonus.Info[questID] = Bonus.Info[questID] or {}
Nenue@16 100 local t = Bonus.Info[questID]
Nenue@16 101 local isInArea, isOnMap, numObjectives = GetTaskInfo(questID)
Nenue@16 102 t.questID = questID
Nenue@16 103 t.numObjectives = numObjectives
Nenue@16 104 t.isInArea = isInArea
Nenue@16 105 t.isOnMap = isOnMap
Nenue@14 106
Nenue@16 107 print(' isInArea', isInArea, 'isOnMap', isOnMap, 'numObj', numObjectives)
Nenue@16 108 local displayObjectives = false
Nenue@16 109 local isComplete = true
Nenue@16 110 if numObjectives >= 1 then
Nenue@16 111 print(' ', numObjectives,'objective rows')
Nenue@14 112 t.objectives = {}
Nenue@14 113 for i = 1, t.numObjectives do
Nenue@14 114 t.objectives[i] = {}
Nenue@14 115 local o = t.objectives[i]
Nenue@14 116 o.index = i
Nenue@16 117 --local text, objectiveType, finished, displayAsObjective =
Nenue@16 118 o.text, o.objectiveType, o.finished, o.displayAsObjective = GetQuestObjectiveInfo(questID, i, false)
Nenue@14 119
Nenue@14 120 print(i, '==>', o.text, o.objectiveType, o.finished, o.displayAsObjective)
Nenue@14 121 t.displayObjectives = t.displayObjectives or o.displayAsObjective
Nenue@14 122 t.isComplete = t.isComplete and o.finished
Nenue@14 123
Nenue@14 124 end
Nenue@14 125 end
Nenue@16 126
Nenue@16 127 t.displayObjectives = displayObjectives
Nenue@16 128
Nenue@16 129
Nenue@16 130 local rewards = {}
Nenue@16 131 t.numCurrencies = GetNumQuestLogRewardCurrencies(questID)
Nenue@16 132 for i = 1, t.numCurrencies do
Nenue@16 133 local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID)
Nenue@16 134 tinsert(rewards,{
Nenue@16 135 type = 'currency',
Nenue@16 136 index = i,
Nenue@16 137 name = name,
Nenue@16 138 texture = texture,
Nenue@16 139 count = count
Nenue@16 140 });
Nenue@16 141 end
Nenue@16 142 -- items
Nenue@16 143 t.numItems = GetNumQuestLogRewards(questID)
Nenue@16 144 for i = 1, t.numItems do
Nenue@16 145 local name, texture, count, quality, isUsable = GetQuestLogRewardInfo(i, questID)
Nenue@16 146 tinsert(rewards, {
Nenue@16 147 type = 'item',
Nenue@16 148 index = i ,
Nenue@16 149 name = name,
Nenue@16 150 texture = texture,
Nenue@16 151 count = count,
Nenue@16 152 quality = quality,
Nenue@16 153 isUsable = isUsable
Nenue@16 154 });
Nenue@16 155 end
Nenue@16 156 -- money
Nenue@16 157
Nenue@16 158 local money = GetQuestLogRewardMoney(questID)
Nenue@16 159 if ( money > 0 ) then
Nenue@16 160 tinsert(rewards, {
Nenue@16 161 type = 'money',
Nenue@16 162 name = GetMoneyString(money),
Nenue@16 163 texture = "Interface\\Icons\\inv_misc_coin_01",
Nenue@16 164 count = 0,
Nenue@16 165 });
Nenue@16 166 end
Nenue@16 167
Nenue@16 168 if #rewards >= 1 then
Nenue@16 169 t.rewardInfo = rewards
Nenue@16 170 end
Nenue@16 171
Nenue@14 172 Bonus.TasksTable[questID] = t
Nenue@14 173
Nenue@14 174 return t
Nenue@14 175 end
Nenue@14 176
Nenue@14 177 -----------------------------
Nenue@13 178 --- QUEST
Nenue@1 179 Quest.itemButtons = {}
Nenue@1 180 Quest.freeButtons = {}
Nenue@1 181 Quest.POI = {}
Nenue@5 182 Quest.QuestBlock = {}
Nenue@16 183 Quest.LogBlock = {}
Nenue@16 184 Quest.LogInfo = {}
Nenue@18 185
Nenue@0 186 Quest.GetNumWatched = function()
Nenue@14 187 Quest.numAll = GetNumQuestLogEntries()
Nenue@14 188 Quest.numWatched = GetNumQuestWatches()
Nenue@14 189 return Quest.numWatched
Nenue@0 190 end
Nenue@0 191 Quest.GetInfo = function (self, watchIndex)
Nenue@0 192 print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)')
Nenue@1 193 local questID, title, questIndex, numObjectives, requiredMoney, isComplete,
Nenue@0 194 startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
Nenue@13 195
Nenue@14 196 local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex)
Nenue@18 197
Nenue@13 198
Nenue@0 199 if not questID then
Nenue@0 200 return
Nenue@0 201 end
Nenue@16 202 Quest.Info[questID] = Quest.Info[questID] or {}
Nenue@0 203
Nenue@16 204 local q = Quest.Info[questID]
Nenue@0 205 q.watchIndex = watchIndex
Nenue@0 206 q.type = 'Quest'
Nenue@0 207 q.questID = questID
Nenue@0 208 q.title = title
Nenue@13 209 q.level = level
Nenue@18 210 q.displayQuestID = displayQuestID
Nenue@18 211 q.suggestedGroup = suggestedGroup
Nenue@1 212 q.questLogIndex = questIndex
Nenue@0 213 q.numObjectives = numObjectives
Nenue@0 214 q.requiredMoney = requiredMoney
Nenue@0 215 q.isComplete = isComplete
Nenue@0 216 q.startEvent = startEvent
Nenue@0 217 q.isAutoComplete = isAutoComplete
Nenue@0 218 q.failureTime = failureTime
Nenue@0 219 q.timeElapsed = timeElapsed
Nenue@0 220 q.questType = questType
Nenue@0 221 q.isTask = isTask
Nenue@0 222 q.isStory = isStory
Nenue@0 223 q.isOnMap = isOnMap
Nenue@0 224 q.hasLocalPOI = hasLocalPOI
Nenue@18 225 q.frequency = frequency
Nenue@13 226 q.isComplete = isComplete
Nenue@13 227 q.isStory = isStory
Nenue@13 228 q.isTask = isTask
Nenue@14 229
Nenue@18 230 --- resolve icon type and template
Nenue@18 231 local tagID, tagName = GetQuestTagInfo(questID)
Nenue@18 232 if ( tagName ) then
Nenue@18 233 local factionGroup = GetQuestFactionGroup(questID);
Nenue@18 234 -- Faction-specific account quests have additional info in the tooltip
Nenue@18 235 if ( tagID == QUEST_TAG_ACCOUNT and factionGroup ) then
Nenue@18 236 local factionString = FACTION_ALLIANCE;
Nenue@18 237 if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
Nenue@18 238 factionString = FACTION_HORDE;
Nenue@18 239 end
Nenue@18 240 tagName = format("%s (%s)", tagName, factionString);
Nenue@18 241 end
Nenue@18 242 if ( QUEST_TAG_TCOORDS[tagID] ) then
Nenue@18 243 local questTypeIcon;
Nenue@18 244 if ( tagID == QUEST_TAG_ACCOUNT and factionGroup ) then
Nenue@18 245 q.typeTag = QUEST_TAG_TCOORDS["ALLIANCE"];
Nenue@18 246 if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
Nenue@18 247 q.typeTag= QUEST_TAG_TCOORDS["HORDE"];
Nenue@18 248 end
Nenue@18 249 else
Nenue@18 250 q.typeTag = QUEST_TAG_TCOORDS[tagID];
Nenue@18 251 end
Nenue@18 252 end
Nenue@14 253 end
Nenue@14 254
Nenue@18 255 if ( frequency == LE_QUEST_FREQUENCY_DAILY ) then
Nenue@18 256 q.frequencyTag = QUEST_TAG_TCOORDS["DAILY"]
Nenue@18 257 q.mainStyle = 'Daily'
Nenue@18 258 elseif ( frequency == LE_QUEST_FREQUENCY_WEEKLY ) then
Nenue@18 259 q.frequencyTag = QUEST_TAG_TCOORDS["WEEKLY"]
Nenue@18 260 q.mainStyle = 'Daily'
Nenue@18 261 end
Nenue@18 262 if ( isComplete and isComplete < 0 ) then
Nenue@18 263 q.completionTag = QUEST_TAG_TCOORDS["FAILED"]
Nenue@18 264 q.subStyle = 'Failed'
Nenue@18 265 elseif isComplete then
Nenue@18 266 q.completionTag = QUEST_TAG_TCOORDS["COMPLETED"]
Nenue@18 267 q.subStyle = 'Complete'
Nenue@18 268 end
Nenue@18 269 q.tagID = tagID
Nenue@18 270 q.tagName = tagName
Nenue@18 271
Nenue@18 272
Nenue@18 273
Nenue@13 274 --q.isBreadCrumb = isBreadCrumb
Nenue@1 275 q.completionText= GetQuestLogCompletionText(questIndex)
Nenue@1 276 q.numObjectives = GetNumQuestLeaderBoards(questIndex)
Nenue@0 277 q.objectives = {}
Nenue@0 278 for i = 1, q.numObjectives do
Nenue@1 279 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex)
Nenue@0 280 q.objectives[i] = {
Nenue@14 281 index = i,
Nenue@0 282 type = type,
Nenue@0 283 text = text,
Nenue@0 284 finished = finished
Nenue@0 285 }
Nenue@0 286 if type == 'event' then
Nenue@0 287 elseif type == 'monster' then
Nenue@0 288 elseif type == 'object' then
Nenue@0 289 elseif type == 'reputation' then
Nenue@0 290 elseif type == 'item' then
Nenue@0 291 end
Nenue@0 292 end
Nenue@0 293
Nenue@1 294 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex)
Nenue@1 295 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex)
Nenue@0 296 if link or icon or charges then
Nenue@0 297 q.specialItem = {
Nenue@1 298 questID = questID,
Nenue@1 299 questIndex = questIndex,
Nenue@0 300 link = link,
Nenue@0 301 charges = charges,
Nenue@0 302 icon = icon,
Nenue@0 303 start = start,
Nenue@0 304 duration = duration,
Nenue@0 305 enable = enable,
Nenue@0 306 }
Nenue@0 307 end
Nenue@0 308
Nenue@1 309 if QuestHasPOIInfo(questID) then
Nenue@1 310 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@1 311 if distance ~= nil and distance > 0 then
Nenue@1 312 self.POI[questIndex] = {
Nenue@1 313 questIndex = questIndex,
Nenue@1 314 questID = questID,
Nenue@1 315 distance = distance,
Nenue@1 316 onContinent = onContinent
Nenue@1 317 }
Nenue@1 318 end
Nenue@1 319 end
Nenue@1 320
Nenue@18 321
Nenue@18 322 q.selected = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue
Nenue@8 323 self.WatchInfo[watchIndex] = q
Nenue@1 324 self.LogInfo[questIndex] = q
Nenue@2 325 print('- logIndex =', questIndex, 'title =', title)
Nenue@0 326 return q
Nenue@0 327 end
Nenue@0 328
Nenue@1 329 Quest.GetClosest = function()
Nenue@1 330 local minID
Nenue@1 331 local minDist = math.huge
Nenue@1 332 for i = 1, Quest.GetNumWatched() do
Nenue@1 333 local info = Quest.GetInfo(i)
Nenue@1 334 if info.hasLocalPOI then
Nenue@1 335 local distance, onContinent = GetDistanceSqToQuest(info.questIndex)
Nenue@1 336 end
Nenue@1 337 end
Nenue@1 338 end
Nenue@1 339
Nenue@6 340
Nenue@0 341 Cheevs.GetNumWatched = function(self)
Nenue@0 342 Cheevs.trackedCheevs = {GetTrackedAchievements()}
Nenue@0 343 return GetNumTrackedAchievements()
Nenue@0 344 end
Nenue@0 345 Cheevs.GetInfo = function(self, index)
Nenue@0 346 local cheevID = Cheevs.trackedCheevs[index]
Nenue@0 347 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
Nenue@0 348
Nenue@0 349 self.Info[cheevID] = {}
Nenue@0 350 local c = self.Info[cheevID]
Nenue@0 351 c.type = 'Cheevs'
Nenue@0 352 c.watchIndex = index
Nenue@0 353 c.cheevID = cheevID
Nenue@0 354 c.title = name
Nenue@0 355 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 356 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy
Nenue@0 357 c.numObjectives = GetAchievementNumCriteria(cheevID)
Nenue@0 358 c.objectives = {}
Nenue@0 359 for i = 1, c.numObjectives do
Nenue@0 360 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i)
Nenue@0 361 c.objectives[i] = {
Nenue@14 362 index = i,
Nenue@8 363 cheevID = cheevID,
Nenue@0 364 text = description,
Nenue@0 365 type = type,
Nenue@0 366 finished = completed,
Nenue@14 367 value = quantity,
Nenue@14 368 maxValue = requiredQuantity,
Nenue@0 369 characterName = characterName,
Nenue@0 370 flags = flags,
Nenue@0 371 assetID = assetID,
Nenue@0 372 quantityString = quantityString,
Nenue@0 373 criteriaID = criteriaID,
Nenue@0 374 }
Nenue@0 375 end
Nenue@3 376 print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description)
Nenue@0 377
Nenue@0 378 self.WatchInfo[index] = c
Nenue@0 379 return self.Info[cheevID]
Nenue@0 380 end