From 80b87e067249ae027a17d35a4bdf46f6756de6ef Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Fri, 21 Nov 2025 23:13:32 +0400 Subject: [PATCH] fix: tooltip on bank view --- Core/Tooltip.lua | 65 ++++++++++++++++++++++++++++++----------------- UI/ItemButton.lua | 4 ++- 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/Core/Tooltip.lua b/Core/Tooltip.lua index eeec7c2..a0704d4 100644 --- a/Core/Tooltip.lua +++ b/Core/Tooltip.lua @@ -301,36 +301,53 @@ function Tooltip:Initialize() -- Hook SetBagItem local oldSetBagItem = GameTooltip.SetBagItem local oldSetInventoryItem = GameTooltip.SetInventoryItem + local oldSetHyperlink = GameTooltip.SetHyperlink function GameTooltip:SetBagItem(bag, slot) return WithDeferredMoney(self, function() - -- 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 + local bankFrame = getglobal("BankFrame") + + if bag == -1 and bankFrame and bankFrame:IsVisible() then + addon:Print('BANK FRAME:') + 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 - else - -- Bank is closed - can't access inventory slots, skip tooltip - return nil + return ret 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) + -- Bank is closed or readonly mode - try to get cached link + if bag == -1 then + -- Get cached link from database for main bank bag + local playerName = addon.Modules.DB:GetPlayerFullName() + local bankData = addon.Modules.DB:GetCharacterBank(playerName) + if bankData and bankData[-1] and bankData[-1].slots and bankData[-1].slots[slot] then + local itemData = bankData[-1].slots[slot] + if itemData.link and string.find(itemData.link, "|H") then + -- Extract hyperlink from full colored string: |cFFFFFFFF|Hitem:...|h[Name]|h|r + -- SetHyperlink needs just the item:... part + local _, _, hyperlink = string.find(itemData.link, "|H(.+)|h") + if hyperlink then + local ret = oldSetHyperlink(self, hyperlink) + Tooltip:AddInventoryInfo(self, itemData.link) + return ret + end + end + end + -- No cached data found + return nil + else + -- Regular bags and bank bags (not main bag) - use normal SetBagItem + 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) end diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index a1b109b..0bbc51d 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -575,7 +575,9 @@ function Guda_ItemButton_OnEnter(self) -- 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 + if self.bagID == -1 then + GameTooltip:SetBagItem(self.bagID, self.slotID) + elseif self.itemData and self.itemData.link then GameTooltip:SetHyperlink(self.itemData.link) end -- Special handling for bank main bag when bank might be closed