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

58 lines
1.5 KiB
C#
Raw Normal View History

// 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
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps.Drawables
{
[LongRunningLoad]
2018-04-13 17:19:50 +08:00
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]
private void load(LargeTextureStore textures)
2018-04-13 17:19:50 +08:00
{
string resource = null;
switch (type)
{
case BeatmapSetCoverType.Cover:
resource = set.OnlineInfo.Covers.Cover;
break;
2019-04-01 11:44:46 +08:00
2018-04-13 17:19:50 +08:00
case BeatmapSetCoverType.Card:
resource = set.OnlineInfo.Covers.Card;
break;
2019-04-01 11:44:46 +08:00
2018-04-13 17:19:50 +08:00
case BeatmapSetCoverType.List:
resource = set.OnlineInfo.Covers.List;
break;
}
if (resource != null)
2018-08-31 06:04:40 +08:00
Texture = textures.Get(resource);
2018-04-13 17:19:50 +08:00
}
}
public enum BeatmapSetCoverType
{
Cover,
Card,
List,
}
}