How to add info to the game tooltips

From ESOUI Wiki

Jump to: navigation, search

This section explains how to add information to the game's tooltips (e.g. item tooltips, skill tooltips).

Important: You cannot change anything at the tooltip texts! Only a few defined String constants (SI_*) can be altered globally and would affect the tooltip texts then, but all other data like skill text, flavour text, icons, data cannot be altered!

You can only append at the bottom, text or controls with charts or icons.


Contents

ZO_Tooltip

The tooltip class of ESO
https://github.com/esoui/esoui/tree/master/esoui/libraries/zo_tooltip


Keyboard mode

Tooltip section explanation

ESOkeyboardTooltip.png
purple = Base game (vanilla) tooltip information (not changable!)
Green = Addon space for custom added tooltip data

Controls

These global control names exist and provide the tooltips for the items, comparison, information (simple text tooltip) etc.

InformationTooltip
ItemTooltip
PopupTooltip
ComparativeTooltip1
ComparativeTooltip2

Hooks

The tooltip's "OnAddGameData" handler can be hooked to add your own addon text/controls after a specified gameData index

ZO_PreHookHandler(PopupTooltip, 'OnAddGameData', tooltipOnAddGameData)

The callback function tooltipOnAddGameData needs the following parameters:

local function tooltipOnAddGameData(tooltipControl, tooltipData)
  --tooltipControl is the control of the tooltip, e.g. PopupTooltip
  --tooltipData is the number of the data added, e.g. TOOLTIP_GAME_DATA_MYTHIC_OR_STOLEN (which currently is the last added to tooltips, so you should add your addon code after this)
  if tooltipData == TOOLTIP_GAME_DATA_MYTHIC_OR_STOLEN then
     ZO_Tooltip_AddDivider(tooltipControl)
     tooltipControl:AddLine("Hello world")
  end
end

Functions

tooltipControl:AddLine(textToAdd) -- Add a line of text to the tooltipControl where tooltipControl will be one of the controls mentioned above
tooltipControl:AddDimensionedControl(control) -- Add a control (which got it's dimensions defined already via control:SetDimensions(width, height) to the tooltip
->And others of ZO_Tooltip class




Gamepad mode

Tooltip section explanation

ESOGamepadTooltip.png red = gamepadParametricScrollList
Green = GAMEPAD_LEFT_TOOLTIP
blue = GAMEPAD_RIGHT_TOOLTIP

Hooks

Depending on what menu you are in that you want info added to, you just need to find the layout function used for the tooltip.
I search "GAMEPAD_TOOLTIPS:Layout"
for example in trading house browser
GAMEPAD_TOOLTIPS:LayoutGuildStoreSearchResult(
and post hook it to add to bottom.

Then the trick will be to build a custom layout function to call from the hook.



local function DoTheThing(self, tooltipStyle)
  local scenes = {
    ['gamepad_inventory_root'] = true,
    ['gamepad_trading_house'] = true,
  }
  
  local currentScene = SCENE_MANAGER:GetCurrentSceneName()
  if not scenes[currentScene] then return end
  
  local currentTooltip = GAMEPAD_TOOLTIPS:GetTooltip(tooltipStyle)
  if not currentTooltip then return end
  
  local currentBodySection = currentTooltip:GetStyle("bodySection")
  local currentBodyDescription = currentTooltip:GetStyle("bodyDescription")
  local currentDividerLine = currentTooltip:GetStyle("dividerLine")
  local currentSection = currentTooltip:AcquireSection(currentBodySection)
  
  currentSection:AddTexture(ZO_GAMEPAD_HEADER_DIVIDER_TEXTURE, currentDividerLine)
  currentSection:AddLine("My Test String", currentBodyDescription)
  currentTooltip:AddSection(currentSection)
end

-- guildstore
SecurePostHook(GAMEPAD_TOOLTIPS, 'LayoutGuildStoreSearchResult', function(self, tooltipStyle)
	DoTheThing(self, tooltipStyle)
end)



One thing to be careful of is what type of item data parameter is used in each function. bag, slot or itemLink.

GAMEPAD_TOOLTIPS:LayoutBagItem -- params bagId, slotIndex
GAMEPAD_TOOLTIPS:LayoutItem -- first param itemLink
GAMEPAD_TOOLTIPS:LayoutGuildStoreSearchResult -- first param itemLink

Inventory is just using GAMEPAD_TOOLTIPS:LayoutBagItem unless it's a quest item.

Functions

All needed functions are available in ZO_Tooltip class.
One needs to append a custom SetLayout function to gamepad's tooltip and build it based off of other SetLayout functions in ZO_Tooltip.
tooltip:SetLayoutCustomSomethingOrOther(params)
The original tooltip data is populated, then custom data is appended to the end.

A tooltip layout is just a collection of data entry calls to insert data into specific elements. To get those elements, format and finalize them.
It's to simplify using them. Just send params or a table and they do the work.
When a tooltip is created, it is fed a table of layouts. Or uses the defaults. Since they generally use the default table one can append their own
layouts to it to use in custom layout functions, or just use any of the original ones.

ZO_TOOLTIP_STYLES

You can add multiple sections and, multiple lines pre section. all can have different layouts using GetStyle.
Although, if you want custom styles, you need to add them to ZO_TOOLTIP_STYLES
can add textures: icons, dividing lines, ect

Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox