How-To: Show Confirmation Dialogs

Goal: show a Yes/No (or OK/Cancel, or fully custom) modal dialog and branch on the player's answer.

Prerequisites
Quick Start done, including a registered UI.Layer.Modal layer - dialogs are pushed there. You will create the dialog widget in step 1 and register it in step 2.

1. Build the confirmation screen widget

Create a widget Blueprint with parent Crimson Confirmation Screen (UCrimsonConfirmationScreen). The base class populates it from a descriptor at runtime; you supply the visuals. Four widgets must exist with these exact names (BindWidget):

Widget nameTypePurpose
Text_TitleUCommonTextBlockReceives the descriptor's Header.
RichText_DescriptionUCommonRichTextBlockReceives the descriptor's Body.
EntryBox_ButtonsUDynamicEntryBoxOne button spawned per descriptor action. Set its Entry Widget Class to a UCrimsonButtonBase subclass.
Border_TapToCloseZoneUCommonBorderFull-screen backdrop; tapping it (touch) cancels the dialog.
Screenshot pendingImages/CrimsonUI/howto-confirmation-widgets.png
WBP_ConfirmationScreen hierarchy: Border_TapToCloseZone (backdrop) containing a panel with Text_Title (CommonTextBlock), RichText_Description (CommonRichTextBlock), EntryBox_Buttons (DynamicEntryBox). The compiler flags any missing BindWidget name.
Verify
The Blueprint compiles with no 'missing required widget' errors - the base class validates the four names at compile time.

2. Register it in Project Settings

Project Settings -> Crimson -> Crimson UI: set ConfirmationDialogClass (used by confirmations) and ErrorDialogClass (used by ShowError; an OK-only variant of the same Blueprint works) to your widget(s).

3. Show it and branch on the result

Screenshot pendingImages/CrimsonUI/howto-show-confirmation-bp.png
Show Confirmation Yes No (async node): Title + Message inputs; On Result pin -> Switch on ECrimsonMessagingResult -> Confirmed / Declined / Cancelled / Killed branches.

Nodes: Show Confirmation Yes No, Show Confirmation Ok Cancel, and Show Confirmation Custom (takes a descriptor - build one with Create Confirmation Yes No Cancel or construct a UCrimsonGameDialogDescriptor and fill Header, Body, and ButtonActions). The single On Result pin delivers an ECrimsonMessagingResult - branch with a Switch on ECrimsonMessagingResult.

ResultMeaning
ConfirmedOK / Yes pressed
DeclinedNo pressed
CancelledCancel pressed, Back action, or tap-to-close
KilledDialog torn down externally before the player answered - treat as 'no decision', not as a No
Verify
The dialog appears above everything on UI.Layer.Modal; each button routes to the matching branch exactly once.

4. Fully custom dialogs

When the standard title/body/buttons layout does not fit (progress dialog, image preview), subclass UCrimsonGameDialog directly (C++) and override SetupDialog(Descriptor, ResultCallback) and KillDialog. Register the class as ConfirmationDialogClass or ErrorDialogClass and the messaging subsystem routes it exactly the same way. Custom button labels and per-button activation delays go through the descriptor's ButtonActions array (FCrimsonConfirmationDialogAction: Result, OptionalDisplayText, ActivationDelay) - a 3-second ActivationDelay on a destructive Confirm gives you the 'hold to confirm' countdown via UCrimsonButtonBase.

See also

  • How-To: Buttons & Action Glyphs - the button base the entry box spawns.
  • How-To: Push & Pop Screens - the layer mechanics dialogs ride on.