ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Hooking ZO_Tooltip:LayoutItem (https://www.esoui.com/forums/showthread.php?t=2257)

mattmillus 09/19/14 01:52 PM

Hooking ZO_Tooltip:LayoutItem
 
I am trying to create a more powerful/graceful way of modifying item tooltips than PreHooking the OnShow and OnUpdate methods (which seems to be what most devs do).

I found this function inside itemtooltips.lua:
function ZO_Tooltip:LayoutItem(itemLink, equipped, creatorName)

This seems to be the perfect place to post-hook in - its the function that branches based on the item type and then draws all of the tooltips rows. However I do not seem to be able to hook the function using the same technique I used for other class functions (such as for hooking GUILD_ROSTER.CompareGuildMembers).

I do:
local origLayoutItem
local function myLayoutItem(self, itemLink, equipped, creatorName) d("HIT") end

and then I tried both:
1)
origLayoutItem = ItemTooltip.LayoutItem
ItemTooltip.LayoutItem = myLayoutItem

and 2)
origLayoutItem = ZO_Tooltip.LayoutItem
ZO_Tooltip.LayoutItem = myLayoutItem

But I cant get my debug to hit. Is this entire function truly not called by the game, or am I doing something wrong with the class object? Could it be a private function or something, how would I tell?

Any help appreciated!

Garkin 09/19/14 02:09 PM

The problem is that even if this method exists, it is never called from within the default UI code, so hooking wont do anything. If you want to modify tooltips, you have to hook methods which are actually used.

mattmillus 09/19/14 02:24 PM

Thanks Garkin!

But how do you know the function isnt used, have you looked at this case in the past? Seems odd that the entire itemtooltips.lua file would be unused, unless its a work in progress for gamepad support or something..?

Is a prehook like follows your preferred method?
ZO_PreHookHandler(ItemTooltip, 'OnShow',function (control) onTooltipShow(control) end)
ZO_PreHookHandler(ItemTooltip, 'OnHide', function (control) onTooltipHide(control) end)

EDIT:
Is the entire ZO_Tooltip class unused? How do I get a handle to objects of this class? It is not the same as the global ItemTooltip control

merlight 09/19/14 02:59 PM

I only found ZO_Tooltip used in
EsoUI/Ingame/Skills/GamepadSkills.lua +404 ZO_Tooltip:Initialize(self.selectedTooltip)
EsoUI/Ingame/Inventory/GamepadInventory.lua +419 ZO_Tooltip:Initialize(self.equippedTooltip)
EsoUI/Ingame/Inventory/GamepadInventory.lua +425 ZO_Tooltip:Initialize(self.selectedTooltip)

Plus, it's not even a "class" in the sense "derived from ZO_Object", it's just a table.
ZO_Tooltip:Initialize(control) mixes ZO_TooltipStyledObject, ZO_TooltipSection, ZO_Tooltip into the control, so rewriting ZO_Tooltip*.* later will have no effect.

ItemTooltip as well as other core tooltip objects have no connection to ZO_Tooltip afaict.

mattmillus 09/19/14 03:15 PM

So I found this thread: http://www.esoui.com/forums/showthread.php?p=10485

And it seems that the entire ZO_Tooltip class wasnt added until 1.3, as its listed under 'new tables' there.

I then used grep to search the entire lua directory structure for "ZO_Tooltip" (with whole word and case filtering on), and the only files that reference this class are gamepadinventory.lua and gamepadskills.lua, so I was actually correct - this class is a work in progress for gamepad support and isnt functional yet. Too bad =(

EDIT: Thanks merlight, didnt see your reply until I had posted! I came to the exact same conclusions!


All times are GMT -6. The time now is 11:15 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI