GetItemCount via C_Item, reagents via C_Spell.GetSpellReagents

Drops the legacy pfUI.api.GetItemCount wrapper (name-based bag walk +
GetItemInfo per slot) entirely — both call sites switch to direct
C_Item.GetItemCount(itemID) calls.

actionbar reagent counter: drops the SPELL_REAGENTS tooltip-scan +
libtipscan dependency. UpdateSlot now does GetActionInfo(slot) →
spellID → C_Spell.GetSpellReagents → reagent itemID, stored per slot.
Counts update via C_Item.GetItemCount(itemID). reagent_counts is
keyed by itemID instead of localized name string. Multi-reagent
spells now resolve cleanly (only first reagent counted, matching old
single-name behavior). Macro and bag-item actions skip cleanly.

questitem: switches to hooksecurefunc("SetItemRef", ...) + the
modern GameTooltip:HasItem / :GetItem pair instead of monkey-patching
_G.SetItemRef and string.find-parsing the "item:NNN" out of the link.
Drops the libtooltip indirection for the regular tooltip path —
GameTooltip:GetItem returns name + itemID directly. AddTooltip
extended to accept the itemID (both callers already had it and were
discarding it).
This commit is contained in:
Brues
2026-05-21 16:20:19 -05:00
parent 1012a67865
commit 8e635afeed
3 changed files with 41 additions and 68 deletions
+19 -18
View File
@@ -2,7 +2,7 @@ pfUI:RegisterModule("questitem", function ()
local questlog = {}
local itemcache = {}
local function AddTooltip(frame, item)
local function AddTooltip(frame, item, itemID)
-- abort when no item was given
if not item then return end
@@ -54,7 +54,8 @@ pfUI:RegisterModule("questitem", function ()
if C.tooltip.questitem.showcount == "1" and itemcache[item] and itemcache[item] ~= false then
local _, _, required = strfind(string.lower(questlog[itemcache[item]]), "_"..string.lower(item).."_(.-)_")
if required then
quest = string.format("%s |cffaaaaaa[%s/%s]", quest, (GetItemCount(item) or 0), required)
local have = itemID and C_Item.GetItemCount(itemID) or 0
quest = string.format("%s |cffaaaaaa[%s/%s]", quest, have, required)
end
end
@@ -134,25 +135,25 @@ pfUI:RegisterModule("questitem", function ()
pfUI.questitem.run = GetTime() + .5
end
-- add to regular tooltips
pfUI.questitem.tooltip = CreateFrame("Frame", "pfQuestItems", GameTooltip )
-- regular tooltip: catch every Show via a child frame's OnShow, then ask
-- the tooltip directly for the item it's displaying. Replaces a libtooltip
-- indirection that did the same query with extra caching layers.
pfUI.questitem.tooltip = CreateFrame("Frame", "pfQuestItems", GameTooltip)
pfUI.questitem.tooltip:SetScript("OnShow", function()
if libtooltip:GetItemLink() then
local id = libtooltip:GetItemID()
if not id then return end
local name = GetItemInfo(id)
AddTooltip(GameTooltip, name)
if GameTooltip:HasItem() then
local name, _, id = GameTooltip:GetItem()
if name and id then AddTooltip(GameTooltip, name, id) end
end
end)
-- add to itemref tooltips
local HookSetItemRef = SetItemRef
_G.SetItemRef = function(link, text, button)
HookSetItemRef(link, text, button)
local item, _, id = string.find(link, "item:(%d+):.*")
if not IsAltKeyDown() and not IsShiftKeyDown() and not IsControlKeyDown() and item then
local name = GetItemInfo(id)
AddTooltip(ItemRefTooltip, name)
-- itemref tooltip (chat link clicks): hooksecurefunc runs after SetItemRef
-- populates ItemRefTooltip, so we just read the item back out of the tooltip
-- instead of re-parsing the "item:NNN" out of the link string.
hooksecurefunc("SetItemRef", function()
if IsAltKeyDown() or IsShiftKeyDown() or IsControlKeyDown() then return end
if ItemRefTooltip:HasItem() then
local name, _, id = ItemRefTooltip:GetItem()
if name and id then AddTooltip(ItemRefTooltip, name, id) end
end
end
end)
end)