2022-07-24 03:20:27 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Localisation;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Dialog
|
|
|
|
{
|
|
|
|
/// <summary>
|
2023-03-07 17:00:37 +08:00
|
|
|
/// A dialog which provides confirmation for actions which result in permanent consequences.
|
2022-07-24 03:20:27 +08:00
|
|
|
/// Differs from <see cref="ConfirmDialog"/> in that the confirmation button is a "dangerous" one
|
|
|
|
/// (requires the confirm button to be held).
|
|
|
|
/// </summary>
|
2023-03-07 17:00:37 +08:00
|
|
|
/// <remarks>
|
|
|
|
/// The default implementation comes with text for a generic deletion operation.
|
|
|
|
/// This can be further customised by specifying custom <see cref="PopupDialog.HeaderText"/>.
|
|
|
|
/// </remarks>
|
2023-02-28 04:57:59 +08:00
|
|
|
public abstract partial class DangerousActionDialog : PopupDialog
|
2022-07-24 03:20:27 +08:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The action which performs the deletion.
|
|
|
|
/// </summary>
|
2023-03-06 03:57:26 +08:00
|
|
|
protected Action? DangerousAction { get; set; }
|
2022-07-24 03:20:27 +08:00
|
|
|
|
2023-12-05 15:54:44 +08:00
|
|
|
/// <summary>
|
|
|
|
/// The action to perform if cancelled.
|
|
|
|
/// </summary>
|
|
|
|
protected Action? CancelAction { get; set; }
|
|
|
|
|
2023-02-28 04:57:59 +08:00
|
|
|
protected DangerousActionDialog()
|
2022-07-24 03:20:27 +08:00
|
|
|
{
|
2024-10-07 15:44:10 +08:00
|
|
|
HeaderText = DialogStrings.CautionHeaderText;
|
2022-07-24 03:20:27 +08:00
|
|
|
|
2024-10-07 15:44:10 +08:00
|
|
|
Icon = FontAwesome.Solid.ExclamationTriangle;
|
2022-07-24 03:20:27 +08:00
|
|
|
|
|
|
|
Buttons = new PopupDialogButton[]
|
|
|
|
{
|
|
|
|
new PopupDialogDangerousButton
|
|
|
|
{
|
2024-05-31 14:09:06 +08:00
|
|
|
Text = DialogStrings.Confirm,
|
2023-03-06 03:57:26 +08:00
|
|
|
Action = () => DangerousAction?.Invoke()
|
2022-07-24 03:20:27 +08:00
|
|
|
},
|
|
|
|
new PopupDialogCancelButton
|
|
|
|
{
|
2024-05-31 10:46:32 +08:00
|
|
|
Text = DialogStrings.Cancel,
|
2023-12-05 15:54:44 +08:00
|
|
|
Action = () => CancelAction?.Invoke()
|
2022-07-24 03:20:27 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|