1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 02:37:25 +08:00
osu-lazer/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs

86 lines
2.2 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-29 06:11:26 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.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
{
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
{
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,
2020-02-17 04:42:05 +08:00
Colour = OsuColour.Gray(0.2f),
2018-05-29 06:11:26 +08:00
};
}
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)
{
Add(displayedCover = new DelayedLoadUnloadWrapper(() =>
{
var 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,
};
cover.OnLoadComplete += d => d.FadeInFromZero(400, Easing.Out);
return cover;
}));
2018-05-29 06:11:26 +08:00
}
}
}
}