annotate ObjectiveTracker/Quests.lua @ 39:92534dc793f2

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