diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 51fa4412bf..88b44fa24d 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -31,7 +31,7 @@ namespace osu.Game.Database /// /// A default representation of a WorkingBeatmap to use when no beatmap is available. /// - public WorkingBeatmap DefaultBeatmap { get; set; } + public WorkingBeatmap DefaultBeatmap { private get; set; } public BeatmapDatabase(Storage storage, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null) : base(storage, connection) { @@ -273,7 +273,7 @@ namespace osu.Game.Database public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { - if (beatmapInfo == DefaultBeatmap?.BeatmapInfo) + if (beatmapInfo == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo) return DefaultBeatmap; if (beatmapInfo.BeatmapSet == null || beatmapInfo.Ruleset == null) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 2e8bb94752..e135fefc6d 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -137,7 +137,7 @@ namespace osu.Game.Screens.Select { selectedGroup = null; selectedPanel = null; - SelectionChanged?.Invoke(database.DefaultBeatmap.BeatmapInfo); + SelectionChanged?.Invoke(null); return; } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ff11a34461..d28a84217b 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -219,31 +219,40 @@ namespace osu.Game.Screens.Select /// private void carouselSelectionChanged(BeatmapInfo beatmap) { - selectionChangedDebounce?.Cancel(); - - if (beatmap.Equals(beatmapNoDebounce)) - return; - - bool preview = beatmap.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID; - - if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) - sampleChangeDifficulty.Play(); - else - sampleChangeBeatmap.Play(); - - beatmapNoDebounce = beatmap; - Action performLoad = delegate { + bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID; + Beatmap.Value = database.GetWorkingBeatmap(beatmap, Beatmap); + ensurePlayingSelected(preview); changeBackground(Beatmap.Value); }; - if (beatmap == Beatmap.Value.BeatmapInfo) - performLoad(); + if (beatmap == null) + { + if (!Beatmap.IsDefault) + performLoad(); + } else - selectionChangedDebounce = Scheduler.AddDelayed(performLoad, 100); + { + selectionChangedDebounce?.Cancel(); + + if (beatmap.Equals(beatmapNoDebounce)) + return; + + if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) + sampleChangeDifficulty.Play(); + else + sampleChangeBeatmap.Play(); + + beatmapNoDebounce = beatmap; + + if (beatmap == Beatmap.Value.BeatmapInfo) + performLoad(); + else + selectionChangedDebounce = Scheduler.AddDelayed(performLoad, 100); + } } private void triggerRandom(UserInputManager input)