osu/osu.Game/Overlays/Dialog/DangerousActionDialog.cs
mk56-spn 908651cc11 make ResetConfirmDialog properly utilise its parent's logic
Adjust name of `DeleteAction` to `DangerousAction`
2023-03-05 20:57:26 +01:00

43 lines
1.4 KiB
C#

// 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>
/// Base class for various confirmation dialogs that concern deletion actions.
/// Differs from <see cref="ConfirmDialog"/> in that the confirmation button is a "dangerous" one
/// (requires the confirm button to be held).
/// </summary>
public abstract partial class DangerousActionDialog : PopupDialog
{
/// <summary>
/// The action which performs the deletion.
/// </summary>
protected Action? DangerousAction { get; set; }
protected DangerousActionDialog()
{
HeaderText = DeleteConfirmationDialogStrings.HeaderText;
Icon = FontAwesome.Regular.TrashAlt;
Buttons = new PopupDialogButton[]
{
new PopupDialogDangerousButton
{
Text = DeleteConfirmationDialogStrings.Confirm,
Action = () => DangerousAction?.Invoke()
},
new PopupDialogCancelButton
{
Text = DeleteConfirmationDialogStrings.Cancel
}
};
}
}
}