View Single Post
02/12/23, 08:58 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
ItemTooltip is a control which shows multiple lines of information about items.
It is defined via XMl:

Code:
 <TopLevelControl name="ItemTooltipTopLevel" inherits="TooltipTopLevel">
            <Controls>
                <Tooltip name="ItemTooltip" inherits="ZO_ItemIconTooltip">
                    <OnHide>
                        ComparativeTooltip1:SetHidden(true)
                        ComparativeTooltip2:SetHidden(true)
                    </OnHide>
                </Tooltip>
            </Controls>
        </TopLevelControl>
-> inherits="ZO_ItemIconTooltip"means there does exist another XML control ZO_ItemIconTooltip which was defined as virtual="true" and which builds the base of this control ItemTooltip too. If you search the ESOUI sources for ZO_ItemTooltip you'll find it
<code> <Tooltip name="ZO_ItemIconTooltip" inherits="ItemTooltipBase" virtual="true"></code>
and this inherits from ZO_BaseTooltip again.



The base information is added via functions like he one Votan mentioned, SetBagItem

There also exist others e.g. these which set a quest reward the tooltip as you taln to a quest turn in NPC and move the mouse above the reward item:
Lua Code:
  1. InitializeTooltip(ItemTooltip)
  2.             ItemTooltip:SetQuestReward(control.index)

Here is an example how SetBagitem works, using the bagId (BAG_BACKPACK which is the player inventory e.g., or BAG_BANK, BAG_VIRTUAL for craftbag etc.) and slotIndex (the index of the item in that bagId):
https://github.com/esoui/esoui/blob/...slot.lua#L2128

Lua Code:
  1. local data = ZO_Inventory_GetSlotDataForInventoryControl(inventorySlot)
  2.             if data then
  3.                 local bag, index = ZO_Inventory_GetBagAndIndex(inventorySlot)
  4.                 ItemTooltip:SetBagItem(bag, index)
  5.             end

It reads the dataEntry.data of inventorySlot and checks for the bagId and slotIndex, then sets the tooltip base info via ItemTooltip:SetBagItem.


Votans function is a so called "manual post hook" of that function SetBagItem.
It will save the original function to a local variable
local origMethod = tooltipControl[method]
-->tooltipControl[method] = ItemTooltip["SetBagItem"] or within another notation ItemTooltip.SetBagItem
And then it redefines that method:

tooltipControl[method] = function(self, ...)

In there it calls the original function first:
origMethod(self, ...)

And then it calls the own Votan function AddRuneInfo
AddRuneInfo(self, GetRuneInfoText(linkFunc(...)))
after the original one was called.
-> This function most probably adds some extra text or whatever to the tooltip so check what it does in Votan's code

Basically you can do that using ZOs function SecurePostHook too:

Lua Code:
  1. SecurePostHook(ItemTooltip, "SetBagItem", function(bagId, slotIndex)
  2.  --Do your stuff here to add extra info to the tooltip control ItemTooltip after he SetBagItem function was called.
  3. -- e.g. use a function like ItemTooltip:AddLine if this exists to add extra data
  4.     ItemTooltip:AddLine("Test Text", "ZoFontWinH4", ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB()) --ZoFontWinH4 is the font, the last parameter is the color
  5. end)

Last edited by Baertram : 02/12/23 at 09:04 AM.
  Reply With Quote