feat(tooltip): accurate per-pin data source attribution

Re-adds the 'Show data source' tooltip option (General tab, default off),
but accurate this time. The previous version was removed because it
guessed the source from the global data-source mode (showing Learner when
data was AscensionDB, etc.). This tags each pin with its real provenance
at creation and reads that tag.

- QuestieDB.GetPinDataSource(entityType, id, spawnData): resolves
  Learner (per-spawn isLearned or learner record), AscensionDB (curated
  ascensionOverrideKeys override), or base Questie DB. Never guesses.
- Objective pins tagged per-spawn in _DetermineIconsToDraw; available/
  finisher pins defaulted by quest in DrawWorldIcon; manual notes tagged
  Townsfolk in DrawManualIcon.
- World-map pins read the per-pin tag (MapIconTooltip); unit/object/item
  hovers derive per-id at the render layer (TooltipHandler via
  QuestieTooltips:GetDataSourceLine). Comms appended via KeyExists.
- No line shown when source is genuinely unknown (never misleading).
This commit is contained in:
Xurkon
2026-06-09 17:57:58 -05:00
parent d207feb3db
commit 0c4631be6e
9 changed files with 134 additions and 6 deletions
+13
View File
@@ -573,6 +573,12 @@ function QuestieMap:DrawManualIcon(data, areaID, x, y, typ)
data.Id = data.id
-- Manual notes are placed by the Townsfolk / menu system. Tag them so the source
-- tooltip line can report it (only if a caller hasn't already set a more specific source).
if data.DataSource == nil then
data.DataSource = "Townsfolk"
end
local uiMapId = _ResolveMapUiMapId(ZoneDB:GetUiMapIdByAreaId(areaID), x, y)
if (not uiMapId) then
Questie:Debug(Questie.DEBUG_CRITICAL, "[QuestieMap:DrawManualIcon] No UiMapID for areaId:", areaID, tostring(data.Name))
@@ -714,6 +720,13 @@ function QuestieMap:DrawWorldIcon(data, areaID, x, y, showFlag)
return nil, nil
end
-- Tag data-source provenance for the source tooltip line. Objective pins set this
-- explicitly (per-spawn). Available/finisher pins are quest-scoped, so derive from the
-- quest. Leave nil for anything else so the tooltip shows no (potentially wrong) source.
if data.DataSource == nil and (data.Type == "available" or data.Type == "complete") then
data.DataSource = QuestieDB.GetPinDataSource("QUEST", data.Id)
end
local uiMapId = _ResolveMapUiMapId(ZoneDB:GetUiMapIdByAreaId(areaID), x, y)
if (not uiMapId) then
local parentMapId
@@ -558,6 +558,18 @@ function QuestieOptions.tabs.general:Initialize()
Questie.db.profile.learnerTooltipUseSecondary = value
end
},
showDataSource = {
type = "toggle",
order = 8.605,
name = function() return l10n('Show data source'); end,
desc = function() return l10n('Adds a "Source:" line to NPC, object and map-pin tooltips showing where the data came from (Questie DB, AscensionDB, Learner, Townsfolk, Comms). Only shown when the source is actually known.'); end,
width = 1.5,
disabled = function() return not Questie.db.profile.enableTooltips; end,
get = function() return Questie.db.profile.enableTooltipsSource == true end,
set = function(_, value)
Questie.db.profile.enableTooltipsSource = value
end
},
partyOnlyToggle = {
type = "toggle",
order = 8.61,
@@ -87,6 +87,7 @@ function QuestieOptionsDefaults:Load()
enableTooltipsObjectID = false,
enableTooltipsQuestID = false,
enableTooltipsQuestLevel = true,
enableTooltipsSource = false,
showQuestXpAtMaxLevel = true,
enableTooltipsNextInChain = true,
learnerTooltips = true,
+2 -1
View File
@@ -1916,7 +1916,8 @@ _DetermineIconsToDraw = function(quest, objective, objectiveIndex, objectiveCent
IconScale = spawnData.GetIconScale(),
Name = spawnData.Name,
Type = objective.Type,
ObjectiveTargetId = spawnData.Id
ObjectiveTargetId = spawnData.Id,
DataSource = QuestieDB.GetPinDataSource(objective.Type == "object" and "OBJECT" or "NPC", id, spawnData)
}
objective.AlreadySpawned[id] = {
+21
View File
@@ -102,6 +102,23 @@ local function _GetWorldMapTooltipSourceLine(pinData)
return nil
end
--- Per-pin data-source attribution line for the hovered world-map icon.
--- Reads the DataSource tag set at pin creation (objective/finisher/available/manual) so
--- the label is accurate, plus a Comms overlay when comms holds data for this id.
local function _GetWorldMapDataSourceLine(pinData)
if not Questie.db.profile.enableTooltipsSource then return nil end
local src = pinData and pinData.DataSource
local parts = {}
if src then tinsert(parts, src) end
local id = pinData and pinData.Id
if id and QuestieComms and QuestieComms.data and QuestieComms.data.KeyExists
and QuestieComms.data:KeyExists("m_" .. tostring(id)) then
tinsert(parts, "Comms")
end
if table.getn(parts) == 0 then return nil end
return "|cFF808080Source: " .. table.concat(parts, " + ") .. "|r"
end
function MapIconTooltip:Show()
local _, _, _, alpha = self.texture:GetVertexColor();
if alpha == 0 then
@@ -751,6 +768,10 @@ function MapIconTooltip:Show()
end
self:AddLine(_GetWorldMapTooltipSourceLine(self.data), 0.55, 0.55, 0.55)
local dataSourceLine = _GetWorldMapDataSourceLine(self.data)
if dataSourceLine then
self:AddLine(dataSourceLine, 0.55, 0.55, 0.55)
end
end
Tooltip:_Rebuild() -- we separate this so things like MODIFIER_STATE_CHANGED can redraw the tooltip
Tooltip:SetFrameStrata("TOOLTIP");
+28 -5
View File
@@ -115,12 +115,27 @@ local function _GetQuestObjectiveSummary(questId)
return summary
end
local function _BuildTooltipSourceLine(sourceFlags)
return nil
end
--- Accurate data-source attribution for a unit/object/item hover tooltip.
--- Derives provenance from the entity id (never from the global mode): AscensionDB
--- curated override, learner record, or base "Questie DB", plus a Comms overlay when
--- comms holds data for this key. Returns nil when the source can't be determined or the
--- option is off, so a wrong/guessed label is never shown.
---@param key string @"m_<npcId>" | "o_<objectId>" | "i_<itemId>"
local function _GetTooltipSourceLine(key)
return nil
if not Questie.db.profile.enableTooltipsSource then return nil end
if not key then return nil end
local prefix = key:sub(1, 2)
local id = tonumber(key:sub(3))
local entityType = (prefix == "o_" and "OBJECT") or (prefix == "i_" and "ITEM") or "NPC"
local parts = {}
local src = id and QuestieDB.GetPinDataSource(entityType, id) or nil
if src then tinsert(parts, src) end
if QuestieComms and QuestieComms.data and QuestieComms.data.KeyExists and QuestieComms.data:KeyExists(key) then
tinsert(parts, "Comms")
end
if table.getn(parts) == 0 then return nil end
return "|cFF808080Source: " .. table.concat(parts, " + ") .. "|r"
end
---@param questId number
@@ -632,6 +647,14 @@ elseif key:sub(1,2) == "o_" then
return tooltipLines
end
--- Public accessor for the data-source attribution line. Called by the render layer
--- (TooltipHandler) rather than appended inside GetTooltip so it never interferes with
--- the quest-title de-duplication that consumes GetTooltip's result.
---@param key string @"m_<npcId>" | "o_<objectId>" | "i_<itemId>"
function QuestieTooltips:GetDataSourceLine(key)
return _GetTooltipSourceLine(key)
end
_InitObjectiveTexts = function(objectivesText, objectiveIndex, playerName)
if (not objectivesText) then
objectivesText = {}
+19
View File
@@ -329,6 +329,12 @@ function _QuestieTooltips:AddUnitDataToTooltip()
end
end
-- Data-source attribution (opt-in; internally gated and nil when source unknown).
local npcSourceLine = QuestieTooltips:GetDataSourceLine("m_" .. npcId)
if npcSourceLine then
GameTooltip:AddLine(npcSourceLine)
end
local npcNum = tonumber(npcId)
if npcNum then
_AddQuestStarterDropsToTooltip(npcNum)
@@ -394,6 +400,11 @@ function _QuestieTooltips:AddItemDataToTooltip()
self:AddLine(v)
end
end
-- Data-source attribution (opt-in; internally gated and nil when source unknown).
local itemSourceLine = QuestieTooltips:GetDataSourceLine("i_" .. (itemId or 0))
if itemSourceLine then
self:AddLine(itemSourceLine)
end
QuestieTooltips.lastGametooltipCount = _QuestieTooltips:CountTooltip()
end
lastItemId = itemId;
@@ -448,6 +459,14 @@ function _QuestieTooltips:AddObjectDataToTooltip(name)
end
end
end
-- Data-source attribution for the hovered object (opt-in; nil when unknown).
local firstObjectId = lookup[1]
if firstObjectId then
local objSourceLine = QuestieTooltips:GetDataSourceLine("o_" .. firstObjectId)
if objSourceLine then
GameTooltip:AddLine(objSourceLine)
end
end
if QuestieTooltips.ResizeTooltip then
QuestieTooltips:ResizeTooltip(GameTooltip)
end