2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2017-11-08 06:13:56 +08:00
|
|
|
|
using System;
|
2017-07-13 12:17:47 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-07-13 12:24:59 +08:00
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2017-07-13 12:17:47 +08:00
|
|
|
|
{
|
2019-11-01 18:40:45 +08:00
|
|
|
|
[LongRunningLoad]
|
2021-10-21 15:53:50 +08:00
|
|
|
|
public partial class OnlineBeatmapSetCover : Sprite
|
2017-07-13 12:17:47 +08:00
|
|
|
|
{
|
2021-10-20 17:43:48 +08:00
|
|
|
|
private readonly IBeatmapSetOnlineInfo set;
|
2017-11-19 21:16:00 +08:00
|
|
|
|
private readonly BeatmapSetCoverType type;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-21 15:53:50 +08:00
|
|
|
|
public OnlineBeatmapSetCover(IBeatmapSetOnlineInfo set, BeatmapSetCoverType type = BeatmapSetCoverType.Cover)
|
2017-07-13 12:17:47 +08:00
|
|
|
|
{
|
2022-12-23 04:27:59 +08:00
|
|
|
|
ArgumentNullException.ThrowIfNull(set);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-07-13 12:17:47 +08:00
|
|
|
|
this.set = set;
|
2017-11-19 21:16:00 +08:00
|
|
|
|
this.type = type;
|
2017-07-13 12:17:47 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-07-13 12:17:47 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2018-12-27 21:13:51 +08:00
|
|
|
|
private void load(LargeTextureStore textures)
|
2017-07-13 12:17:47 +08:00
|
|
|
|
{
|
2017-11-19 21:16:00 +08:00
|
|
|
|
string resource = null;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-19 21:16:00 +08:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case BeatmapSetCoverType.Cover:
|
2021-10-20 17:43:48 +08:00
|
|
|
|
resource = set.Covers.Cover;
|
2017-11-19 21:16:00 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2017-11-19 21:16:00 +08:00
|
|
|
|
case BeatmapSetCoverType.Card:
|
2021-10-20 17:43:48 +08:00
|
|
|
|
resource = set.Covers.Card;
|
2017-11-19 21:16:00 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2017-11-19 21:16:00 +08:00
|
|
|
|
case BeatmapSetCoverType.List:
|
2021-10-20 17:43:48 +08:00
|
|
|
|
resource = set.Covers.List;
|
2017-11-19 21:16:00 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-07-13 12:17:47 +08:00
|
|
|
|
if (resource != null)
|
2018-08-31 06:04:40 +08:00
|
|
|
|
Texture = textures.Get(resource);
|
2017-07-13 12:17:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-11-19 21:16:00 +08:00
|
|
|
|
public enum BeatmapSetCoverType
|
|
|
|
|
{
|
|
|
|
|
Cover,
|
|
|
|
|
Card,
|
|
|
|
|
List,
|
|
|
|
|
}
|
2017-07-13 12:17:47 +08:00
|
|
|
|
}
|