1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 16:52:55 +08:00
osu-lazer/osu.Game/Beatmaps/Drawables/BeatmapSetCover.cs

55 lines
1.5 KiB
C#
Raw Normal View History

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
using System;
2017-07-13 12:17:47 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Beatmaps.Drawables
2017-07-13 12:17:47 +08:00
{
public class BeatmapSetCover : Sprite
{
private readonly BeatmapSetInfo set;
private readonly BeatmapSetCoverType type;
public BeatmapSetCover(BeatmapSetInfo set, BeatmapSetCoverType type = BeatmapSetCoverType.Cover)
2017-07-13 12:17:47 +08:00
{
if (set == null)
throw new ArgumentNullException(nameof(set));
2017-07-13 12:17:47 +08:00
this.set = set;
this.type = type;
2017-07-13 12:17:47 +08:00
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
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);
}
}
public enum BeatmapSetCoverType
{
Cover,
Card,
List,
}
2017-07-13 12:17:47 +08:00
}