mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 18:42:56 +08:00
Split confirmation dialog classes apart
This commit is contained in:
parent
0ede28da2f
commit
0f5bce70ad
@ -11,30 +11,27 @@ namespace osu.Game.Overlays.Dialog
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ConfirmDialog : PopupDialog
|
public class ConfirmDialog : PopupDialog
|
||||||
{
|
{
|
||||||
protected PopupDialogOkButton ButtonConfirm;
|
|
||||||
protected PopupDialogCancelButton ButtonCancel;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct a new dialog.
|
/// Construct a new confirmation dialog.
|
||||||
/// </summary>
|
/// </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="onConfirm">An action to perform on confirmation.</param>
|
||||||
/// <param name="onCancel">An optional action to perform on cancel.</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}?";
|
HeaderText = message;
|
||||||
BodyText = "Last chance to back out.";
|
BodyText = "Last chance to turn back";
|
||||||
|
|
||||||
Icon = FontAwesome.Solid.ExclamationTriangle;
|
Icon = FontAwesome.Solid.ExclamationTriangle;
|
||||||
|
|
||||||
Buttons = new PopupDialogButton[]
|
Buttons = new PopupDialogButton[]
|
||||||
{
|
{
|
||||||
ButtonConfirm = new PopupDialogOkButton
|
new PopupDialogOkButton
|
||||||
{
|
{
|
||||||
Text = @"Yes",
|
Text = @"Yes",
|
||||||
Action = onConfirm
|
Action = onConfirm
|
||||||
},
|
},
|
||||||
ButtonCancel = new PopupDialogCancelButton
|
new PopupDialogCancelButton
|
||||||
{
|
{
|
||||||
Text = @"Cancel",
|
Text = @"Cancel",
|
||||||
Action = onCancel
|
Action = onCancel
|
||||||
|
@ -2,17 +2,38 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Dialog;
|
using osu.Game.Overlays.Dialog;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Menu
|
namespace osu.Game.Screens.Menu
|
||||||
{
|
{
|
||||||
public class ConfirmExitDialog : ConfirmDialog
|
public class ConfirmExitDialog : PopupDialog
|
||||||
{
|
{
|
||||||
public ConfirmExitDialog(Action confirm, Action onCancel = null)
|
/// <summary>
|
||||||
: base("exit osu!", confirm, onCancel)
|
/// 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!";
|
HeaderText = "Are you sure you want to exit osu!?";
|
||||||
ButtonCancel.Text = "Just a little more...";
|
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
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
|
|
||||||
if (!exitConfirmed && dialogOverlay != null)
|
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;
|
exitConfirmed = true;
|
||||||
this.Exit();
|
this.Exit();
|
||||||
|
Loading…
Reference in New Issue
Block a user