Game.UI.Editor.IEditorPanel
Assembly: Game
Namespace: Game.UI.Editor
Type: Interface
Base: None
Summary:
Represents the contract for an editor panel used by in-game editors. Implementers provide an optional localized title, a collection of child widgets, and a widget renderer, and handle UI events such as value changes, cancel requests, and panel close requests. This interface is intended for modders who create custom editor panels for Cities: Skylines 2.
Fields
- None
Interfaces do not declare instance fields; only properties and methods are defined.
Properties
-
LocalizableString title { get; }
[CanBeNull] The optional title of the editor panel. Implementations can return null when no title should be displayed. This is a localized string type used by the game's UI localization system. -
IList<IWidget> children { get; }
The list of child widgets that are part of the panel. Modders should populate this list with the widgets (controls) that represent the panel's content and state. -
EditorPanelWidgetRenderer widgetRenderer { get; }
The renderer responsible for drawing or laying out the panel's widgets. Implementations supply or reuse an appropriate renderer instance for the panel's widgets.
Constructors
- Interfaces have no constructors. Implement concrete classes to create instances.
Methods
-
void OnValueChanged(IWidget widget)
Called when a child widget's value changes. Implementers should update internal state or react to the change (validation, enabling/disabling other widgets, etc.). The widget parameter identifies which child triggered the change. -
bool OnCancel()
Called when a cancel action is requested (for example pressing a Cancel button or Escape). Return value convention: implementers should return true if the cancel request was handled by the panel (and no further action is required), or false if the system should perform default behavior. (Interpretation may vary by host; treat true as "handled".) -
bool OnClose()
Called when the panel is requested to close. Implementers should return true to indicate the panel accepts the close (or that it has handled necessary cleanup), or false to veto/prevent closing (for example when unsaved changes must be confirmed). Confirm the exact semantics against host UI expectations.
Usage Example
using System.Collections.Generic;
using Colossal.Annotations;
using Game.UI.Localization;
using Game.UI.Widgets;
using Game.UI.Editor;
public class MyEditorPanel : IEditorPanel
{
// Title can be null if no title should be shown
[CanBeNull]
public LocalizedString title => new LocalizedString("My Custom Panel");
// Child widgets making up the panel UI
public IList<IWidget> children { get; } = new List<IWidget>();
// Renderer used to render the widgets (create or reuse)
public EditorPanelWidgetRenderer widgetRenderer { get; } = new EditorPanelWidgetRenderer();
public void OnValueChanged(IWidget widget)
{
// React to widget value changes (validation, update other widgets, etc.)
}
public bool OnCancel()
{
// Return true if the cancel was handled and no further action is needed.
// Return false if the default cancel behavior should proceed.
return true;
}
public bool OnClose()
{
// Return true to allow closing (or to indicate cleanup is complete),
// return false to prevent the panel from closing (e.g. confirm unsaved changes).
return true;
}
}
Notes: - The exact semantics of the boolean return values for OnCancel and OnClose should be verified against the host UI framework used by Cities: Skylines 2; typically true indicates the action was handled/accepted, false indicates it was not/should be vetoed. - Use LocalizedString for titles to support localization of your panel text.