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