Building "Tooltips" for Gamepad - ESOUI
Thread Tools Display Modes
11/06/15, 11:43 AM   #1
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,022
Building "Tooltips" for Gamepad

Hello there, still me with this.. [email protected]?# gamepad UI.

So, in keyboard we got this :
  1. ItemTooltip (+ ComparativeTooltip1 / ComparativeTooltip2)
    = Tooltips that comes from hovering an item in bags (bag, worn, bank, etc)

  2. InformationTooltip
    = Base tooltip used almost everywhere to display simple text, map tooltips, etc.

  3. AbilityTooltip
    = Used to display skill tooltips such as one in the K panel or in the ability bar

  4. GameTooltip
    = Almost unused, very few code behind it

  5. PopupTooltip
    = Used by LinkHandlers. they got the property to hide themselves when clicking back on the link, but they also got object properties of other tooltips (like itemtooltip).

  6. SkillTooltip
    = Used to display skill effect other than abilities : ex : AvA passives given by map domination, keep & resources bonuses, champions skills & passives.

  7. KeepUpgradeTooltip
    = AvA Keep Tooltips

Each tooltip got its own methods, properties to help devs to build custom tooltips.

In gamepad, we got ... something else.
There is not really tooltip, but "Information panels" even if the code, there called tooltips. Data is same, but displayed differently. User move with his joystick between pins and info is displayed.

Ex of panels :

Core tooltips :

Consider almost all core InformationTooltip as not displayed.
All thoses little help tooltips are simply.. not displayed fo console users. Some of them are displayed. Map is the best exemple. I found also some info on the C panel, the buffs tooltip is displayed, but that's all.

So How to write a "panel" Gamepad Tooltip ?

ZO_ScrollTooltip_Gamepad is the base. But it's a bit.. empty in functions.

To find list of available tooltips objects, you'll need to find the tooltip object (the CT_TOOLTIP) with the inheritance of ZO_ScrollTooltip_Gamepad and .. virtual is not our friend. there is a lot of potential object and findig them seems obviously hard.

I found 2 tooltips. one by /zgoo a lot, and 1 in the code iself. It was : ZO_MapLocationTooltip_Gamepad

so.. how to do ? For map pins ok, but what about other stuff ?

So, We'll use ZO_GamepadTooltip & ZO_Tooltip

ZO_GamepadTooltip got a nice method :GetTooltip() intended to rewrite the object and append or delete info ? maybe, to check.

ZO_GamepadTooltip:GetTooltip() seems to accept 1 parameter which is :
  • GAMEPAD_LEFT_TOOLTIP = Tooltip displayed at the right of the screen
  • GAMEPAD_RIGHT_TOOLTIP = Tooltip displayed at the left of the screen
  • GAMEPAD_MOVABLE_TOOLTIP = Moveable tooltip (didn't found anyone for now)
  • GAMEPAD_QUAD3_TOOLTIP = Still unknown

Do this and you'll get your object in a variable ?

Then, how to modify the tooltip itself ?

You'll need to use one of the methods of ZO_Tooltip : http://wiki.esoui.com/API#ingame.5Ctooltip

But.. there is no AddLine or LayoutString or LayoutLine.. ?! How to do ?

To get our :AddLine(), you'll need

To work on the trolly object ZO_MapLocationTooltip_Gamepad or get the name of the ****** object (good luck).

Lua Code:
  1. local myTooltip = ZO_MapLocationTooltip_Gamepad
  2. myTooltip:LayoutIconStringLine(myTooltip.tooltip, icon:nilable, textToAdd, styleDefinedIn_ZO_TOOLTIP_STYLES)

ex :

Lua Code:
  1. --tooltip creator
  2. local pinTooltipCreator = {}
  3. pinTooltipCreator.tooltip = 1 --TOOLTIP_MODE.INFORMATION
  4. pinTooltipCreator.creator = function(pin)
  6.     -- some code
  8.     if IsInGamepadPreferredMode() and ZO_MapLocationTooltip_Gamepad
  9.         INFORMATION_TOOLTIP:LayoutIconStringLine(INFORMATION_TOOLTIP.tooltip, icon, text, arrayStyle)
  10.     else
  11.         INFORMATION_TOOLTIP:AddLine(text, arrayStyle)
  12.     end
  14. end
  16. local function OnGamepadPreferredModeChanged()
  17.    if IsInGamepadPreferredMode() then
  18.       INFORMATION_TOOLTIP = ZO_MapLocationTooltip_Gamepad
  19.    else
  20.       INFORMATION_TOOLTIP = InformationTooltip
  21.    end
  22. end
  24. local function OnAddonLoaded()
  26.    --LibMapPin
  27.    LMP:AddPinType(pinTypeString, pinTypeAddCallback, pinTypeOnResizeCallback, pinLayoutData, pinTooltipCreator)
  29.     OnGamepadPreferredModeChanged()
  33. end


Still untested , Don't succeed to make it work.

Get the Style of the Tooltip : For now I didn't found how to get the style of a tooltip. I can guess it, but not get it..

Acquire the tooltip (don't work)

Lua Code:
  1. -- local myTooltip = ZO_GamepadTooltip:GetTooltip(GAMEPAD_LEFT_TOOLTIP)

Acquire the section

Lua Code:
  1. local headerSection = self:AcquireSection(self:GetStyle("myStyle"))

Add line.

Lua Code:
  1. headerSection:AddLine(myText, self:GetStyle("myStyle"))

The list of styles is defined in ZO_TOOLTIP_STYLES (/zgoo ZO_TOOLTIP_STYLES)

well maybe it's a lot of things untested or not really good to do, but it's a start, if you got any tips, come on.
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil
  Reply With Quote
11/06/15, 12:10 PM   #2
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,022
A little screenshot and associated code for map tooltips :

Lua Code:
  1. pinTooltipCreator.creator = function(pin)
  2.     local pinTag = pin.m_PinTag
  3.     local title, icon, known = GetLoreBookInfo(1, pinTag[3], pinTag[4])
  4.     local collection = GetLoreCollectionInfo(1, pinTag[3])
  5.     local moreinfo = {}
  7.     if pinTag[6] then
  8.         table.insert(moreinfo, "[" .. GetString("LBOOKS_MOREINFO", pinTag[6]) .. "]")
  9.     end
  10.     if pinTag[5] then
  11.         table.insert(moreinfo, "[" .. zo_iconFormat(GetAllianceSymbolIcon(pinTag[5]), 24, 24) .. "]")
  12.     end
  13.     if known then
  14.         table.insert(moreinfo, "[" .. GetString(LBOOKS_KNOWN) .. "]")
  15.     end
  17.      if IsInGamepadPreferredMode() and ZO_MapLocationTooltip_Gamepad then
  18.         INFORMATION_TOOLTIP:LayoutIconStringLine(INFORMATION_TOOLTIP.tooltip, nil, zo_strformat(collection), INFORMATION_TOOLTIP.tooltip:GetStyle("mapTitle"))
  19.         INFORMATION_TOOLTIP:LayoutIconStringLine(INFORMATION_TOOLTIP.tooltip, icon, title, INFORMATION_TOOLTIP.tooltip:GetStyle("mapLocationTooltipContent"))
  20.         if #moreinfo > 0 then
  21.             INFORMATION_TOOLTIP:LayoutIconStringLine(INFORMATION_TOOLTIP.tooltip, nil, table.concat(moreinfo, " / "), INFORMATION_TOOLTIP.tooltip:GetStyle("worldMapTooltip"))
  22.         end
  23.     else
  24.         INFORMATION_TOOLTIP:AddLine(text, arrayStyle)
  25.         INFORMATION_TOOLTIP:AddLine(zo_strformat(collection), "ZoFontGameOutline", ZO_SELECTED_TEXT:UnpackRGB())
  26.         ZO_Tooltip_AddDivider(INFORMATION_TOOLTIP)
  27.         INFORMATION_TOOLTIP:AddLine(zo_iconTextFormat(icon, 32, 32, title), "", ZO_HIGHLIGHT_TEXT:UnpackRGB())
  28.         if #moreinfo > 0 then
  29.             INFORMATION_TOOLTIP:AddLine(table.concat(moreinfo, " / "), "", ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB())
  30.         end
  31.     end
  33. end
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil
  Reply With Quote
11/06/15, 01:03 PM   #3
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 519
In addition to Ayantir:
GAMEPAD_TOOLTIPS seems to be the official global name.
:AddLine accepts a dynamic list of styles. A "style" is a table which contains style-values. /zgoo ZO_TOOLTIP_STYLES to see which values are supported. The style-value defined first wins => The priority goes from left to right.
Lua Code:
  1. -- ....
  2. local mystyle = { fontSize = 34, fontColorField = GAMEPAD_TOOLTIP_COLOR_GENERAL_COLOR_1, }
  3. local function AddInfo_Gamepad(tooltip, itemLink)
  4.     if itemLink then
  5.         tooltip:AddLine("Whatever text you want to add", mystyle, tooltip:GetStyle("bodySection"))
  6.     end
  7. end
  9. -- ...
  11. local function TooltipHook_Gamepad(tooltipControl, method, linkFunc)
  12.     local origMethod = tooltipControl[method]
  14.     tooltipControl[method] = function(self, ...)
  15.         origMethod(self, ...)
  16.         AddInfo_Gamepad(self, linkFunc(...))
  17.     end
  18. end
  20. -- This helper function is just there in case the position of the item-link will change
  21. local function ReturnItemLink(itemLink)
  22.     return itemLink
  23. end
  25. local function HookBagTips()
  26. -- ...
  28.     TooltipHook_Gamepad(GAMEPAD_TOOLTIPS:GetTooltip(GAMEPAD_LEFT_TOOLTIP), "LayoutItem", ReturnItemLink)
  29.     TooltipHook_Gamepad(GAMEPAD_TOOLTIPS:GetTooltip(GAMEPAD_RIGHT_TOOLTIP), "LayoutItem", ReturnItemLink)
  30.     TooltipHook_Gamepad(GAMEPAD_TOOLTIPS:GetTooltip(GAMEPAD_MOVABLE_TOOLTIP), "LayoutItem", ReturnItemLink)
  31. end
  32. --...
The first parameter of :LayoutItem is an item-link. You have to adapt the TooltipHook_Gamepad to your needs. It's just an example to start with.
@votan73 (EU - megaserver)

Last edited by votan : 11/06/15 at 01:48 PM.
  Reply With Quote
11/07/15, 09:58 AM   #4
Posts: n/a
Maybe (just maybe) it is this one : when at a crafting station, it displays on the principle left colunm like an expanded info under the selected item name (doesn't display in a new panel).
not very clear, but just check a station. That one is almost /zgoo mousable btw. could help understanding others.
  Reply With Quote

ESOUI » Developer Discussions » Tutorials & Other Helpful Info » Building "Tooltips" for Gamepad

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off