diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 1dcab6cb5d..c52576fb9f 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -170,7 +170,7 @@ namespace osu.Game.Beatmaps /// Delete a beatmap from the manager. /// Is a no-op for already deleted beatmaps. /// - /// The beatmap to delete. + /// The beatmap set to delete. public void Delete(BeatmapSetInfo beatmapSet) { lock (beatmaps) @@ -180,6 +180,16 @@ namespace osu.Game.Beatmaps files.Dereference(beatmapSet.Files.Select(f => f.FileInfo).ToArray()); } + /// + /// Delete a beatmap from the manager. + /// Is a no-op for already deleted beatmaps. + /// + /// The beatmap difficulty to delete. + public void Delete(BeatmapInfo beatmap) + { + //todo: implement + } + /// /// Returns a to a usable state if it has previously been deleted but not yet purged. /// Is a no-op for already usable beatmaps. diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index a4c7da71d8..b47210620d 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -25,6 +25,8 @@ namespace osu.Game.Beatmaps.Drawables public Action DeleteRequested; + public Action DeleteDifficultyRequested; + public BeatmapSetHeader Header; private BeatmapGroupState state; @@ -77,6 +79,7 @@ namespace osu.Game.Beatmaps.Drawables { Alpha = 0, GainedSelection = panelGainedSelection, + DeleteRequested = p => DeleteDifficultyRequested?.Invoke(p), StartRequested = p => { StartRequested?.Invoke(p.Beatmap); }, RelativeSizeAxes = Axes.X, }).ToList(); diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 448f5395b6..a1c7f64188 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -140,7 +140,9 @@ namespace osu.Game.Screens.Select public Action StartRequested; - public Action DeleteRequested; + public Action DeleteRequested; + + public Action DeleteDifficultyRequested; public void SelectNext(int direction = 1, bool skipDifficulties = true) { @@ -308,6 +310,7 @@ namespace osu.Game.Screens.Select SelectionChanged = (g, p) => selectGroup(g, p), StartRequested = b => StartRequested?.Invoke(), DeleteRequested = b => DeleteRequested?.Invoke(b), + DeleteDifficultyRequested = b => DeleteDifficultyRequested?.Invoke(b), State = BeatmapGroupState.Collapsed }; } diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index 96caf2f236..15ec84a7d8 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -13,29 +13,36 @@ namespace osu.Game.Screens.Select { private BeatmapManager manager; + private readonly Action deleteAction; + [BackgroundDependencyLoader] private void load(BeatmapManager beatmapManager) { manager = beatmapManager; } - public BeatmapDeleteDialog(WorkingBeatmap beatmap) + public BeatmapDeleteDialog(BeatmapSetInfo beatmap) : this() { - if (beatmap == null) throw new ArgumentNullException(nameof(beatmap)); + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title} (ALL DIFFICULTIES)"; + deleteAction = () => manager.Delete(beatmap); + } + public BeatmapDeleteDialog(BeatmapInfo beatmap) : this() + { + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title} [{beatmap.Version}]"; + deleteAction = () => manager.Delete(beatmap); + } + + public BeatmapDeleteDialog() + { Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; - BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}"; Buttons = new PopupDialogButton[] { new PopupDialogOkButton { Text = @"Yes. Totally. Delete it.", - Action = () => - { - beatmap.Dispose(); - manager.Delete(beatmap.BeatmapSetInfo); - }, + Action = () => deleteAction(), }, new PopupDialogCancelButton { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6cd47aa9f6..b3ee33e7c6 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -107,6 +107,7 @@ namespace osu.Game.Screens.Select SelectionChanged = carouselSelectionChanged, BeatmapsChanged = carouselBeatmapsLoaded, DeleteRequested = b => promptDelete(b), + DeleteDifficultyRequested = b => promptDelete(b), StartRequested = () => carouselRaisedStart(), }); Add(FilterControl = new FilterControl @@ -164,7 +165,7 @@ namespace osu.Game.Screens.Select Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2); Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); - BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap), Key.Number4, float.MaxValue); + BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); } if (manager == null) @@ -399,6 +400,14 @@ namespace osu.Game.Screens.Select dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); } + private void promptDelete(BeatmapInfo beatmap) + { + if (beatmap == null) + return; + + dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); + } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (args.Repeat) return false;