mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 15:46:56 +00:00
d27db55abf
sellvalue.lua: SetItemRef hook follows the same pattern questitem.lua got earlier — replaces the local-Hook + _G.SetItemRef monkey-patch with hooksecurefunc, drops the string.find link-parser, and reads itemID directly from ItemRefTooltip:GetItem after the original populates the tooltip. The OnShow path also moves from libtooltip:GetItemLink/GetItemID to GameTooltip:HasItem/GetItem (libtooltip:GetItemCount stays — it's populated by libtooltip's own SetBagItem hook and carries the stack count, which GetItem doesn't return). unusable.lua: the two post-hooks (pfUI.bag.UpdateSlot and BankFrameItemButton_UpdateLock) are textbook hooksecurefunc cases — both ran the original then did extra work, no conditional skip or return-value tampering. The table form of hooksecurefunc handles pfUI.bag.UpdateSlot cleanly.
50 lines
1.7 KiB
Lua
50 lines
1.7 KiB
Lua
pfUI:RegisterModule("sellvalue", "vanilla:tbc", function ()
|
|
local function AddVendorPrices(frame, id, count)
|
|
if pfSellData[id] then
|
|
local _, _, sell, buy = strfind(pfSellData[id], "(.*),(.*)")
|
|
sell = tonumber(sell)
|
|
buy = tonumber(buy)
|
|
|
|
if not MerchantFrame:IsShown() then
|
|
if sell > 0 then SetTooltipMoney(frame, sell * count) end
|
|
end
|
|
|
|
if IsShiftKeyDown() or C.tooltip.vendor.showalways == "1" then
|
|
frame:AddLine(" ")
|
|
|
|
if count > 1 then
|
|
frame:AddDoubleLine(T["Sell"] .. ":", CreateGoldString(sell) .. "|cff555555 // " .. CreateGoldString(sell*count), 1, 1, 1)
|
|
else
|
|
frame:AddDoubleLine(T["Sell"] .. ":", CreateGoldString(sell * count), 1, 1, 1)
|
|
end
|
|
|
|
if count > 1 then
|
|
frame:AddDoubleLine(T["Buy"] .. ":", CreateGoldString(buy) .. "|cff555555 // " .. CreateGoldString(buy*count), 1, 1, 1)
|
|
else
|
|
frame:AddDoubleLine(T["Buy"] .. ":", CreateGoldString(buy), 1, 1, 1)
|
|
end
|
|
end
|
|
frame:Show()
|
|
end
|
|
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)
|
|
|
|
hooksecurefunc("SetItemRef", function()
|
|
if IsAltKeyDown() or IsShiftKeyDown() or IsControlKeyDown() then return end
|
|
if ItemRefTooltip:HasItem() then
|
|
local _, _, id = ItemRefTooltip:GetItem()
|
|
if id then AddVendorPrices(ItemRefTooltip, id, 1) end
|
|
end
|
|
end)
|
|
end)
|