mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 07:36:56 +00:00
6936fd894b
The libtipscan approach scanned each bag/bank item's tooltip for red text, then had to carve out broken (0-durability) items since those also color red. C_PlayerInfo.CanUseItem checks item requirements directly (proficiency, level, class/race, skill/spell/rep) and ignores item state, so broken-but-equippable gear is never flagged and the durability exclusion drops out entirely. Bank slots resolve through C_Container.GetContainerItemID(-1, slot) instead of the inventory-slot workaround the scanner needed.
38 lines
1.3 KiB
Lua
38 lines
1.3 KiB
Lua
pfUI:RegisterModule("unusable", function ()
|
|
if not pfUI.bag then return end
|
|
if C.appearance.bags.unusable ~= "1" then return end
|
|
|
|
pfUI.unusable = {}
|
|
|
|
local r, g, b, a = strsplit(",", C.appearance.bags.unusable_color)
|
|
|
|
function pfUI.unusable:UpdateSlot(bag, slot)
|
|
-- break on invalid bag slots
|
|
if not pfUI.bags[bag] then return end
|
|
if not pfUI.bags[bag].slots[slot] then return end
|
|
|
|
-- return on empty buttons
|
|
local frame = pfUI.bags[bag].slots[slot].frame
|
|
if not frame.hasItem then return end
|
|
|
|
-- C_PlayerInfo.CanUseItem is the "is this red in the tooltip" gate:
|
|
-- proficiency, required level, class/race, skill/spell/rep. It checks
|
|
-- *requirements* only, so a broken (0-durability) item still reads as
|
|
-- usable -- no durability-line exclusion needed like the old scanner.
|
|
local itemID = C_Container.GetContainerItemID(bag, slot)
|
|
if itemID and not C_PlayerInfo.CanUseItem(itemID) then
|
|
_G.SetItemButtonTextureVertexColor(frame, r, g, b, a)
|
|
end
|
|
end
|
|
|
|
-- update on regular pfUI button updates
|
|
hooksecurefunc(pfUI.bag, "UpdateSlot", function(self, bag, slot)
|
|
pfUI.unusable:UpdateSlot(bag, slot)
|
|
end)
|
|
|
|
-- update on bank frame itemlock updates
|
|
hooksecurefunc("BankFrameItemButton_UpdateLock", function()
|
|
pfUI.unusable:UpdateSlot(-1, this:GetID())
|
|
end)
|
|
end)
|