1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:42:56 +08:00

Add back fallback behavior for match creation

This commit is contained in:
David Zhao 2019-03-05 16:41:59 +09:00
parent 11e353c152
commit 166a8c8bbb
4 changed files with 22 additions and 4 deletions

View File

@ -263,6 +263,9 @@ namespace osu.Game.Beatmaps
if (beatmapInfo.Metadata == null)
beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata;
var info = beatmapInfo;
beatmapInfo = QueryBeatmap(p => info.OnlineBeatmapID == p.OnlineBeatmapID) ?? beatmapInfo;
WorkingBeatmap working = new BeatmapManagerWorkingBeatmap(Files.Store, new LargeTextureStore(host?.CreateTextureLoaderStore(Files.Store)), beatmapInfo, audioManager);
previous?.TransferTo(working);

View File

@ -20,10 +20,13 @@ namespace osu.Game.Beatmaps.Drawables
private readonly BeatmapSetCoverType beatmapSetCoverType;
public UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
private readonly bool fallback;
public UpdateableBeatmapBackgroundSprite(bool fallback = false, BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
{
Beatmap.BindValueChanged(b => Model = b.NewValue);
this.beatmapSetCoverType = beatmapSetCoverType;
this.fallback = fallback;
}
protected override Drawable CreateDrawable(BeatmapInfo model)
@ -32,11 +35,18 @@ namespace osu.Game.Beatmaps.Drawables
{
Drawable drawable;
var localBeatmap = beatmaps.GetWorkingBeatmap(model);
if (model?.BeatmapSet?.OnlineInfo != null)
drawable = new BeatmapSetCover(model.BeatmapSet, beatmapSetCoverType);
else if (fallback && localBeatmap.BeatmapInfo.ID != 0)
{
// Fall back to local background if one exists
drawable = new BeatmapBackgroundSprite(beatmaps.GetWorkingBeatmap(model));
}
else
{
// Use the default background if somehow an online set does not exist.
// Use the default background if somehow an online set does not exist and we don't have a local copy.
drawable = new BeatmapBackgroundSprite(beatmaps.GetWorkingBeatmap(null));
}

View File

@ -205,7 +205,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
private class MultiplayerListSprite : MultiplayerBackgroundSprite
{
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType.List) { RelativeSizeAxes = Axes.Both };
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(beatmapSetCoverType: BeatmapSetCoverType.List) { RelativeSizeAxes = Axes.Both };
}
private class RoomName : OsuSpriteText

View File

@ -132,10 +132,15 @@ namespace osu.Game.Screens.Multi.Match.Components
private class HeaderBackgroundSprite : MultiplayerBackgroundSprite
{
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BackgroundSprite { RelativeSizeAxes = Axes.Both };
protected override UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new BackgroundSprite(true) { RelativeSizeAxes = Axes.Both };
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
{
public BackgroundSprite(bool fallback = false, BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
: base(fallback, beatmapSetCoverType)
{
}
protected override double FadeDuration => 200;
}
}