Game.UI.Menu.ButtonWithConfirmation
Assembly:
Game (assembly inferred)
Namespace: Game.UI.Menu
Type:
public class
Base:
Game.UI.Widgets.Button
Summary:
A Button subclass that can hold an optional confirmation message (a localized string). When serialized (via WriteProperties) the confirmationMessage is written to the JSON output. The property setter marks the control as changed by calling SetPropertiesChanged() when the value actually changes.
Note: the implementation uses m_ConfirmationMessage.Equals(value) to detect a change. Because m_ConfirmationMessage is nullable this can throw a NullReferenceException if m_ConfirmationMessage is null. Consider using a null-safe equality check (for example, !object.Equals(m_ConfirmationMessage, value) or EqualityComparer.Default.Equals) to avoid that problem.
Fields
private Game.UI.Localization.LocalizedString? m_ConfirmationMessage
Holds the optional confirmation/localized message displayed or serialized for this button. Default is null. The backing field is used by the public confirmationMessage property.
Properties
public Game.UI.Localization.LocalizedString? confirmationMessage { get; set }
Gets or sets the confirmation message for the button. Setting the property performs an equality check against the backing field and calls SetPropertiesChanged() if the value differs (intended to flag the control for UI/serialization updates). Because the equality check is implemented as m_ConfirmationMessage.Equals(value), a null backing field may cause a NullReferenceException — a null-safe equality comparison is recommended.
Constructors
public ButtonWithConfirmation()
No explicit constructors are declared in the class; the default parameterless constructor is used/inherited.
Methods
protected override WriteProperties(IJsonWriter writer) : System.Void
Overrides the base Button.WriteProperties to include the confirmationMessage in the serialized output. Implementation behavior:- Calls base.WriteProperties(writer) to emit base class properties.
- Writes a property named "confirmationMessage" and writes the current confirmationMessage value via writer.Write(confirmationMessage).
- Ensure the IJsonWriter implementation can handle LocalizedString? (including null) when writing.
Usage Example
// Create the button and assign a confirmation message obtained from your localization system.
var btn = new ButtonWithConfirmation();
// Obtain a LocalizedString from your localization system; exact construction depends on that API.
LocalizedString confirm = /* get localized string, e.g. from a resource key */;
btn.confirmationMessage = confirm;
// When the UI is serialized, WriteProperties will include:
// "confirmationMessage": <localized value or null>