From 3913a0a9ee688551e9a5d7154d6e0948c178988c Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Tue, 14 Mar 2017 04:59:44 +0800 Subject: [PATCH] Fix removal of the last one beatmap. --- osu.Game/Overlays/MusicController.cs | 20 +++++++++++++------- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 12 +++++++++--- osu.Game/Screens/Select/PlaySongSelect.cs | 7 +++---- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 1b4692f50e..5c9adb6b20 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -210,7 +210,7 @@ namespace osu.Game.Overlays } } }; - + this.beatmaps = beatmaps; trackManager = osuGame.Audio.Track; preferUnicode = config.GetBindable(OsuConfig.ShowUnicode); @@ -247,6 +247,8 @@ namespace osu.Game.Overlays if (current.Track.HasCompleted && !current.Track.Looping) next(); } + else + playButton.Icon = FontAwesome.fa_play_circle_o; } private void preferUnicode_changed(object sender, EventArgs e) @@ -337,12 +339,16 @@ namespace osu.Game.Overlays Task.Run(() => { if (beatmap?.Beatmap == null) - //todo: we may need to display some default text here (currently in the constructor). - return; - - BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; - title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); - artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); + { + title.Text = @"Nothing to play"; + artist.Text = @"Nothing to play"; + } + else + { + BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); + artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); + } }); MusicControllerBackground newBackground; diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index bc3b16079c..eac12f7370 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -16,7 +16,6 @@ using osu.Game.Database; using osu.Framework.Graphics.Colour; using osu.Game.Beatmaps.Drawables; using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.MathUtils; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -56,8 +55,15 @@ namespace osu.Game.Screens.Select public void UpdateBeatmap(WorkingBeatmap beatmap) { if (beatmap?.BeatmapInfo == null) + { + FadeOut(250); + beatmapInfoContainer?.FadeOut(250); + beatmapInfoContainer?.Expire(); + beatmapInfoContainer = null; return; + } + FadeIn(250); var lastContainer = beatmapInfoContainer; float newDepth = lastContainer?.Depth + 1 ?? 0; @@ -84,7 +90,7 @@ namespace osu.Game.Screens.Select })); //get statistics fromt he current ruleset. - Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).ForEach(s => labels.Add(new InfoLabel(s))); + labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s))); } (beatmapInfoContainer = new BufferedContainer @@ -191,7 +197,7 @@ namespace osu.Game.Screens.Select private string getBPMRange(Beatmap beatmap) { - double bpmMax = beatmap.BPMMaximum; + double bpmMax = beatmap.BPMMaximum; double bpmMin = beatmap.BPMMinimum; if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm"; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 86f9bc30cf..09ba794122 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -326,8 +326,7 @@ namespace osu.Game.Screens.Select backgroundModeBeatmap.FadeTo(1, 250); } - if (beatmap != null) - beatmapInfoWedge.UpdateBeatmap(beatmap); + beatmapInfoWedge.UpdateBeatmap(beatmap); } /// @@ -337,11 +336,11 @@ namespace osu.Game.Screens.Select { base.OnBeatmapChanged(beatmap); - beatmap.Mods.BindTo(modSelect.SelectedMods); + beatmap?.Mods.BindTo(modSelect.SelectedMods); //todo: change background in selectionChanged instead; support per-difficulty backgrounds. changeBackground(beatmap); - carousel.SelectBeatmap(beatmap.BeatmapInfo); + carousel.SelectBeatmap(beatmap?.BeatmapInfo); } ///