Skip to content

Game.UI.Tooltip.IconTooltip

Assembly: Assembly-CSharp
Namespace: Game.UI.Tooltip

Type: abstract class

Base: Game.UI.Widgets.Widget

Summary:
An abstract Widget that represents a tooltip which can display a small icon and a tint/color. Provides properties to get/set the icon identifier and tooltip color; when these properties change the widget marks itself dirty so the UI system can update/serialize the new values.


Fields

  • private string m_Icon
    Backing field for the public icon property. Marked [CanBeNull] in source — it may be null to indicate no icon. Holds the identifier/name of the icon resource to show.

  • private TooltipColor m_Color
    Backing field for the public color property. Holds the tooltip color (an enum of type TooltipColor). Changes to this field are propagated via the color property which calls SetPropertiesChanged().

Properties

  • public string icon { get; private set }
    Public property exposing the icon identifier (can be null). When set to a different value the setter calls SetPropertiesChanged() so the UI serialization/update pipeline knows to refresh the widget.

  • public TooltipColor color { get; private set }
    Public property exposing the tooltip color. When changed the setter calls SetPropertiesChanged() to mark the widget as needing update/serialization.

Constructors

  • public IconTooltip()
    No explicit constructor is defined in the source; the class uses the default parameterless constructor. Initialization of fields uses their default values (m_Icon = null, m_Color = default(TooltipColor)).

Methods

  • protected override void WriteProperties(IJsonWriter writer) : System.Void
    Overrides the widget serialization method. Calls base.WriteProperties(writer) and then writes two properties to the JSON writer:
  • Writes property name "icon" and the current icon string (may be null).
  • Writes property name "color" and the integer value of the color enum (writes (int)color). This method is used by the UI binding/serialization system to transfer the widget's state to the UI layer.

Usage Example

// Example subclass that configures icon and color in OnCreate
using Colossal.Annotations;
using Game.UI.Tooltip;

public class MyIconTooltip : IconTooltip
{
    [Preserve]
    protected override void OnCreate()
    {
        base.OnCreate();

        // Assign an icon identifier (null = no icon)
        icon = "MyMod/Icons/ExampleIcon";

        // Assign a tooltip color (TooltipColor is an enum defined by the game)
        color = TooltipColor.Positive;
    }
}

Notes for modders: - Setting icon or color triggers SetPropertiesChanged(), which causes the widget state to be re-serialized to the UI. Avoid rapidly changing these properties every frame for performance reasons. - icon may be null to indicate no icon should be rendered. - The color is written as an integer via WriteProperties; ensure any UI-side code that reads this expects the enum value as an int.