From 8fe422c35a70593e67fee7b904a5f13bd6a63674 Mon Sep 17 00:00:00 2001 From: Salman Alshamrani Date: Wed, 14 May 2025 12:51:44 +0300 Subject: [PATCH 1/2] Expose general song select operations --- .../Select/BeatmapClearScoresDialog.cs | 4 ++-- osu.Game/Screens/SelectV2/SoloSongSelect.cs | 13 +++++++++++++ osu.Game/Screens/SelectV2/SongSelect.cs | 19 +++++++++++++++---- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs index 8efad451df..e3981c85f0 100644 --- a/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs +++ b/osu.Game/Screens/Select/BeatmapClearScoresDialog.cs @@ -15,13 +15,13 @@ namespace osu.Game.Screens.Select [Resolved] private ScoreManager scoreManager { get; set; } = null!; - public BeatmapClearScoresDialog(BeatmapInfo beatmapInfo, Action onCompletion) + public BeatmapClearScoresDialog(BeatmapInfo beatmapInfo, Action? onCompletion = null) { BodyText = $"All local scores on {beatmapInfo.GetDisplayTitle()}"; DangerousAction = () => { Task.Run(() => scoreManager.Delete(beatmapInfo)) - .ContinueWith(_ => onCompletion); + .ContinueWith(_ => onCompletion?.Invoke()); }; } } diff --git a/osu.Game/Screens/SelectV2/SoloSongSelect.cs b/osu.Game/Screens/SelectV2/SoloSongSelect.cs index e6ecdc6705..a5e4934c2e 100644 --- a/osu.Game/Screens/SelectV2/SoloSongSelect.cs +++ b/osu.Game/Screens/SelectV2/SoloSongSelect.cs @@ -3,12 +3,25 @@ using System; using osu.Framework.Screens; +using osu.Game.Beatmaps; +using osu.Game.Screens.Edit; using osu.Game.Screens.Play; namespace osu.Game.Screens.SelectV2 { public partial class SoloSongSelect : SongSelect { + /// + /// Opens beatmap editor with the given beatmap. + /// + public void Edit(BeatmapInfo beatmap) + { + // Forced refetch is important here to guarantee correct invalidation across all difficulties. + Beatmap.Value = Beatmaps.GetWorkingBeatmap(beatmap, true); + + this.Push(new EditorLoader()); + } + protected override bool OnStart() { this.Push(new PlayerLoaderV2(() => new SoloPlayer())); diff --git a/osu.Game/Screens/SelectV2/SongSelect.cs b/osu.Game/Screens/SelectV2/SongSelect.cs index ecf2111cbd..f4ecd9d520 100644 --- a/osu.Game/Screens/SelectV2/SongSelect.cs +++ b/osu.Game/Screens/SelectV2/SongSelect.cs @@ -74,6 +74,9 @@ namespace osu.Game.Screens.SelectV2 [Resolved] private OsuLogo? logo { get; set; } + [Resolved] + protected BeatmapManager Beatmaps { get; private set; } = null!; + [Resolved] private IDialogOverlay? dialogs { get; set; } @@ -346,11 +349,19 @@ namespace osu.Game.Screens.SelectV2 #region Beatmap management /// - /// Opens up with the given beatmap set. + /// Requests the user for confirmation to delete the given beatmap set. /// - public void RequestDeleteBeatmap(BeatmapSetInfo set) + public void DeleteBeatmap(BeatmapSetInfo beatmapSet) { - dialogs?.Push(new BeatmapDeleteDialog(set)); + dialogs?.Push(new BeatmapDeleteDialog(beatmapSet)); + } + + /// + /// Requests the user for confirmation to clear all local scores in the given beatmap. + /// + public void ClearScores(BeatmapInfo beatmap) + { + dialogs?.Push(new BeatmapClearScoresDialog(beatmap)); } #endregion @@ -387,7 +398,7 @@ namespace osu.Game.Screens.SelectV2 if (e.ShiftPressed) { if (!Beatmap.IsDefault) - RequestDeleteBeatmap(Beatmap.Value.BeatmapSetInfo); + DeleteBeatmap(Beatmap.Value.BeatmapSetInfo); return true; } From 5eb14a5b26477ac71ddbd8744fee9c703e64c5f5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 15 May 2025 01:55:49 +0900 Subject: [PATCH 2/2] Move dependency to correct class and use more appropriate name --- osu.Game/Screens/SelectV2/SoloSongSelect.cs | 6 +++++- osu.Game/Screens/SelectV2/SongSelect.cs | 9 +++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/SelectV2/SoloSongSelect.cs b/osu.Game/Screens/SelectV2/SoloSongSelect.cs index a5e4934c2e..7e26fc1e32 100644 --- a/osu.Game/Screens/SelectV2/SoloSongSelect.cs +++ b/osu.Game/Screens/SelectV2/SoloSongSelect.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Framework.Allocation; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Screens.Edit; @@ -11,13 +12,16 @@ namespace osu.Game.Screens.SelectV2 { public partial class SoloSongSelect : SongSelect { + [Resolved] + private BeatmapManager beatmaps { get; set; } = null!; + /// /// Opens beatmap editor with the given beatmap. /// public void Edit(BeatmapInfo beatmap) { // Forced refetch is important here to guarantee correct invalidation across all difficulties. - Beatmap.Value = Beatmaps.GetWorkingBeatmap(beatmap, true); + Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, true); this.Push(new EditorLoader()); } diff --git a/osu.Game/Screens/SelectV2/SongSelect.cs b/osu.Game/Screens/SelectV2/SongSelect.cs index f4ecd9d520..b9898e841d 100644 --- a/osu.Game/Screens/SelectV2/SongSelect.cs +++ b/osu.Game/Screens/SelectV2/SongSelect.cs @@ -75,10 +75,7 @@ namespace osu.Game.Screens.SelectV2 private OsuLogo? logo { get; set; } [Resolved] - protected BeatmapManager Beatmaps { get; private set; } = null!; - - [Resolved] - private IDialogOverlay? dialogs { get; set; } + private IDialogOverlay? dialogOverlay { get; set; } [BackgroundDependencyLoader] private void load() @@ -353,7 +350,7 @@ namespace osu.Game.Screens.SelectV2 /// public void DeleteBeatmap(BeatmapSetInfo beatmapSet) { - dialogs?.Push(new BeatmapDeleteDialog(beatmapSet)); + dialogOverlay?.Push(new BeatmapDeleteDialog(beatmapSet)); } /// @@ -361,7 +358,7 @@ namespace osu.Game.Screens.SelectV2 /// public void ClearScores(BeatmapInfo beatmap) { - dialogs?.Push(new BeatmapClearScoresDialog(beatmap)); + dialogOverlay?.Push(new BeatmapClearScoresDialog(beatmap)); } #endregion