annotate ObjectiveTracker/QuestData.lua @ 47:1a322b92dbfa

file cleanup
author Nenue
date Thu, 28 Apr 2016 05:54:21 -0400
parents aa693607b813
children f253baf6022d
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@40 16 local fprint = B.print('Frame')
Nenue@38 17
Nenue@38 18
Nenue@30 19 local superTrackQuestID, playerMoney, inScenario, showPOIs
Nenue@28 20 Quest.Update = function(self, reason, ...)
Nenue@38 21 local print = self.print
Nenue@28 22 print('QuestTracker:Update() received')
Nenue@28 23 T.UpdateActionButtons()
Nenue@28 24 Default.Update(self, reason, ...)
Nenue@28 25 end
Nenue@28 26
Nenue@28 27 T.Quest.numButtons = 0
Nenue@28 28 local usedButtons = T.Quest.itemButtons
Nenue@28 29 local freeButtons = T.Quest.freeButtons
Nenue@28 30
Nenue@38 31 Quest.UpdateObjectives = function(self, block)
Nenue@28 32 local print = lprint
Nenue@38 33 print('|cFF'..self.internalColor..'UpdateObjectives()')
Nenue@28 34 local info = block.info
Nenue@28 35
Nenue@28 36 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 37
Nenue@38 38 local displayObjectives = true
Nenue@34 39 local block_schema = 'default'
Nenue@28 40 if info.isAccount then
Nenue@28 41 if info.isFaction then
Nenue@28 42 print(' faction', info.tagID)
Nenue@34 43 block_schema = 'faction_'..info.tagID
Nenue@28 44 else
Nenue@28 45 print(' account', info.isAccount, info.isFaction)
Nenue@34 46 block_schema = 'account'
Nenue@28 47 end
Nenue@28 48 elseif info.isDaily then
Nenue@28 49 print(' daily', info.frequency)
Nenue@34 50 block_schema = 'daily'
Nenue@28 51 elseif info.isWeekly then
Nenue@28 52 print(' weekly', info.frequency)
Nenue@34 53 block_schema = 'weekly'
Nenue@28 54 end
Nenue@28 55 local completionText
Nenue@45 56
Nenue@45 57 if info.isAutoComplete and info.isComplete then
Nenue@45 58 displayObjectives = false
Nenue@45 59 info.numObjectives = 1
Nenue@45 60 self:AddLine(block, info.completionText, nil, 'complete')
Nenue@45 61 elseif info.isComplete then
Nenue@44 62 if T.Conf.ShowCompletionText then
Nenue@44 63 self:AddLine(block, info.completionText, nil, 'complete')
Nenue@45 64 displayObjectives = false
Nenue@28 65 end
Nenue@44 66 if not T.Conf.ShowObjectivesWhenComplete then
Nenue@44 67 displayObjectives = false
Nenue@44 68 end
Nenue@38 69 print('|cFF'..self.internalColor..' :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"')
Nenue@44 70 block_schema = 'complete'
Nenue@28 71 end
Nenue@28 72
Nenue@45 73
Nenue@38 74 Default.UpdateObjectives(self, block, block_schema, displayObjectives)
Nenue@40 75 return 0, block_schema
Nenue@28 76 end
Nenue@28 77
Nenue@38 78 Quest.UpdateLine = function(handler, block, data)
Nenue@28 79 local objectiveType = data.type
Nenue@31 80 return data.text, nil, objectiveType
Nenue@28 81 end
Nenue@28 82
Nenue@28 83 -----------------------------
Nenue@28 84 --- QUEST
Nenue@37 85 local tremove, tinsert = tremove, tinsert
Nenue@37 86 local GetQuestLogIndexByID, IsQuestWatched = GetQuestLogIndexByID, IsQuestWatched
Nenue@28 87 Quest.QuestBlock = {}
Nenue@28 88 Quest.LogBlock = {}
Nenue@28 89 Quest.LogInfo = {}
Nenue@37 90
Nenue@39 91 Quest.OnRemoved = function(block)
Nenue@37 92
Nenue@37 93 end
Nenue@39 94
Nenue@39 95 Quest.GetBlock = function(self, index)
Nenue@39 96 local block = Default.GetBlock(self, index)
Nenue@39 97 block:SetScript('OnEvent', Quest.OnRemoved)
Nenue@39 98 block:RegisterEvent('QUEST_REMOVED')
Nenue@39 99 return block
Nenue@39 100 end
Nenue@39 101
Nenue@37 102 local GetQuestWatchIndex = GetQuestWatchIndex
Nenue@43 103 local numAnimating = 0
Nenue@43 104 local blocksChecked = {}
Nenue@43 105
Nenue@37 106 --- Get a total of things to show, and straighten out the index while we're at it
Nenue@37 107 --- Return the number shown, total in log, and the info table to parse
Nenue@37 108 Quest.GetNumWatched = function (self, id, added)
Nenue@38 109 local print = self.print
Nenue@40 110 B.print('Block')('########')
Nenue@40 111 B.print('Block')('########')
Nenue@30 112 superTrackQuestID = GetSuperTrackedQuestID()
Nenue@30 113 playerMoney = GetMoney();
Nenue@30 114 inScenario = C_Scenario.IsInScenario();
Nenue@30 115 showPOIs = GetCVarBool("questPOI");
Nenue@37 116 local numAll = GetNumQuestLogEntries()
Nenue@37 117 local numWatched = GetNumQuestWatches()
Nenue@37 118 local bottomIndex = 1
Nenue@37 119 local start, limit = 1, numAll
Nenue@37 120
Nenue@37 121 if id and not added then
Nenue@40 122 -- if a particular id is supplied, add to checklist
Nenue@37 123 if self.InfoBlock[id] then
Nenue@40 124 blocksChecked[self.InfoBlock[id]] = self.InfoBlock[id]
Nenue@37 125 end
Nenue@37 126 end
Nenue@37 127
Nenue@43 128 numAnimating = 0
Nenue@44 129 local numEntries = 0
Nenue@37 130 for logIndex = start, limit do
Nenue@37 131 local reason1, reason2 = '', ''
Nenue@37 132 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex)
Nenue@37 133 local watchIndex = GetQuestWatchIndex(logIndex)
Nenue@37 134
Nenue@43 135 --- Start of crazy audit flagging
Nenue@37 136 if watchIndex and watchIndex >= bottomIndex then
Nenue@43 137 -- do watch data pointers match?
Nenue@37 138 local watchInfo = self.WatchInfo[watchIndex]
Nenue@37 139 local watchBlock = self.WatchBlock[watchIndex]
Nenue@37 140 if watchInfo and watchInfo.questID ~= questID then
Nenue@38 141 print('GetNumWatched', 'trimming WatchInfo ['..watchIndex..'] =/=', questID)
Nenue@37 142 self.WatchInfo[watchIndex] = nil
Nenue@37 143 end
Nenue@37 144 if watchBlock and watchBlock.info.questID ~= questID then
Nenue@38 145 print('GetNumWatched', 'trimming WatchBlock ['..watchIndex..'] =/=', watchBlock:GetName())
Nenue@37 146 self.WatchBlock[watchIndex] = nil
Nenue@40 147 blocksChecked[watchBlock] = watchBlock
Nenue@37 148 end
Nenue@37 149 end
Nenue@37 150
Nenue@43 151 -- check log-block pointer
Nenue@37 152 local logBlock = self.LogBlock[logIndex]
Nenue@43 153 if logBlock then
Nenue@43 154 -- check later that the block isn't for a dropped quest
Nenue@43 155 if logBlock.info.questID ~= questID then
Nenue@43 156 print('GetQuests', 'replace info', logBlock.info.questID, '->', questID)
Nenue@43 157 self.LogBlock[logIndex] = nil
Nenue@43 158 blocksChecked[logBlock] = logBlock
Nenue@43 159 end
Nenue@37 160 end
Nenue@43 161 --- end of crazy audit flagging
Nenue@37 162
Nenue@40 163 -- add to watch index if: the questID is non-zero
Nenue@37 164 if questID ~= 0 then
Nenue@44 165 self:GetInfo(logIndex, watchIndex)
Nenue@44 166 print('GetQuests', format('request info |cFF00FF00%2d|r |cFFFFFF00%6d|r |cFFFF4400%3s|r |cFF00FFFF%3s|r', logIndex, questID, tostring(watchIndex or ''), numEntries))
Nenue@37 167 end
Nenue@37 168 end
Nenue@37 169
Nenue@44 170
Nenue@44 171
Nenue@40 172 --- After GetInfo pass, look for any non-conformant blocks and deal with them
Nenue@44 173 for index, block in ipairs(self.usedBlocks) do
Nenue@44 174
Nenue@40 175 local logIndex = GetQuestLogIndexByID(block.info.questID, 'player')
Nenue@43 176 -- animating blocks have been evaluated
Nenue@46 177 if not block.blockFadeOut:IsPlaying() then
Nenue@43 178 if not logIndex then
Nenue@43 179 self:ClearBlock(block)
Nenue@45 180 print('GetNumWatched', '|cFF44FF00'.. index, (block and block:GetName() or '|cFFFF0000-|r'), '(trim not active)')
Nenue@43 181 elseif not IsQuestWatched(block.info.logIndex) then
Nenue@43 182 self:ClearBlock(block)
Nenue@45 183 print('GetNumWatched', '|cFFFF4400'.. index, (block and block:GetName() or '|cFFFF0000-|r'), '(trim non-watched)')
Nenue@45 184 else
Nenue@45 185 print('GetNumWatched', '|cFF0088FF'.. index, (block and block:GetName() or '|cFFFF0000-|r'), logIndex or '|cFF444444-|r')
Nenue@43 186 end
Nenue@45 187 else
Nenue@45 188
Nenue@45 189 print('GetNumWatched', '|cFF00FFFF'.. index, (block and block:GetName() or '|cFFFF0000-|r'), ' (animating)')
Nenue@37 190 end
Nenue@37 191 end
Nenue@37 192
Nenue@37 193 self.numWatched = numWatched
Nenue@37 194 self.numAll = numAll
Nenue@37 195
Nenue@44 196 print('GetNumWatched', 'RESULT', numWatched, 'of', numAll)
Nenue@37 197 return numWatched, numAll, self.WatchList
Nenue@28 198 end
Nenue@30 199
Nenue@37 200
Nenue@30 201 --- Returns an iterable table from which tracker blocks can be filled out. Data includes:
Nenue@30 202 -- All entry-layer GetXInfo return values
Nenue@30 203 -- Manifest of line data to be displayed in relation to the tracked object
Nenue@37 204 Quest.GetInfo = function (self, logIndex, watchIndex)
Nenue@28 205 local print = iprint
Nenue@44 206 print('')
Nenue@37 207 local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex)
Nenue@30 208 if ( not questID ) then
Nenue@38 209 tprint('GetNumWatched', logIndex, watchIndex, '|cFFFF2299no data|r')
Nenue@44 210 return 0
Nenue@28 211 end
Nenue@28 212
Nenue@37 213 Quest.Info[questID] = Quest.Info[questID] or {}
Nenue@44 214 local numEntries = 0
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@44 224 self.print('WatchIndex', watchIndex)
Nenue@37 225 local _
Nenue@44 226 _, _, _, numObjectives, requiredMoney, _, _, isAutoComplete,
Nenue@37 227 failureTime, timeElapsed, questType = GetQuestWatchInfo(watchIndex)
Nenue@44 228 self.WatchList[watchIndex] = q
Nenue@37 229 --tprint(' |cFF88FF00GetInfo:|r set watch entry', watchIndex)
Nenue@44 230 self.print('WatchIndex', logIndex, watchIndex + numAnimating, '|cFFFF2299'..title..'|r')
Nenue@37 231 end
Nenue@37 232 self.LogInfo[logIndex] = q
Nenue@28 233
Nenue@37 234 q.numObjectives = numObjectives
Nenue@37 235 q.requiredMoney = requiredMoney
Nenue@37 236 q.failureTime = failureTime
Nenue@37 237 q.timeElapsed = timeElapsed
Nenue@30 238
Nenue@37 239
Nenue@37 240
Nenue@32 241 q.type = 'Quest'
Nenue@32 242 q.title = title
Nenue@32 243 q.level = level
Nenue@32 244 q.displayQuestID = displayQuestID
Nenue@32 245 q.suggestedGroup = suggestedGroup
Nenue@32 246
Nenue@30 247 -- re-use Blizzard logic for consistency
Nenue@32 248 local showQuest = true
Nenue@32 249 if isTask then showQuest = false end
Nenue@30 250 local watchMoney = false;
Nenue@30 251 local tagID, typeTag, frequencyTag, completionTag, completionText
Nenue@30 252 local isAccount, isFaction, isWeekly, isDaily = false, false, false, false
Nenue@30 253 local isBreadcrumb = false
Nenue@30 254 local questFailed = false
Nenue@30 255 local watchMoney = false
Nenue@30 256 local timerInfo, moneyInfo = false, false
Nenue@30 257 local objectives = q.objectives or {}
Nenue@30 258
Nenue@30 259
Nenue@30 260 -- Case 1: completed quest or "go to thing" breadcrumb
Nenue@30 261 -- * 1 line containing the completion text
Nenue@30 262 if ( isComplete and isComplete < 0 ) then
Nenue@30 263 isComplete = false
Nenue@30 264 questFailed = true
Nenue@30 265 elseif ( numObjectives == 0 and playerMoney >= requiredMoney and not startEvent ) then
Nenue@30 266 isComplete = true;
Nenue@30 267 questFailed = false
Nenue@30 268 if ( requiredMoney == 0 ) then
Nenue@30 269 isBreadcrumb = true;
Nenue@30 270 end
Nenue@30 271 end
Nenue@44 272 print('QuestFlags', (isComplete and 'isComplete' or ''), (questFailed and 'questFailed' or ''), (isBreadcrumb and 'isBreadcrumb' or ''), numObjectives)
Nenue@30 273
Nenue@30 274 -- completion message?
Nenue@30 275 local isSequenced = IsQuestSequenced(questID)
Nenue@30 276 local temp_status = ''
Nenue@30 277 if ( isComplete ) then
Nenue@30 278 temp_status = 'COMPLETED_OBJECTIVES'
Nenue@44 279 --objectives = Quest.GetObjectives(logIndex, numObjectives, true, isSequenced, isStory)
Nenue@30 280 if ( isAutoComplete ) then
Nenue@30 281 temp_status = 'AUTOCOMPLETE_OBJECTIVES'
Nenue@30 282 completionText = _G.QUEST_WATCH_CLICK_TO_COMPLETE
Nenue@30 283 else
Nenue@30 284 if ( isBreadcrumb ) then
Nenue@30 285 temp_status = 'COMPLETE_BREADCRUMB'
Nenue@44 286 completionText = GetQuestLogCompletionText(logIndex)
Nenue@30 287 else
Nenue@30 288 temp_status = 'COMPLETE_READY_FOR_TURN_IN'
Nenue@30 289 completionText = _G.QUEST_WATCH_QUEST_READY
Nenue@30 290 end
Nenue@30 291 end
Nenue@45 292 if not T.Conf.ShowObjectivesWhenComplete then
Nenue@45 293 q.objectives = {}
Nenue@45 294 end
Nenue@30 295 elseif ( questFailed ) then
Nenue@30 296 temp_status = 'FAILED'
Nenue@30 297 -- Case 2: failed quest
Nenue@30 298 -- * 1 status line; hide other info
Nenue@30 299 completionText = _G.FAILED
Nenue@30 300 else
Nenue@30 301
Nenue@30 302 temp_status = 'PROGRESS_OBJECTIVES'
Nenue@30 303 -- Case 3: quest in progress
Nenue@30 304 -- * Multiple objective lines
Nenue@30 305 -- * Possible extra lines for money and timer data respectively
Nenue@39 306 self.print(' QuestInfo', title, questType, isAutoComplete)
Nenue@37 307 objectives = Quest.GetObjectives(logIndex, numObjectives, false, isSequenced, isStory)
Nenue@30 308 q.objectives = objectives
Nenue@30 309
Nenue@30 310 --- anything past here gets appended to existing objectives
Nenue@30 311
Nenue@30 312 -- money
Nenue@30 313 if ( requiredMoney > playerMoney ) then
Nenue@30 314
Nenue@30 315 temp_status = temp_status .. '_MONEY'
Nenue@30 316 local text = GetMoneyString(playerMoney).." / "..GetMoneyString(requiredMoney);
Nenue@30 317 moneyInfo = {
Nenue@30 318 type = 'money',
Nenue@30 319 text = text,
Nenue@30 320 finished = false,
Nenue@30 321 requiredMoney = requiredMoney,
Nenue@30 322 playerMoney = playerMoney,
Nenue@30 323 }
Nenue@31 324 tinsert(objectives, moneyInfo)
Nenue@30 325 end
Nenue@30 326
Nenue@30 327 -- time limit
Nenue@30 328 if ( failureTime ) then
Nenue@30 329 temp_status = temp_status .. '_TIMED'
Nenue@30 330 if ( timeElapsed and timeElapsed <= failureTime ) then
Nenue@30 331 timerInfo = {
Nenue@30 332 type = 'timer',
Nenue@30 333 finished = false,
Nenue@30 334 timeElapsed = timeElapsed,
Nenue@30 335 failureTime = failureTime,
Nenue@30 336 }
Nenue@31 337 tinsert(objectives, timerInfo)
Nenue@30 338 end
Nenue@30 339 end
Nenue@30 340 end
Nenue@30 341 q.moneyInfo = moneyInfo
Nenue@30 342 q.timerInfo = timerInfo
Nenue@30 343 q.completionText = completionText
Nenue@30 344
Nenue@30 345 -- POI data
Nenue@30 346 local POI = false
Nenue@30 347 if ( showPOIs ) then
Nenue@30 348 POI = {
Nenue@30 349 questID = questID,
Nenue@37 350 logIndex = logIndex,
Nenue@37 351 watchIndex = watchIndex
Nenue@30 352 }
Nenue@30 353 local poiButton;
Nenue@30 354 if ( hasLocalPOI ) then
Nenue@30 355
Nenue@30 356 if ( isComplete ) then
Nenue@30 357 POI.type = 'normal'
Nenue@30 358 else
Nenue@30 359 POI.type = 'numeric'
Nenue@30 360 end
Nenue@30 361 elseif ( isComplete ) then
Nenue@30 362 POI.type = 'remote'
Nenue@30 363 end
Nenue@30 364
Nenue@37 365 local distance, onContinent = GetDistanceSqToQuest(logIndex)
Nenue@30 366 if distance ~= nil and distance > 0 then
Nenue@30 367 POI.distance = distance
Nenue@30 368 POI.onContinent = onContinent
Nenue@30 369 end
Nenue@30 370 end
Nenue@30 371 q.POI = POI
Nenue@30 372
Nenue@30 373 --- Block Tags
Nenue@30 374 -- completionTag - in progres, complete, failed, autocomplete
Nenue@30 375 -- typeTag - account, faction, pvp, dungeon, group
Nenue@30 376 -- frequencyTag - daily/weekly
Nenue@37 377 local schema = 'default'
Nenue@30 378 local questTagID, tagName = GetQuestTagInfo(questID)
Nenue@30 379 local tagInfo = {}
Nenue@30 380 local tagCoords = {}
Nenue@30 381 local factionGroup = GetQuestFactionGroup(questID);
Nenue@30 382 if( questTagID and questTagID == QUEST_TAG_ACCOUNT ) then
Nenue@30 383 if( factionGroup ) then
Nenue@30 384 tagID = "ALLIANCE"
Nenue@37 385 schema = 'alliance'
Nenue@30 386 if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
Nenue@30 387 tagID = "HORDE"
Nenue@37 388 schema = 'horde'
Nenue@30 389 end
Nenue@30 390 isFaction = true
Nenue@30 391 else
Nenue@30 392 tagID = QUEST_TAG_ACCOUNT
Nenue@30 393 isAccount = true
Nenue@30 394 end
Nenue@44 395 tagInfo['type'] = QUEST_TAG_TCOORDS[tagID]
Nenue@30 396 elseif ( factionGroup) then
Nenue@30 397 tagID = "ALLIANCE"
Nenue@30 398 if ( factionGroup == LE_QUEST_FACTION_HORDE ) then
Nenue@30 399 tagID = "HORDE"
Nenue@30 400 end
Nenue@30 401 isFaction = true
Nenue@44 402 tagInfo['type'] = QUEST_TAG_TCOORDS[tagID]
Nenue@30 403 end
Nenue@30 404
Nenue@30 405 if( frequency == LE_QUEST_FREQUENCY_DAILY and (not isComplete or isComplete == 0) ) then
Nenue@30 406 tagID = 'DAILY'
Nenue@44 407 tagInfo['frequency'] = QUEST_TAG_TCOORDS[tagID]
Nenue@30 408 isDaily = true
Nenue@37 409 schema = 'daily'
Nenue@30 410 elseif( frequency == LE_QUEST_FREQUENCY_WEEKLY and (not isComplete or isComplete == 0) )then
Nenue@30 411 tagID = 'WEEKLY'
Nenue@44 412 tagInfo['frequency'] = 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@44 420 tagInfo['completion'] = QUEST_TAG_TCOORDS['COMPLETED']
Nenue@30 421 elseif ( questFailed ) then
Nenue@44 422 tagInfo['completion'] = QUEST_TAG_TCOORDS['FAILED']
Nenue@30 423 end
Nenue@30 424
Nenue@30 425 q.tagInfo = tagInfo
Nenue@44 426 q.tagID = tagID -- defining primary tags for compact view
Nenue@30 427 q.tagName = tagName
Nenue@30 428
Nenue@30 429 -- action button information
Nenue@37 430 local link, icon, charges = GetQuestLogSpecialItemInfo(logIndex)
Nenue@37 431 local start, duration, enable = GetQuestLogSpecialItemCooldown(logIndex)
Nenue@30 432 if link or icon or charges then
Nenue@30 433 q.specialItem = {
Nenue@30 434 questID = questID,
Nenue@37 435 logIndex = questLogIndex,
Nenue@30 436 link = link,
Nenue@30 437 charges = charges,
Nenue@30 438 icon = icon,
Nenue@30 439 start = start,
Nenue@30 440 duration = duration,
Nenue@30 441 enable = enable,
Nenue@30 442 }
Nenue@30 443 end
Nenue@30 444
Nenue@32 445 if moneyInfo or timerInfo then
Nenue@32 446 numObjectives = #objectives
Nenue@32 447 end
Nenue@30 448
Nenue@30 449 -- raw data
Nenue@28 450 q.isComplete = isComplete
Nenue@28 451 q.startEvent = startEvent
Nenue@28 452 q.isAutoComplete = isAutoComplete
Nenue@28 453 q.questType = questType
Nenue@28 454 q.isTask = isTask
Nenue@28 455 q.isStory = isStory
Nenue@28 456 q.isOnMap = isOnMap
Nenue@28 457 q.hasLocalPOI = hasLocalPOI
Nenue@28 458 q.frequency = frequency
Nenue@28 459 q.isComplete = isComplete
Nenue@28 460 q.isStory = isStory
Nenue@28 461 q.isTask = isTask
Nenue@31 462 q.statusKey = temp_status
Nenue@32 463 q.selected = (questID == superTrackQuestID)
Nenue@28 464
Nenue@32 465 T.SetRewards(q, questID)
Nenue@32 466
Nenue@34 467 q.questID = questID
Nenue@37 468 q.logIndex = logIndex
Nenue@34 469 q.watchIndex = watchIndex
Nenue@34 470 q.id = questID
Nenue@37 471 q.schema = schema
Nenue@28 472
Nenue@30 473 if Devian and Devian.InWorkspace() then
Nenue@38 474 print('QuestStatus', temp_status, '|cFF00FF00questLogIndex|r:', logIndex, title)
Nenue@30 475 local temp ={}
Nenue@38 476 local data_txt = '|cFF'..self.internalColor..'values:|r'
Nenue@30 477 for k,v in pairs(q) do
Nenue@30 478 if type(v) =='number' then
Nenue@30 479 data_txt = data_txt .. ' |cFFFFFF00'..k..'|r: ' .. tostring(v)
Nenue@30 480 elseif type(v) == 'table' then
Nenue@30 481 tinsert(temp, k)
Nenue@28 482 end
Nenue@28 483 end
Nenue@38 484 print('DataStatus',data_txt)
Nenue@30 485 sort(temp, function(a,b) return a < b end)
Nenue@30 486 for i, k in ipairs(temp) do
Nenue@38 487 iprint('GetInfo', questID, ''..k..'|r')
Nenue@30 488 for kk,v in pairs(q[k]) do
Nenue@38 489 iprint('GetInfo', questID, kk, '=', v)
Nenue@30 490 end
Nenue@28 491 end
Nenue@28 492 end
Nenue@28 493
Nenue@44 494 return numEntries
Nenue@30 495 end
Nenue@28 496
Nenue@37 497 Quest.GetObjectives = function(logIndex, numObjectives, isComplete, isSequenced, isStory)
Nenue@38 498 local print = Quest.print
Nenue@30 499 local objectives = {}
Nenue@39 500 if not logIndex then
Nenue@39 501 return
Nenue@39 502 end
Nenue@39 503
Nenue@30 504 for i = 1, numObjectives do
Nenue@37 505 local text, type, finished = GetQuestLogLeaderBoard(i, logIndex)
Nenue@39 506
Nenue@39 507 local progress = 0
Nenue@39 508 if finished then
Nenue@39 509 progress = 1
Nenue@39 510 elseif text then
Nenue@39 511 local quantity, maxQuantity = text:match('^(%d+)/(%d+)')
Nenue@39 512 if quantity and maxQuantity then
Nenue@39 513 progress = quantity / maxQuantity
Nenue@39 514 --print('GetObjectives', 'calculated objective progress:', quantity, '/', maxQuantity, '=', progress)
Nenue@39 515 end
Nenue@39 516 end
Nenue@39 517
Nenue@39 518 print('GetObjectives', format('|cFF88FF88#%d %s %s %s', i, tostring(type), tostring(text), tostring(finished)), '('.. tostring(progress)..')')
Nenue@39 519
Nenue@39 520
Nenue@30 521 objectives[i] = {
Nenue@28 522 index = i,
Nenue@28 523 type = type,
Nenue@28 524 text = text,
Nenue@39 525 finished = finished,
Nenue@39 526 progress = progress
Nenue@28 527 }
Nenue@28 528 end
Nenue@30 529 return objectives
Nenue@28 530 end
Nenue@28 531
Nenue@30 532 local huge, sqrt = math.huge, math.sqrt
Nenue@28 533 Quest.GetClosest = function()
Nenue@28 534 local minID, minTitle
Nenue@30 535 local minDist = huge
Nenue@28 536 local numQuests = GetNumQuestLogEntries()
Nenue@28 537 for questIndex = 1, numQuests do
Nenue@28 538 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@28 539 local title, level, _, _, _, _, _, _, questID = GetQuestLogTitle(questIndex)
Nenue@28 540 if onContinent and distance < minDist then
Nenue@28 541 minDist = distance
Nenue@28 542 minTitle = title
Nenue@28 543 minID = questID
Nenue@28 544 end
Nenue@28 545 end
Nenue@28 546
Nenue@30 547 print('nearest quest is', minTitle, 'by', sqrt(minDist))
Nenue@28 548 return minID, minTitle, minDist
Nenue@28 549 end
Nenue@28 550
Nenue@28 551 Quest.OnTurnIn = function(self, questID, xp, money)
Nenue@28 552 end
Nenue@28 553
Nenue@29 554 Quest.Select = function (handler, block)
Nenue@29 555 if block.info.isAutoComplete and block.info.isComplete then
Nenue@34 556 ShowQuestComplete(block.info.logIndex)
Nenue@28 557 else
Nenue@29 558 SetSuperTrackedQuestID(block.info.questID)
Nenue@28 559 end
Nenue@28 560 end
Nenue@28 561
Nenue@29 562 Quest.Link = function(handler, block)
Nenue@34 563 local questLink = GetQuestLink(block.info.logIndex);
Nenue@28 564 if ( questLink ) then
Nenue@28 565 ChatEdit_InsertLink(questLink);
Nenue@28 566 end
Nenue@28 567 end
Nenue@28 568
Nenue@29 569 Quest.Open = function(handler, block)
Nenue@29 570 QuestMapFrame_OpenToQuestDetails(block.info.questID)
Nenue@28 571 end
Nenue@28 572
Nenue@29 573 Quest.Remove = function(handler, block)
Nenue@34 574 print('removing', block.info.logIndex, 'from watcher')
Nenue@34 575 RemoveQuestWatch(block.info.logIndex)
Nenue@29 576 end