Split confirmation dialog classes apart

This commit is contained in:
Dean Herbert 2021-03-03 20:34:36 +09:00
parent 0ede28da2f
commit 0f5bce70ad
3 changed files with 34 additions and 16 deletions

View File

@ -11,30 +11,27 @@ namespace osu.Game.Overlays.Dialog
/// </summary>
public class ConfirmDialog : PopupDialog
{
protected PopupDialogOkButton ButtonConfirm;
protected PopupDialogCancelButton ButtonCancel;
/// <summary>
/// Construct a new dialog.
/// Construct a new confirmation dialog.
/// </summary>
/// <param name="description">The description of the action to be displayed to the user.</param>
/// <param name="message">The description of the action to be displayed to the user.</param>
/// <param name="onConfirm">An action to perform on confirmation.</param>
/// <param name="onCancel">An optional action to perform on cancel.</param>
public ConfirmDialog(string description, Action onConfirm, Action onCancel = null)
public ConfirmDialog(string message, Action onConfirm, Action onCancel = null)
{
HeaderText = $"Are you sure you want to {description}?";
BodyText = "Last chance to back out.";
HeaderText = message;
BodyText = "Last chance to turn back";
Icon = FontAwesome.Solid.ExclamationTriangle;
Buttons = new PopupDialogButton[]
{
ButtonConfirm = new PopupDialogOkButton
new PopupDialogOkButton
{
Text = @"Yes",
Action = onConfirm
},
ButtonCancel = new PopupDialogCancelButton
new PopupDialogCancelButton
{
Text = @"Cancel",
Action = onCancel

View File

@ -2,17 +2,38 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Graphics.Sprites;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Screens.Menu
{
public class ConfirmExitDialog : ConfirmDialog
public class ConfirmExitDialog : PopupDialog
{
public ConfirmExitDialog(Action confirm, Action onCancel = null)
: base("exit osu!", confirm, onCancel)
/// <summary>
/// Construct a new exit confirmation dialog.
/// </summary>
/// <param name="onConfirm">An action to perform on confirmation.</param>
/// <param name="onCancel">An optional action to perform on cancel.</param>
public ConfirmExitDialog(Action onConfirm, Action onCancel = null)
{
ButtonConfirm.Text = "Let me out!";
ButtonCancel.Text = "Just a little more...";
HeaderText = "Are you sure you want to exit osu!?";
BodyText = "Last chance to turn back";
Icon = FontAwesome.Solid.ExclamationTriangle;
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Let me out!",
Action = onConfirm
},
new PopupDialogCancelButton
{
Text = @"Just a little more...",
Action = onCancel
},
};
}
}
}

View File

@ -302,7 +302,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
if (!exitConfirmed && dialogOverlay != null)
{
dialogOverlay.Push(new ConfirmDialog("leave this multiplayer match", () =>
dialogOverlay.Push(new ConfirmDialog("Are you sure you want to leave this multiplayer match?", () =>
{
exitConfirmed = true;
this.Exit();