annotate ObjectiveInfo.lua @ 22:9b3fa734abff

ObjectiveFrame - polish quest rewards display - implement money objectives - set line metrics in UpdateLine - set block metrics in UpdateBlock (sum of line metrics)
author Nenue
date Sat, 09 Apr 2016 07:32:45 -0400
parents d5ee940de273
children
rev   line source
Nenue@0 1 local B = select(2,...).frame
Nenue@22 2 local wipe, pairs, ipairs, min, max, unpack, format, mod = table.wipe, pairs, ipairs, min, max, unpack, format, mod
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@22 12 local GetMoney, floor = GetMoney, floor
Nenue@22 13 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@22 14 local print = B.print('Info')
Nenue@18 15 local QUEST_TAG_DUNGEON = QUEST_TAG_DUNGEON
Nenue@18 16 local QUEST_TAG_GROUP = QUEST_TAG_GROUP
Nenue@18 17 local QUEST_TAG_ACCOUNT = QUEST_TAG_ACCOUNT
Nenue@18 18 local QUEST_TAG_TCOORDS = QUEST_TAG_TCOORDS
Nenue@18 19 local LE_QUEST_FREQUENCY_DAILY = LE_QUEST_FREQUENCY_DAILY
Nenue@18 20 local LE_QUEST_FREQUENCY_WEEKLY = LE_QUEST_FREQUENCY_WEEKLY
Nenue@18 21 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 22
Nenue@22 23 local Tracker, Bonus, AutoQuest, Quest, Cheevs = T.DefaultTracker, T.Bonus, T.AutoQuest, T.Quest, T.Cheevs
Nenue@0 24 --------------------------------------------------------------------
Nenue@0 25 --- Tracker-specific data retrieval functions
Nenue@0 26 --------------------------------------------------------------------
Nenue@13 27
Nenue@13 28
Nenue@22 29 local DoQuestRewards= function(t, questID)
Nenue@22 30 local rewards = {}
Nenue@22 31 t.numCurrencies = GetNumQuestLogRewardCurrencies(questID)
Nenue@22 32 for i = 1, t.numCurrencies do
Nenue@22 33 local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID)
Nenue@22 34 tinsert(rewards,{
Nenue@22 35 type = 'currency',
Nenue@22 36 index = i,
Nenue@22 37 name = name,
Nenue@22 38 texture = texture,
Nenue@22 39 count = count
Nenue@22 40 });
Nenue@22 41 end
Nenue@22 42 -- items
Nenue@22 43 t.numItems = GetNumQuestLogRewards(questID)
Nenue@22 44 for i = 1, t.numItems do
Nenue@22 45 local name, texture, count, quality, isUsable = GetQuestLogRewardInfo(i, questID)
Nenue@22 46 tinsert(rewards, {
Nenue@22 47 type = 'item',
Nenue@22 48 index = i ,
Nenue@22 49 name = name,
Nenue@22 50 texture = texture,
Nenue@22 51 count = count,
Nenue@22 52 quality = quality,
Nenue@22 53 isUsable = isUsable
Nenue@22 54 });
Nenue@22 55 end
Nenue@22 56 -- money
Nenue@22 57
Nenue@22 58 local money = GetQuestLogRewardMoney(questID)
Nenue@22 59 if ( money > 0 ) then
Nenue@22 60 tinsert(rewards, {
Nenue@22 61 type = 'money',
Nenue@22 62 name = GetMoneyString(money),
Nenue@22 63 texture = "Interface\\Icons\\inv_misc_coin_01",
Nenue@22 64 count = 0,
Nenue@22 65 });
Nenue@22 66 end
Nenue@22 67
Nenue@22 68 if #rewards >= 1 then
Nenue@22 69 t.rewardInfo = rewards
Nenue@22 70 end
Nenue@22 71 end
Nenue@22 72
Nenue@22 73
Nenue@13 74 -----------------------------
Nenue@13 75 --- AUTO_QUEST
Nenue@16 76 AutoQuest.LogInfo = {}
Nenue@16 77 AutoQuest.LogBlock = {}
Nenue@16 78 AutoQuest.QuestBlock = {}
Nenue@16 79 AutoQuest.WatchBlock = {}
Nenue@19 80 function AutoQuest:GetNumWatched ()
Nenue@19 81 print(self.name, self)
Nenue@21 82 Quest:GetNumWatched()
Nenue@19 83 self.numWatched = GetNumAutoQuestPopUps()
Nenue@21 84
Nenue@19 85 return self.numWatched
Nenue@16 86 end
Nenue@16 87 AutoQuest.GetInfo = function(self, popupIndex)
Nenue@16 88
Nenue@22 89
Nenue@16 90 local questID, type = GetAutoQuestPopUp(popupIndex)
Nenue@16 91 local questIndex = GetQuestLogIndexByID(questID)
Nenue@21 92 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex)
Nenue@16 93
Nenue@22 94 self.Info[questID] = self.Info[questID] or {}
Nenue@22 95 local popup = self.Info[questID]
Nenue@22 96 popup.title = title
Nenue@22 97 popup.description = type
Nenue@22 98 popup.popupType = type
Nenue@22 99 popup.questID = questID
Nenue@22 100 popup.questIndex = questIndex
Nenue@22 101 popup.popupIndex = popupIndex
Nenue@22 102
Nenue@22 103 self.Info[questID] = popup
Nenue@22 104 self.WatchInfo[popupIndex] = popup
Nenue@16 105
Nenue@16 106
Nenue@16 107 return self.Info[questID]
Nenue@13 108 end
Nenue@13 109
Nenue@13 110 -----------------------------
Nenue@14 111 --- BONUS OBJECTIVE
Nenue@21 112 -- The default UI pops them up as you enter their relevant areas, but the data is actually available at all times.
Nenue@21 113 -- The only requirement is that you've been to said area and progressed any of the objectives.
Nenue@21 114 -- Blizzard deal with this fact by caching any task data collected during session and masking out whatever gets completed.
Nenue@21 115 -- For the addon's module structure to work, GetNumWatched method also invokes a tasks table scan.
Nenue@21 116 -- That composes the table searched by GetInfo().
Nenue@14 117
Nenue@21 118 ------------------------------------------------------------------------------------------
Nenue@21 119 --- These functions are copied from Blizzard_BonusObjectiveTracker.lua;
Nenue@21 120 -- It's kind of dumb, but this avoids the risk of code taint.
Nenue@21 121
Nenue@21 122 --- Returns a tasks table modified to include recently completed objectives
Nenue@22 123 local UnitName, GetRealmName = UnitName, GetRealmName
Nenue@21 124 local InternalGetTasksTable = function()
Nenue@22 125 local completedTasks = T.Conf.TasksLog
Nenue@22 126 local char = UnitName("player")
Nenue@22 127 local realm = GetRealmName()
Nenue@21 128 local tasks = GetTasksTable()
Nenue@22 129
Nenue@22 130 for questID, data in pairs(Bonus.Info) do
Nenue@22 131
Nenue@22 132 print(' -- questID:', questID, #data.objectives)
Nenue@22 133 for i, o in ipairs(data.objectives) do
Nenue@22 134 print(' --', i, o.text)
Nenue@22 135 end
Nenue@22 136
Nenue@22 137 end
Nenue@22 138
Nenue@22 139
Nenue@21 140 for questID, data in pairs(completedTasks) do
Nenue@21 141 if questID > 0 then
Nenue@21 142 local found = false
Nenue@21 143 for i = 1, #tasks do
Nenue@21 144 if tasks[i] == questID then
Nenue@21 145 found = true
Nenue@21 146 break
Nenue@21 147 end
Nenue@21 148 end
Nenue@21 149 -- if it's not part of the current table, then try to insert it where it was last found
Nenue@21 150 if not found then
Nenue@21 151 if data.watchIndex < #tasks then
Nenue@21 152 tinsert(tasks, data.watchIndex, data)
Nenue@21 153 else
Nenue@21 154 tinsert(tasks, data)
Nenue@21 155 end
Nenue@21 156 end
Nenue@21 157 end
Nenue@21 158 end
Nenue@21 159 return tasks
Nenue@21 160 end
Nenue@21 161
Nenue@21 162 --- Returns an entry from the composed tasks table if possible, otherwise makes an API pull
Nenue@21 163 local InternalGetTaskInfo = function(questID)
Nenue@22 164 local completedTasks = T.Conf.TasksLog
Nenue@21 165 if completedTasks[questID] then
Nenue@21 166 return true, true, #completedTasks[questID].objectives
Nenue@21 167 else
Nenue@21 168 return GetTaskInfo(questID)
Nenue@21 169 end
Nenue@21 170 end
Nenue@21 171
Nenue@21 172 --- Same as above but for the objective entries
Nenue@21 173 local InternalGetQuestObjectiveInfo = function(questID, objectiveIndex)
Nenue@22 174 local completedTasks = T.Conf.TasksLog
Nenue@21 175 if ( completedTasks[questID] ) then
Nenue@22 176 print('using internal data')
Nenue@21 177 return completedTasks[questID].objectives[objectiveIndex], completedTasks[questID].objectiveType, true;
Nenue@21 178 else
Nenue@21 179 return GetQuestObjectiveInfo(questID, objectiveIndex, false);
Nenue@21 180 end
Nenue@21 181 end
Nenue@21 182
Nenue@21 183 --- end redundant copy of silliness
Nenue@21 184 ------------------------------------------------------------------------------------------
Nenue@21 185
Nenue@21 186 Bonus.Completed = {}
Nenue@21 187 Bonus.POI = {}
Nenue@21 188 Bonus.Scenario = {}
Nenue@14 189 Bonus.QuestBlock = {}
Nenue@22 190 Bonus.WatchInfo = {}
Nenue@19 191 function Bonus:GetNumWatched ()
Nenue@19 192 print(self.name, self)
Nenue@22 193
Nenue@21 194 local tasks = InternalGetTasksTable()
Nenue@21 195 local numWatched = 0
Nenue@21 196 local numAll = 0
Nenue@21 197 self.WatchInfo = {}
Nenue@16 198 print('|cFFFFFF00Bonus.GetNumWatched()|r', #tasks)
Nenue@22 199 print(' TasksTable pull:')
Nenue@16 200 for i, questID in ipairs(tasks) do
Nenue@21 201 local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID)
Nenue@21 202 local existingTask = self.QuestBlock[questID]
Nenue@21 203 local displayObjectiveHeader = false;
Nenue@22 204 local test = (isInArea or (isOnMap and existingTask))
Nenue@22 205 --local test = true
Nenue@22 206 if test then
Nenue@21 207 self.Info[questID] = self.Info[questID] or {}
Nenue@21 208
Nenue@21 209 local t = self.Info[questID]
Nenue@21 210 self.WatchInfo[i] = t
Nenue@21 211 t.isInArea = isInArea
Nenue@21 212 t.isOnMap = isOnMap
Nenue@21 213 t.existingTask = existingTask
Nenue@21 214 t.questID = questID
Nenue@21 215 t.objectives = {}
Nenue@21 216 t.taskIndex = i
Nenue@21 217
Nenue@22 218
Nenue@22 219 DoQuestRewards(t, questID)
Nenue@22 220
Nenue@22 221 local taskTitle
Nenue@21 222 local taskFinished = true;
Nenue@21 223 for objectiveIndex = 1, numObjectives do
Nenue@21 224 local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false);
Nenue@21 225 displayObjectiveHeader = displayObjectiveHeader or displayAsObjective;
Nenue@22 226 if not taskTitle then
Nenue@22 227 if objectiveType == 'progressbar' and not text:match('^%d%+\\%d+') then
Nenue@22 228 taskTitle = text
Nenue@22 229 text = ''
Nenue@22 230 end
Nenue@22 231 end
Nenue@22 232
Nenue@22 233
Nenue@21 234 print(' --', text, objectiveType, finished, displayAsObjective)
Nenue@21 235 t.objectives[objectiveIndex] = t.objectives[objectiveIndex] or {}
Nenue@21 236 local o = t.objectives[objectiveIndex]
Nenue@21 237
Nenue@21 238 o.objectiveIndex = objectiveIndex
Nenue@21 239 o.text = text
Nenue@21 240 o.objectiveType = objectiveType
Nenue@21 241 o.finished = finished
Nenue@21 242 o.displayAsObjective = displayAsObjective
Nenue@21 243 print(' |cFF00FF88*', objectiveIndex, text)
Nenue@21 244 end
Nenue@22 245
Nenue@22 246 -- didn't get a name from progress bar? what about area name
Nenue@22 247 if not taskTitle then
Nenue@22 248 if isInArea then
Nenue@22 249 taskTitle = GetMapNameByID(GetCurrentMapAreaID())
Nenue@22 250 end
Nenue@22 251 end
Nenue@22 252 t.title = taskTitle
Nenue@14 253 end
Nenue@22 254
Nenue@22 255 print (' |cFF00FF88#', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N'), (test and '|cFF00FF00show|r' or '|cFFFF0088hide|r'))
Nenue@14 256 end
Nenue@21 257
Nenue@21 258
Nenue@21 259 self.numAll = #tasks
Nenue@21 260 self.numWatched = #self.WatchInfo
Nenue@22 261 print(' stats:', self.numAll, 'active tasks,', self.numWatched, 'nearby or animating')
Nenue@21 262 --return #tasks
Nenue@22 263 return #self.WatchInfo
Nenue@22 264 end
Nenue@22 265
Nenue@22 266 --- info cleanup done when turn-ins are detected
Nenue@22 267 Bonus.OnTurnIn = function(self, questID, xp, money)
Nenue@22 268 print('|cFFFF8800'..self.name..':OnTurnIn call', questID, xp, money)
Nenue@22 269
Nenue@22 270
Nenue@22 271
Nenue@14 272 end
Nenue@16 273
Nenue@16 274 Bonus.GetInfo = function(self, taskIndex)
Nenue@19 275 print(self.name, self)
Nenue@21 276 return self.WatchInfo[taskIndex]
Nenue@16 277 end
Nenue@16 278
Nenue@21 279 Bonus.Store = function(questID)
Nenue@16 280
Nenue@14 281 if not questID then
Nenue@16 282 print('|cFFFF4400invalid quest ID', questID)
Nenue@14 283 return
Nenue@14 284 end
Nenue@14 285
Nenue@16 286 Bonus.Info[questID] = Bonus.Info[questID] or {}
Nenue@16 287 local t = Bonus.Info[questID]
Nenue@16 288 local isInArea, isOnMap, numObjectives = GetTaskInfo(questID)
Nenue@16 289 t.questID = questID
Nenue@16 290 t.numObjectives = numObjectives
Nenue@16 291 t.isInArea = isInArea
Nenue@16 292 t.isOnMap = isOnMap
Nenue@14 293
Nenue@16 294 print(' isInArea', isInArea, 'isOnMap', isOnMap, 'numObj', numObjectives)
Nenue@16 295 local displayObjectives = false
Nenue@16 296 local isComplete = true
Nenue@16 297 if numObjectives >= 1 then
Nenue@16 298 print(' ', numObjectives,'objective rows')
Nenue@14 299 t.objectives = {}
Nenue@14 300 for i = 1, t.numObjectives do
Nenue@14 301 t.objectives[i] = {}
Nenue@14 302 local o = t.objectives[i]
Nenue@14 303 o.index = i
Nenue@16 304 --local text, objectiveType, finished, displayAsObjective =
Nenue@16 305 o.text, o.objectiveType, o.finished, o.displayAsObjective = GetQuestObjectiveInfo(questID, i, false)
Nenue@14 306
Nenue@14 307 print(i, '==>', o.text, o.objectiveType, o.finished, o.displayAsObjective)
Nenue@14 308 t.displayObjectives = t.displayObjectives or o.displayAsObjective
Nenue@14 309 t.isComplete = t.isComplete and o.finished
Nenue@14 310
Nenue@14 311 end
Nenue@14 312 end
Nenue@16 313
Nenue@16 314 t.displayObjectives = displayObjectives
Nenue@16 315
Nenue@22 316 DoQuestRewards(t, questID)
Nenue@16 317
Nenue@14 318 Bonus.TasksTable[questID] = t
Nenue@14 319
Nenue@14 320 return t
Nenue@14 321 end
Nenue@14 322
Nenue@14 323 -----------------------------
Nenue@13 324 --- QUEST
Nenue@1 325 Quest.itemButtons = {}
Nenue@1 326 Quest.freeButtons = {}
Nenue@1 327 Quest.POI = {}
Nenue@5 328 Quest.QuestBlock = {}
Nenue@16 329 Quest.LogBlock = {}
Nenue@16 330 Quest.LogInfo = {}
Nenue@18 331
Nenue@19 332 function Quest:GetNumWatched ()
Nenue@19 333 print(self.name, self)
Nenue@19 334 self.numAll = GetNumQuestLogEntries()
Nenue@19 335 self.numWatched = GetNumQuestWatches()
Nenue@19 336 return self.numWatched, self.numAll
Nenue@0 337 end
Nenue@0 338 Quest.GetInfo = function (self, watchIndex)
Nenue@0 339 print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)')
Nenue@1 340 local questID, title, questIndex, numObjectives, requiredMoney, isComplete,
Nenue@0 341 startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
Nenue@13 342
Nenue@19 343 if not questIndex then
Nenue@19 344 return
Nenue@19 345 end
Nenue@19 346
Nenue@14 347 local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex)
Nenue@18 348
Nenue@13 349
Nenue@0 350 if not questID then
Nenue@0 351 return
Nenue@0 352 end
Nenue@16 353 Quest.Info[questID] = Quest.Info[questID] or {}
Nenue@0 354
Nenue@16 355 local q = Quest.Info[questID]
Nenue@0 356 q.watchIndex = watchIndex
Nenue@0 357 q.type = 'Quest'
Nenue@0 358 q.questID = questID
Nenue@0 359 q.title = title
Nenue@13 360 q.level = level
Nenue@18 361 q.displayQuestID = displayQuestID
Nenue@18 362 q.suggestedGroup = suggestedGroup
Nenue@1 363 q.questLogIndex = questIndex
Nenue@0 364 q.numObjectives = numObjectives
Nenue@0 365 q.requiredMoney = requiredMoney
Nenue@0 366 q.isComplete = isComplete
Nenue@0 367 q.startEvent = startEvent
Nenue@0 368 q.isAutoComplete = isAutoComplete
Nenue@0 369 q.failureTime = failureTime
Nenue@0 370 q.timeElapsed = timeElapsed
Nenue@0 371 q.questType = questType
Nenue@0 372 q.isTask = isTask
Nenue@0 373 q.isStory = isStory
Nenue@0 374 q.isOnMap = isOnMap
Nenue@0 375 q.hasLocalPOI = hasLocalPOI
Nenue@18 376 q.frequency = frequency
Nenue@13 377 q.isComplete = isComplete
Nenue@13 378 q.isStory = isStory
Nenue@13 379 q.isTask = isTask
Nenue@14 380
Nenue@18 381 --- resolve icon type and template
Nenue@18 382 local tagID, tagName = GetQuestTagInfo(questID)
Nenue@18 383 if ( tagName ) then
Nenue@18 384 local factionGroup = GetQuestFactionGroup(questID);
Nenue@18 385 -- Faction-specific account quests have additional info in the tooltip
Nenue@18 386 if ( tagID == QUEST_TAG_ACCOUNT and factionGroup ) then
Nenue@18 387 local factionString = FACTION_ALLIANCE;
Nenue@18 388 if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
Nenue@18 389 factionString = FACTION_HORDE;
Nenue@18 390 end
Nenue@18 391 tagName = format("%s (%s)", tagName, factionString);
Nenue@18 392 end
Nenue@18 393 if ( QUEST_TAG_TCOORDS[tagID] ) then
Nenue@18 394 local questTypeIcon;
Nenue@18 395 if ( tagID == QUEST_TAG_ACCOUNT and factionGroup ) then
Nenue@18 396 q.typeTag = QUEST_TAG_TCOORDS["ALLIANCE"];
Nenue@18 397 if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
Nenue@18 398 q.typeTag= QUEST_TAG_TCOORDS["HORDE"];
Nenue@18 399 end
Nenue@18 400 else
Nenue@18 401 q.typeTag = QUEST_TAG_TCOORDS[tagID];
Nenue@18 402 end
Nenue@18 403 end
Nenue@14 404 end
Nenue@14 405
Nenue@18 406 if ( frequency == LE_QUEST_FREQUENCY_DAILY ) then
Nenue@18 407 q.frequencyTag = QUEST_TAG_TCOORDS["DAILY"]
Nenue@18 408 q.mainStyle = 'Daily'
Nenue@18 409 elseif ( frequency == LE_QUEST_FREQUENCY_WEEKLY ) then
Nenue@18 410 q.frequencyTag = QUEST_TAG_TCOORDS["WEEKLY"]
Nenue@18 411 q.mainStyle = 'Daily'
Nenue@18 412 end
Nenue@18 413 if ( isComplete and isComplete < 0 ) then
Nenue@18 414 q.completionTag = QUEST_TAG_TCOORDS["FAILED"]
Nenue@18 415 q.subStyle = 'Failed'
Nenue@18 416 elseif isComplete then
Nenue@18 417 q.completionTag = QUEST_TAG_TCOORDS["COMPLETED"]
Nenue@18 418 q.subStyle = 'Complete'
Nenue@18 419 end
Nenue@18 420 q.tagID = tagID
Nenue@18 421 q.tagName = tagName
Nenue@18 422
Nenue@18 423
Nenue@18 424
Nenue@13 425 --q.isBreadCrumb = isBreadCrumb
Nenue@1 426 q.completionText= GetQuestLogCompletionText(questIndex)
Nenue@1 427 q.numObjectives = GetNumQuestLeaderBoards(questIndex)
Nenue@0 428 q.objectives = {}
Nenue@0 429 for i = 1, q.numObjectives do
Nenue@1 430 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex)
Nenue@22 431 print(format(' #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished)))
Nenue@0 432 q.objectives[i] = {
Nenue@14 433 index = i,
Nenue@0 434 type = type,
Nenue@0 435 text = text,
Nenue@0 436 finished = finished
Nenue@0 437 }
Nenue@0 438 if type == 'event' then
Nenue@0 439 elseif type == 'monster' then
Nenue@0 440 elseif type == 'object' then
Nenue@0 441 elseif type == 'reputation' then
Nenue@0 442 elseif type == 'item' then
Nenue@0 443 end
Nenue@0 444 end
Nenue@0 445
Nenue@22 446 if requiredMoney >= 1 then
Nenue@22 447 local money = GetMoney()
Nenue@22 448 local moneyText = money
Nenue@22 449 local requiredSilver, requiredCopper
Nenue@22 450 local requiredGold = (requiredMoney > 10000) and (floor(requiredMoney/10000)) or nil
Nenue@22 451 if mod(requiredMoney, 10000) ~= 0 then
Nenue@22 452 requiredSilver = (requiredMoney > 100) and (mod(requiredMoney, 10000) / 100) or nil
Nenue@22 453 if mod(requiredMoney, 100) ~= 0 then
Nenue@22 454 requiredCopper = mod(requiredMoney, 100)
Nenue@22 455 end
Nenue@22 456 end
Nenue@22 457
Nenue@22 458 -- round the money value down
Nenue@22 459 if requiredMoney > 9999 and not (requiredSilver or requiredCopper) then
Nenue@22 460 moneyText = floor(money/10000)
Nenue@22 461 elseif requiredMoney < 10000 and mod(requiredMoney,100) == 0 then
Nenue@22 462 moneyText = floor(money/100)
Nenue@22 463 end
Nenue@22 464
Nenue@22 465 local text = moneyText
Nenue@22 466 local index = #q.objectives + 1
Nenue@22 467 local finished = (GetMoney() >= requiredMoney)
Nenue@22 468
Nenue@22 469 if not finished then
Nenue@22 470 text = text .. ' / ' .. GetCoinTextureString(requiredMoney, 15)
Nenue@22 471 else
Nenue@22 472 text = '' .. GetCoinTextureString(requiredMoney, 15)
Nenue@22 473 end
Nenue@22 474 q.objectives[index] = {
Nenue@22 475 index = index,
Nenue@22 476 type = 'progressbar',
Nenue@22 477 quantity = money,
Nenue@22 478 requiredQuantity = requiredMoney,
Nenue@22 479 text = text,
Nenue@22 480 finished = finished
Nenue@22 481 }
Nenue@22 482 print(format(' #%d %s %s %s', index, 'money', text, tostring(finished)))
Nenue@22 483 end
Nenue@22 484
Nenue@22 485
Nenue@1 486 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex)
Nenue@1 487 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex)
Nenue@0 488 if link or icon or charges then
Nenue@0 489 q.specialItem = {
Nenue@1 490 questID = questID,
Nenue@1 491 questIndex = questIndex,
Nenue@0 492 link = link,
Nenue@0 493 charges = charges,
Nenue@0 494 icon = icon,
Nenue@0 495 start = start,
Nenue@0 496 duration = duration,
Nenue@0 497 enable = enable,
Nenue@0 498 }
Nenue@0 499 end
Nenue@0 500
Nenue@1 501 if QuestHasPOIInfo(questID) then
Nenue@1 502 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@1 503 if distance ~= nil and distance > 0 then
Nenue@1 504 self.POI[questIndex] = {
Nenue@1 505 questIndex = questIndex,
Nenue@1 506 questID = questID,
Nenue@1 507 distance = distance,
Nenue@1 508 onContinent = onContinent
Nenue@1 509 }
Nenue@1 510 end
Nenue@1 511 end
Nenue@1 512
Nenue@18 513
Nenue@18 514 q.selected = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue
Nenue@8 515 self.WatchInfo[watchIndex] = q
Nenue@1 516 self.LogInfo[questIndex] = q
Nenue@2 517 print('- logIndex =', questIndex, 'title =', title)
Nenue@0 518 return q
Nenue@0 519 end
Nenue@0 520
Nenue@1 521 Quest.GetClosest = function()
Nenue@1 522 local minID
Nenue@1 523 local minDist = math.huge
Nenue@1 524 for i = 1, Quest.GetNumWatched() do
Nenue@1 525 local info = Quest.GetInfo(i)
Nenue@1 526 if info.hasLocalPOI then
Nenue@1 527 local distance, onContinent = GetDistanceSqToQuest(info.questIndex)
Nenue@1 528 end
Nenue@1 529 end
Nenue@1 530 end
Nenue@1 531
Nenue@6 532
Nenue@0 533 Cheevs.GetNumWatched = function(self)
Nenue@21 534 print('|cFF00FF00' .. GetTime())
Nenue@0 535 Cheevs.trackedCheevs = {GetTrackedAchievements()}
Nenue@0 536 return GetNumTrackedAchievements()
Nenue@0 537 end
Nenue@0 538 Cheevs.GetInfo = function(self, index)
Nenue@0 539 local cheevID = Cheevs.trackedCheevs[index]
Nenue@0 540 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
Nenue@0 541
Nenue@0 542 self.Info[cheevID] = {}
Nenue@0 543 local c = self.Info[cheevID]
Nenue@0 544 c.type = 'Cheevs'
Nenue@0 545 c.watchIndex = index
Nenue@0 546 c.cheevID = cheevID
Nenue@0 547 c.title = name
Nenue@0 548 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 549 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy
Nenue@0 550 c.numObjectives = GetAchievementNumCriteria(cheevID)
Nenue@0 551 c.objectives = {}
Nenue@0 552 for i = 1, c.numObjectives do
Nenue@0 553 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i)
Nenue@0 554 c.objectives[i] = {
Nenue@21 555 objectiveIndex = i,
Nenue@8 556 cheevID = cheevID,
Nenue@0 557 text = description,
Nenue@0 558 type = type,
Nenue@0 559 finished = completed,
Nenue@14 560 value = quantity,
Nenue@14 561 maxValue = requiredQuantity,
Nenue@0 562 characterName = characterName,
Nenue@0 563 flags = flags,
Nenue@0 564 assetID = assetID,
Nenue@0 565 quantityString = quantityString,
Nenue@0 566 criteriaID = criteriaID,
Nenue@0 567 }
Nenue@0 568 end
Nenue@3 569 print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description)
Nenue@0 570
Nenue@0 571 self.WatchInfo[index] = c
Nenue@0 572 return self.Info[cheevID]
Nenue@0 573 end