annotate ObjectiveInfo.lua @ 2:a2396b03ce63

- identify action buttons by the associated QuestID instead of QuestLogIndex - deferred button placement in general to a self-destructing OnUpdate -- and defer self-destruct to a end of combat event if InCombatLockdown - tracker wrapper has an experience/reputation bar; the two elements "feel" related and it's a very simple info display
author Nenue
date Thu, 31 Mar 2016 01:38:47 -0400
parents b0447b382f36
children 3397aae1f44d
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@0 15 Quest.GetNumWatched = function()
Nenue@0 16 return GetNumQuestWatches ()
Nenue@0 17 end
Nenue@0 18 Quest.GetInfo = function (self, watchIndex)
Nenue@0 19 print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)')
Nenue@1 20 local questID, title, questIndex, numObjectives, requiredMoney, isComplete,
Nenue@0 21 startEvent, isAutoComplete, failureTime, timeElapsed, questType, isTask, isStory, isOnMap, hasLocalPOI = GetQuestWatchInfo(watchIndex)
Nenue@0 22 if not questID then
Nenue@0 23 return
Nenue@0 24 end
Nenue@0 25 self.Info[questID] = self.Info[questID] or {}
Nenue@0 26
Nenue@0 27 local q = self.Info[questID]
Nenue@0 28 q.watchIndex = watchIndex
Nenue@0 29 q.type = 'Quest'
Nenue@0 30 q.questID = questID
Nenue@0 31 q.title = title
Nenue@1 32 q.questLogIndex = questIndex
Nenue@0 33 q.numObjectives = numObjectives
Nenue@0 34 q.requiredMoney = requiredMoney
Nenue@0 35 q.isComplete = isComplete
Nenue@0 36 q.startEvent = startEvent
Nenue@0 37 q.isAutoComplete = isAutoComplete
Nenue@0 38 q.failureTime = failureTime
Nenue@0 39 q.timeElapsed = timeElapsed
Nenue@0 40 q.questType = questType
Nenue@0 41 q.isTask = isTask
Nenue@0 42 q.isStory = isStory
Nenue@0 43 q.isOnMap = isOnMap
Nenue@0 44 q.hasLocalPOI = hasLocalPOI
Nenue@0 45
Nenue@0 46 --- Start QuestLogEntry calls
Nenue@0 47 -----------------------------------------
Nenue@1 48 SelectQuestLogEntry(questIndex)
Nenue@0 49 q.greenRange = GetQuestGreenRange()
Nenue@0 50 q.isDaily = QuestIsDaily()
Nenue@0 51 q.isWeekly = QuestIsWeekly()
Nenue@0 52 -----------------------------------------
Nenue@0 53 --- End QuestLogEntry calls
Nenue@0 54
Nenue@0 55 q.isComplete = IsQuestComplete(questID)
Nenue@0 56 q.isBreadCrumb = IsBreadcrumbQuest(questID)
Nenue@0 57 q.isStoryQuest = IsStoryQuest(questID)
Nenue@1 58 q.completionText= GetQuestLogCompletionText(questIndex)
Nenue@0 59 q.trackingID = questID
Nenue@0 60 q.superTracked = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue
Nenue@1 61 q.numObjectives = GetNumQuestLeaderBoards(questIndex)
Nenue@1 62 q.isWatched = IsQuestWatched(questIndex)
Nenue@0 63 q.objectives = {}
Nenue@0 64 for i = 1, q.numObjectives do
Nenue@1 65 local text, type, finished = GetQuestLogLeaderBoard(i, questIndex)
Nenue@0 66 q.objectives[i] = {
Nenue@0 67 type = type,
Nenue@0 68 text = text,
Nenue@0 69 finished = finished
Nenue@0 70 }
Nenue@0 71 if type == 'event' then
Nenue@0 72 elseif type == 'monster' then
Nenue@0 73 elseif type == 'object' then
Nenue@0 74 elseif type == 'reputation' then
Nenue@0 75 elseif type == 'item' then
Nenue@0 76 end
Nenue@0 77 end
Nenue@0 78
Nenue@1 79 local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex)
Nenue@1 80 local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex)
Nenue@0 81 if link or icon or charges then
Nenue@0 82 q.specialItem = {
Nenue@1 83 questID = questID,
Nenue@1 84 questIndex = questIndex,
Nenue@0 85 link = link,
Nenue@0 86 charges = charges,
Nenue@0 87 icon = icon,
Nenue@0 88 start = start,
Nenue@0 89 duration = duration,
Nenue@0 90 enable = enable,
Nenue@0 91 }
Nenue@0 92 end
Nenue@0 93
Nenue@1 94
Nenue@1 95 if QuestHasPOIInfo(questID) then
Nenue@1 96 local distance, onContinent = GetDistanceSqToQuest(questIndex)
Nenue@1 97 if distance ~= nil and distance > 0 then
Nenue@1 98 self.POI[questIndex] = {
Nenue@1 99 questIndex = questIndex,
Nenue@1 100 questID = questID,
Nenue@1 101 distance = distance,
Nenue@1 102 onContinent = onContinent
Nenue@1 103 }
Nenue@1 104 end
Nenue@1 105 end
Nenue@1 106
Nenue@1 107 self.LogInfo[questIndex] = q
Nenue@2 108 print('- logIndex =', questIndex, 'title =', title)
Nenue@0 109 return q
Nenue@0 110 end
Nenue@0 111
Nenue@1 112 Quest.GetClosest = function()
Nenue@1 113 local minID
Nenue@1 114 local minDist = math.huge
Nenue@1 115 for i = 1, Quest.GetNumWatched() do
Nenue@1 116 local info = Quest.GetInfo(i)
Nenue@1 117 if info.hasLocalPOI then
Nenue@1 118 local distance, onContinent = GetDistanceSqToQuest(info.questIndex)
Nenue@1 119 end
Nenue@1 120 end
Nenue@1 121 end
Nenue@1 122
Nenue@0 123 Cheevs.GetNumWatched = function(self)
Nenue@0 124 Cheevs.trackedCheevs = {GetTrackedAchievements()}
Nenue@0 125 return GetNumTrackedAchievements()
Nenue@0 126 end
Nenue@0 127 Cheevs.GetInfo = function(self, index)
Nenue@0 128 local cheevID = Cheevs.trackedCheevs[index]
Nenue@0 129 local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
Nenue@0 130
Nenue@0 131 print('|cFF00FF00', GetAchievementNumCriteria(cheevID))
Nenue@0 132 self.Info[cheevID] = {}
Nenue@0 133 local c = self.Info[cheevID]
Nenue@0 134 c.type = 'Cheevs'
Nenue@0 135 c.watchIndex = index
Nenue@0 136 c.cheevID = cheevID
Nenue@0 137 c.title = name
Nenue@0 138 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 139 points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy
Nenue@0 140 c.numObjectives = GetAchievementNumCriteria(cheevID)
Nenue@0 141 c.objectives = {}
Nenue@0 142 for i = 1, c.numObjectives do
Nenue@0 143 local description, type, completed, quantity, requiredQuantity, characterName, flags, assetID, quantityString, criteriaID = GetAchievementCriteriaInfo(cheevID, i)
Nenue@0 144 c.objectives[i] = {
Nenue@0 145 text = description,
Nenue@0 146 type = type,
Nenue@0 147 finished = completed,
Nenue@0 148 quantity = quantity,
Nenue@0 149 requiredQuantity = requiredQuantity,
Nenue@0 150 characterName = characterName,
Nenue@0 151 flags = flags,
Nenue@0 152 assetID = assetID,
Nenue@0 153 quantityString = quantityString,
Nenue@0 154 criteriaID = criteriaID,
Nenue@0 155 }
Nenue@0 156 end
Nenue@0 157
Nenue@0 158 self.WatchInfo[index] = c
Nenue@0 159 return self.Info[cheevID]
Nenue@0 160 end