fix: tooltip on bank view
This commit is contained in:
+41
-24
@@ -301,36 +301,53 @@ function Tooltip:Initialize()
|
|||||||
-- Hook SetBagItem
|
-- Hook SetBagItem
|
||||||
local oldSetBagItem = GameTooltip.SetBagItem
|
local oldSetBagItem = GameTooltip.SetBagItem
|
||||||
local oldSetInventoryItem = GameTooltip.SetInventoryItem
|
local oldSetInventoryItem = GameTooltip.SetInventoryItem
|
||||||
|
local oldSetHyperlink = GameTooltip.SetHyperlink
|
||||||
function GameTooltip:SetBagItem(bag, slot)
|
function GameTooltip:SetBagItem(bag, slot)
|
||||||
return WithDeferredMoney(self, function()
|
return WithDeferredMoney(self, function()
|
||||||
-- Handle bank main bag (-1) specially using inventory slots
|
local bankFrame = getglobal("BankFrame")
|
||||||
if bag == -1 then
|
|
||||||
-- Bank inventory slots are only accessible when bank is open
|
if bag == -1 and bankFrame and bankFrame:IsVisible() then
|
||||||
local bankFrame = getglobal("BankFrame")
|
addon:Print('BANK FRAME:')
|
||||||
if bankFrame and bankFrame:IsVisible() then
|
local invSlot = BankButtonIDToInvSlotID(slot)
|
||||||
-- BankButtonIDToInvSlotID expects 0-based button ID (0-23), slot is 1-based (1-24)
|
if invSlot then
|
||||||
local invSlot = BankButtonIDToInvSlotID(slot)
|
-- Use the inventory item method for bank main bag
|
||||||
if invSlot then
|
local ret = oldSetInventoryItem(self, "player", invSlot)
|
||||||
-- Use the inventory item method for bank main bag
|
local link = GetInventoryItemLink("player", invSlot)
|
||||||
local ret = oldSetInventoryItem(self, "player", invSlot)
|
if link then
|
||||||
local link = GetInventoryItemLink("player", invSlot)
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
if link then
|
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
else
|
return ret
|
||||||
-- Bank is closed - can't access inventory slots, skip tooltip
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Regular bags and bank bags (not main bag)
|
-- Bank is closed or readonly mode - try to get cached link
|
||||||
local ret = oldSetBagItem(self, bag, slot)
|
if bag == -1 then
|
||||||
local link = GetContainerItemLink(bag, slot)
|
-- Get cached link from database for main bank bag
|
||||||
if link then
|
local playerName = addon.Modules.DB:GetPlayerFullName()
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
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
|
end
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-1
@@ -575,7 +575,9 @@ function Guda_ItemButton_OnEnter(self)
|
|||||||
|
|
||||||
-- For other characters or read-only mode, use cached item link
|
-- For other characters or read-only mode, use cached item link
|
||||||
if self.otherChar or self.isReadOnly then
|
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)
|
GameTooltip:SetHyperlink(self.itemData.link)
|
||||||
end
|
end
|
||||||
-- Special handling for bank main bag when bank might be closed
|
-- Special handling for bank main bag when bank might be closed
|
||||||
|
|||||||
Reference in New Issue
Block a user