2019-01-24 16:43:03 +08:00
|
|
|
|
// 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-29 06:11:26 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-05-29 06:11:26 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Drawables
|
|
|
|
|
{
|
|
|
|
|
public class UpdateableBeatmapSetCover : Container
|
|
|
|
|
{
|
|
|
|
|
private Drawable displayedCover;
|
|
|
|
|
|
|
|
|
|
private BeatmapSetInfo beatmapSet;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-05-29 06:11:26 +08:00
|
|
|
|
public BeatmapSetInfo BeatmapSet
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => beatmapSet;
|
2018-05-29 06:11:26 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == beatmapSet) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-05-29 06:11:26 +08:00
|
|
|
|
beatmapSet = value;
|
|
|
|
|
|
|
|
|
|
if (IsLoaded)
|
|
|
|
|
updateCover();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BeatmapSetCoverType coverType = BeatmapSetCoverType.Cover;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-05-29 06:11:26 +08:00
|
|
|
|
public BeatmapSetCoverType CoverType
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => coverType;
|
2018-05-29 06:11:26 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == coverType) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-05-29 06:11:26 +08:00
|
|
|
|
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 16:48:42 +08:00
|
|
|
|
displayedCover = null;
|
2018-05-29 06:11:26 +08:00
|
|
|
|
|
|
|
|
|
if (beatmapSet != null)
|
|
|
|
|
{
|
2019-03-17 12:43:23 +08:00
|
|
|
|
BeatmapSetCover cover;
|
|
|
|
|
|
2018-05-29 06:11:26 +08:00
|
|
|
|
Add(displayedCover = new DelayedLoadWrapper(
|
2019-03-17 12:43:23 +08:00
|
|
|
|
cover = new BeatmapSetCover(beatmapSet, coverType)
|
2018-05-29 06:11:26 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
FillMode = FillMode.Fill,
|
|
|
|
|
})
|
|
|
|
|
);
|
2019-03-17 12:43:23 +08:00
|
|
|
|
|
|
|
|
|
cover.OnLoadComplete += d => d.FadeInFromZero(400, Easing.Out);
|
2018-05-29 06:11:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|