The tracker dropped dungeon, daily and custom Turtle quests that pfQuest's database does not know (13/20 shown on a 20-quest log). It now builds the list from the native quest log and falls back to log data when the database has no entry, so all 20 show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
613 lines
24 KiB
Diff
613 lines
24 KiB
Diff
--- a/quest.lua
|
|
+++ b/quest.lua
|
|
@@ -369,7 +369,7 @@
|
|
pfJournal.dirty = true
|
|
end
|
|
|
|
- if pfQuest_config["trackingmethod"] ~= 4 then
|
|
+ if pfDB.quests.data[entry[2]] and pfQuest_config["trackingmethod"] ~= 4 then
|
|
-- delete nodes by title
|
|
local t0 = GetTime()
|
|
pfMap:DeleteNode("PFQUEST", entry[1])
|
|
@@ -410,7 +410,7 @@
|
|
end
|
|
|
|
-- update quest nodes
|
|
- if pfQuest_config["trackingmethod"] ~= 4 then
|
|
+ if pfDB.quests.data[entry[2]] and pfQuest_config["trackingmethod"] ~= 4 then
|
|
-- delete node by title
|
|
local t0 = GetTime()
|
|
pfMap:DeleteNode("PFQUEST", entry[1])
|
|
@@ -476,23 +476,17 @@
|
|
-- initialize flip flop if not yet defined
|
|
pfQuest.questlog_tmp = pfQuest.questlog_tmp or questlog_flip
|
|
|
|
- local numEntries = GetNumQuestLogEntries() or 0
|
|
local change = nil
|
|
|
|
-- iterate over all quests
|
|
- for qlogid = 1, numEntries do
|
|
- local title, _, _, header, _, complete = compat.GetQuestLogTitle(qlogid)
|
|
- local objectives = GetNumQuestLeaderBoards(qlogid)
|
|
- local watched, questid, state
|
|
-
|
|
- if title and not header then
|
|
- -- A legacy same-title lookup can select hidden quest rows. While the
|
|
- -- Quest Log is open, keep background refreshes read-only so collapsed
|
|
- -- categories remain collapsed through progress and completion updates.
|
|
- local preserveSelection = QuestLogFrame and QuestLogFrame:IsShown()
|
|
- questid = pfDatabase:GetQuestIDs(qlogid, preserveSelection)
|
|
- questid = questid and tonumber(questid[1]) or title
|
|
- watched = IsQuestWatched(qlogid)
|
|
+ for qlogid, info in NativeQuestLogEntries() do
|
|
+ local title, questid = info.title, info.questID
|
|
+ local complete = C_QuestLog.IsComplete(questid)
|
|
+ local objectives = C_QuestLog.GetQuestObjectives(questid)
|
|
+ local watched, state
|
|
+
|
|
+ if title then
|
|
+ watched = C_QuestLog.GetQuestWatchType(questid) ~= nil
|
|
|
|
-- build state string using table.concat (avoid string concat garbage)
|
|
-- Completion can change without adding or removing objective rows (for
|
|
@@ -500,8 +494,8 @@
|
|
-- its ender pin is rebuilt from the client state.
|
|
local stateParts = { watched and "track" or "", complete and "complete" or "incomplete" }
|
|
if objectives then
|
|
- for i = 1, objectives, 1 do
|
|
- local text, _, done = GetQuestLogLeaderBoard(i, qlogid)
|
|
+ for i, objective in ipairs(objectives) do
|
|
+ local text, done = objective.text, objective.finished
|
|
stateParts[getn(stateParts) + 1] = i
|
|
stateParts[getn(stateParts) + 1] = text or ""
|
|
stateParts[getn(stateParts) + 1] = done and "done" or "todo"
|
|
@@ -542,7 +536,11 @@
|
|
|
|
-- quest removal events
|
|
for questid, data in pairs(pfQuest.questlog) do
|
|
- if not pfQuest.questlog_tmp[questid] then
|
|
+ if not pfQuest.questlog_tmp[questid] and C_QuestLog.IsOnQuest and C_QuestLog.IsOnQuest(questid) then
|
|
+ -- A filter can hide a still-accepted quest. Its old index may now name another quest.
|
|
+ data.qlogid = nil
|
|
+ pfQuest.questlog_tmp[questid] = data
|
|
+ elseif not pfQuest.questlog_tmp[questid] then
|
|
queueAdd({ data.title, questid, nil, "REMOVE" })
|
|
change = true
|
|
end
|
|
--- a/tracker.lua
|
|
+++ b/tracker.lua
|
|
@@ -25,24 +25,10 @@
|
|
return string.lower(string.gsub(title, "[^%w]", ""))
|
|
end
|
|
|
|
--- Some clients omit collapsed quests from the list; others still return them.
|
|
--- Support both layouts without removing anything from pfQuest's quest cache.
|
|
-local function ReadQuestLogVisibility()
|
|
- local visible, signature = {}, {}
|
|
- local hidden, hasCollapsed = false, false
|
|
- for i = 1, GetNumQuestLogEntries() do
|
|
- local title, _, _, header, collapsed = compat.GetQuestLogTitle(i)
|
|
- if title then
|
|
- if header then
|
|
- hidden = collapsed == true or collapsed == 1
|
|
- if hidden then hasCollapsed = true end
|
|
- elseif not hidden then
|
|
- visible[title] = true
|
|
- end
|
|
- table.insert(signature, title .. ":" .. tostring(header) .. ":" .. tostring(collapsed))
|
|
- end
|
|
- end
|
|
- return hasCollapsed and visible or nil, table.concat(signature, "\n")
|
|
+-- Numeric native quest IDs distinguish independent quests with the same title.
|
|
+local function ButtonKey(title, questid)
|
|
+ if tracker.mode == "QUEST_TRACKING" then return questid end
|
|
+ return TrackerTitleKey(title)
|
|
end
|
|
|
|
local function HideTooltip()
|
|
@@ -71,24 +57,18 @@
|
|
GameTooltip:AddLine(" ")
|
|
end
|
|
|
|
- local qlogid = pfQuest.questlog[this.node.questid] and pfQuest.questlog[this.node.questid].qlogid
|
|
- if qlogid then
|
|
- local objectives = GetNumQuestLeaderBoards(qlogid)
|
|
- if objectives and objectives > 0 then
|
|
- for i = 1, objectives, 1 do
|
|
- local text, _, done = GetQuestLogLeaderBoard(i, qlogid)
|
|
- local _, _, obj, cur, req = strfind(gsub(text, "\239\188\154", ":"), "(.*):%s*([%d]+)%s*/%s*([%d]+)")
|
|
- if done then
|
|
- GameTooltip:AddLine(" - " .. text, 0, 1, 0)
|
|
- elseif cur and req then
|
|
- local r, g, b = pfMap.tooltip:GetColor(cur, req)
|
|
- GameTooltip:AddLine(" - " .. text, r, g, b)
|
|
- else
|
|
- GameTooltip:AddLine(" - " .. text, 1, 0, 0)
|
|
- end
|
|
+ if tracker.mode == "QUEST_TRACKING" then
|
|
+ local objectives = C_QuestLog.GetQuestObjectives(this.questid) or {}
|
|
+ for _, objective in ipairs(objectives) do
|
|
+ local r, g, b = 1, 0, 0
|
|
+ if objective.finished then
|
|
+ r, g, b = 0, 1, 0
|
|
+ elseif objective.numRequired and objective.numRequired > 0 then
|
|
+ r, g, b = pfMap.tooltip:GetColor(objective.numFulfilled or 0, objective.numRequired)
|
|
end
|
|
- GameTooltip:AddLine(" ")
|
|
+ GameTooltip:AddLine(" - " .. (objective.text or ""), r, g, b)
|
|
end
|
|
+ if #objectives > 0 then GameTooltip:AddLine(" ") end
|
|
end
|
|
end
|
|
|
|
@@ -167,7 +147,7 @@
|
|
|
|
for _, button in pairs(tracker.buttons) do
|
|
if not button.empty then
|
|
- local distance = nearestByID[button.questid] or nearestByTitle[button.title]
|
|
+ local distance = nearestByID[button.questid] or (not button.questid and nearestByTitle[button.title])
|
|
if button.distance ~= distance then
|
|
button.distance = distance
|
|
changed = true
|
|
@@ -196,7 +176,8 @@
|
|
-- differs from route.coords: a tracker sort must include objectives even when
|
|
-- their route line, arrow, cluster, or endpoint display is disabled.
|
|
function tracker.RegisterQuestPoint(title, node, x, y)
|
|
- local id = tracker.buttonByTitle[TrackerTitleKey(title)]
|
|
+ if tracker.mode == "QUEST_TRACKING" and node.addon ~= "PFQUEST" then return end
|
|
+ local id = tracker.buttonByKey[ButtonKey(title, node.questid)]
|
|
local button = id and tracker.buttons[id]
|
|
if not button or button.empty then return end
|
|
|
|
@@ -244,6 +225,10 @@
|
|
-- read-only and coalesce row refreshes outside their dispatch stack.
|
|
if (this.contentTick or 0) <= GetTime() then
|
|
this.contentTick = GetTime() + 0.2
|
|
+ if this.logPending then
|
|
+ this.logPending = nil
|
|
+ tracker.SyncQuestRows()
|
|
+ end
|
|
for _, button in pairs(this.buttons or {}) do
|
|
if button.contentPending then
|
|
button.contentPending = nil
|
|
@@ -294,6 +279,8 @@
|
|
-- Section collapse/expand emits QUEST_LOG_UPDATE. Refresh on that event
|
|
-- instead of scanning the full quest log from the map tracker's OnUpdate.
|
|
tracker:RegisterEvent("QUEST_LOG_UPDATE")
|
|
+tracker:RegisterEvent("QUEST_ACCEPTED")
|
|
+tracker:RegisterEvent("QUEST_REMOVED")
|
|
tracker:SetScript("OnEvent", function()
|
|
if event == "PLAYER_ENTERING_WORLD" then
|
|
-- update font sizes according to config
|
|
@@ -306,9 +293,15 @@
|
|
else
|
|
this:Show()
|
|
end
|
|
+ this.logPending = true
|
|
UpdateSortButton()
|
|
- elseif event == "QUEST_LOG_UPDATE" then
|
|
- this.sectionSignature = nil
|
|
+ elseif event == "QUEST_ACCEPTED" or event == "QUEST_REMOVED" or event == "QUEST_LOG_UPDATE" then
|
|
+ if event == "QUEST_ACCEPTED" and type(arg1) == "number" then
|
|
+ this.acceptedIDs[arg1] = true
|
|
+ elseif event == "QUEST_REMOVED" then
|
|
+ this.acceptedIDs[arg1] = nil
|
|
+ end
|
|
+ this.logPending = true
|
|
this:ScheduleLayout()
|
|
end
|
|
end)
|
|
@@ -328,7 +321,9 @@
|
|
end)
|
|
|
|
tracker.buttons = {}
|
|
-tracker.buttonByTitle = {} -- reverse map: title → button index, for O(1) duplicate detection
|
|
+tracker.buttonByKey = {}
|
|
+tracker.logByID = {}
|
|
+tracker.acceptedIDs = {}
|
|
tracker.mode = "QUEST_TRACKING"
|
|
|
|
tracker.backdrop = CreateFrame("Frame", nil, tracker)
|
|
@@ -466,7 +461,7 @@
|
|
end
|
|
|
|
function tracker.ButtonEnter()
|
|
- pfMap.highlight = this.title
|
|
+ pfMap.highlight = (tracker.mode ~= "QUEST_TRACKING" or not this.node.dummy) and this.title or nil
|
|
tracker.ButtonUpdate(this)
|
|
ShowTooltip()
|
|
end
|
|
@@ -502,6 +497,11 @@
|
|
|
|
function tracker.ButtonClick()
|
|
if arg1 == "RightButton" then
|
|
+ if tracker.mode == "QUEST_TRACKING" then
|
|
+ C_QuestLog.SetSelectedQuest(this.questid)
|
|
+ ShowUIPanel(QuestLogFrame)
|
|
+ return
|
|
+ end
|
|
for questid, data in pairs(pfQuest.questlog) do
|
|
if data.title == this.title then
|
|
-- show questlog
|
|
@@ -512,8 +512,9 @@
|
|
end
|
|
end
|
|
elseif IsShiftKeyDown() then
|
|
+ if tracker.mode == "QUEST_TRACKING" and this.node.dummy then return end
|
|
-- mark as done if node is quest and not in questlog
|
|
- if this.node.questid and not this.node.qlogid then
|
|
+ if tracker.mode ~= "QUEST_TRACKING" and this.node.questid and not this.node.qlogid then
|
|
-- mark as done in history
|
|
pfQuest_history[this.node.questid] = { time(), UnitLevel("player") }
|
|
UIErrorsFrame:AddMessage(
|
|
@@ -538,17 +539,18 @@
|
|
WorldMapFrame:Show()
|
|
end
|
|
elseif IsControlKeyDown() and pfQuest_config["spawncolors"] == "0" then
|
|
+ if tracker.mode == "QUEST_TRACKING" and this.node.dummy then return end
|
|
-- switch color
|
|
pfQuest_colors[this.title] = { pfMap.str2rgb(this.title .. GetTime()) }
|
|
pfMap:RefreshPinColor(this.title)
|
|
pfMap:UpdateNodes()
|
|
- elseif expand_states[this.title] == 0 then
|
|
- expand_states[this.title] = 1
|
|
- manual_expand_states[this.title] = true
|
|
+ elseif expand_states[this.questid or this.title] == 0 then
|
|
+ expand_states[this.questid or this.title] = 1
|
|
+ manual_expand_states[this.questid or this.title] = true
|
|
tracker.ButtonEvent(this)
|
|
- elseif expand_states[this.title] == 1 then
|
|
- expand_states[this.title] = 0
|
|
- manual_expand_states[this.title] = true
|
|
+ elseif expand_states[this.questid or this.title] == 1 then
|
|
+ expand_states[this.questid or this.title] = 0
|
|
+ manual_expand_states[this.questid or this.title] = true
|
|
tracker.ButtonEvent(this)
|
|
end
|
|
end
|
|
@@ -556,6 +558,8 @@
|
|
local function trackersort(a, b)
|
|
if a.empty then
|
|
return false
|
|
+ elseif b.empty then
|
|
+ return true
|
|
elseif (a.tracked and 1 or -1) ~= (b.tracked and 1 or -1) then
|
|
return (a.tracked and 1 or -1) > (b.tracked and 1 or -1)
|
|
elseif tracker.mode == "QUEST_TRACKING" and GetQuestSortMode() == "distance"
|
|
@@ -577,11 +581,6 @@
|
|
end
|
|
end
|
|
|
|
--- Reusable cache for GetQuestLogLeaderBoard results within a single ButtonEvent
|
|
--- call. Avoids calling the API twice per objective (once for progress, once for
|
|
--- display). Cleared at the start of each ButtonEvent invocation.
|
|
-local board_cache = {}
|
|
-
|
|
function tracker.ButtonEvent(self)
|
|
local self = self or this
|
|
local title = self.title
|
|
@@ -626,68 +625,31 @@
|
|
end
|
|
|
|
if tracker.mode == "QUEST_TRACKING" then
|
|
- local qlogid = pfQuest.questlog[qid] and pfQuest.questlog[qid].qlogid or 0
|
|
- local qtitle, level, tag, header, collapsed, complete = compat.GetQuestLogTitle(qlogid)
|
|
- if not qlogid or not qtitle then
|
|
- return
|
|
- end
|
|
- local objectives = GetNumQuestLeaderBoards(qlogid)
|
|
- -- A quest button can retain the node texture captured before the client
|
|
- -- reports its final state. Refresh the completion icon from the current
|
|
- -- quest log on every event; objective-free talk/report quests are ready
|
|
- -- by the same rule used by pfQuest's map tooltip and objective state.
|
|
- if complete or objectives == 0 then
|
|
+ local info = tracker.logByID[qid]
|
|
+ if not info then return end
|
|
+ local level = info.level
|
|
+ local objectives = C_QuestLog.GetQuestObjectives(qid) or {}
|
|
+ local complete = C_QuestLog.IsComplete(qid)
|
|
+ local color = pfQuestCompat.GetDifficultyColor(level)
|
|
+ local cur, max = 0, 0
|
|
+ for _, objective in ipairs(objectives) do
|
|
+ local goal = math.max(1, objective.numRequired or 0)
|
|
+ max = max + goal
|
|
+ cur = cur + (objective.finished and goal or math.min(goal, objective.numFulfilled or 0))
|
|
+ end
|
|
+ if complete then
|
|
self.icon:SetTexture(pfQuestConfig.path .. "\\img\\complete_c")
|
|
self.icon:SetVertexColor(1, 1, 1, 1)
|
|
- end
|
|
- local watched = IsQuestWatched(qlogid)
|
|
- local color = pfQuestCompat.GetDifficultyColor(level)
|
|
- local cur, max = 0, 0
|
|
- local percent = 0
|
|
-
|
|
- -- write expand state
|
|
- if not expand_states[title] then
|
|
- expand_states[title] = pfQuest_config["trackerexpand"] == "1" and 1 or 0
|
|
- end
|
|
-
|
|
- local expanded = expand_states[title] == 1 and true or nil
|
|
-
|
|
- if objectives and objectives > 0 then
|
|
- -- populate cache and compute progress in one pass
|
|
- for i = 1, objectives, 1 do
|
|
- local text, type, done = GetQuestLogLeaderBoard(i, qlogid)
|
|
- board_cache[i] = { text, type, done }
|
|
- local _, _, obj, objNum, objNeeded = strfind(gsub(text, "\239\188\154", ":"), "(.*):%s*([%d]+)%s*/%s*([%d]+)")
|
|
- if objNum and objNeeded then
|
|
- max = max + objNeeded
|
|
- cur = cur + objNum
|
|
- elseif not done then
|
|
- max = max + 1
|
|
- end
|
|
- end
|
|
- -- clear stale entries beyond current objective count
|
|
- for i = objectives + 1, table.getn(board_cache) do
|
|
- board_cache[i] = nil
|
|
- end
|
|
- end
|
|
-
|
|
- if cur == max or complete then
|
|
cur, max = 1, 1
|
|
- percent = 100
|
|
- else
|
|
- percent = cur / max * 100
|
|
- end
|
|
-
|
|
- -- expand button to show objectives
|
|
- if objectives and (expanded or (percent > 0 and percent < 100)) then
|
|
- self:SetHeight(entryheight + objectives * fontsize)
|
|
-
|
|
- for i = 1, objectives, 1 do
|
|
- -- read from cache instead of calling GetQuestLogLeaderBoard again
|
|
- local entry = board_cache[i]
|
|
- local text, _, done = entry[1], entry[2], entry[3]
|
|
- local _, _, obj, objNum, objNeeded = strfind(gsub(text, "\239\188\154", ":"), "(.*):%s*([%d]+)%s*/%s*([%d]+)")
|
|
-
|
|
+ end
|
|
+ max = math.max(1, max)
|
|
+ local percent = cur / max * 100
|
|
+ if expand_states[qid] == nil then
|
|
+ expand_states[qid] = pfQuest_config["trackerexpand"] == "1" and 1 or 0
|
|
+ end
|
|
+ if expand_states[qid] == 1 or (percent > 0 and percent < 100) then
|
|
+ self:SetHeight(entryheight + #objectives * fontsize)
|
|
+ for i, objective in ipairs(objectives) do
|
|
if not self.objectives[i] then
|
|
self.objectives[i] = self:CreateFontString(nil, "HIGH", "GameFontNormal")
|
|
self.objectives[i]:SetFont(pfUI.font_default, fontsize)
|
|
@@ -696,25 +658,31 @@
|
|
self.objectives[i]:SetPoint("TOPRIGHT", -10, -fontsize * i - 6)
|
|
end
|
|
|
|
- if objNum and objNeeded then
|
|
- local r, g, b = pfMap.tooltip:GetColor(objNum, objNeeded)
|
|
- self.objectives[i]:SetTextColor(r + 0.2, g + 0.2, b + 0.2)
|
|
- self.objectives[i]:SetText(string.format("|cffffffff- %s:|r %s/%s", obj, objNum, objNeeded))
|
|
+ local goal = objective.numRequired or 0
|
|
+ if objective.finished then
|
|
+ self.objectives[i]:SetTextColor(0, 1, 0)
|
|
+ elseif goal > 0 then
|
|
+ self.objectives[i]:SetTextColor(pfMap.tooltip:GetColor(objective.numFulfilled or 0, goal))
|
|
else
|
|
self.objectives[i]:SetTextColor(0.8, 0.8, 0.8)
|
|
- self.objectives[i]:SetText("|cffffffff- " .. text)
|
|
end
|
|
-
|
|
+ self.objectives[i]:SetText("|cffffffff- " .. (objective.text or ""))
|
|
self.objectives[i]:Show()
|
|
end
|
|
end
|
|
|
|
local r, g, b = pfMap.tooltip:GetColor(cur, max)
|
|
local colorperc = string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
|
|
- local showlevel = pfQuest_config["trackerlevel"] == "1" and "[" .. (level or "??") .. (tag and "+" or "") .. "] "
|
|
+ local tag = C_QuestLog.GetQuestTagInfo and C_QuestLog.GetQuestTagInfo(qid)
|
|
+ local suffix = ""
|
|
+ if tag and Enum and Enum.QuestTag then
|
|
+ if tag.tagID == Enum.QuestTag.Dungeon then suffix = "D"
|
|
+ elseif tag.tagID == Enum.QuestTag.Group then suffix = "+" end
|
|
+ end
|
|
+ local showlevel = pfQuest_config["trackerlevel"] == "1" and "[" .. (level or "??") .. suffix .. "] "
|
|
or ""
|
|
|
|
- self.tracked = watched
|
|
+ self.tracked = C_QuestLog.GetQuestWatchType(qid) ~= nil
|
|
-- The tracker sort uses the numeric quest level. Keep it on the quest
|
|
-- button just as giver entries do, otherwise level-first compares every
|
|
-- quest as an unset value.
|
|
@@ -756,11 +724,7 @@
|
|
-- Mark for sort instead of sorting immediately (deferred)
|
|
tracker.needsSort = true
|
|
tracker:ScheduleLayout()
|
|
- if tracker.mode == "QUEST_TRACKING" and tracker.visibleQuests and not tracker.visibleQuests[title] then
|
|
- self:Hide()
|
|
- else
|
|
- self:Show()
|
|
- end
|
|
+ self:Show()
|
|
end
|
|
|
|
-- Separate function for layout (only called when needed)
|
|
@@ -808,19 +772,16 @@
|
|
|
|
-- Sorting moves frame objects between numeric slots. Rebuild the reverse
|
|
-- lookup so later updates address the frame that now owns each title.
|
|
- for title in pairs(tracker.buttonByTitle) do
|
|
- tracker.buttonByTitle[title] = nil
|
|
+ for title in pairs(tracker.buttonByKey) do
|
|
+ tracker.buttonByKey[title] = nil
|
|
end
|
|
for id = 1, getn(tracker.buttons) do
|
|
local button = tracker.buttons[id]
|
|
if button and not button.empty and button.title then
|
|
- tracker.buttonByTitle[TrackerTitleKey(button.title)] = id
|
|
- end
|
|
- end
|
|
- end
|
|
-
|
|
- local visibleQuests = tracker.mode == "QUEST_TRACKING" and ReadQuestLogVisibility() or nil
|
|
- tracker.visibleQuests = visibleQuests
|
|
+ tracker.buttonByKey[ButtonKey(button.title, button.questid)] = id
|
|
+ end
|
|
+ end
|
|
+ end
|
|
|
|
-- resize window and align buttons
|
|
local height = panelheight
|
|
@@ -831,7 +792,7 @@
|
|
button:ClearAllPoints()
|
|
button:SetPoint("TOPRIGHT", tracker, "TOPRIGHT", 0, -height)
|
|
button:SetPoint("TOPLEFT", tracker, "TOPLEFT", 0, -height)
|
|
- if not button.empty and (not visibleQuests or visibleQuests[button.title]) then
|
|
+ if not button.empty then
|
|
button:Show()
|
|
height = height + button:GetHeight()
|
|
|
|
@@ -868,30 +829,11 @@
|
|
return
|
|
end
|
|
|
|
- -- O(1) questid lookup: node.questid is set for all PFQUEST nodes from the DB.
|
|
- -- For the rare case it's missing or not in questlog (title-keyed quests), fall
|
|
- -- back to the linear scan so correctness is preserved.
|
|
local questid = node.questid
|
|
- -- Reset() creates dummy entries without a database node. Resolve those by
|
|
- -- title too; otherwise the QUEST_TRACKING guard below rejects every dummy
|
|
- -- entry before it can display (notably client-unwatched quests).
|
|
- if not questid or not pfQuest.questlog[questid] then
|
|
- questid = title
|
|
- for qid, data in pairs(pfQuest.questlog) do
|
|
- if data.title == title then
|
|
- questid = qid
|
|
- break
|
|
- end
|
|
- end
|
|
- end
|
|
-
|
|
- if tracker.mode == "QUEST_TRACKING" then -- skip everything that isn't in questlog
|
|
- if node.addon ~= "PFQUEST" then
|
|
- return
|
|
- end
|
|
- if not pfQuest.questlog or not pfQuest.questlog[questid] then
|
|
- return
|
|
- end
|
|
+ if tracker.mode == "QUEST_TRACKING" then
|
|
+ local entry = questid and tracker.logByID[questid]
|
|
+ if node.addon ~= "PFQUEST" or not entry then return end
|
|
+ title = entry.title
|
|
elseif tracker.mode == "GIVER_TRACKING" then -- skip everything that isn't a questgiver
|
|
if node.addon ~= "PFQUEST" then
|
|
return
|
|
@@ -913,10 +855,15 @@
|
|
local id
|
|
|
|
-- O(1) duplicate check via reverse map (replaces linear scan of tracker.buttons)
|
|
- local existing = tracker.buttonByTitle[TrackerTitleKey(title)]
|
|
+ local key = ButtonKey(title, questid)
|
|
+ local existing = tracker.buttonByKey[key]
|
|
if existing then
|
|
local button = tracker.buttons[existing]
|
|
- if node.dummy or not node.texture then
|
|
+ if tracker.mode == "QUEST_TRACKING" and button.node and button.node.dummy and not node.dummy then
|
|
+ id = existing
|
|
+ elseif tracker.mode == "QUEST_TRACKING" and node.dummy and button.node and not button.node.dummy then
|
|
+ return
|
|
+ elseif node.dummy or not node.texture then
|
|
id = existing -- node icon takes slot
|
|
elseif node.cluster and (not button.node or button.node.texture) then
|
|
id = existing -- cluster icon, acceptable
|
|
@@ -982,7 +929,7 @@
|
|
tracker.buttons[id].questid = questid
|
|
|
|
-- keep reverse map in sync
|
|
- tracker.buttonByTitle[TrackerTitleKey(title)] = id
|
|
+ tracker.buttonByKey[key] = id
|
|
|
|
-- reload button data
|
|
tracker.ButtonEvent(tracker.buttons[id])
|
|
@@ -993,6 +940,7 @@
|
|
tracker:SetHeight(panelheight)
|
|
tracker.questPoints = {}
|
|
for id, button in pairs(tracker.buttons) do
|
|
+ button.questid = nil
|
|
button.level = nil
|
|
button.title = nil
|
|
button.perc = nil
|
|
@@ -1001,25 +949,56 @@
|
|
button:Hide()
|
|
end
|
|
-- reverse map is only valid while buttons hold titles; clear on full reset
|
|
- for k in pairs(tracker.buttonByTitle) do
|
|
- tracker.buttonByTitle[k] = nil
|
|
- end
|
|
-
|
|
+ for k in pairs(tracker.buttonByKey) do
|
|
+ tracker.buttonByKey[k] = nil
|
|
+ end
|
|
+
|
|
+ tracker.SyncQuestRows()
|
|
+end
|
|
+
|
|
+function tracker.SyncQuestRows()
|
|
if tracker.mode ~= "QUEST_TRACKING" then return end
|
|
- local numEntries = GetNumQuestLogEntries() or 0
|
|
-
|
|
- -- iterate over all quests
|
|
- for qlogid = 1, numEntries do
|
|
- local title, level, tag, header, collapsed, complete = compat.GetQuestLogTitle(qlogid)
|
|
- if title and not header then
|
|
- -- Map pins follow their tracking settings. This list follows the quest log.
|
|
- local img = complete
|
|
- and pfQuestConfig.path .. "\\img\\complete_c"
|
|
- or pfQuestConfig.path .. "\\img\\complete"
|
|
- pfQuest.tracker.ButtonAdd(title, { dummy = true, addon = "PFQUEST", texture = img })
|
|
- end
|
|
- end
|
|
- -- Note: DoLayout is called by UpdateNodes after all ButtonAdd calls complete
|
|
+ local entries = {}
|
|
+ for _, info in NativeQuestLogEntries() do entries[info.questID] = info end
|
|
+ -- A client filter can temporarily omit previously enumerated rows entirely.
|
|
+ -- Retain one only while the native membership query confirms its quest ID.
|
|
+ for questid, info in pairs(tracker.logByID) do
|
|
+ if not entries[questid] and C_QuestLog.IsOnQuest and C_QuestLog.IsOnQuest(questid) then
|
|
+ entries[questid] = info
|
|
+ end
|
|
+ end
|
|
+ for questid in pairs(tracker.acceptedIDs) do
|
|
+ if entries[questid] then
|
|
+ tracker.acceptedIDs[questid] = nil
|
|
+ elseif C_QuestLog.IsOnQuest(questid) then
|
|
+ local title = C_QuestLog.GetTitleForQuestID(questid)
|
|
+ if title then
|
|
+ entries[questid] = {questID = questid, title = title, level = C_QuestLog.GetQuestDifficultyLevel(questid)}
|
|
+ tracker.acceptedIDs[questid] = nil
|
|
+ end
|
|
+ end
|
|
+ end
|
|
+ tracker.logByID = entries
|
|
+ for _, button in ipairs(tracker.buttons) do
|
|
+ if not button.empty and not entries[button.questid] then
|
|
+ if button.questid then tracker.buttonByKey[button.questid] = nil end
|
|
+ button.empty, button.title = true, nil
|
|
+ button:Hide()
|
|
+ tracker.needsSort = true
|
|
+ end
|
|
+ end
|
|
+ for questid, info in pairs(entries) do
|
|
+ local id = tracker.buttonByKey[questid]
|
|
+ if not id then
|
|
+ tracker.ButtonAdd(info.title, {dummy = true, addon = "PFQUEST", questid = questid,
|
|
+ texture = pfQuestConfig.path .. "\\img\\complete"})
|
|
+ else
|
|
+ local button = tracker.buttons[id]
|
|
+ button.title = info.title
|
|
+ button.contentPending = true
|
|
+ end
|
|
+ end
|
|
+ tracker:ScheduleLayout()
|
|
end
|
|
|
|
-- make global available
|