2021-08-19 18:10:54 +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.
|
|
|
|
|
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
|
|
|
{
|
|
|
|
public class PlaylistItemBackground : Background
|
|
|
|
{
|
2021-11-01 16:30:19 +08:00
|
|
|
public readonly IBeatmapInfo? Beatmap;
|
2021-08-19 18:10:54 +08:00
|
|
|
|
|
|
|
public PlaylistItemBackground(PlaylistItem? playlistItem)
|
|
|
|
{
|
2021-11-04 12:36:32 +08:00
|
|
|
Beatmap = playlistItem?.Beatmap.Value;
|
2021-08-19 18:10:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(BeatmapManager beatmaps, LargeTextureStore textures)
|
|
|
|
{
|
|
|
|
Texture? texture = null;
|
|
|
|
|
|
|
|
// prefer online cover where available.
|
2021-11-01 16:30:19 +08:00
|
|
|
if (Beatmap?.BeatmapSet is IBeatmapSetOnlineInfo online)
|
|
|
|
texture = textures.Get(online.Covers.Cover);
|
2021-08-19 18:10:54 +08:00
|
|
|
|
|
|
|
Sprite.Texture = texture ?? beatmaps.DefaultBeatmap.Background;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool Equals(Background? other)
|
|
|
|
{
|
|
|
|
if (ReferenceEquals(null, other)) return false;
|
|
|
|
if (ReferenceEquals(this, other)) return true;
|
|
|
|
|
|
|
|
return other.GetType() == GetType()
|
2021-11-01 16:30:19 +08:00
|
|
|
&& ((PlaylistItemBackground)other).Beatmap == Beatmap;
|
2021-08-19 18:10:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|