2022-07-23 19:20:27 +00: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 09:00:37 +00:00
|
|
|
/// A dialog which provides confirmation for actions which result in permanent consequences.
|
2022-07-23 19:20:27 +00: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 09:00:37 +00: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-27 20:57:59 +00:00
|
|
|
public abstract partial class DangerousActionDialog : PopupDialog
|
2022-07-23 19:20:27 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The action which performs the deletion.
|
|
|
|
/// </summary>
|
2023-03-05 19:57:26 +00:00
|
|
|
protected Action? DangerousAction { get; set; }
|
2022-07-23 19:20:27 +00:00
|
|
|
|
2023-12-05 07:54:44 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The action to perform if cancelled.
|
|
|
|
/// </summary>
|
|
|
|
protected Action? CancelAction { get; set; }
|
|
|
|
|
2023-02-27 20:57:59 +00:00
|
|
|
protected DangerousActionDialog()
|
2022-07-23 19:20:27 +00:00
|
|
|
{
|
2024-05-31 06:09:06 +00:00
|
|
|
HeaderText = DialogStrings.Caution;
|
2022-07-23 19:20:27 +00:00
|
|
|
|
|
|
|
Icon = FontAwesome.Regular.TrashAlt;
|
|
|
|
|
|
|
|
Buttons = new PopupDialogButton[]
|
|
|
|
{
|
|
|
|
new PopupDialogDangerousButton
|
|
|
|
{
|
2024-05-31 06:09:06 +00:00
|
|
|
Text = DialogStrings.Confirm,
|
2023-03-05 19:57:26 +00:00
|
|
|
Action = () => DangerousAction?.Invoke()
|
2022-07-23 19:20:27 +00:00
|
|
|
},
|
|
|
|
new PopupDialogCancelButton
|
|
|
|
{
|
2024-05-31 02:46:32 +00:00
|
|
|
Text = DialogStrings.Cancel,
|
2023-12-05 07:54:44 +00:00
|
|
|
Action = () => CancelAction?.Invoke()
|
2022-07-23 19:20:27 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|