From acab272ec0543d1eef01e2ea183663cfe39779e6 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 9 Jul 2026 22:05:25 -0500 Subject: [PATCH] Generalize vendor price display across all tooltip types Replace the single GameTooltip hook with a comprehensive hooking system that displays vendor prices across 17+ tooltip methods, including loot, quests, bags, mail, auctions, trades, merchants, and crafting. This ensures players see vendor prices consistently regardless of where they view items. --- modules/sellvalue.lua | 149 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 14 deletions(-) diff --git a/modules/sellvalue.lua b/modules/sellvalue.lua index a51968ad..e87ea803 100644 --- a/modules/sellvalue.lua +++ b/modules/sellvalue.lua @@ -1,13 +1,11 @@ pfUI:RegisterModule("sellvalue", function () local function AddVendorPrices(frame, id, count) if not id then return end - -- Sell price comes from the engine (item DBC); buy price from pfSellData - -- (curated vendor data, since vendor purchase prices aren't a static field). local sell = C_Item.GetItemSellPriceByID(id) or 0 local buy = pfSellData[id] if sell == 0 and not buy then return end - if C.tooltip.vendor.showalways == "1" or IsShiftKeyDown() then + if C.tooltip.vendor.showalways == "1" or IsShiftKeyDown() then frame:AddLine(" ") if sell > 0 then @@ -29,17 +27,6 @@ pfUI:RegisterModule("sellvalue", function () frame:Show() end - pfUI.sellvalue = CreateFrame("Frame", "pfGameTooltip", GameTooltip) - pfUI.sellvalue:SetScript("OnShow", function() - if GameTooltip:HasItem() then - local _, _, id = GameTooltip:GetItem() - if id then - local count = tonumber(libtooltip:GetItemCount()) or 1 - AddVendorPrices(GameTooltip, id, math.max(count, 1)) - end - end - end) - pfUI.hooksecurefunc("SetItemRef", function() if IsModifierKeyDown() then return end if ItemRefTooltip:HasItem() then @@ -47,4 +34,138 @@ pfUI:RegisterModule("sellvalue", function () if id then AddVendorPrices(ItemRefTooltip, id, 1) end end end) + + local TooltipHooks = { + SetLootRollItem = { + id = GetLootRollItemID, + count = function(slot) + local _, _, count = GetLootRollItemInfo(slot) + return count + end + }, + SetLootItem = { + id = GetLootSlotItemID, + count = function(slot) + local _, _, count = GetLootSlotInfo(slot) + return count + end + }, + SetQuestLogItem = { + id = GetQuestLogItemID, + count = function(type, index) + local itemCount, _; + if type == "choice" then + _, _, itemCount = GetQuestLogChoiceInfo(index); + else + _, _, itemCount = GetQuestLogRewardInfo(index) + end + return itemCount + end, + }, + SetQuestItem = { + id = GetQuestItemID, + count = function(type, index) + local _, _, count = GetQuestItemInfo(type, index); + return count + end, + }, + SetHyperlink = { id = C_Item.GetItemInfoInstant }, + SetBagItem = { + id = C_Container.GetContainerItemID, + count = function(container, slot) + local _, count = GetContainerItemInfo(container, slot) + return count + end, + }, + SetInboxItem = { + id = GetInboxItemID, + count = function(index) + local _, _, _, count = GetInboxItem(index) + return count + end, + }, + SetSendMailItem = { + id = function() + local _, id = GetSendMailItemLink() + return id + end, + count = function() + local _, _, count = GetSendMailItem() + return count + end, + }, + SetInventoryItem = { id = GetInventoryItemID }, + SetTradeSkillItem = { + id = function(skillIndex, reagentIndex) + if reagentIndex then + return GetTradeSkillReagentItemID(skillIndex, reagentIndex) + else + return GetTradeSkillItemID(skillIndex) + end + end, + count = function(skillIndex, reagentIndex) + if reagentIndex then + local _, _, itemCount = GetTradeSkillReagentInfo(skillIndex, reagentIndex) + return itemCount + else + return GetTradeSkillNumMade(skillIndex) + end + end, + }, + SetAuctionItem = { + id = GetAuctionItemLink, + count = function(viewType, index) + local _, _, count = GetAuctionItemInfo(viewType, index) + return count + end, + }, + SetAuctionSellItem = { id = GetAuctionSellItemLink }, + SetTradePlayerItem = { + id = GetTradePlayerItemLink, + count = function(id) + local _, _, count = GetTradePlayerItemInfo(id) + return count + end, + }, + SetTradeTargetItem = { + id = GetTradeTargetItemLink, + count = function(id) + local _, _, count = GetTradeTargetItemInfo(id) + return count + end, + }, + SetMerchantItem = { + id = GetMerchantItemID, + count = function(index) + local _, _, _, itemCount = GetMerchantItemInfo(index) + return itemCount + end + }, + SetCraftItem = { + id = function(recipeIndex, reagentIndex) + return GetCraftReagentItemID(recipeIndex, reagentIndex) + end + }, + SetBuybackItem = { + id = C_MerchantFrame.GetBuybackItemID, + count = function(slotIndex) + local _, _, _, itemCount = GetBuybackItemInfo(slotIndex) + return itemCount + end + } + } + + local function makeHook(entry) + return function(tooltip, arg1, arg2, arg3) + AddVendorPrices(tooltip, entry.id(arg1, arg2, arg3), entry.count and entry.count(arg1, arg2, arg3) or 1) + end + end + + local function HookTooltip(tooltip) + for setter, entry in pairs(TooltipHooks) do + pfUI.hooksecurefunc(tooltip, setter, makeHook(entry)) + end + end + + HookTooltip(GameTooltip) end)