osu/osu.Game/Beatmaps/Drawables/OnlineBeatmapSetCover.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

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