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