Skip to content

Game.UI.Tooltip.NotificationTooltip

Assembly:
Game

Namespace:
Game.UI.Tooltip

Type:
class

Base:
Game.UI.Widgets.Widget

Summary:
Represents a tooltip widget used to show notification information (name, severity color and optional verbose flag). The widget exposes public properties for the notification name, color (TooltipColor) and whether to show verbose details. Changing any of these properties triggers SetPropertiesChanged() so the UI system knows to update the rendered widget. The class also provides a helper GetColor method that maps an IconPriority value to a TooltipColor (Info/Warning/Error).


Fields

  • private string m_Name
    Holds the notification text / name shown in the tooltip. Backing field for the public name property.

  • private TooltipColor m_Color
    Backing field for the color property. Represents the visual severity (TooltipColor enum).

  • private bool m_Verbose
    Backing field for the verbose property. When true the tooltip is intended to display additional details.

Properties

  • public string name { get; set }
    Public accessor for the tooltip text. On set, if the value changes it assigns m_Name and calls SetPropertiesChanged() so the widget can update.

  • public TooltipColor color { get; set }
    Public accessor for the tooltip color. On set, if the value changes it assigns m_Color and calls SetPropertiesChanged(). When serialized via WriteProperties the color is written as an int.

  • public bool verbose { get; set }
    Public accessor indicating whether verbose details should be shown. On set, if the value changes it assigns m_Verbose and calls SetPropertiesChanged().

Constructors

  • public NotificationTooltip()
    No explicit constructor is defined in source (implicit parameterless constructor). Default state: m_Name is null, m_Color is default(TooltipColor) and m_Verbose is false. Any initialization should be performed after construction or by subclassing.

Methods

  • protected override void WriteProperties(IJsonWriter writer)
    Writes the widget properties to the provided IJsonWriter. Calls base.WriteProperties(writer) then writes:
  • "name" -> name (string)
  • "color" -> (int)color (TooltipColor serialized as integer)
  • "verbose" -> verbose (bool)

This method is used to serialize the widget state for UI binding/serialization.

  • public static TooltipColor GetColor(IconPriority iconPriority)
    Maps an IconPriority to a TooltipColor using priority thresholds:
  • iconPriority >= 200 -> TooltipColor.Error
  • iconPriority >= 50 -> TooltipColor.Warning
  • otherwise -> TooltipColor.Info

Useful for converting notification icon priority values into the tooltip severity color.

Usage Example

// Create and configure a tooltip
var tip = new Game.UI.Tooltip.NotificationTooltip();
tip.name = "Water shortage";                     // sets m_Name and triggers SetPropertiesChanged()
tip.color = Game.Notifications.TooltipColor.Warning;
tip.verbose = true;

// Or derive color from an icon priority
var color = Game.UI.Tooltip.NotificationTooltip.GetColor(Game.Notifications.IconPriority.Critical);
tip.color = color;

// When the UI system serializes this widget, WriteProperties will emit:
// { "name": "Water shortage", "color": (int)TooltipColor.Warning, "verbose": true }