Game.UI.Tooltip.InputHintTooltip
Assembly:
Assembly-CSharp
Namespace:
Game.UI.Tooltip
Type:
public class
Base:
Game.UI.Widgets.Widget
Summary:
InputHintTooltip is a UI widget that provides a localized/input-device-specific "input hint" representation for a ProxyAction. It keeps a cached InputHint object built from the associated ProxyAction and the specified input device (e.g., keyboard, controller). The widget constructs its UI data via InputHintBindings and exposes the hint as a JSON property named "hint" when serialized. The tooltip updates its cache when the action display name changes and signals the UI to refresh.
Fields
-
private const string kInputHint = "hint"
Used as the JSON property name when writing the hint to the IJsonWriter. Keeps the literal key centralized. -
public ProxyAction m_Action
The ProxyAction instance the tooltip represents. Provided at construction and used to build the InputHint contents. -
private InputHintBindings.InputHint m_Hint
Cached InputHint object created and populated from m_Action and m_Device. This is what gets serialized into the "hint" property. -
private InputManager.DeviceType m_Device
The device type (keyboard, controller, etc.) used to collect hint items. Affects how InputHintBindings.CollectHintItems constructs the hint.
Properties
- None declared in this class. (All state is exposed via fields; behavior is provided by methods.)
Constructors
public InputHintTooltip(ProxyAction action, InputManager.DeviceType device)
Constructs the tooltip for the given ProxyAction and device type. It:- assigns m_Action and m_Device,
- sets base.path to action.title + device (used by the widget system to identify the widget),
- calls Refresh() to build the initial hint data.
Methods
public void Refresh()
Rebuilds the cached m_Hint when necessary. The method checks whether m_Hint is null or its name differs from the action's current display name (preferring m_Action.displayOverride?.displayName over m_Action.title). If rebuilding is required:- Creates a new InputHint via InputHintBindings.InputHint.Create(m_Action),
- Calls InputHintBindings.CollectHintItems(m_Hint, m_Action, m_Device, transform) to populate the hint; transform is taken from m_Action.displayOverride?.transform or UIBaseInputAction.Transform.None,
-
Calls SetPropertiesChanged() to notify the UI system that the widget's properties changed and it should re-render/serialize.
-
protected override void WriteProperties(IJsonWriter writer)
Serializes widget properties into the provided IJsonWriter. This implementation: - calls base.WriteProperties(writer) to write base widget properties,
- writes the property name "hint" (kInputHint),
- writes the cached m_Hint object (writer.Write(m_Hint)). The m_Hint object must be serializable by the writer.
Usage Example
// Create a tooltip for an action and a device (e.g., keyboard)
ProxyAction action = /* obtain proxy action */;
var tooltip = new InputHintTooltip(action, InputManager.DeviceType.Keyboard);
// If action's display name or bindings change, refresh to rebuild the hint
tooltip.Refresh();
// When the widget system serializes the widget, WriteProperties will include:
// "hint": { ... } based on the populated InputHintBindings.InputHint
Additional notes: - Dependencies: ProxyAction, InputHintBindings, InputHintBindings.InputHint, InputManager.DeviceType, UIBaseInputAction.Transform, IJsonWriter, and the Widget base class. - The class relies on InputHintBindings to know how to translate a ProxyAction and device into the displayable hint structure.