fix: tooltip on main bank item slots
This commit is contained in:
+29
-5
@@ -300,14 +300,38 @@ function Tooltip:Initialize()
|
|||||||
|
|
||||||
-- Hook SetBagItem
|
-- Hook SetBagItem
|
||||||
local oldSetBagItem = GameTooltip.SetBagItem
|
local oldSetBagItem = GameTooltip.SetBagItem
|
||||||
|
local oldSetInventoryItem = GameTooltip.SetInventoryItem
|
||||||
function GameTooltip:SetBagItem(bag, slot)
|
function GameTooltip:SetBagItem(bag, slot)
|
||||||
return WithDeferredMoney(self, function()
|
return WithDeferredMoney(self, function()
|
||||||
local ret = oldSetBagItem(self, bag, slot)
|
-- Handle bank main bag (-1) specially using inventory slots
|
||||||
local link = GetContainerItemLink(bag, slot)
|
if bag == -1 then
|
||||||
if link then
|
-- Bank inventory slots are only accessible when bank is open
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
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
|
end
|
||||||
return ret
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+15
-15
@@ -573,23 +573,23 @@ function Guda_ItemButton_OnEnter(self)
|
|||||||
|
|
||||||
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
||||||
|
|
||||||
-- For bank items, use the item link directly since SetBagItem might not work for bank bags
|
-- For other characters or read-only mode, use cached item link
|
||||||
if self.isBank then
|
if self.otherChar or self.isReadOnly then
|
||||||
if self.bagID == -1 then
|
if self.itemData and self.itemData.link then
|
||||||
local bankSlotId = BankButtonIDToInvSlotID(self.slotID)
|
GameTooltip:SetHyperlink(self.itemData.link)
|
||||||
addon:Print("BANK MAIN BAG:" .. bankSlotId)
|
end
|
||||||
GameTooltip:SetInventoryItem('player', bankSlotId)
|
-- Special handling for bank main bag when bank might be closed
|
||||||
elseif self.itemData.link then
|
elseif self.isBank and self.bagID == -1 then
|
||||||
local _, _, hyperlink = strfind(self.itemData.link, "|H(.+)|h")
|
local bankFrame = getglobal("BankFrame")
|
||||||
if hyperlink then
|
if bankFrame and bankFrame:IsVisible() then
|
||||||
GameTooltip:SetHyperlink(hyperlink)
|
-- Bank is open - use SetBagItem which will trigger inventory slot handling
|
||||||
else
|
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
||||||
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
elseif self.itemData and self.itemData.link then
|
||||||
end
|
-- Bank is closed - use cached link
|
||||||
addon:Print("OTHER BANK BAG")
|
GameTooltip:SetHyperlink(self.itemData.link)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
addon:Print("OTHER BAG")
|
-- For live mode: use SetBagItem for all bags
|
||||||
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user