From 6c3bfeb2c8316ea0bae9bf227f7650998af9cdcd Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Fri, 21 Nov 2025 22:12:34 +0400 Subject: [PATCH] fix: tooltip on main bank item slots --- Core/Tooltip.lua | 34 +++++++++++++++++++++++++++++----- UI/ItemButton.lua | 30 +++++++++++++++--------------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Core/Tooltip.lua b/Core/Tooltip.lua index 533ce93..eeec7c2 100644 --- a/Core/Tooltip.lua +++ b/Core/Tooltip.lua @@ -300,14 +300,38 @@ function Tooltip:Initialize() -- Hook SetBagItem local oldSetBagItem = GameTooltip.SetBagItem + local oldSetInventoryItem = GameTooltip.SetInventoryItem function GameTooltip:SetBagItem(bag, slot) return WithDeferredMoney(self, function() - local ret = oldSetBagItem(self, bag, slot) - local link = GetContainerItemLink(bag, slot) - if link then - Tooltip:AddInventoryInfo(self, link) + -- Handle bank main bag (-1) specially using inventory slots + if bag == -1 then + -- Bank inventory slots are only accessible when bank is open + local bankFrame = getglobal("BankFrame") + if bankFrame and bankFrame:IsVisible() then + -- BankButtonIDToInvSlotID expects 0-based button ID (0-23), slot is 1-based (1-24) + local invSlot = BankButtonIDToInvSlotID(slot) + if invSlot then + -- Use the inventory item method for bank main bag + local ret = oldSetInventoryItem(self, "player", invSlot) + local link = GetInventoryItemLink("player", invSlot) + if link then + Tooltip:AddInventoryInfo(self, link) + end + return ret + end + else + -- Bank is closed - can't access inventory slots, skip tooltip + return nil + end + else + -- Regular bags and bank bags (not main bag) + local ret = oldSetBagItem(self, bag, slot) + local link = GetContainerItemLink(bag, slot) + if link then + Tooltip:AddInventoryInfo(self, link) + end + return ret end - return ret end) end diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index 8a40d69..a1b109b 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -573,23 +573,23 @@ function Guda_ItemButton_OnEnter(self) GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - -- For bank items, use the item link directly since SetBagItem might not work for bank bags - if self.isBank then - if self.bagID == -1 then - local bankSlotId = BankButtonIDToInvSlotID(self.slotID) - addon:Print("BANK MAIN BAG:" .. bankSlotId) - GameTooltip:SetInventoryItem('player', bankSlotId) - elseif self.itemData.link then - local _, _, hyperlink = strfind(self.itemData.link, "|H(.+)|h") - if hyperlink then - GameTooltip:SetHyperlink(hyperlink) - else - GameTooltip:SetBagItem(self.bagID, self.slotID) - end - addon:Print("OTHER BANK BAG") + -- For other characters or read-only mode, use cached item link + if self.otherChar or self.isReadOnly then + if self.itemData and self.itemData.link then + GameTooltip:SetHyperlink(self.itemData.link) + end + -- Special handling for bank main bag when bank might be closed + elseif self.isBank and self.bagID == -1 then + local bankFrame = getglobal("BankFrame") + if bankFrame and bankFrame:IsVisible() then + -- Bank is open - use SetBagItem which will trigger inventory slot handling + GameTooltip:SetBagItem(self.bagID, self.slotID) + elseif self.itemData and self.itemData.link then + -- Bank is closed - use cached link + GameTooltip:SetHyperlink(self.itemData.link) end else - addon:Print("OTHER BAG") + -- For live mode: use SetBagItem for all bags GameTooltip:SetBagItem(self.bagID, self.slotID) end