mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 21:43:22 +08:00
Don't prompt to remove empty collection
This commit is contained in:
parent
c2da3d9c84
commit
17e8171827
@ -1,7 +1,7 @@
|
||||
// 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 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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user