Game.UI.InGame.TabbedGamePanel
Assembly:
Assembly-CSharp
Namespace: Game.UI.InGame
Type:
public abstract class
Base:
GamePanel, IEquatable
Summary:
An abstract game UI panel that exposes a selectable tab index and integrates that value into the panel's serialized properties. Intended as a base class for in-game panels that support tabbed content. Provides a virtual integer property selectedTab which is written into an IJsonWriter when BindProperties is called, and implements IEquatable
Fields
- None (no explicit private fields declared in this class)
No backing fields are defined directly in source; the auto-property selectedTab has a compiler-generated backing field.
Properties
public virtual int selectedTab { get; set; }
Represents the currently selected tab index for the panel. The property is virtual so derived classes may override get/set behavior. The value is included in property bindings via BindProperties (written as "selectedTab").
Constructors
public TabbedGamePanel()
Default parameterless constructor (compiler-generated). The class is abstract, so this constructor is only invoked by derived classes.
Methods
-
protected override void BindProperties(IJsonWriter writer)
Overrides GamePanel.BindProperties to append the selectedTab value to the JSON writer. Implementation calls base.BindProperties(writer), then writes the property name "selectedTab" followed by the current selectedTab value. This allows the UI system or serialization to capture which tab is selected. -
public bool Equals(TabbedGamePanel other)
Implements IEquatable. Returns false if other is null. If the two references are identical, returns true. Otherwise compares the selectedTab values and returns the result of that comparison. Note this equality only considers the selectedTab field and not other potential state in derived classes or the base class.
Usage Example
// Example derived panel that ensures selectedTab is bound into JSON when the panel properties are serialized
using Colossal.UI.Binding;
public class MyTabbedPanel : TabbedGamePanel
{
public MyTabbedPanel()
{
// initialize default selected tab if desired
selectedTab = 0;
}
protected override void BindProperties(IJsonWriter writer)
{
base.BindProperties(writer);
// base implementation already writes "selectedTab", but
// derived classes can write additional properties here.
}
}
// Example equality usage:
var a = new MyTabbedPanel { selectedTab = 1 };
var b = new MyTabbedPanel { selectedTab = 1 };
bool equal = a.Equals(b); // true because selectedTab values match
Notes and tips: - Because selectedTab is virtual, derived classes can override the property to add side effects (for example: updating UI when the value changes). - BindProperties uses Colossal.UI.Binding.IJsonWriter; ensure the UI serialization pipeline is available when relying on this behavior. - Equals only compares selectedTab. If you need full-value equality (including base class state or additional derived-class fields), override Equals and GetHashCode in the derived type accordingly.