1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 19:27:31 +08:00
osu-lazer/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs

56 lines
1.5 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
2018-08-27 16:26:44 +08:00
using System.Threading.Tasks;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps.Drawables
{
public class BeatmapSetCover : Sprite
{
private readonly BeatmapSetInfo set;
private readonly BeatmapSetCoverType type;
public BeatmapSetCover(BeatmapSetInfo set, BeatmapSetCoverType type = BeatmapSetCoverType.Cover)
{
if (set == null)
throw new ArgumentNullException(nameof(set));
this.set = set;
this.type = type;
}
[BackgroundDependencyLoader]
2018-08-27 16:26:44 +08:00
private async Task load(TextureStore textures)
2018-04-13 17:19:50 +08:00
{
string resource = null;
switch (type)
{
case BeatmapSetCoverType.Cover:
resource = set.OnlineInfo.Covers.Cover;
break;
case BeatmapSetCoverType.Card:
resource = set.OnlineInfo.Covers.Card;
break;
case BeatmapSetCoverType.List:
resource = set.OnlineInfo.Covers.List;
break;
}
if (resource != null)
2018-08-27 16:26:44 +08:00
Texture = await textures.GetAsync(resource);
2018-04-13 17:19:50 +08:00
}
}
public enum BeatmapSetCoverType
{
Cover,
Card,
List,
}
}