mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 02:43:02 +08: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>
|
/// <summary>
|
||||||
/// Display a beatmap background from a local source, but fallback to online source if not available.
|
/// Display a beatmap background from a local source, but fallback to online source if not available.
|
||||||
/// </summary>
|
/// </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;
|
protected override double LoadDelay => 500;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
protected override double TransformDuration => 400;
|
protected override double TransformDuration => 400;
|
||||||
|
|
||||||
protected override Drawable CreateDrawable(BeatmapInfo model)
|
protected override Drawable CreateDrawable(IBeatmapInfo model)
|
||||||
{
|
{
|
||||||
var drawable = getDrawableForModel(model);
|
var drawable = getDrawableForModel(model);
|
||||||
drawable.RelativeSizeAxes = Axes.Both;
|
drawable.RelativeSizeAxes = Axes.Both;
|
||||||
@ -50,15 +50,16 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getDrawableForModel(BeatmapInfo model)
|
private Drawable getDrawableForModel(IBeatmapInfo model)
|
||||||
{
|
{
|
||||||
// prefer online cover where available.
|
// prefer online cover where available.
|
||||||
if (model?.BeatmapSet?.OnlineInfo != null)
|
if (model?.BeatmapSet is IBeatmapSetOnlineInfo online)
|
||||||
return new OnlineBeatmapSetCover(model.BeatmapSet, beatmapSetCoverType);
|
return new OnlineBeatmapSetCover(online, beatmapSetCoverType);
|
||||||
|
|
||||||
return model?.ID > 0
|
if (model is BeatmapInfo localModel)
|
||||||
? new BeatmapBackgroundSprite(beatmaps.GetWorkingBeatmap(model))
|
return new BeatmapBackgroundSprite(beatmaps.GetWorkingBeatmap(localModel));
|
||||||
: new BeatmapBackgroundSprite(beatmaps.DefaultBeatmap);
|
|
||||||
|
return new BeatmapBackgroundSprite(beatmaps.DefaultBeatmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,13 +333,14 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
|
|
||||||
public PanelBackground()
|
public PanelBackground()
|
||||||
{
|
{
|
||||||
|
UpdateableBeatmapBackgroundSprite backgroundSprite;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
new UpdateableBeatmapBackgroundSprite
|
backgroundSprite = new UpdateableBeatmapBackgroundSprite
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
FillMode = FillMode.Fill,
|
FillMode = FillMode.Fill,
|
||||||
Beatmap = { BindTarget = Beatmap }
|
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
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