annotate ObjectiveInfo.lua @ 6:589de8ea05b9

- validate tracked objects' existence by use of those handler.Info tables we made - apply collision checking to action buttons when their corresponding entry has scrolled out
author Nenue
date Fri, 01 Apr 2016 01:30:42 -0400
parents e9b61fd5f607
children 7923243ae972
rev   line source
Nenue@0 1 local B = select(2,...).frame
Nenue@0 2 local wipe, pairs, ipairs, min, max, unpack = table.wipe, pairs, ipairs, min, max, unpack
Nenue@0 3 local GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo = GetNumQuestLeaderBoards, GetAchievementNumCriteria, GetQuestLogLeaderBoard, GetAchievementCriteriaInfo
Nenue@0 4 local GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo = GetQuestLogIndexByID, GetSuperTrackedQuestID, SetSuperTrackedQuestID, GetQuestWatchInfo
Nenue@0 5 local mod = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
Nenue@0 6 local print = B.print('Objectives')
Nenue@0 7
Nenue@0 8 local Tracker, AutoQuest, Quest, Cheevs = mod.Tracker, mod.AutoQuest, mod.Quest, mod.Cheevs
Nenue@0 9 --------------------------------------------------------------------
Nenue@0 10 --- Tracker-specific data retrieval functions
Nenue@0 11 --------------------------------------------------------------------
Nenue@1 12 Quest.itemButtons = {}
Nenue@1 13 Quest.freeButtons = {}
Nenue@1 14 Quest.POI = {}
Nenue@5 15 Quest.QuestBlock = {}
Nenue@0 16 Quest.GetNumWatched = function()
Nenue@0 17 return GetNumQuestWatches ()
Nenue@0 18 end
Nenue@0 19 Quest.GetInfo = function (self, watchIndex)
Nenue@0 20 print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)')
Nenue@1 21 local questID, title, questIndex, numObjectives, requiredMoney, isComplete,
Nenue@0 22 startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
Nenue@0 23 if not questID then
Nenue@0 24 return
Nenue@0 25 end
Nenue@0 26 self.Info[questID] = self.Info[questID] or {}
Nenue@0 27
Nenue@0 28 local q = self.Info[questID]
Nenue@0 29 q.watchIndex = watchIndex
Nenue@0 30 q.type = 'Quest'
Nenue@0 31 q.questID = questID
Nenue@0 32 q.title = title
Nenue@1 33 q.questLogIndex = questIndex
Nenue@0 34 q.numObjectives = numObjectives
Nenue@0 35 q.requiredMoney = requiredMoney
Nenue@0 36 q.isComplete = isComplete
Nenue@0 37 q.startEvent = startEvent
Nenue@0 38 q.isAutoComplete = isAutoComplete
Nenue@0 39 q.failureTime = failureTime
Nenue@0 40 q.timeElapsed = timeElapsed
Nenue@0 41 q.questType = questType
Nenue@0 42 q.isTask = isTask
Nenue@0 43 q.isStory = isStory
Nenue@0 44 q.isOnMap = isOnMap
Nenue@0 45 q.hasLocalPOI = hasLocalPOI
Nenue@0 46
Nenue@0 47 --- Start QuestLogEntry calls
Nenue@0 48 -----------------------------------------
Nenue@1 49 SelectQuestLogEntry(questIndex)
Nenue@0 50 q.greenRange = GetQuestGreenRange()
Nenue@0 51 q.isDaily = QuestIsDaily()
Nenue@0 52 q.isWeekly = QuestIsWeekly()
Nenue@0 53 -----------------------------------------
Nenue@0 54 --- End QuestLogEntry calls
Nenue@0 55
Nenue@0 56 q.isComplete = IsQuestComplete(questID)
Nenue@0 57 q.isBreadCrumb = IsBreadcrumbQuest(questID)
Nenue@0 58 q.isStoryQuest = IsStoryQuest(questID)
Nenue@1 59 q.completionText= GetQuestLogCompletionText(questIndex)
Nenue@0 60 q.trackingID = questID
Nenue@0 61 q.superTracked = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue
Nenue@1 62 q.numObjectives = GetNumQuestLeaderBoards(questIndex)
Nenue@1 63 q.isWatched = IsQuestWatched(questIndex)
Nenue@0 64 q.objectives = {}
Nenue@0 65 for i = 1, q.numObjectives do
Nenue@1 66 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex)
Nenue@0 67 q.objectives[i] = {
Nenue@0 68 type = type,
Nenue@0 69 text = text,
Nenue@0 70 finished = finished
Nenue@0 71 }
Nenue@0 72 if type == 'event' then
Nenue@0 73 elseif type == 'monster' then
Nenue@0 74 elseif type == 'object' then
Nenue@0 75 elseif type == 'reputation' then
Nenue@0 76 elseif type == 'item' then
Nenue@0 77 end
Nenue@0 78 end
Nenue@0 79
Nenue@1 80 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex)
Nenue@1 81 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex)
Nenue@0 82 if link or icon or charges then
Nenue@0 83 q.specialItem = {
Nenue@1 84 questID = questID,
Nenue@1 85 questIndex = questIndex,
Nenue@0 86 link = link,
Nenue@0 87 charges = charges,
Nenue@0 88 icon = icon,
Nenue@0 89 start = start,
Nenue@0 90 duration = duration,
Nenue@0 91 enable = enable,
Nenue@0 92 }
Nenue@0 93 end
Nenue@0 94
Nenue@1 95
Nenue@1 96 if QuestHasPOIInfo(questID) then
Nenue@1 97 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@1 98 if distance ~= nil and distance > 0 then
Nenue@1 99 self.POI[questIndex] = {
Nenue@1 100 questIndex = questIndex,
Nenue@1 101 questID = questID,
Nenue@1 102 distance = distance,
Nenue@1 103 onContinent = onContinent
Nenue@1 104 }
Nenue@1 105 end
Nenue@1 106 end
Nenue@1 107
Nenue@1 108 self.LogInfo[questIndex] = q
Nenue@2 109 print('- logIndex =', questIndex, 'title =', title)
Nenue@0 110 return q
Nenue@0 111 end
Nenue@0 112
Nenue@1 113 Quest.GetClosest = function()
Nenue@1 114 local minID
Nenue@1 115 local minDist = math.huge
Nenue@1 116 for i = 1, Quest.GetNumWatched() do
Nenue@1 117 local info = Quest.GetInfo(i)
Nenue@1 118 if info.hasLocalPOI then
Nenue@1 119 local distance, onContinent = GetDistanceSqToQuest(info.questIndex)
Nenue@1 120 end
Nenue@1 121 end
Nenue@1 122 end
Nenue@1 123
Nenue@6 124 AutoQuest.GetInfo = function(watchIndex)
Nenue@6 125 return Quest.GetInfo(watchIndex)
Nenue@6 126 end
Nenue@6 127
Nenue@6 128
Nenue@0 129 Cheevs.GetNumWatched = function(self)
Nenue@0 130 Cheevs.trackedCheevs = {GetTrackedAchievements()}
Nenue@0 131 return GetNumTrackedAchievements()
Nenue@0 132 end
Nenue@0 133 Cheevs.GetInfo = function(self, index)
Nenue@0 134 local cheevID = Cheevs.trackedCheevs[index]
Nenue@0 135 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
Nenue@0 136
Nenue@0 137 self.Info[cheevID] = {}
Nenue@0 138 local c = self.Info[cheevID]
Nenue@0 139 c.type = 'Cheevs'
Nenue@0 140 c.watchIndex = index
Nenue@0 141 c.cheevID = cheevID
Nenue@0 142 c.title = name
Nenue@0 143 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 144 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy
Nenue@0 145 c.numObjectives = GetAchievementNumCriteria(cheevID)
Nenue@0 146 c.objectives = {}
Nenue@0 147 for i = 1, c.numObjectives do
Nenue@0 148 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i)
Nenue@0 149 c.objectives[i] = {
Nenue@0 150 text = description,
Nenue@0 151 type = type,
Nenue@0 152 finished = completed,
Nenue@0 153 quantity = quantity,
Nenue@0 154 requiredQuantity = requiredQuantity,
Nenue@0 155 characterName = characterName,
Nenue@0 156 flags = flags,
Nenue@0 157 assetID = assetID,
Nenue@0 158 quantityString = quantityString,
Nenue@0 159 criteriaID = criteriaID,
Nenue@0 160 }
Nenue@0 161 end
Nenue@3 162 print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description)
Nenue@0 163
Nenue@0 164 self.WatchInfo[index] = c
Nenue@0 165 return self.Info[cheevID]
Nenue@0 166 end