diff --git a/osu.Game/Collections/DeleteCollectionDialog.cs b/osu.Game/Collections/DeleteCollectionDialog.cs index f2b8de7c1e..8c8c897146 100644 --- a/osu.Game/Collections/DeleteCollectionDialog.cs +++ b/osu.Game/Collections/DeleteCollectionDialog.cs @@ -1,7 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Allocation; +using System; using osu.Framework.Graphics.Sprites; using osu.Game.Overlays.Dialog; @@ -9,10 +9,7 @@ namespace osu.Game.Collections { public class DeleteCollectionDialog : PopupDialog { - [Resolved] - private BeatmapCollectionManager collectionManager { get; set; } - - public DeleteCollectionDialog(BeatmapCollection collection) + public DeleteCollectionDialog(BeatmapCollection collection, Action deleteAction) { HeaderText = "Confirm deletion of"; BodyText = collection.Name.Value; @@ -24,7 +21,7 @@ namespace osu.Game.Collections new PopupDialogOkButton { Text = @"Yes. Go for it.", - Action = () => collectionManager.Collections.Remove(collection) + Action = deleteAction }, new PopupDialogCancelButton { diff --git a/osu.Game/Collections/DrawableCollectionListItem.cs b/osu.Game/Collections/DrawableCollectionListItem.cs index 9b7505f7c3..a1fc55556e 100644 --- a/osu.Game/Collections/DrawableCollectionListItem.cs +++ b/osu.Game/Collections/DrawableCollectionListItem.cs @@ -95,6 +95,9 @@ namespace osu.Game.Collections [Resolved(CanBeNull = true)] private DialogOverlay dialogOverlay { get; set; } + [Resolved] + private BeatmapCollectionManager collectionManager { get; set; } + private readonly BeatmapCollection collection; private Drawable background; @@ -146,9 +149,16 @@ namespace osu.Game.Collections protected override bool OnClick(ClickEvent e) { background.FlashColour(Color4.White, 150); - dialogOverlay?.Push(new DeleteCollectionDialog(collection)); + + if (collection.Beatmaps.Count == 0) + deleteCollection(); + else + dialogOverlay?.Push(new DeleteCollectionDialog(collection, deleteCollection)); + return true; } + + private void deleteCollection() => collectionManager.Collections.Remove(collection); } } }