mirror of
https://github.com/ppy/osu.git
synced 2024-11-07 04:37:51 +08:00
39 lines
1.3 KiB
C#
39 lines
1.3 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
|
|
{
|
|
private readonly BeatmapSetCoverType beatmapSetCoverType;
|
|
private UpdateableBeatmapBackgroundSprite sprite;
|
|
|
|
public OnlinePlayBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
|
|
{
|
|
this.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 };
|
|
}
|
|
}
|