Give song select a better default background whecn the beatmap's can't be loaded

This commit is contained in:
Dean Herbert 2017-07-19 13:33:00 +09:00
parent d0dea33faa
commit 8e8767cd37
2 changed files with 7 additions and 5 deletions

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using OpenTK;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Backgrounds;
@ -26,11 +27,12 @@ public WorkingBeatmap Beatmap
{
if (beatmap == value && beatmap != null)
return;
beatmap = value;
Schedule(() =>
{
var newBackground = beatmap == null ? new Background(@"Backgrounds/bg1") : new BeatmapBackground(beatmap);
var newBackground = new BeatmapBackground(beatmap);
LoadComponentAsync(newBackground, delegate
{
@ -51,7 +53,7 @@ public WorkingBeatmap Beatmap
}
}
public BackgroundScreenBeatmap(WorkingBeatmap beatmap)
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
{
Beatmap = beatmap;
}
@ -80,9 +82,9 @@ public BeatmapBackground(WorkingBeatmap beatmap)
}
[BackgroundDependencyLoader]
private void load()
private void load(TextureStore textures)
{
Sprite.Texture = beatmap?.Background;
Sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
}
}
}

View File

@ -29,7 +29,7 @@ public abstract class SongSelect : OsuScreen
{
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private BeatmapDatabase database;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
private readonly BeatmapCarousel carousel;
private TrackManager trackManager;