diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index debe4c6829..6db038355f 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -358,6 +358,31 @@ namespace osu.Game.Beatmaps
});
}
+ ///
+ /// Hard-Delete a beatmap difficulty locally.
+ ///
+ /// is generally preferred as it keeps the local beatmap set in sync with the server.
+ /// The beatmap difficulty to hide.
+ public void DeleteLocal(BeatmapInfo beatmapInfo)
+ {
+ Realm.Run(r =>
+ {
+ using (var transaction = r.BeginWrite())
+ {
+ if (!beatmapInfo.IsManaged)
+ beatmapInfo = r.Find(beatmapInfo.ID);
+
+ var setInfo = beatmapInfo.BeatmapSet!;
+ DeleteFile(setInfo, beatmapInfo.File!);
+ setInfo.Beatmaps.Remove(beatmapInfo);
+
+ var liveSetInfo = r.Find(setInfo.ID);
+ setInfo.CopyChangesToRealm(liveSetInfo);
+ transaction.Commit();
+ }
+ });
+ }
+
///
/// Delete videos from a list of beatmaps.
/// This will post notifications tracking progress.
diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs
index 5cee634fd8..129e71ea30 100644
--- a/osu.Game/Screens/Edit/Editor.cs
+++ b/osu.Game/Screens/Edit/Editor.cs
@@ -851,7 +851,16 @@ namespace osu.Game.Screens.Edit
private void deleteDifficulty()
{
- dialogOverlay?.Push(new PromptForDifficultyDeleteDialog(confirmDifficultyDelete, () => { }));
+ dialogOverlay?.Push(new PromptForDifficultyDeleteDialog(confirmDifficultyHide, confirmDifficultyDelete, () => { }));
+ }
+
+ private void confirmDifficultyHide()
+ {
+ var current = playableBeatmap.BeatmapInfo;
+ if (current is null) return;
+
+ beatmapManager.Hide(current);
+ switchBeatmapOrExit(current.BeatmapSet);
}
private void confirmDifficultyDelete()
@@ -859,8 +868,19 @@ namespace osu.Game.Screens.Edit
var current = playableBeatmap.BeatmapInfo;
if (current is null) return;
- beatmapManager.Hide(current);
- this.Exit();
+ beatmapManager.DeleteLocal(current);
+ switchBeatmapOrExit(current.BeatmapSet);
+ }
+
+ private void switchBeatmapOrExit([CanBeNull] BeatmapSetInfo setInfo)
+ {
+ if (setInfo is null || setInfo.Beatmaps.Count() <= 1)
+ this.Exit();
+ var nextBeatmap = setInfo!.Beatmaps.First();
+
+ // Force a refresh of the beatmap (and beatmap set) so the `Change difficulty` list is also updated.
+ Beatmap.Value = beatmapManager.GetWorkingBeatmap(nextBeatmap, true);
+ SwitchToDifficulty(Beatmap.Value.BeatmapInfo);
}
private void updateLastSavedHash()
diff --git a/osu.Game/Screens/Edit/PromptForDifficultyDeleteDialog.cs b/osu.Game/Screens/Edit/PromptForDifficultyDeleteDialog.cs
index a8f8afd47c..dcea9f1210 100644
--- a/osu.Game/Screens/Edit/PromptForDifficultyDeleteDialog.cs
+++ b/osu.Game/Screens/Edit/PromptForDifficultyDeleteDialog.cs
@@ -9,7 +9,7 @@ namespace osu.Game.Screens.Edit
{
public class PromptForDifficultyDeleteDialog : PopupDialog
{
- public PromptForDifficultyDeleteDialog(Action delete, Action cancel)
+ public PromptForDifficultyDeleteDialog(Action hide, Action delete, Action cancel)
{
HeaderText = "Are you sure you want to delete this difficulty?";
@@ -17,9 +17,14 @@ namespace osu.Game.Screens.Edit
Buttons = new PopupDialogButton[]
{
+ new PopupDialogOkButton
+ {
+ Text = @"Hide this difficulty instead (recommended)",
+ Action = hide
+ },
new PopupDialogDangerousButton
{
- Text = @"Yes, delete this difficulty!",
+ Text = @"Yes, DELETE this difficulty!",
Action = delete
},
new PopupDialogCancelButton