Game.UI.ErrorDialog
Assembly: Game
Namespace: Game.UI
Type: class
Base: IJsonWritable
Summary:
Represents a serializable description of an error or warning dialog shown by the game's UI. Contains severity, permitted user actions, localized title/message and optional detailed error text. The instance can be written to a JSON writer via IJsonWritable.Write for persistence, logging or inter-process communication. The Actions enum is a Flags enum allowing combinations; Default is a combination of Quit and SaveAndQuit.
Fields
public enum Severity
Enumeration describing the dialog severity. Values:Warning
-
Error
-
public enum Actions
Flags enumeration describing which actions the dialog should present to the user. Values: None = 0
Quit = 1
SaveAndQuit = 2
SaveAndContinue = 4
-
Default = 3
(combination of Quit | SaveAndQuit) -
public Severity severity = Severity.Error
The dialog's severity. Defaults toSeverity.Error
. Used to differentiate warnings from errors when presenting the dialog or deciding behavior. -
public Actions actions = Actions.Default
Allowed user actions for the dialog. Defaults toActions.Default
(Quit + SaveAndQuit). As a Flags enum, values may be combined. -
public LocalizedString localizedTitle
Localized title for the dialog. Stored as a LocalizedString and written via the JSON writer. May be null if not set. -
public LocalizedString localizedMessage
Localized main message/body for the dialog. Stored as a LocalizedString and written via the JSON writer. May be null if not set. -
[CanBeNull] public string errorDetails
Optional detailed error text (stack trace, debug info, etc.). Marked as nullable; may be null when no extra details are available.
Properties
- None.
This type exposes public fields rather than CLR properties.
Constructors
public ErrorDialog()
Default parameterless constructor (compiler-generated). Fields initialize to their declared defaults:severity
=Severity.Error
,actions
=Actions.Default
,localizedTitle
/localizedMessage
= default(LocalizedString) (likely null/uninitialized),errorDetails
= null.
Methods
public void Write(IJsonWriter writer)
Writes the ErrorDialog instance to the supplied JSON writer. Implementation details:- Begins a type block using the runtime full type name.
- Writes
severity
andactions
as integer values (their enum integer representations). - Writes
localizedTitle
andlocalizedMessage
via the writer (delegating serialization of LocalizedString). - Writes
errorDetails
(nullable string). - Ends the type block. This method implements IJsonWritable, allowing the dialog to be serialized in the game's JSON-based persistence/communication format.
Usage Example
// Create an error dialog describing a critical failure
var dialog = new ErrorDialog
{
severity = ErrorDialog.Severity.Error,
actions = ErrorDialog.Actions.SaveAndQuit | ErrorDialog.Actions.SaveAndContinue,
localizedTitle = new LocalizedString("ErrorDialog_Title_Key"),
localizedMessage = new LocalizedString("ErrorDialog_Message_Key"),
errorDetails = exception?.ToString()
};
// Serialize to JSON using an IJsonWriter implementation
jsonWriter.TypeBegin(dialog.GetType().FullName);
dialog.Write(jsonWriter);
jsonWriter.TypeEnd();
Notes: - The Actions enum is decorated with [Flags], so combine values with bitwise operators when multiple actions should be offered. - LocalizedString handling depends on the game's localization system; when serializing, the LocalizedString object is forwarded to the writer for appropriate treatment.