Game.UI.ConfirmationDialogBase
Assembly: Assembly-CSharp
Namespace: Game.UI
Type: abstract class
Base: IJsonWritable
Summary:
A base class for confirmation/dialog UI payloads used by the game's UI system. Holds localized text for title, message, action buttons and optional details, supports different UI skins and a toggleable "copy" button. Implements IJsonWritable to serialize the dialog data into a JSON writer consumed by the UI layer. This class is intended to be subclassed to provide concrete dialog instances with specific localized content and behavior.
Fields
-
protected const string kDefaultSkin = "Default"
Default skin identifier used by the dialog when no other skin is specified. -
protected const string kParadoxSkin = "Paradox"
Alternate skin identifier (likely used for a Paradox-branded appearance). -
private LocalizedString? title
Optional localized title text for the dialog. Nullable — dialog may omit a title. -
private LocalizedString message
Required localized main message/body of the dialog. -
private LocalizedString confirmAction
Localized label for the primary/confirm action button. -
private LocalizedString? cancelAction
Optional localized label for a cancel/secondary action button. -
[CanBeNull] private LocalizedString[] otherActions
Optional array of additional localized action labels (can be null). Marked with CanBeNull attribute. -
private LocalizedString? details
Optional localized details text (e.g., a longer explanation or technical details). -
private bool copyButton
When true, indicates the dialog should include a "copy" button (typically to copy details/error text).
Properties
-
protected virtual string skin { get; }
Default implementation returns "Default". Subclasses can override to select a different UI skin (for example "Paradox"). -
protected virtual bool dismissible { get; }
Default implementation returns false. Subclasses can override to indicate whether the dialog can be dismissed without choosing an action.
Constructors
protected ConfirmationDialogBase(LocalizedString? title, LocalizedString message, LocalizedString? details, bool copyButton, LocalizedString confirmAction, LocalizedString? cancelAction, [CanBeNull] params LocalizedString[] otherActions)
Creates a new confirmation dialog payload. Parameters:- title: optional localized title.
- message: main localized message (required).
- details: optional longer details text.
- copyButton: whether to show a copy-to-clipboard button.
- confirmAction: label for the confirm button.
- cancelAction: optional label for the cancel button.
- otherActions: optional additional action labels.
Initializes the backing fields used during JSON serialization.
Methods
public void Write(IJsonWriter writer)
Serializes the dialog's data to the provided IJsonWriter. The method:- Begins a typed object using the runtime type name (writer.TypeBegin(GetType().FullName)).
- Writes the following properties in order: dismissible, skin, title, message, confirmAction, cancelAction, otherActions, details, copyButton.
- For otherActions: writes an array of strings if present, otherwise writes an empty array.
- Ends the typed object (writer.TypeEnd()).
This method is the implementation of IJsonWritable and is what the UI system uses to receive dialog payloads.
Usage Example
// Example subclass and usage
public class ConfirmDeleteDialog : ConfirmationDialogBase
{
public ConfirmDeleteDialog(string itemName)
: base(
title: new LocalizedString("Confirm Delete"),
message: new LocalizedString($"Are you sure you want to delete {itemName}?"),
details: null,
copyButton: false,
confirmAction: new LocalizedString("Delete"),
cancelAction: new LocalizedString("Cancel"))
{
}
// Optionally override skin or dismissible:
protected override string skin => kParadoxSkin;
protected override bool dismissible => true;
}
// Writing the dialog to a JSON writer (IJsonWriter comes from the UI system)
IJsonWriter writer = /* obtain writer from UI system */;
var dialog = new ConfirmDeleteDialog("Road A");
dialog.Write(writer);