annotate ObjectiveTracker/Quests.lua @ 37:e84d645c8ab8

- revised the tracker update function to build its complete data list up front and use the values as points of comparison for determining possible out of place blocks, which will be iterated over afterward to remove what wasn't re-used - also entailed revising the exact role of global event handlers and function hooks, limiting their directions of communication so one doesn't end up calling the other multiple or inifinity times - schema handling polish
author Nenue
date Mon, 18 Apr 2016 07:56:23 -0400
parents 69d03f8e293e
children 1f8f9cc3d956
rev   line source
Nenue@28 1 local B = select(2,...).frame
Nenue@28 2 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@28 3 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
Nenue@30 4 local GetQuestWatchInfo, GetQuestLogCompletionText = GetQuestWatchInfo, GetQuestLogCompletionText
Nenue@30 5 local GetQuestLogLeaderBoard, GetNumQuestLogEntries, GetQuestLogTitle = GetQuestLogLeaderBoard, GetNumQuestLogEntries, GetQuestLogTitle
Nenue@30 6 local GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown = GetQuestLogSpecialItemInfo, GetQuestLogSpecialItemCooldown
Nenue@30 7 local GetSuperTrackedQuestID, GetMoney, C_Scenario, GetCVarBool, GetNumQuestWatches = GetSuperTrackedQuestID, GetMoney, C_Scenario, GetCVarBool, GetNumQuestWatches
Nenue@30 8 local GetQuestTagInfo, GetMoneyString, GetDistanceSqToQuest, GetQuestFactionGroup = GetQuestTagInfo, GetMoneyString, GetDistanceSqToQuest, GetQuestFactionGroup
Nenue@30 9 local QUEST_TAG_ACCOUNT, LE_QUEST_FACTION_HORDE, LE_QUEST_FREQUENCY_DAILY, LE_QUEST_FREQUENCY_WEEKLY = QUEST_TAG_ACCOUNT, LE_QUEST_FACTION_HORDE, LE_QUEST_FREQUENCY_DAILY, LE_QUEST_FREQUENCY_WEEKLY
Nenue@30 10 local QUEST_TAG_TCOORDS, IsQuestSequenced = QUEST_TAG_TCOORDS, IsQuestSequenced
Nenue@28 11 local Default, Quest = T.DefaultHandler, T.Quest
Nenue@37 12 local format, wipe, select = format, table.wipe, select
Nenue@37 13 local wipeall = B.wipeall
Nenue@37 14 local lprint, iprint, tprint = B.print('Line'), B.print('Info'), B.print('Tracker')
Nenue@37 15 local print = tprint
Nenue@28 16
Nenue@30 17 local superTrackQuestID, playerMoney, inScenario, showPOIs
Nenue@28 18 Quest.Update = function(self, reason, ...)
Nenue@28 19 local print = tprint
Nenue@28 20 print('QuestTracker:Update() received')
Nenue@28 21 T.UpdateActionButtons()
Nenue@28 22 Default.Update(self, reason, ...)
Nenue@28 23 end
Nenue@28 24
Nenue@28 25 T.Quest.numButtons = 0
Nenue@28 26 local usedButtons = T.Quest.itemButtons
Nenue@28 27 local freeButtons = T.Quest.freeButtons
Nenue@28 28
Nenue@28 29 Quest.UpdateObjectives = function(handler, block)
Nenue@28 30 local print = lprint
Nenue@28 31 print('|cFF00FFFFUpdateObjectives()')
Nenue@28 32 local info = block.info
Nenue@28 33
Nenue@28 34 print((info.isAccount and 'isAccount' or ''), (info.isFaction and 'isFaction' or ''), (info.isDaily and 'isDaily' or ''), (info.isWeekly and 'isWeekly' or ''), info.tagID, info.tagName)
Nenue@28 35
Nenue@34 36 local block_schema = 'default'
Nenue@28 37 if info.isAccount then
Nenue@28 38 if info.isFaction then
Nenue@28 39 print(' faction', info.tagID)
Nenue@34 40 block_schema = 'faction_'..info.tagID
Nenue@28 41 else
Nenue@28 42 print(' account', info.isAccount, info.isFaction)
Nenue@34 43 block_schema = 'account'
Nenue@28 44 end
Nenue@28 45 elseif info.isDaily then
Nenue@28 46 print(' daily', info.frequency)
Nenue@34 47 block_schema = 'daily'
Nenue@28 48 elseif info.isWeekly then
Nenue@28 49 print(' weekly', info.frequency)
Nenue@34 50 block_schema = 'weekly'
Nenue@28 51 end
Nenue@28 52 local completionText
Nenue@28 53 if info.isComplete then
Nenue@28 54 if info.isAutoComplete then
Nenue@34 55 local questID, popupType = GetAutoQuestPopUp(info.logIndex)
Nenue@28 56 if popupType == 'COMPLETE' then
Nenue@28 57 print(' :: auto-complete quest :: set the message')
Nenue@28 58 info.completionText = T.strings.CLICK_TO_COMPLETE
Nenue@28 59 end
Nenue@28 60 else
Nenue@28 61 if not completionText or info.completionText then
Nenue@34 62 info.completionText = GetQuestLogCompletionText(info.logIndex)
Nenue@28 63 end
Nenue@28 64 end
Nenue@28 65 print(' :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"')
Nenue@28 66 end
Nenue@28 67
Nenue@34 68 Default.UpdateObjectives(handler, block, block_schema)
Nenue@34 69 return block_schema
Nenue@28 70 end
Nenue@28 71
Nenue@28 72 Quest.UpdateLine = function(handler, block, line, data)
Nenue@28 73 local print = lprint
Nenue@28 74 local objectiveType = data.type
Nenue@31 75 return data.text, nil, objectiveType
Nenue@28 76 end
Nenue@28 77
Nenue@28 78 -----------------------------
Nenue@28 79 --- QUEST
Nenue@37 80 local tremove, tinsert = tremove, tinsert
Nenue@37 81 local GetQuestLogIndexByID, IsQuestWatched = GetQuestLogIndexByID, IsQuestWatched
Nenue@28 82 Quest.QuestBlock = {}
Nenue@28 83 Quest.LogBlock = {}
Nenue@28 84 Quest.LogInfo = {}
Nenue@37 85 function Quest:FreeBlock (block)
Nenue@37 86 local used = Quest.usedBlocks
Nenue@37 87 local free = Quest.freeBlocks
Nenue@37 88 local reason = ''
Nenue@37 89 local doRelease = false
Nenue@37 90 local info = block.info
Nenue@37 91 local questID = info.questID
Nenue@37 92 local logIndex = info.logIndex
Nenue@28 93
Nenue@37 94 if info.posIndex then
Nenue@37 95 if used[info.posIndex] == block then
Nenue@37 96 doRelease = true
Nenue@37 97 reason = 'posIndex mismatch'
Nenue@37 98 end
Nenue@37 99 elseif logIndex then
Nenue@37 100 if not IsQuestWatched(logIndex) then
Nenue@37 101 reason = 'not being watched'
Nenue@37 102 elseif not self.LogBlock[logIndex] then
Nenue@37 103 doRelease = true
Nenue@37 104 reason = 'missing logBlock entry'
Nenue@37 105 elseif (self.LogBlock[logIndex] ~= block) then
Nenue@37 106 doRelease = true
Nenue@37 107 reason = 'different block using index'
Nenue@37 108 end
Nenue@37 109 elseif info.questID then
Nenue@37 110 if not GetQuestLogIndexByID(info.questID) then
Nenue@37 111 doRelease = true
Nenue@37 112 reason = 'no identifiable quest log entry'
Nenue@37 113 end
Nenue@37 114 end
Nenue@37 115
Nenue@37 116
Nenue@37 117 if doRelease then
Nenue@37 118 print(' |cFF00FF00FreeBlock (' .. block:GetName() .. '):', reason)
Nenue@37 119 block:Hide()
Nenue@37 120 tremove(used, info.posIndex)
Nenue@37 121 tinsert(free, block)
Nenue@37 122 end
Nenue@37 123
Nenue@37 124
Nenue@37 125 end
Nenue@37 126 local watchesChecked = {}
Nenue@37 127 local infosChecked = {}
Nenue@37 128 local blocksChecked = {}
Nenue@37 129 local GetQuestWatchIndex = GetQuestWatchIndex
Nenue@37 130 --- Get a total of things to show, and straighten out the index while we're at it
Nenue@37 131 --- Return the number shown, total in log, and the info table to parse
Nenue@37 132 Quest.GetNumWatched = function (self, id, added)
Nenue@30 133 superTrackQuestID = GetSuperTrackedQuestID()
Nenue@30 134 playerMoney = GetMoney();
Nenue@30 135 inScenario = C_Scenario.IsInScenario();
Nenue@30 136 showPOIs = GetCVarBool("questPOI");
Nenue@37 137 local numAll = GetNumQuestLogEntries()
Nenue@37 138 local numWatched = GetNumQuestWatches()
Nenue@37 139 local bottomIndex = 1
Nenue@37 140 print(' |cFF00FF88GetNumWatched:|r',self.name, numWatched, 'of', numAll)
Nenue@37 141 local start, limit = 1, numAll
Nenue@37 142
Nenue@37 143 --- start a list of blocks affected by this function
Nenue@37 144 wipe(blocksChecked)
Nenue@37 145 if id and not added then
Nenue@37 146 if self.InfoBlock[id] then
Nenue@37 147 tinsert(blocksChecked, self.InfoBlock[id])
Nenue@37 148 end
Nenue@37 149 end
Nenue@37 150
Nenue@37 151 for logIndex = start, limit do
Nenue@37 152 local reason1, reason2 = '', ''
Nenue@37 153 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex)
Nenue@37 154 local watchIndex = GetQuestWatchIndex(logIndex)
Nenue@37 155
Nenue@37 156 if watchIndex and watchIndex >= bottomIndex then
Nenue@37 157 local watchInfo = self.WatchInfo[watchIndex]
Nenue@37 158 local watchBlock = self.WatchBlock[watchIndex]
Nenue@37 159 if watchInfo and watchInfo.questID ~= questID then
Nenue@37 160 print(' |cFFBBFF00GetNumWatched: trimming WatchInfo ['..watchIndex..'] =/=', questID)
Nenue@37 161 self.WatchInfo[watchIndex] = nil
Nenue@37 162 end
Nenue@37 163 if watchBlock and watchBlock.info.questID ~= questID then
Nenue@37 164 print(' |cFFBBFF00GetNumWatched: trimming WatchBlock ['..watchIndex..'] =/=', watchBlock:GetName())
Nenue@37 165 self.WatchBlock[watchIndex] = nil
Nenue@37 166 tinsert(blocksChecked, watchBlock)
Nenue@37 167 end
Nenue@37 168 end
Nenue@37 169
Nenue@37 170 local logBlock = self.LogBlock[logIndex]
Nenue@37 171 if logBlock and logBlock.info.questID ~= questID then
Nenue@37 172 --print(' |cFFBBFF00GetNumWatched: trimming LogBlock ['..logIndex..'] =/=', logBlock:GetName())
Nenue@37 173 self.LogBlock[logIndex] = nil
Nenue@37 174 tinsert(blocksChecked, logBlock)
Nenue@37 175 end
Nenue@37 176
Nenue@37 177 if questID ~= 0 then
Nenue@37 178 self.Info[questID] = self:GetInfo(logIndex, watchIndex)
Nenue@37 179 --print(' |cFF44BBFFGetNumWatched:|r map', questID, 'to', logIndex, (watchIndex and ('('..watchIndex..')') or ''))
Nenue@37 180 end
Nenue@37 181 end
Nenue@37 182
Nenue@37 183 --- remove any orphaned blocks from view and, if possible, free it for re-use
Nenue@37 184 for i, block in ipairs(blocksChecked) do
Nenue@37 185 if not GetQuestLogIndexByID(block.info.questID, 'player') then
Nenue@37 186 print(' |cFFBBFF00GetNumWatched:|r literating a block without an index |cFFBBFF00'.. block:GetName()..'|r')
Nenue@37 187 block:Hide()
Nenue@37 188 self:FreeBlock(block)
Nenue@37 189 end
Nenue@37 190 if not IsQuestWatched(block.info.logIndex) then
Nenue@37 191 print(' |cFFBBFF00GetNumWatched:|r hiding untracked quest |cFFBBFF00'.. block:GetName()..'|r')
Nenue@37 192 block:Hide()
Nenue@37 193 end
Nenue@37 194 end
Nenue@37 195
Nenue@37 196 self.numWatched = numWatched
Nenue@37 197 self.numAll = numAll
Nenue@37 198
Nenue@37 199 return numWatched, numAll, self.WatchList
Nenue@28 200 end
Nenue@30 201
Nenue@37 202
Nenue@30 203 --- Returns an iterable table from which tracker blocks can be filled out. Data includes:
Nenue@30 204 -- All entry-layer GetXInfo return values
Nenue@30 205 -- Manifest of line data to be displayed in relation to the tracked object
Nenue@37 206 Quest.GetInfo = function (self, logIndex, watchIndex)
Nenue@28 207 local print = iprint
Nenue@37 208 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex)
Nenue@30 209 if ( not questID ) then
Nenue@37 210 tprint(' |cFFFF0088GetInfo:|r', logIndex, watchIndex, '|cFFFF2299no data|r')
Nenue@28 211 return
Nenue@28 212 end
Nenue@28 213
Nenue@37 214 Quest.Info[questID] = Quest.Info[questID] or {}
Nenue@37 215 local q = Quest.Info[questID]
Nenue@37 216 q.questID = questID
Nenue@37 217 q.id = questID
Nenue@37 218 q.logIndex = logIndex
Nenue@37 219 q.watchIndex = watchIndex
Nenue@28 220
Nenue@37 221 local numObjectives, requiredMoney, isAutoComplete, failureTime, timeElapsed, questType
Nenue@37 222 = 0, 0, nil, false, false, 0
Nenue@37 223 if watchIndex then
Nenue@37 224 local _
Nenue@37 225 _,_,_, numObjectives, requiredMoney, _, _, isAutoComplete,
Nenue@37 226 failureTime, timeElapsed, questType = GetQuestWatchInfo(watchIndex)
Nenue@37 227 self.WatchList[watchIndex] = q
Nenue@37 228 --tprint(' |cFF88FF00GetInfo:|r set watch entry', watchIndex)
Nenue@37 229 tprint(' |cFFFFBB00GetInfo:|r', logIndex, watchIndex, '|cFFFF2299'..title..'|r')
Nenue@37 230 end
Nenue@37 231 self.LogInfo[logIndex] = q
Nenue@28 232
Nenue@37 233 q.numObjectives = numObjectives
Nenue@37 234 q.requiredMoney = requiredMoney
Nenue@37 235 q.failureTime = failureTime
Nenue@37 236 q.timeElapsed = timeElapsed
Nenue@30 237
Nenue@37 238
Nenue@37 239
Nenue@32 240 q.type = 'Quest'
Nenue@32 241 q.title = title
Nenue@32 242 q.level = level
Nenue@32 243 q.displayQuestID = displayQuestID
Nenue@32 244 q.suggestedGroup = suggestedGroup
Nenue@32 245
Nenue@30 246 -- re-use Blizzard logic for consistency
Nenue@32 247 local showQuest = true
Nenue@32 248 if isTask then showQuest = false end
Nenue@30 249 local watchMoney = false;
Nenue@30 250 local tagID, typeTag, frequencyTag, completionTag, completionText
Nenue@30 251 local isAccount, isFaction, isWeekly, isDaily = false, false, false, false
Nenue@30 252 local isBreadcrumb = false
Nenue@30 253 local questFailed = false
Nenue@30 254 local watchMoney = false
Nenue@30 255 local timerInfo, moneyInfo = false, false
Nenue@30 256 local objectives = q.objectives or {}
Nenue@30 257
Nenue@30 258
Nenue@30 259 -- Case 1: completed quest or "go to thing" breadcrumb
Nenue@30 260 -- * 1 line containing the completion text
Nenue@30 261 if ( isComplete and isComplete < 0 ) then
Nenue@30 262 isComplete = false
Nenue@30 263 questFailed = true
Nenue@30 264 elseif ( numObjectives == 0 and playerMoney >= requiredMoney and not startEvent ) then
Nenue@30 265 isComplete = true;
Nenue@30 266 questFailed = false
Nenue@30 267 if ( requiredMoney == 0 ) then
Nenue@30 268 isBreadcrumb = true;
Nenue@30 269 end
Nenue@30 270 end
Nenue@30 271 print('|cFF0088FFflags:|r', (isComplete and 'isComplete' or ''), (questFailed and 'questFailed' or ''), (isBreadcrumb and 'isBreadcrumb' or ''))
Nenue@30 272
Nenue@30 273 -- completion message?
Nenue@30 274 local isSequenced = IsQuestSequenced(questID)
Nenue@30 275 local temp_status = ''
Nenue@30 276 if ( isComplete ) then
Nenue@30 277 temp_status = 'COMPLETED_OBJECTIVES'
Nenue@30 278 objectives = Quest.GetObjectives(questLogIndex, numObjectives, true, isSequenced, isStory)
Nenue@30 279 if ( isAutoComplete ) then
Nenue@30 280 temp_status = 'AUTOCOMPLETE_OBJECTIVES'
Nenue@30 281 completionText = _G.QUEST_WATCH_CLICK_TO_COMPLETE
Nenue@30 282 else
Nenue@30 283 if ( isBreadcrumb ) then
Nenue@30 284 temp_status = 'COMPLETE_BREADCRUMB'
Nenue@30 285 completionText = GetQuestLogCompletionText(questLogIndex)
Nenue@30 286 else
Nenue@30 287 temp_status = 'COMPLETE_READY_FOR_TURN_IN'
Nenue@30 288 completionText = _G.QUEST_WATCH_QUEST_READY
Nenue@30 289 end
Nenue@30 290 end
Nenue@30 291 elseif ( questFailed ) then
Nenue@30 292 temp_status = 'FAILED'
Nenue@30 293 -- Case 2: failed quest
Nenue@30 294 -- * 1 status line; hide other info
Nenue@30 295 completionText = _G.FAILED
Nenue@30 296 else
Nenue@30 297
Nenue@30 298 temp_status = 'PROGRESS_OBJECTIVES'
Nenue@30 299 -- Case 3: quest in progress
Nenue@30 300 -- * Multiple objective lines
Nenue@30 301 -- * Possible extra lines for money and timer data respectively
Nenue@37 302 objectives = Quest.GetObjectives(logIndex, numObjectives, false, isSequenced, isStory)
Nenue@30 303 q.objectives = objectives
Nenue@30 304
Nenue@30 305 --- anything past here gets appended to existing objectives
Nenue@30 306
Nenue@30 307 -- money
Nenue@30 308 if ( requiredMoney > playerMoney ) then
Nenue@30 309
Nenue@30 310 temp_status = temp_status .. '_MONEY'
Nenue@30 311 local text = GetMoneyString(playerMoney).." / "..GetMoneyString(requiredMoney);
Nenue@30 312 moneyInfo = {
Nenue@30 313 type = 'money',
Nenue@30 314 text = text,
Nenue@30 315 finished = false,
Nenue@30 316 requiredMoney = requiredMoney,
Nenue@30 317 playerMoney = playerMoney,
Nenue@30 318 }
Nenue@31 319 tinsert(objectives, moneyInfo)
Nenue@30 320 end
Nenue@30 321
Nenue@30 322 -- time limit
Nenue@30 323 if ( failureTime ) then
Nenue@30 324 temp_status = temp_status .. '_TIMED'
Nenue@30 325 if ( timeElapsed and timeElapsed <= failureTime ) then
Nenue@30 326 timerInfo = {
Nenue@30 327 type = 'timer',
Nenue@30 328 finished = false,
Nenue@30 329 timeElapsed = timeElapsed,
Nenue@30 330 failureTime = failureTime,
Nenue@30 331 }
Nenue@31 332 tinsert(objectives, timerInfo)
Nenue@30 333 end
Nenue@30 334 end
Nenue@30 335 end
Nenue@30 336 q.objectives = objectives
Nenue@30 337 q.moneyInfo = moneyInfo
Nenue@30 338 q.timerInfo = timerInfo
Nenue@30 339 q.completionText = completionText
Nenue@30 340
Nenue@30 341 -- POI data
Nenue@30 342 local POI = false
Nenue@30 343 if ( showPOIs ) then
Nenue@30 344 POI = {
Nenue@30 345 questID = questID,
Nenue@37 346 logIndex = logIndex,
Nenue@37 347 watchIndex = watchIndex
Nenue@30 348 }
Nenue@30 349 local poiButton;
Nenue@30 350 if ( hasLocalPOI ) then
Nenue@30 351
Nenue@30 352 if ( isComplete ) then
Nenue@30 353 POI.type = 'normal'
Nenue@30 354 else
Nenue@30 355 POI.type = 'numeric'
Nenue@30 356 end
Nenue@30 357 elseif ( isComplete ) then
Nenue@30 358 POI.type = 'remote'
Nenue@30 359 end
Nenue@30 360
Nenue@37 361 local distance, onContinent = GetDistanceSqToQuest(logIndex)
Nenue@30 362 if distance ~= nil and distance > 0 then
Nenue@30 363 POI.distance = distance
Nenue@30 364 POI.onContinent = onContinent
Nenue@30 365 end
Nenue@30 366 end
Nenue@30 367 q.POI = POI
Nenue@30 368
Nenue@30 369 --- Block Tags
Nenue@30 370 -- completionTag - in progres, complete, failed, autocomplete
Nenue@30 371 -- typeTag - account, faction, pvp, dungeon, group
Nenue@30 372 -- frequencyTag - daily/weekly
Nenue@37 373 local schema = 'default'
Nenue@30 374 local questTagID, tagName = GetQuestTagInfo(questID)
Nenue@30 375 local tagInfo = {}
Nenue@30 376 local tagCoords = {}
Nenue@30 377 local factionGroup = GetQuestFactionGroup(questID);
Nenue@30 378 if( questTagID and questTagID == QUEST_TAG_ACCOUNT ) then
Nenue@30 379 if( factionGroup ) then
Nenue@30 380 tagID = "ALLIANCE"
Nenue@37 381 schema = 'alliance'
Nenue@30 382 if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
Nenue@30 383 tagID = "HORDE"
Nenue@37 384 schema = 'horde'
Nenue@30 385 end
Nenue@30 386 isFaction = true
Nenue@30 387 else
Nenue@30 388 tagID = QUEST_TAG_ACCOUNT
Nenue@30 389 isAccount = true
Nenue@30 390 end
Nenue@30 391 tagInfo['typeTag'] = tagID
Nenue@30 392 tagCoords['typeTag'] = QUEST_TAG_TCOORDS[tagID]
Nenue@30 393 elseif ( factionGroup) then
Nenue@30 394 tagID = "ALLIANCE"
Nenue@30 395 if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
Nenue@30 396 tagID = "HORDE"
Nenue@30 397 end
Nenue@30 398 isFaction = true
Nenue@30 399 tagInfo['typeTag'] = tagID
Nenue@30 400 tagCoords['typeTag'] = QUEST_TAG_TCOORDS[tagID]
Nenue@30 401 end
Nenue@30 402
Nenue@30 403 if( frequency == LE_QUEST_FREQUENCY_DAILY and (not isComplete or isComplete == 0) ) then
Nenue@30 404 tagID = 'DAILY'
Nenue@30 405 tagInfo['frequencyTag'] = tagID
Nenue@30 406 tagCoords['frequencyTag'] = QUEST_TAG_TCOORDS[tagID]
Nenue@30 407 isDaily = true
Nenue@37 408 schema = 'daily'
Nenue@30 409 elseif( frequency == LE_QUEST_FREQUENCY_WEEKLY and (not isComplete or isComplete == 0) )then
Nenue@30 410 tagID = 'WEEKLY'
Nenue@30 411 tagInfo['frequencyTag'] = tagID
Nenue@30 412 tagCoords['frequencyTag'] = QUEST_TAG_TCOORDS[tagID]
Nenue@30 413 isWeekly = true
Nenue@37 414 schema = 'weekly'
Nenue@30 415 elseif( questTagID ) then
Nenue@30 416 tagID = questTagID
Nenue@30 417 end
Nenue@30 418
Nenue@30 419 if( isComplete ) then
Nenue@30 420 tagInfo['completionTag'] = 'COMPLETED'
Nenue@30 421 elseif ( questFailed ) then
Nenue@30 422 tagInfo['completionTag'] = 'FAILED'
Nenue@30 423 end
Nenue@30 424 tagCoords['completionTag'] = QUEST_TAG_TCOORDS[tagInfo['completionTag']]
Nenue@30 425
Nenue@30 426 q.tagInfo = tagInfo
Nenue@30 427 q.tagCoords = tagCoords
Nenue@30 428 -- establishes the primary block tag for view compacting
Nenue@30 429 q.tagID = tagID
Nenue@30 430 q.tagName = tagName
Nenue@30 431
Nenue@30 432 -- action button information
Nenue@37 433 local link, icon, charges = GetQuestLogSpecialItemInfo(logIndex)
Nenue@37 434 local start, duration, enable = GetQuestLogSpecialItemCooldown(logIndex)
Nenue@30 435 if link or icon or charges then
Nenue@30 436 q.specialItem = {
Nenue@30 437 questID = questID,
Nenue@37 438 logIndex = questLogIndex,
Nenue@30 439 link = link,
Nenue@30 440 charges = charges,
Nenue@30 441 icon = icon,
Nenue@30 442 start = start,
Nenue@30 443 duration = duration,
Nenue@30 444 enable = enable,
Nenue@30 445 }
Nenue@30 446 end
Nenue@30 447
Nenue@32 448 if moneyInfo or timerInfo then
Nenue@32 449 numObjectives = #objectives
Nenue@32 450 end
Nenue@30 451
Nenue@30 452 -- raw data
Nenue@28 453 q.isComplete = isComplete
Nenue@28 454 q.startEvent = startEvent
Nenue@28 455 q.isAutoComplete = isAutoComplete
Nenue@28 456 q.questType = questType
Nenue@28 457 q.isTask = isTask
Nenue@28 458 q.isStory = isStory
Nenue@28 459 q.isOnMap = isOnMap
Nenue@28 460 q.hasLocalPOI = hasLocalPOI
Nenue@28 461 q.frequency = frequency
Nenue@28 462 q.isComplete = isComplete
Nenue@28 463 q.isStory = isStory
Nenue@28 464 q.isTask = isTask
Nenue@31 465 q.statusKey = temp_status
Nenue@32 466 q.selected = (questID == superTrackQuestID)
Nenue@28 467
Nenue@32 468 T.SetRewards(q, questID)
Nenue@32 469
Nenue@34 470 q.questID = questID
Nenue@37 471 q.logIndex = logIndex
Nenue@34 472 q.watchIndex = watchIndex
Nenue@34 473 q.id = questID
Nenue@37 474 q.schema = schema
Nenue@28 475
Nenue@30 476 if Devian and Devian.InWorkspace() then
Nenue@37 477 print('|cFF00DDFFstatus:|r', temp_status, '|cFF00FF00questLogIndex|r:', logIndex, title)
Nenue@30 478 local temp ={}
Nenue@30 479 local data_txt = '|cFFFF4400values:|r'
Nenue@30 480 for k,v in pairs(q) do
Nenue@30 481 if type(v) =='number' then
Nenue@30 482 data_txt = data_txt .. ' |cFFFFFF00'..k..'|r: ' .. tostring(v)
Nenue@30 483 elseif type(v) == 'table' then
Nenue@30 484 tinsert(temp, k)
Nenue@28 485 end
Nenue@28 486 end
Nenue@30 487 print(data_txt)
Nenue@30 488 sort(temp, function(a,b) return a < b end)
Nenue@30 489 for i, k in ipairs(temp) do
Nenue@30 490 print('|cFF00FF00'..k..'|r')
Nenue@30 491 for kk,v in pairs(q[k]) do
Nenue@30 492 print(' ', kk, '=', v)
Nenue@30 493 end
Nenue@28 494 end
Nenue@28 495 end
Nenue@28 496
Nenue@30 497 return q
Nenue@30 498 end
Nenue@28 499
Nenue@37 500 Quest.GetObjectives = function(logIndex, numObjectives, isComplete, isSequenced, isStory)
Nenue@30 501 local objectives = {}
Nenue@30 502 for i = 1, numObjectives do
Nenue@37 503 local text, type, finished = GetQuestLogLeaderBoard(i, logIndex)
Nenue@34 504 print(format(' |cFFFF4400GetObjectives:|r #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished)))
Nenue@30 505 objectives[i] = {
Nenue@28 506 index = i,
Nenue@28 507 type = type,
Nenue@28 508 text = text,
Nenue@28 509 finished = finished
Nenue@28 510 }
Nenue@28 511 end
Nenue@30 512 return objectives
Nenue@28 513 end
Nenue@28 514
Nenue@30 515 local huge, sqrt = math.huge, math.sqrt
Nenue@28 516 Quest.GetClosest = function()
Nenue@28 517 local minID, minTitle
Nenue@30 518 local minDist = huge
Nenue@28 519 local numQuests = GetNumQuestLogEntries()
Nenue@28 520 for questIndex = 1, numQuests do
Nenue@28 521 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@28 522 local title, level, _, _, _, _, _, _, questID = GetQuestLogTitle(questIndex)
Nenue@28 523 if onContinent and distance < minDist then
Nenue@28 524 minDist = distance
Nenue@28 525 minTitle = title
Nenue@28 526 minID = questID
Nenue@28 527 end
Nenue@28 528 end
Nenue@28 529
Nenue@30 530 print('nearest quest is', minTitle, 'by', sqrt(minDist))
Nenue@28 531 return minID, minTitle, minDist
Nenue@28 532 end
Nenue@28 533
Nenue@28 534 Quest.OnTurnIn = function(self, questID, xp, money)
Nenue@28 535 end
Nenue@28 536
Nenue@29 537 Quest.Select = function (handler, block)
Nenue@29 538 if block.info.isAutoComplete and block.info.isComplete then
Nenue@34 539 ShowQuestComplete(block.info.logIndex)
Nenue@28 540 else
Nenue@29 541 SetSuperTrackedQuestID(block.info.questID)
Nenue@28 542 end
Nenue@28 543 end
Nenue@28 544
Nenue@29 545 Quest.Link = function(handler, block)
Nenue@34 546 local questLink = GetQuestLink(block.info.logIndex);
Nenue@28 547 if ( questLink ) then
Nenue@28 548 ChatEdit_InsertLink(questLink);
Nenue@28 549 end
Nenue@28 550 end
Nenue@28 551
Nenue@29 552 Quest.Open = function(handler, block)
Nenue@29 553 QuestMapFrame_OpenToQuestDetails(block.info.questID)
Nenue@28 554 end
Nenue@28 555
Nenue@29 556 Quest.Remove = function(handler, block)
Nenue@34 557 print('removing', block.info.logIndex, 'from watcher')
Nenue@34 558 RemoveQuestWatch(block.info.logIndex)
Nenue@29 559 end