2019-02-05 18:00:01 +08:00
|
|
|
// 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.
|
|
|
|
|
2020-02-13 17:48:28 +08:00
|
|
|
using System.Linq;
|
2019-02-05 18:00:01 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2019-02-05 18:00:01 +08:00
|
|
|
{
|
2020-12-26 00:12:46 +08:00
|
|
|
public class OnlinePlayBackgroundSprite : OnlinePlayComposite
|
2019-02-05 18:00:01 +08:00
|
|
|
{
|
2019-03-05 17:59:25 +08:00
|
|
|
private readonly BeatmapSetCoverType beatmapSetCoverType;
|
2020-02-13 17:48:28 +08:00
|
|
|
private UpdateableBeatmapBackgroundSprite sprite;
|
2019-03-05 17:59:25 +08:00
|
|
|
|
2020-12-26 00:12:46 +08:00
|
|
|
public OnlinePlayBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
|
2019-03-05 17:59:25 +08:00
|
|
|
{
|
|
|
|
this.beatmapSetCoverType = beatmapSetCoverType;
|
|
|
|
}
|
|
|
|
|
2019-02-05 18:00:01 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
InternalChild = sprite = CreateBackgroundSprite();
|
|
|
|
|
2020-02-17 14:06:14 +08:00
|
|
|
Playlist.CollectionChanged += (_, __) => updateBeatmap();
|
2020-02-13 17:48:28 +08:00
|
|
|
|
|
|
|
updateBeatmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateBeatmap()
|
|
|
|
{
|
|
|
|
sprite.Beatmap.Value = Playlist.FirstOrDefault()?.Beatmap.Value;
|
2019-02-05 18:00:01 +08:00
|
|
|
}
|
|
|
|
|
2019-03-05 17:59:25 +08:00
|
|
|
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(beatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
2019-02-05 18:00:01 +08:00
|
|
|
}
|
|
|
|
}
|