Game.UI.InGame.GamePanel
Assembly:
Assembly-CSharp (game runtime assembly; class is part of the game's main managed assembly)
{{ This class is defined in the game's runtime assembly (commonly Assembly-CSharp) and used by in-game UI code. }}
Namespace:
Game.UI.InGame
{{ Grouping for in-game UI panel classes. }}
Type:
abstract class
{{ GamePanel is an abstract base class intended to be subclassed to implement specific in-game UI panels. }}
Base:
IJsonWritable
{{ Implements IJsonWritable to allow the panel to serialize its properties to JSON via the provided writer interface. }}
Summary:
GamePanel is a lightweight base class for in-game UI panels. It exposes a small set of virtual read-only properties that control layout and retention behavior:
- blocking: whether the panel blocks input (defaults to false).
- retainSelection / retainProperties: whether the panel should keep selection or property UI state across openings (defaults to false).
- position: preferred layout position (a nested LayoutPosition enum; defaults to Undefined).
It also implements IJsonWritable.Write, and provides a protected virtual BindProperties method that subclasses should override to write their own properties to the provided IJsonWriter. The default BindProperties does nothing.
Fields
None
{{ GamePanel declares no instance fields in the provided source. All state is exposed by properties or implemented in subclasses. }}
Properties
-
public virtual bool blocking { get; }
{{ Controls whether the panel is considered blocking (e.g., prevents other interactions). Default implementation returns false; override to change behavior. }} -
public virtual bool retainSelection { get; }
{{ Indicates whether selection state should be retained when this panel is opened/closed. Default false; override in subclasses that need to preserve selection. }} -
public virtual bool retainProperties { get; }
{{ Indicates whether property UI state should be retained. Default false; override as needed. }} -
public virtual LayoutPosition position { get; }
{{ Preferred layout position for the panel. Default is LayoutPosition.Undefined. Override to request Left, Center, or Right placement. }}
Nested Types
public enum LayoutPosition { Undefined, Left, Center, Right }
{{ Enum describing preferred horizontal layout slot for the panel. Subclasses can return one of these from the position property. }}
Constructors
public GamePanel()
{{ No explicit constructor is defined in source, so the default public parameterless constructor is available. Subclasses should call base() implicitly. }}
Methods
-
public void Write(Colossal.UI.Binding.IJsonWriter writer)
{{ Implements IJsonWritable. The method writes a type begin marker using the concrete type's full name, calls BindProperties(writer) to let subclasses emit their properties, then writes a type end marker. This is the standard hook for serializing panel-specific state. }} -
protected virtual void BindProperties(Colossal.UI.Binding.IJsonWriter writer)
{{ Protected virtual hook for subclasses to write properties into the provided IJsonWriter. Default implementation is empty. Subclasses should override and call writer members to serialize any relevant state. }}
Usage Example
using Colossal.UI.Binding;
using Game.UI.InGame;
public class MyInfoPanel : GamePanel
{
public override bool blocking => true;
public override LayoutPosition position => LayoutPosition.Right;
private string someState = "default";
protected override void BindProperties(IJsonWriter writer)
{
// Example serialization of a simple property
writer.ValueBegin("someState");
writer.ValueString(someState);
writer.ValueEnd();
}
}
// Serializing an instance:
IJsonWriter writer = /* obtain writer from framework */;
MyInfoPanel panel = new MyInfoPanel();
panel.Write(writer);
{{ Notes: - Override BindProperties to serialize any state your panel needs to persist. - The Write method uses the concrete type's full name as the type identifier; readers should expect that when deserializing. - Because GamePanel is abstract, you will create subclasses that implement UI and behavior and optionally override the provided virtual properties to change layout/retention behavior. }}