Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion osu.Game/Localisation/SongSelectStrings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 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.

using osu.Framework.Localisation;
Expand Down Expand Up @@ -149,6 +149,11 @@ public static class SongSelectStrings
/// </summary>
public static LocalisableString RestoreAllHidden => new TranslatableString(getKey(@"restore_all_hidden"), @"Restore all hidden");

/// <summary>
/// "Delete all in group"
/// </summary>
public static LocalisableString DeleteAllInGroup => new TranslatableString(getKey(@"delete_all_in_group"), @"Delete all in group");

/// <summary>
/// "{0} stars"
/// </summary>
Expand Down
11 changes: 10 additions & 1 deletion osu.Game/Screens/Select/BeatmapCarousel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 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.

using System;
Expand Down Expand Up @@ -63,6 +63,15 @@ public partial class BeatmapCarousel : Carousel<BeatmapInfo>
/// </summary>
public int MatchedBeatmapsCount => Filters.Last().BeatmapItemsCount;

/// <summary>
/// Retrieves all beatmap sets which are currently contained within the specified <see cref="GroupDefinition"/>.
/// </summary>
/// <param name="group">The group to retrieve beatmap sets for.</param>
public IEnumerable<BeatmapSetInfo> GetBeatmapSetsForGroup(GroupDefinition group)
=> grouping.SetItems.Keys
.Where(set => EqualityComparer<GroupDefinition?>.Default.Equals(set.Group, group))
.Select(set => set.BeatmapSet);

protected override float GetSpacingBetweenPanels(CarouselItem top, CarouselItem bottom)
{
// Group panels do not overlap with any other panel but should overlap with themselves.
Expand Down
32 changes: 32 additions & 0 deletions osu.Game/Screens/Select/BeatmapGroupDeleteDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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.Collections.Generic;
using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Overlays.Dialog;

namespace osu.Game.Screens.Select
{
public partial class BeatmapGroupDeleteDialog : DeletionDialog
{
private readonly IReadOnlyList<BeatmapSetInfo> beatmapSets;

public BeatmapGroupDeleteDialog(GroupDefinition group, IReadOnlyList<BeatmapSetInfo> beatmapSets)
{
this.beatmapSets = beatmapSets;
BodyText = group.Title;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dialog should definitely show a count of how many beatmap sets are to be deleted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Are you thinking something like this?

image

}

[BackgroundDependencyLoader]
private void load(BeatmapManager beatmapManager)
{
DangerousAction = () =>
{
foreach (var set in beatmapSets)
beatmapManager.Delete(set);
};
}
}
}

6 changes: 6 additions & 0 deletions osu.Game/Screens/Select/ISongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public interface ISongSelect
/// </summary>
void RestoreAllHidden(BeatmapSetInfo beatmapSet);

/// <summary>
/// Requests the user for confirmation to delete all beatmap sets contained within the given group.
/// </summary>
/// <param name="group">The group whose contents should be deleted.</param>
void DeleteGroup(GroupDefinition group);

/// <summary>
/// Opens the manage collections dialog.
/// </summary>
Expand Down
26 changes: 25 additions & 1 deletion osu.Game/Screens/Select/PanelGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using osu.Game.Graphics.Carousel;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays;
using osuTK;
using osuTK.Graphics;
Expand All @@ -38,6 +39,9 @@ public partial class PanelGroup : Panel
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;

[Resolved]
private ISongSelect? songSelect { get; set; }

[BackgroundDependencyLoader]
private void load()
{
Expand Down Expand Up @@ -168,9 +172,29 @@ public override MenuItem[] ContextMenuItems
if (Item == null)
return Array.Empty<MenuItem>();

var group = (GroupDefinition)Item.Model;

var expandItem = new OsuMenuItem(
Expanded.Value ? WebCommonStrings.ButtonsCollapse.ToSentence() : WebCommonStrings.ButtonsExpand.ToSentence(),
MenuItemType.Highlighted,
() => TriggerClick());

if (songSelect == null)
{
return new MenuItem[]
{
expandItem
};
}

return new MenuItem[]
{
new OsuMenuItem(Expanded.Value ? WebCommonStrings.ButtonsCollapse.ToSentence() : WebCommonStrings.ButtonsExpand.ToSentence(), MenuItemType.Highlighted, () => TriggerClick())
expandItem,
new OsuMenuItemSpacer(),
new OsuMenuItem(
SongSelectStrings.DeleteAllInGroup,
MenuItemType.Destructive,
() => songSelect.DeleteGroup(group))
};
}
}
Expand Down
13 changes: 13 additions & 0 deletions osu.Game/Screens/Select/SongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,19 @@ protected IEnumerable<OsuMenuItem> CreateCollectionMenuActions(BeatmapInfo beatm

public void Delete(BeatmapSetInfo beatmapSet) => dialogOverlay?.Push(new BeatmapDeleteDialog(beatmapSet));

public void DeleteGroup(GroupDefinition group)
{
if (dialogOverlay == null)
return;

var beatmapSets = carousel.GetBeatmapSetsForGroup(group).ToArray();

if (beatmapSets.Length == 0)
return;

dialogOverlay.Push(new BeatmapGroupDeleteDialog(group, beatmapSets));
}

public void RestoreAllHidden(BeatmapSetInfo beatmapSet)
{
foreach (var b in beatmapSet.Beatmaps)
Expand Down
Loading