2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-07-13 12:17:47 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
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;
|
|
|
|
|
|
2017-07-13 12:24:59 +08:00
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
2017-07-13 12:17:47 +08:00
|
|
|
|
{
|
|
|
|
|
public class BeatmapSetCover : Sprite
|
|
|
|
|
{
|
|
|
|
|
private readonly BeatmapSetInfo set;
|
2017-11-19 21:16:00 +08:00
|
|
|
|
private readonly BeatmapSetCoverType type;
|
|
|
|
|
|
|
|
|
|
public BeatmapSetCover(BeatmapSetInfo set, BeatmapSetCoverType type = BeatmapSetCoverType.Cover)
|
2017-07-13 12:17:47 +08:00
|
|
|
|
{
|
2017-11-08 06:13:56 +08:00
|
|
|
|
if (set == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(set));
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(TextureStore textures)
|
|
|
|
|
{
|
2017-11-19 21:16:00 +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;
|
|
|
|
|
}
|
2017-07-13 12:17:47 +08:00
|
|
|
|
|
|
|
|
|
if (resource != null)
|
|
|
|
|
Texture = textures.Get(resource);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-19 21:16:00 +08:00
|
|
|
|
|
|
|
|
|
public enum BeatmapSetCoverType
|
|
|
|
|
{
|
|
|
|
|
Cover,
|
|
|
|
|
Card,
|
|
|
|
|
List,
|
|
|
|
|
}
|
2017-07-13 12:17:47 +08:00
|
|
|
|
}
|