feat(tooltip): ElvUI style without ElvUI; source in secondary only; fix learner source label
- ElvUI tooltip style: new 'ElvUI tooltip style' option (General tab, on by default) skins GameTooltip/WorldMapTooltip/ItemRefTooltip/shopping tooltips and the secondary learner frame with ElvUI's transparent flat look (dark bg + thin 1px border) when ElvUI is not installed. Corrected the secondary frame fallback that used the chunky WoW border. No-op when ElvUI is loaded. - Source attribution now shows ONLY inside the secondary learner tooltip when 'Use secondary learner tooltip' is enabled; removed from the main NPC/object/ item tooltip and gated off entirely when the secondary tooltip is disabled (map-pin source gated the same way). - Fixed learner-learned pins mislabelled 'AscensionDB': GetPinDataSource is now mode-aware and returns 'Learner' in learner mode when the entity has a learner record, even if AscensionDB also curates it (curated coords are discarded by GetNPC/GetObject in learner mode anyway). Test-neutral (145 successes / same 7 pre-existing failures + 1 error).
This commit is contained in:
@@ -562,14 +562,32 @@ function QuestieOptions.tabs.general:Initialize()
|
||||
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,
|
||||
desc = function() return l10n('Adds a "Source:" line (Questie DB, AscensionDB, Learner, Townsfolk, Comms) inside the secondary learner tooltip. Requires "Use secondary learner tooltip"; never shown in the main tooltip and not shown at all when the secondary tooltip is disabled. Only shown when the source is actually known.'); end,
|
||||
width = 1.5,
|
||||
disabled = function() return not Questie.db.profile.enableTooltips; end,
|
||||
disabled = function() return not (Questie.db.profile.enableTooltips and Questie.db.profile.learnerTooltipUseSecondary == true); end,
|
||||
get = function() return Questie.db.profile.enableTooltipsSource == true end,
|
||||
set = function(_, value)
|
||||
Questie.db.profile.enableTooltipsSource = value
|
||||
end
|
||||
},
|
||||
elvuiStyleTooltips = {
|
||||
type = "toggle",
|
||||
order = 8.606,
|
||||
name = function() return l10n('ElvUI tooltip style'); end,
|
||||
desc = function() return l10n('Skin Questie tooltips (NPC/item/map-pin and the secondary learner tooltip) with the ElvUI transparent style even when ElvUI is not installed. Has no effect when ElvUI is loaded, since ElvUI skins them itself. Takes full effect after a reload.'); end,
|
||||
width = 1.5,
|
||||
disabled = function() return not Questie.db.profile.enableTooltips; end,
|
||||
get = function() return Questie.db.profile.elvuiStyleTooltips ~= false end,
|
||||
set = function(_, value)
|
||||
Questie.db.profile.elvuiStyleTooltips = value
|
||||
if value then
|
||||
local QuestieTooltips = QuestieLoader:ImportModule("QuestieTooltips")
|
||||
if QuestieTooltips and QuestieTooltips.SkinDefaultTooltips then
|
||||
QuestieTooltips:SkinDefaultTooltips()
|
||||
end
|
||||
end
|
||||
end
|
||||
},
|
||||
partyOnlyToggle = {
|
||||
type = "toggle",
|
||||
order = 8.61,
|
||||
|
||||
@@ -88,6 +88,7 @@ function QuestieOptionsDefaults:Load()
|
||||
enableTooltipsQuestID = false,
|
||||
enableTooltipsQuestLevel = true,
|
||||
enableTooltipsSource = false,
|
||||
elvuiStyleTooltips = true,
|
||||
showQuestXpAtMaxLevel = true,
|
||||
enableTooltipsNextInChain = true,
|
||||
learnerTooltips = true,
|
||||
|
||||
@@ -4615,17 +4615,19 @@ local function _ApplyElvUIStyleTooltip(frame)
|
||||
return
|
||||
end
|
||||
end
|
||||
-- ElvUI default "Transparent" template — see ElvUI/Core/Toolkit.lua:82
|
||||
-- and ElvUI/Settings/Profile.lua:29-31. Hard-coded so the secondary
|
||||
-- frame looks the same with or without ElvUI.
|
||||
-- ElvUI "Transparent" template — see ElvUI/Core/Toolkit.lua SetTemplate and
|
||||
-- ElvUI/Settings/Profile.lua:29-31. ElvUI uses a FLAT texture for both the
|
||||
-- background and the border with a 1px (E.mult) edge, NOT the chunky default
|
||||
-- WoW tooltip border — so use a solid texture and edgeSize 1 to match.
|
||||
if not frame.SetBackdrop then return end
|
||||
local FLAT = "Interface\\ChatFrame\\ChatFrameBackground" -- solid 1x1 texture on 3.3.5
|
||||
frame:SetBackdrop({
|
||||
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
|
||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||
tile = true,
|
||||
tileSize = 16,
|
||||
edgeSize = 12,
|
||||
insets = {left = 3, right = 3, top = 3, bottom = 3},
|
||||
bgFile = FLAT,
|
||||
edgeFile = FLAT,
|
||||
tile = false,
|
||||
tileSize = 0,
|
||||
edgeSize = 1,
|
||||
insets = {left = 0, right = 0, top = 0, bottom = 0},
|
||||
})
|
||||
-- (0.06, 0.06, 0.06, 0.8) — ElvUI's default backdropfadecolor
|
||||
frame:SetBackdropColor(0.06, 0.06, 0.06, 0.8)
|
||||
@@ -4779,6 +4781,15 @@ local function _AddLearnedSpawnTooltipLine(unitToken)
|
||||
for _, pair in ipairs(lines) do
|
||||
rendered[#rendered + 1] = pair[1] .. ": " .. pair[2]
|
||||
end
|
||||
-- Data-source attribution belongs ONLY in this secondary frame, and only when the
|
||||
-- source option is enabled. It is never added to the main tooltip; when the secondary
|
||||
-- learner tooltip is disabled it does not appear at all.
|
||||
local QuestieTooltips = QuestieLoader:ImportModule("QuestieTooltips")
|
||||
local sourceLine = QuestieTooltips and QuestieTooltips.GetDataSourceLine
|
||||
and QuestieTooltips:GetDataSourceLine("m_" .. npcId)
|
||||
if sourceLine then
|
||||
rendered[#rendered + 1] = sourceLine
|
||||
end
|
||||
-- Spacer after learner section
|
||||
rendered[#rendered + 1] = " "
|
||||
_ShowLearnerTooltipFrame(GameTooltip, rendered)
|
||||
|
||||
@@ -107,6 +107,9 @@ end
|
||||
--- 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
|
||||
-- Source attribution is tied to the secondary learner tooltip: only show it when that
|
||||
-- option is enabled, and never otherwise (matches the unit-hover behaviour).
|
||||
if Questie.db.profile.learnerTooltipUseSecondary ~= true then return nil end
|
||||
local src = pinData and pinData.DataSource
|
||||
local parts = {}
|
||||
if src then tinsert(parts, src) end
|
||||
|
||||
@@ -123,6 +123,9 @@ end
|
||||
---@param key string @"m_<npcId>" | "o_<objectId>" | "i_<itemId>"
|
||||
local function _GetTooltipSourceLine(key)
|
||||
if not Questie.db.profile.enableTooltipsSource then return nil end
|
||||
-- Source attribution is shown only inside the secondary learner tooltip; never when
|
||||
-- that option is disabled (the only caller is the secondary frame, but gate here too).
|
||||
if Questie.db.profile.learnerTooltipUseSecondary ~= true then return nil end
|
||||
if not key then return nil end
|
||||
local prefix = key:sub(1, 2)
|
||||
local id = tonumber(key:sub(3))
|
||||
@@ -668,6 +671,49 @@ _InitObjectiveTexts = function(objectivesText, objectiveIndex, playerName)
|
||||
return objectivesText
|
||||
end
|
||||
|
||||
-- Apply ElvUI's "Transparent" tooltip look (flat dark background + thin 1px border) so
|
||||
-- Questie's tooltips match the ElvUI style even when ElvUI is not installed. ElvUI uses a
|
||||
-- FLAT texture for both the background and the border with a 1px edge (see
|
||||
-- ElvUI/Core/Toolkit.lua SetTemplate + Settings/Profile.lua:29-31), not the chunky default
|
||||
-- WoW tooltip border.
|
||||
local _ELV_FLAT = "Interface\\ChatFrame\\ChatFrameBackground" -- solid 1x1 texture on 3.3.5
|
||||
local function _ApplyElvUIStyle(frame)
|
||||
if not frame or not frame.SetBackdrop then return end
|
||||
frame:SetBackdrop({
|
||||
bgFile = _ELV_FLAT,
|
||||
edgeFile = _ELV_FLAT,
|
||||
tile = false,
|
||||
tileSize = 0,
|
||||
edgeSize = 1,
|
||||
insets = { left = 0, right = 0, top = 0, bottom = 0 },
|
||||
})
|
||||
frame:SetBackdropColor(0.06, 0.06, 0.06, 0.8) -- ElvUI backdropfadecolor
|
||||
frame:SetBackdropBorderColor(0, 0, 0, 1) -- ElvUI bordercolor (black)
|
||||
end
|
||||
|
||||
-- Skins the standard tooltip frames Questie writes into. No-op when ElvUI is loaded (it
|
||||
-- skins them itself) or when the option is disabled.
|
||||
function QuestieTooltips:SkinDefaultTooltips()
|
||||
if (not Questie.db) or (not Questie.db.profile) or Questie.db.profile.elvuiStyleTooltips == false then return end
|
||||
if IsAddOnLoaded("ElvUI") then return end
|
||||
for _, name in ipairs({ "GameTooltip", "ItemRefTooltip", "ShoppingTooltip1", "ShoppingTooltip2", "WorldMapTooltip" }) do
|
||||
local frame = _G[name]
|
||||
if frame then
|
||||
_ApplyElvUIStyle(frame)
|
||||
-- The default UI re-applies its template backdrop (e.g. item-quality borders) on
|
||||
-- some shows; re-assert our flat look on show so it doesn't revert.
|
||||
if not frame.__questieElvHook then
|
||||
frame.__questieElvHook = true
|
||||
frame:HookScript("OnShow", function(self)
|
||||
if Questie.db.profile.elvuiStyleTooltips ~= false and not IsAddOnLoaded("ElvUI") then
|
||||
_ApplyElvUIStyle(self)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function QuestieTooltips:Initialize()
|
||||
-- For the clicked item frame.
|
||||
ItemRefTooltip:HookScript("OnTooltipSetItem", _QuestieTooltips.AddItemDataToTooltip)
|
||||
@@ -750,6 +796,8 @@ function QuestieTooltips:Initialize()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
QuestieTooltips:SkinDefaultTooltips()
|
||||
end
|
||||
|
||||
return QuestieTooltips
|
||||
|
||||
@@ -329,11 +329,9 @@ 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
|
||||
-- Data-source attribution is rendered by QuestieLearner's secondary tooltip frame
|
||||
-- (only when the secondary learner tooltip is enabled), never inline in the main
|
||||
-- tooltip — see _AddLearnedSpawnTooltipLine.
|
||||
|
||||
local npcNum = tonumber(npcId)
|
||||
if npcNum then
|
||||
@@ -400,11 +398,6 @@ 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;
|
||||
@@ -459,14 +452,6 @@ 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