osu/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs

80 lines
2.1 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-05-28 22:11:26 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2018-11-20 07:51:59 +00:00
using osuTK.Graphics;
2018-05-28 22:11:26 +00:00
namespace osu.Game.Beatmaps.Drawables
{
public class UpdateableBeatmapSetCover : Container
{
private Drawable displayedCover;
private BeatmapSetInfo beatmapSet;
public BeatmapSetInfo BeatmapSet
{
get { return beatmapSet; }
set
{
if (value == beatmapSet) return;
beatmapSet = value;
if (IsLoaded)
updateCover();
}
}
private BeatmapSetCoverType coverType = BeatmapSetCoverType.Cover;
public BeatmapSetCoverType CoverType
{
get { return coverType; }
set
{
if (value == coverType) return;
coverType = value;
if (IsLoaded)
updateCover();
}
}
public UpdateableBeatmapSetCover()
{
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
};
}
protected override void LoadComplete()
{
base.LoadComplete();
updateCover();
}
private void updateCover()
{
displayedCover?.FadeOut(400);
displayedCover?.Expire();
2018-05-31 08:48:42 +00:00
displayedCover = null;
2018-05-28 22:11:26 +00:00
if (beatmapSet != null)
{
Add(displayedCover = new DelayedLoadWrapper(
new BeatmapSetCover(beatmapSet, coverType)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
})
);
}
}
}
}