mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 19:32:55 +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.
|
// 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.
|
// 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.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Dialog;
|
using osu.Game.Overlays.Dialog;
|
||||||
|
|
||||||
@ -9,10 +9,7 @@ namespace osu.Game.Collections
|
|||||||
{
|
{
|
||||||
public class DeleteCollectionDialog : PopupDialog
|
public class DeleteCollectionDialog : PopupDialog
|
||||||
{
|
{
|
||||||
[Resolved]
|
public DeleteCollectionDialog(BeatmapCollection collection, Action deleteAction)
|
||||||
private BeatmapCollectionManager collectionManager { get; set; }
|
|
||||||
|
|
||||||
public DeleteCollectionDialog(BeatmapCollection collection)
|
|
||||||
{
|
{
|
||||||
HeaderText = "Confirm deletion of";
|
HeaderText = "Confirm deletion of";
|
||||||
BodyText = collection.Name.Value;
|
BodyText = collection.Name.Value;
|
||||||
@ -24,7 +21,7 @@ namespace osu.Game.Collections
|
|||||||
new PopupDialogOkButton
|
new PopupDialogOkButton
|
||||||
{
|
{
|
||||||
Text = @"Yes. Go for it.",
|
Text = @"Yes. Go for it.",
|
||||||
Action = () => collectionManager.Collections.Remove(collection)
|
Action = deleteAction
|
||||||
},
|
},
|
||||||
new PopupDialogCancelButton
|
new PopupDialogCancelButton
|
||||||
{
|
{
|
||||||
|
@ -95,6 +95,9 @@ namespace osu.Game.Collections
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private DialogOverlay dialogOverlay { get; set; }
|
private DialogOverlay dialogOverlay { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BeatmapCollectionManager collectionManager { get; set; }
|
||||||
|
|
||||||
private readonly BeatmapCollection collection;
|
private readonly BeatmapCollection collection;
|
||||||
|
|
||||||
private Drawable background;
|
private Drawable background;
|
||||||
@ -146,9 +149,16 @@ namespace osu.Game.Collections
|
|||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
background.FlashColour(Color4.White, 150);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteCollection() => collectionManager.Collections.Remove(collection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user