Nenue@28: local B = select(2,...).frame Nenue@28: local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') Nenue@28: local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band Nenue@28: local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText Nenue@28: local Default, Quest = T.DefaultHandler, T.Quest Nenue@28: local format = format Nenue@28: local print = B.print('Tracker') Nenue@28: local lprint = B.print('Line') Nenue@28: local iprint = B.print('Info') Nenue@28: Nenue@28: local colors = T.colors Nenue@28: Nenue@28: local tprint = B.print('Tracker') Nenue@28: Quest.Update = function(self, reason, ...) Nenue@28: local print = tprint Nenue@28: print('QuestTracker:Update() received') Nenue@28: T.UpdateActionButtons() Nenue@28: Default.Update(self, reason, ...) Nenue@28: end Nenue@28: Nenue@28: T.Quest.numButtons = 0 Nenue@28: local usedButtons = T.Quest.itemButtons Nenue@28: local freeButtons = T.Quest.freeButtons Nenue@28: Nenue@28: Quest.UpdateObjectives = function(handler, block) Nenue@28: local print = lprint Nenue@28: print('|cFF00FFFFUpdateObjectives()') Nenue@28: local info = block.info Nenue@28: Nenue@28: local titlebg, textbg = colors.default.titlebg, colors.default.textbg Nenue@28: 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: Nenue@28: if info.isAccount then Nenue@28: if info.isFaction then Nenue@28: print(' faction', info.tagID) Nenue@28: titlebg, textbg = colors['faction_'..info.tagID].titlebg, colors.default.textbg Nenue@28: else Nenue@28: print(' account', info.isAccount, info.isFaction) Nenue@28: titlebg, textbg = colors.account.titlebg, colors.account.textbg Nenue@28: end Nenue@28: elseif info.isDaily then Nenue@28: print(' daily', info.frequency) Nenue@28: titlebg, textbg = colors.daily.titlebg, colors.daily.textbg Nenue@28: elseif info.isWeekly then Nenue@28: print(' weekly', info.frequency) Nenue@28: titlebg, textbg = colors.weekly.titlebg, colors.weekly.textbg Nenue@28: end Nenue@28: Nenue@28: block.titlebg:SetGradientAlpha(unpack(titlebg)) Nenue@28: block.statusbg:SetGradientAlpha(unpack(textbg)) Nenue@28: Nenue@28: local completionText Nenue@28: if info.isComplete then Nenue@28: if info.isAutoComplete then Nenue@28: local questID, popupType = GetAutoQuestPopUp(info.questLogIndex) Nenue@28: if popupType == 'COMPLETE' then Nenue@28: print(' :: auto-complete quest :: set the message') Nenue@28: info.completionText = T.strings.CLICK_TO_COMPLETE Nenue@28: end Nenue@28: else Nenue@28: if not completionText or info.completionText then Nenue@28: info.completionText = GetQuestLogCompletionText(info.questLogIndex) Nenue@28: end Nenue@28: end Nenue@28: print(' :: complete quest :: show instruction: "'.. tostring(info.completionText) .. '"') Nenue@28: end Nenue@28: Nenue@28: Default.UpdateObjectives(handler, block) Nenue@28: end Nenue@28: Nenue@28: Quest.UpdateLine = function(handler, block, line, data) Nenue@28: local print = lprint Nenue@28: local objectiveType = data.type Nenue@28: local r, g, b, a = 0, 1, 1, 1 Nenue@28: Nenue@28: line.progress = 0 Nenue@28: if data.finished then Nenue@28: line.progress = 2 Nenue@28: r, g, b, a = 0, 1, 0, 1 Nenue@28: elseif objectiveType == 'monster' then Nenue@28: r, g, b, a = 1, .55, .2, 1 Nenue@28: elseif objectiveType == 'item' then Nenue@28: r, g, b, a = .8, .8, .8, 1 Nenue@28: elseif objectiveType == 'object' then Nenue@28: r, g, b, a = 1, 1, 1, 1 Nenue@28: elseif objectiveType == 'player' then Nenue@28: r, g, b, a = 0, 0.8, 1, 1 Nenue@28: end Nenue@28: print(format(' |cFF%02X%02X%02X%0.1f, %0.1f, %0.1f|r', (r * 255), g * 255, b * 255, r, g, b)) Nenue@28: Nenue@28: line.displayColor = {r, g, b, a} Nenue@28: line.status:SetTextColor(r, g, b, a) Nenue@28: line.displayText = data.text Nenue@28: Nenue@28: return line Nenue@28: end Nenue@28: Nenue@28: ----------------------------- Nenue@28: --- QUEST Nenue@28: Quest.POI = {} Nenue@28: Quest.QuestBlock = {} Nenue@28: Quest.LogBlock = {} Nenue@28: Quest.LogInfo = {} Nenue@28: Nenue@28: function Quest:GetNumWatched () Nenue@28: print(self.name, self) Nenue@28: self.numAll = GetNumQuestLogEntries() Nenue@28: self.numWatched = GetNumQuestWatches() Nenue@28: return self.numWatched, self.numAll Nenue@28: end Nenue@28: Quest.GetInfo = function (self, watchIndex) Nenue@28: local print = iprint Nenue@28: print('|cFF00DDFFQuest|r.|cFF0088FFGetInfo(|r'.. tostring(watchIndex)..'|r)') Nenue@28: local questID, title, questIndex, numObjectives, requiredMoney, _, Nenue@28: _, isAutoComplete, failureTime, timeElapsed, questType, _, _, _, _ = GetQuestWatchInfo(watchIndex) Nenue@28: Nenue@28: if not questIndex then Nenue@28: return Nenue@28: end Nenue@28: Nenue@28: Nenue@28: local _, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, _, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(questIndex) Nenue@28: Nenue@28: Nenue@28: if not questID then Nenue@28: return Nenue@28: end Nenue@28: Quest.Info[questID] = Quest.Info[questID] or {} Nenue@28: Nenue@28: local q = Quest.Info[questID] Nenue@28: q.watchIndex = watchIndex Nenue@28: q.type = 'Quest' Nenue@28: q.questID = questID Nenue@28: q.title = title Nenue@28: q.level = level Nenue@28: q.displayQuestID = displayQuestID Nenue@28: q.suggestedGroup = suggestedGroup Nenue@28: q.questLogIndex = questIndex Nenue@28: q.numObjectives = numObjectives Nenue@28: q.requiredMoney = requiredMoney Nenue@28: q.isComplete = isComplete Nenue@28: q.startEvent = startEvent Nenue@28: q.isAutoComplete = isAutoComplete Nenue@28: q.failureTime = failureTime Nenue@28: q.timeElapsed = timeElapsed Nenue@28: q.questType = questType Nenue@28: q.isTask = isTask Nenue@28: q.isStory = isStory Nenue@28: q.isOnMap = isOnMap Nenue@28: q.hasLocalPOI = hasLocalPOI Nenue@28: q.frequency = frequency Nenue@28: q.isComplete = isComplete Nenue@28: q.isStory = isStory Nenue@28: q.isTask = isTask Nenue@28: Nenue@28: --- resolve icon type and template Nenue@28: local questTagID, tagName = GetQuestTagInfo(questID) Nenue@28: local tagID Nenue@28: Nenue@28: local factionGroup = GetQuestFactionGroup(questID); Nenue@28: if( questTagID and questTagID == QUEST_TAG_ACCOUNT ) then Nenue@28: if( factionGroup ) then Nenue@28: tagID = "ALLIANCE"; Nenue@28: if ( factionGroup == LE_QUEST_FACTION_HORDE ) then Nenue@28: tagID = "HORDE"; Nenue@28: end Nenue@28: q.isFaction = true Nenue@28: else Nenue@28: tagID = QUEST_TAG_ACCOUNT; Nenue@28: q.isAccount = true Nenue@28: end Nenue@28: q.typeTag = QUEST_TAG_TCOORDS[tagID] Nenue@28: elseif ( factionGroup) then Nenue@28: tagID = "ALLIANCE"; Nenue@28: if ( factionGroup == LE_QUEST_FACTION_HORDE ) then Nenue@28: tagID = "HORDE"; Nenue@28: end Nenue@28: q.isFaction = true Nenue@28: end Nenue@28: Nenue@28: if( frequency == LE_QUEST_FREQUENCY_DAILY and (not isComplete or isComplete == 0) ) then Nenue@28: tagID = "DAILY"; Nenue@28: q.frequencyTag = QUEST_TAG_TCOORDS["DAILY"] Nenue@28: q.isDaily = true Nenue@28: elseif( frequency == LE_QUEST_FREQUENCY_WEEKLY and (not isComplete or isComplete == 0) )then Nenue@28: tagID = "WEEKLY"; Nenue@28: q.frequencyTag = QUEST_TAG_TCOORDS["WEEKLY"] Nenue@28: q.isWeekly = true Nenue@28: elseif( questTagID ) then Nenue@28: tagID = questTagID; Nenue@28: end Nenue@28: Nenue@28: if ( isComplete and isComplete < 0 ) then Nenue@28: q.completionTag = QUEST_TAG_TCOORDS["FAILED"] Nenue@28: q.isFailed = true Nenue@28: elseif isComplete then Nenue@28: q.completionTag = QUEST_TAG_TCOORDS["COMPLETED"] Nenue@28: end Nenue@28: Nenue@28: Nenue@28: q.tagID = questTagID Nenue@28: q.tagName = tagName Nenue@28: --q.isBreadCrumb = isBreadCrumb Nenue@28: q.completionText= GetQuestLogCompletionText(questIndex) Nenue@28: q.numObjectives = GetNumQuestLeaderBoards(questIndex) Nenue@28: q.objectives = {} Nenue@28: for i = 1, q.numObjectives do Nenue@28: local text, type, finished = GetQuestLogLeaderBoard(i, questIndex) Nenue@28: print(format(' #%d %s %s %s', i, tostring(type), tostring(text), tostring(finished))) Nenue@28: q.objectives[i] = { Nenue@28: index = i, Nenue@28: type = type, Nenue@28: text = text, Nenue@28: finished = finished Nenue@28: } Nenue@28: if type == 'event' then Nenue@28: elseif type == 'monster' then Nenue@28: elseif type == 'object' then Nenue@28: elseif type == 'reputation' then Nenue@28: elseif type == 'item' then Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: if requiredMoney >= 1 then Nenue@28: local money = GetMoney() Nenue@28: local moneyText = money Nenue@28: local requiredSilver, requiredCopper Nenue@28: local requiredGold = (requiredMoney > 10000) and (floor(requiredMoney/10000)) or nil Nenue@28: if mod(requiredMoney, 10000) ~= 0 then Nenue@28: requiredSilver = (requiredMoney > 100) and (mod(requiredMoney, 10000) / 100) or nil Nenue@28: if mod(requiredMoney, 100) ~= 0 then Nenue@28: requiredCopper = mod(requiredMoney, 100) Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: -- round the money value down Nenue@28: if requiredMoney > 9999 and not (requiredSilver or requiredCopper) then Nenue@28: moneyText = floor(money/10000) Nenue@28: elseif requiredMoney < 10000 and mod(requiredMoney,100) == 0 then Nenue@28: moneyText = floor(money/100) Nenue@28: end Nenue@28: Nenue@28: local text = moneyText Nenue@28: local index = #q.objectives + 1 Nenue@28: local finished = (GetMoney() >= requiredMoney) Nenue@28: Nenue@28: if not finished then Nenue@28: text = text .. ' / ' .. GetCoinTextureString(requiredMoney, 12) Nenue@28: else Nenue@28: text = '' .. GetCoinTextureString(requiredMoney, 12) Nenue@28: end Nenue@28: q.objectives[index] = { Nenue@28: index = index, Nenue@28: type = 'progressbar', Nenue@28: quantity = money, Nenue@28: requiredQuantity = requiredMoney, Nenue@28: text = text, Nenue@28: finished = finished Nenue@28: } Nenue@28: print(format(' #%d %s %s %s', index, 'money', text, tostring(finished))) Nenue@28: end Nenue@28: Nenue@28: Nenue@28: local link, icon, charges = GetQuestLogSpecialItemInfo(questIndex) Nenue@28: local start, duration, enable = GetQuestLogSpecialItemCooldown(questIndex) Nenue@28: if link or icon or charges then Nenue@28: q.specialItem = { Nenue@28: questID = questID, Nenue@28: questIndex = questIndex, Nenue@28: link = link, Nenue@28: charges = charges, Nenue@28: icon = icon, Nenue@28: start = start, Nenue@28: duration = duration, Nenue@28: enable = enable, Nenue@28: } Nenue@28: end Nenue@28: Nenue@28: if QuestHasPOIInfo(questID) then Nenue@28: local distance, onContinent = GetDistanceSqToQuest(questIndex) Nenue@28: if distance ~= nil and distance > 0 then Nenue@28: self.POI[questIndex] = { Nenue@28: questIndex = questIndex, Nenue@28: questID = questID, Nenue@28: distance = distance, Nenue@28: onContinent = onContinent Nenue@28: } Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: Nenue@28: q.selected = (questID == GetSuperTrackedQuestID()) -- call directly so artifact data doesn't become an issue Nenue@28: self.WatchInfo[watchIndex] = q Nenue@28: self.LogInfo[questIndex] = q Nenue@28: print('- logIndex =', questIndex, 'title =', title) Nenue@28: for k,v in pairs(q) do Nenue@28: print('|cFFFFFF00'..k..'|r:', v) Nenue@28: end Nenue@28: return q Nenue@28: end Nenue@28: Nenue@28: Quest.GetClosest = function() Nenue@28: local minID, minTitle Nenue@28: local minDist = math.huge Nenue@28: local numQuests = GetNumQuestLogEntries() Nenue@28: for questIndex = 1, numQuests do Nenue@28: local distance, onContinent = GetDistanceSqToQuest(questIndex) Nenue@28: local title, level, _, _, _, _, _, _, questID = GetQuestLogTitle(questIndex) Nenue@28: if onContinent and distance < minDist then Nenue@28: minDist = distance Nenue@28: minTitle = title Nenue@28: minID = questID Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: print('nearest quest is', minTitle, 'by', math.sqrt(minDist)) Nenue@28: return minID, minTitle, minDist Nenue@28: end Nenue@28: Nenue@28: Quest.OnTurnIn = function(self, questID, xp, money) Nenue@28: Nenue@28: end Nenue@28: Nenue@28: Nenue@28: Quest.Select = function(self) Nenue@28: Nenue@28: if self.info.isAutoComplete and self.info.isComplete then Nenue@28: ShowQuestComplete(self.info.questLogIndex) Nenue@28: else Nenue@28: SetSuperTrackedQuestID(self.info.questID) Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: Quest.Link = function(self) Nenue@28: Nenue@28: local questLink = GetQuestLink(self.info.questLogIndex); Nenue@28: if ( questLink ) then Nenue@28: ChatEdit_InsertLink(questLink); Nenue@28: end Nenue@28: end Nenue@28: Nenue@28: Quest.Open = function(self) Nenue@28: Nenue@28: QuestMapFrame_OpenToQuestDetails(self.info.questID) Nenue@28: end Nenue@28: Nenue@28: Quest.Remove = function(self) Nenue@28: Nenue@28: print('removing', self.info.questLogIndex, 'from watcher') Nenue@28: RemoveQuestWatch(self.info.questLogIndex) Nenue@28: end