mirror of
https://github.com/ppy/osu.git
synced 2024-11-17 17:22:54 +08:00
e8e387b549
Consider this a request for comment. It's the cleanest solution I can come up with without dropping either the blur, or use of `ModelBackedDrawable`. Intended to resolve https://github.com/ppy/osu/issues/14276.
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System.Linq;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Graphics;
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
|
{
|
|
public class OnlinePlayBackgroundSprite : OnlinePlayComposite
|
|
{
|
|
protected readonly BeatmapSetCoverType BeatmapSetCoverType;
|
|
private UpdateableBeatmapBackgroundSprite sprite;
|
|
|
|
public OnlinePlayBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
|
|
{
|
|
BeatmapSetCoverType = beatmapSetCoverType;
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
InternalChild = sprite = CreateBackgroundSprite();
|
|
|
|
Playlist.CollectionChanged += (_, __) => updateBeatmap();
|
|
|
|
updateBeatmap();
|
|
}
|
|
|
|
private void updateBeatmap()
|
|
{
|
|
sprite.Beatmap.Value = Playlist.FirstOrDefault()?.Beatmap.Value;
|
|
}
|
|
|
|
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
|
}
|
|
}
|