Fix removal of the last one beatmap.

This commit is contained in:
Huo Yaoyuan 2017-03-14 04:59:44 +08:00
parent 14a22f032f
commit 3913a0a9ee
3 changed files with 25 additions and 14 deletions

View File

@ -247,6 +247,8 @@ protected override void Update()
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 @@ private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
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;

View File

@ -16,7 +16,6 @@
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 @@ private void load(OsuGameBase game)
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 @@ public void UpdateBeatmap(WorkingBeatmap beatmap)
}));
//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

View File

@ -326,8 +326,7 @@ private void changeBackground(WorkingBeatmap beatmap)
backgroundModeBeatmap.FadeTo(1, 250);
}
if (beatmap != null)
beatmapInfoWedge.UpdateBeatmap(beatmap);
beatmapInfoWedge.UpdateBeatmap(beatmap);
}
/// <summary>
@ -337,11 +336,11 @@ protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
{
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);
}
/// <summary>