Cleanup dialog implementation

This commit is contained in:
Dan Balasescu 2022-06-08 18:10:41 +09:00
parent 3a90aa0b9b
commit f8594acb1d
1 changed files with 19 additions and 29 deletions

View File

@ -5,48 +5,38 @@
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Dialog;
using osu.Game.Database;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
public class SkinDeleteDialog : PopupDialog public class SkinDeleteDialog : PopupDialog
{ {
private SkinManager manager; [Resolved]
private SkinManager manager { get; set; }
[BackgroundDependencyLoader]
private void load(SkinManager skinManager)
{
manager = skinManager;
}
public SkinDeleteDialog(Skin skin) public SkinDeleteDialog(Skin skin)
{ {
skin.SkinInfo.PerformRead(s => BodyText = skin.SkinInfo.Value.Name;
Icon = FontAwesome.Regular.TrashAlt;
HeaderText = @"Confirm deletion of";
Buttons = new PopupDialogButton[]
{ {
BodyText = s.Name; new PopupDialogDangerousButton
Icon = FontAwesome.Regular.TrashAlt;
HeaderText = @"Confirm deletion of";
Buttons = new PopupDialogButton[]
{ {
new PopupDialogDangerousButton Text = @"Yes. Totally. Delete it.",
Action = () =>
{ {
Text = @"Yes. Totally. Delete it.", if (manager == null)
Action = () => return;
{
if (manager == null)
return;
manager.Delete(s); manager.Delete(skin.SkinInfo.Value);
manager.CurrentSkinInfo.Value = DefaultSkin.CreateInfo().ToLiveUnmanaged(); manager.CurrentSkinInfo.SetDefault();
},
}, },
new PopupDialogCancelButton },
{ new PopupDialogCancelButton
Text = @"Firetruck, I didn't mean to!", {
}, Text = @"Firetruck, I didn't mean to!",
}; },
}); };
} }
} }
} }