Here's what I have so far which miraculously solves most of the problems. It is genius that you can just write the name of the function as it would otherwise exist in the code and redefine it. My only issue is the style return from an item link is just a name or number. It's clearly possible from the CharacterKnowledge addon an many others to determine if you have, for example, the nord boots motif, but I am not sure it's possible to do the reverse and go from having nord boots to seeing if you have that motif unlocked. There are a few issues: some motif books just unlock everything at once, which would make those impossible. Clearly, something in the outfit styles collection is already tracking basically everything individually, which I want to access, but don't know how.
Lua Code:
TestAddon = {} -- Initialize addon object
TestAddon.name = "TestAddon" -- Give addon object a reference name
local function TooltipHook(tooltipControl, method, linkFunc)
local origMethod = tooltipControl[method] -- Saves the original method (ex. ItemTooltip[SetBagItem])
tooltipControl[method] = function(self, ...) -- We are now going to rewrite the original method
origMethod(self, ...) -- Let it do what it originally did
if (GetItemLinkItemType(linkFunc(...)) == ITEMTYPE_ARMOR) or (GetItemLinkItemType(linkFunc(...)) == ITEMTYPE_WEAPON) then -- Check if item is armor or a weapon (visual equipment with styles)
local style = GetItemLinkItemStyle(linkFunc(...)) -- Get the item style
self:AddVerticalPadding(20) -- Add some space away from the rest of the tooltip
self:AddLine(GetItemStyleName(style)) -- Write the style name
end
end
end
local function HookBagTips() -- We are going to hook functions into the itemtooltips for most kinds that we want to see.
TooltipHook(ItemTooltip, "SetBagItem", GetItemLink) -- Inventory bags
TooltipHook(ItemTooltip, "SetTradeItem", GetTradeItemLink) -- Trade screens
TooltipHook(ItemTooltip, "SetBuybackItem", GetBuybackItemLink)
TooltipHook(ItemTooltip, "SetStoreItem", GetStoreItemLink) -- Stores, etc.
TooltipHook(ItemTooltip, "SetAttachedMailItem", GetAttachedItemLink)
TooltipHook(ItemTooltip, "SetLootItem", GetLootItemLink) -- Loot, you get the idea
TooltipHook(ItemTooltip, "SetTradingHouseItem", GetTradingHouseSearchResultItemLink)
TooltipHook(ItemTooltip, "SetTradingHouseListing", GetTradingHouseListingItemLink)
TooltipHook(ItemTooltip, "SetLink", ReturnItemLink)
TooltipHook(PopupTooltip, "SetLink", ReturnItemLink)
end
local function OnAddOnLoaded(event, name)
if name ~= TestAddon.name then return end -- If it's not our addon loaded, don't run this. Would get errors.
HookBagTips();
EVENT_MANAGER:UnregisterForEvent(TestAddon.name, event) -- We no longer want this to run as the game loads addons. It only needs to run once.
end
EVENT_MANAGER:RegisterForEvent(TestAddon.name, EVENT_ADD_ON_LOADED, OnAddOnLoaded) -- As the game loads, the event manager registers our addon for an event. It takes the name of the addon, and upon the event of loading the addon, it runs the function "OnAddOnLoaded".)