inventory above money
This commit is contained in:
+156
-99
@@ -127,184 +127,241 @@ end
|
|||||||
function Tooltip:Initialize()
|
function Tooltip:Initialize()
|
||||||
addon:Print("Initializing tooltip module...")
|
addon:Print("Initializing tooltip module...")
|
||||||
|
|
||||||
|
-- Helper function to defer vendor money so we can insert our Inventory block above it
|
||||||
|
local Orig_SetTooltipMoney = SetTooltipMoney
|
||||||
|
local function WithDeferredMoney(tooltip, buildFunc)
|
||||||
|
local queue = {}
|
||||||
|
-- Temporarily override global SetTooltipMoney
|
||||||
|
SetTooltipMoney = function(frame, money, a1, a2, a3, a4, a5)
|
||||||
|
if frame == tooltip then
|
||||||
|
tinsert(queue, {frame, money, a1, a2, a3, a4, a5})
|
||||||
|
else
|
||||||
|
Orig_SetTooltipMoney(frame, money, a1, a2, a3, a4, a5)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Perform the original population + our Inventory augmentation
|
||||||
|
local ret = buildFunc()
|
||||||
|
|
||||||
|
-- Restore and flush queued money so it appears after our Inventory block
|
||||||
|
SetTooltipMoney = Orig_SetTooltipMoney
|
||||||
|
for i = 1, getn(queue) do
|
||||||
|
local q = queue[i]
|
||||||
|
Orig_SetTooltipMoney(q[1], q[2], q[3], q[4], q[5], q[6], q[7])
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
-- Hook SetBagItem
|
-- Hook SetBagItem
|
||||||
local oldSetBagItem = GameTooltip.SetBagItem
|
local oldSetBagItem = GameTooltip.SetBagItem
|
||||||
function GameTooltip:SetBagItem(bag, slot)
|
function GameTooltip:SetBagItem(bag, slot)
|
||||||
local ret = oldSetBagItem(self, bag, slot)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetContainerItemLink(bag, slot)
|
local ret = oldSetBagItem(self, bag, slot)
|
||||||
if link then
|
local link = GetContainerItemLink(bag, slot)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetHyperlink for chat links
|
-- Hook SetHyperlink for chat links
|
||||||
local oldSetHyperlink = GameTooltip.SetHyperlink
|
local oldSetHyperlink = GameTooltip.SetHyperlink
|
||||||
function GameTooltip:SetHyperlink(link)
|
function GameTooltip:SetHyperlink(link)
|
||||||
local ret = oldSetHyperlink(self, link)
|
return WithDeferredMoney(self, function()
|
||||||
if link and strfind(link, "item:") then
|
local ret = oldSetHyperlink(self, link)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link and strfind(link, "item:") then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetInventoryItem for character paperdoll
|
-- Hook SetInventoryItem for character paperdoll
|
||||||
local oldSetInventoryItem = GameTooltip.SetInventoryItem
|
local oldSetInventoryItem = GameTooltip.SetInventoryItem
|
||||||
function GameTooltip:SetInventoryItem(unit, slot)
|
function GameTooltip:SetInventoryItem(unit, slot)
|
||||||
local ret = oldSetInventoryItem(self, unit, slot)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetInventoryItemLink(unit, slot)
|
local ret = oldSetInventoryItem(self, unit, slot)
|
||||||
if link then
|
local link = GetInventoryItemLink(unit, slot)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetLootItem for loot windows
|
-- Hook SetLootItem for loot windows
|
||||||
local oldSetLootItem = GameTooltip.SetLootItem
|
local oldSetLootItem = GameTooltip.SetLootItem
|
||||||
function GameTooltip:SetLootItem(slot)
|
function GameTooltip:SetLootItem(slot)
|
||||||
local ret = oldSetLootItem(self, slot)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetLootSlotLink(slot)
|
local ret = oldSetLootItem(self, slot)
|
||||||
if link then
|
local link = GetLootSlotLink(slot)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetQuestItem for quest rewards
|
-- Hook SetQuestItem for quest rewards
|
||||||
local oldSetQuestItem = GameTooltip.SetQuestItem
|
local oldSetQuestItem = GameTooltip.SetQuestItem
|
||||||
function GameTooltip:SetQuestItem(itemType, index)
|
function GameTooltip:SetQuestItem(itemType, index)
|
||||||
local ret = oldSetQuestItem(self, itemType, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetQuestItemLink(itemType, index)
|
local ret = oldSetQuestItem(self, itemType, index)
|
||||||
if link then
|
local link = GetQuestItemLink(itemType, index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetQuestLogItem for quest log items
|
-- Hook SetQuestLogItem for quest log items
|
||||||
local oldSetQuestLogItem = GameTooltip.SetQuestLogItem
|
local oldSetQuestLogItem = GameTooltip.SetQuestLogItem
|
||||||
function GameTooltip:SetQuestLogItem(itemType, index)
|
function GameTooltip:SetQuestLogItem(itemType, index)
|
||||||
local ret = oldSetQuestLogItem(self, itemType, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetQuestLogItemLink(itemType, index)
|
local ret = oldSetQuestLogItem(self, itemType, index)
|
||||||
if link then
|
local link = GetQuestLogItemLink(itemType, index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetTradeSkillItem for tradeskill windows
|
-- Hook SetTradeSkillItem for tradeskill windows
|
||||||
local oldSetTradeSkillItem = GameTooltip.SetTradeSkillItem
|
local oldSetTradeSkillItem = GameTooltip.SetTradeSkillItem
|
||||||
function GameTooltip:SetTradeSkillItem(skillIndex, reagentIndex)
|
function GameTooltip:SetTradeSkillItem(skillIndex, reagentIndex)
|
||||||
local ret = oldSetTradeSkillItem(self, skillIndex, reagentIndex)
|
return WithDeferredMoney(self, function()
|
||||||
local link
|
local ret = oldSetTradeSkillItem(self, skillIndex, reagentIndex)
|
||||||
if reagentIndex then
|
local link
|
||||||
link = GetTradeSkillReagentItemLink(skillIndex, reagentIndex)
|
if reagentIndex then
|
||||||
else
|
link = GetTradeSkillReagentItemLink(skillIndex, reagentIndex)
|
||||||
link = GetTradeSkillItemLink(skillIndex)
|
else
|
||||||
end
|
link = GetTradeSkillItemLink(skillIndex)
|
||||||
if link then
|
end
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetCraftItem for craft windows
|
-- Hook SetCraftItem for craft windows
|
||||||
local oldSetCraftItem = GameTooltip.SetCraftItem
|
local oldSetCraftItem = GameTooltip.SetCraftItem
|
||||||
function GameTooltip:SetCraftItem(skillIndex, reagentIndex)
|
function GameTooltip:SetCraftItem(skillIndex, reagentIndex)
|
||||||
local ret = oldSetCraftItem(self, skillIndex, reagentIndex)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetCraftReagentItemLink(skillIndex, reagentIndex)
|
local ret = oldSetCraftItem(self, skillIndex, reagentIndex)
|
||||||
if link then
|
local link = GetCraftReagentItemLink(skillIndex, reagentIndex)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetAuctionItem for auction house
|
-- Hook SetAuctionItem for auction house
|
||||||
local oldSetAuctionItem = GameTooltip.SetAuctionItem
|
local oldSetAuctionItem = GameTooltip.SetAuctionItem
|
||||||
function GameTooltip:SetAuctionItem(type, index)
|
function GameTooltip:SetAuctionItem(type, index)
|
||||||
local ret = oldSetAuctionItem(self, type, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetAuctionItemLink(type, index)
|
local ret = oldSetAuctionItem(self, type, index)
|
||||||
if link then
|
local link = GetAuctionItemLink(type, index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetInboxItem for mail
|
-- Hook SetInboxItem for mail
|
||||||
local oldSetInboxItem = GameTooltip.SetInboxItem
|
local oldSetInboxItem = GameTooltip.SetInboxItem
|
||||||
function GameTooltip:SetInboxItem(index)
|
function GameTooltip:SetInboxItem(index)
|
||||||
local ret = oldSetInboxItem(self, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetInboxItemLink(index)
|
local ret = oldSetInboxItem(self, index)
|
||||||
if link then
|
local link = GetInboxItemLink(index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetSendMailItem for sending mail
|
-- Hook SetSendMailItem for sending mail
|
||||||
local oldSetSendMailItem = GameTooltip.SetSendMailItem
|
local oldSetSendMailItem = GameTooltip.SetSendMailItem
|
||||||
function GameTooltip:SetSendMailItem(index)
|
function GameTooltip:SetSendMailItem(index)
|
||||||
local ret = oldSetSendMailItem(self, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetSendMailItemLink(index)
|
local ret = oldSetSendMailItem(self, index)
|
||||||
if link then
|
local link = GetSendMailItemLink(index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetMerchantItem for vendor items
|
-- Hook SetMerchantItem for vendor items
|
||||||
local oldSetMerchantItem = GameTooltip.SetMerchantItem
|
local oldSetMerchantItem = GameTooltip.SetMerchantItem
|
||||||
function GameTooltip:SetMerchantItem(index)
|
function GameTooltip:SetMerchantItem(index)
|
||||||
local ret = oldSetMerchantItem(self, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetMerchantItemLink(index)
|
local ret = oldSetMerchantItem(self, index)
|
||||||
if link then
|
local link = GetMerchantItemLink(index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetBuybackItem for buyback items
|
-- Hook SetBuybackItem for buyback items
|
||||||
local oldSetBuybackItem = GameTooltip.SetBuybackItem
|
local oldSetBuybackItem = GameTooltip.SetBuybackItem
|
||||||
function GameTooltip:SetBuybackItem(index)
|
function GameTooltip:SetBuybackItem(index)
|
||||||
local ret = oldSetBuybackItem(self, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetBuybackItemLink(index)
|
local ret = oldSetBuybackItem(self, index)
|
||||||
if link then
|
local link = GetBuybackItemLink(index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetTradePlayerItem for trade window (player side)
|
-- Hook SetTradePlayerItem for trade window (player side)
|
||||||
local oldSetTradePlayerItem = GameTooltip.SetTradePlayerItem
|
local oldSetTradePlayerItem = GameTooltip.SetTradePlayerItem
|
||||||
function GameTooltip:SetTradePlayerItem(index)
|
function GameTooltip:SetTradePlayerItem(index)
|
||||||
local ret = oldSetTradePlayerItem(self, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetTradePlayerItemLink(index)
|
local ret = oldSetTradePlayerItem(self, index)
|
||||||
if link then
|
local link = GetTradePlayerItemLink(index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetTradeTargetItem for trade window (target side)
|
-- Hook SetTradeTargetItem for trade window (target side)
|
||||||
local oldSetTradeTargetItem = GameTooltip.SetTradeTargetItem
|
local oldSetTradeTargetItem = GameTooltip.SetTradeTargetItem
|
||||||
function GameTooltip:SetTradeTargetItem(index)
|
function GameTooltip:SetTradeTargetItem(index)
|
||||||
local ret = oldSetTradeTargetItem(self, index)
|
return WithDeferredMoney(self, function()
|
||||||
local link = GetTradeTargetItemLink(index)
|
local ret = oldSetTradeTargetItem(self, index)
|
||||||
if link then
|
local link = GetTradeTargetItemLink(index)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Also hook ItemRefTooltip for chat links
|
-- Also hook ItemRefTooltip for chat links
|
||||||
if ItemRefTooltip then
|
if ItemRefTooltip then
|
||||||
local oldItemRefSetHyperlink = ItemRefTooltip.SetHyperlink
|
local oldItemRefSetHyperlink = ItemRefTooltip.SetHyperlink
|
||||||
function ItemRefTooltip:SetHyperlink(link)
|
function ItemRefTooltip:SetHyperlink(link)
|
||||||
local ret = oldItemRefSetHyperlink(self, link)
|
return WithDeferredMoney(self, function()
|
||||||
if link and strfind(link, "item:") then
|
local ret = oldItemRefSetHyperlink(self, link)
|
||||||
Tooltip:AddInventoryInfo(self, link)
|
if link and strfind(link, "item:") then
|
||||||
end
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
return ret
|
end
|
||||||
|
return ret
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user