2019-02-05 10:00:01 +00: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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2019-02-05 10:00:01 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2021-12-20 12:19:00 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2019-02-05 10:00:01 +00:00
|
|
|
|
2020-12-25 15:50:00 +00:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2019-02-05 10:00:01 +00:00
|
|
|
{
|
2020-12-25 16:12:46 +00:00
|
|
|
public partial class OnlinePlayBackgroundSprite : OnlinePlayComposite
|
2019-02-05 10:00:01 +00:00
|
|
|
{
|
2021-08-15 23:02:23 +00:00
|
|
|
protected readonly BeatmapSetCoverType BeatmapSetCoverType;
|
2020-02-13 09:48:28 +00:00
|
|
|
private UpdateableBeatmapBackgroundSprite sprite;
|
2019-03-05 09:59:25 +00:00
|
|
|
|
2020-12-25 16:12:46 +00:00
|
|
|
public OnlinePlayBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
|
2019-03-05 09:59:25 +00:00
|
|
|
{
|
2021-08-15 23:02:23 +00:00
|
|
|
BeatmapSetCoverType = beatmapSetCoverType;
|
2019-03-05 09:59:25 +00:00
|
|
|
}
|
|
|
|
|
2019-02-05 10:00:01 +00:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
InternalChild = sprite = CreateBackgroundSprite();
|
|
|
|
|
2022-02-21 10:02:21 +00:00
|
|
|
CurrentPlaylistItem.BindValueChanged(_ => updateBeatmap());
|
2022-06-24 12:25:23 +00:00
|
|
|
Playlist.CollectionChanged += (_, _) => updateBeatmap();
|
2020-02-13 09:48:28 +00:00
|
|
|
|
|
|
|
updateBeatmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateBeatmap()
|
|
|
|
{
|
2022-02-21 10:02:21 +00:00
|
|
|
sprite.Beatmap.Value = CurrentPlaylistItem.Value?.Beatmap ?? Playlist.GetCurrentItem()?.Beatmap;
|
2019-02-05 10:00:01 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 23:02:23 +00:00
|
|
|
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
2019-02-05 10:00:01 +00:00
|
|
|
}
|
|
|
|
}
|