mirror of
https://github.com/ppy/osu
synced 2024-12-12 09:58:22 +00:00
Update UpdateableBeatmapBackgroundSprite
to accept IBeatmapInfo
This commit is contained in:
parent
45db99171e
commit
f268363924
@ -12,9 +12,9 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
/// <summary>
|
||||
/// Display a beatmap background from a local source, but fallback to online source if not available.
|
||||
/// </summary>
|
||||
public class UpdateableBeatmapBackgroundSprite : ModelBackedDrawable<BeatmapInfo>
|
||||
public class UpdateableBeatmapBackgroundSprite : ModelBackedDrawable<IBeatmapInfo>
|
||||
{
|
||||
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||
public readonly Bindable<IBeatmapInfo> Beatmap = new Bindable<IBeatmapInfo>();
|
||||
|
||||
protected override double LoadDelay => 500;
|
||||
|
||||
@ -39,7 +39,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
protected override double TransformDuration => 400;
|
||||
|
||||
protected override Drawable CreateDrawable(BeatmapInfo model)
|
||||
protected override Drawable CreateDrawable(IBeatmapInfo model)
|
||||
{
|
||||
var drawable = getDrawableForModel(model);
|
||||
drawable.RelativeSizeAxes = Axes.Both;
|
||||
@ -50,15 +50,16 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
return drawable;
|
||||
}
|
||||
|
||||
private Drawable getDrawableForModel(BeatmapInfo model)
|
||||
private Drawable getDrawableForModel(IBeatmapInfo model)
|
||||
{
|
||||
// prefer online cover where available.
|
||||
if (model?.BeatmapSet?.OnlineInfo != null)
|
||||
return new OnlineBeatmapSetCover(model.BeatmapSet, beatmapSetCoverType);
|
||||
if (model?.BeatmapSet is IBeatmapSetOnlineInfo online)
|
||||
return new OnlineBeatmapSetCover(online, beatmapSetCoverType);
|
||||
|
||||
return model?.ID > 0
|
||||
? new BeatmapBackgroundSprite(beatmaps.GetWorkingBeatmap(model))
|
||||
: new BeatmapBackgroundSprite(beatmaps.DefaultBeatmap);
|
||||
if (model is BeatmapInfo localModel)
|
||||
return new BeatmapBackgroundSprite(beatmaps.GetWorkingBeatmap(localModel));
|
||||
|
||||
return new BeatmapBackgroundSprite(beatmaps.DefaultBeatmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -333,13 +333,14 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
|
||||
public PanelBackground()
|
||||
{
|
||||
UpdateableBeatmapBackgroundSprite backgroundSprite;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new UpdateableBeatmapBackgroundSprite
|
||||
backgroundSprite = new UpdateableBeatmapBackgroundSprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fill,
|
||||
Beatmap = { BindTarget = Beatmap }
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
@ -374,6 +375,10 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// manual binding required as playlists don't expose IBeatmapInfo currently.
|
||||
// may be removed in the future if this changes.
|
||||
Beatmap.BindValueChanged(beatmap => backgroundSprite.Beatmap.Value = beatmap.NewValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user