fix: tooltip on main bank item slots
This commit is contained in:
+29
-5
@@ -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
|
||||
|
||||
|
||||
+15
-15
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user