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.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using OpenTK; using OpenTK;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
@ -26,11 +27,12 @@ namespace osu.Game.Screens.Backgrounds
{ {
if (beatmap == value && beatmap != null) if (beatmap == value && beatmap != null)
return; return;
beatmap = value; beatmap = value;
Schedule(() => Schedule(() =>
{ {
var newBackground = beatmap == null ? new Background(@"Backgrounds/bg1") : new BeatmapBackground(beatmap); var newBackground = new BeatmapBackground(beatmap);
LoadComponentAsync(newBackground, delegate LoadComponentAsync(newBackground, delegate
{ {
@ -51,7 +53,7 @@ namespace osu.Game.Screens.Backgrounds
} }
} }
public BackgroundScreenBeatmap(WorkingBeatmap beatmap) public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
{ {
Beatmap = beatmap; Beatmap = beatmap;
} }
@ -80,9 +82,9 @@ namespace osu.Game.Screens.Backgrounds
} }
[BackgroundDependencyLoader] [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 @@ namespace osu.Game.Screens.Select
{ {
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>(); private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private BeatmapDatabase database; private BeatmapDatabase database;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
private readonly BeatmapCarousel carousel; private readonly BeatmapCarousel carousel;
private TrackManager trackManager; private TrackManager trackManager;