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:
@@ -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");
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user