2021-10-22 20:03:37 +00: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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Drawables.Cards
|
|
|
|
{
|
2021-11-02 23:07:03 +00:00
|
|
|
public partial class BeatmapCardContentBackground : CompositeDrawable
|
2021-10-22 20:03:37 +00:00
|
|
|
{
|
2021-11-02 23:07:03 +00:00
|
|
|
public BindableBool Dimmed { get; } = new BindableBool();
|
2021-10-22 20:03:37 +00:00
|
|
|
|
2021-11-02 23:07:03 +00:00
|
|
|
private readonly Box background;
|
|
|
|
private readonly DelayedLoadUnloadWrapper cover;
|
2021-10-22 20:03:37 +00:00
|
|
|
|
2021-11-02 23:07:03 +00:00
|
|
|
[Resolved]
|
|
|
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
2021-10-22 20:03:37 +00:00
|
|
|
|
2021-11-02 23:07:03 +00:00
|
|
|
public BeatmapCardContentBackground(IBeatmapSetOnlineInfo onlineInfo)
|
2021-10-22 20:03:37 +00:00
|
|
|
{
|
2021-11-02 23:07:03 +00:00
|
|
|
InternalChildren = new Drawable[]
|
2021-10-22 20:03:37 +00:00
|
|
|
{
|
2021-11-02 23:07:03 +00:00
|
|
|
background = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
cover = new DelayedLoadUnloadWrapper(() => createCover(onlineInfo), 500, 500)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Colour4.Transparent
|
|
|
|
}
|
2021-10-22 20:03:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-11-02 23:07:03 +00:00
|
|
|
private static Drawable createCover(IBeatmapSetOnlineInfo onlineInfo) => new OnlineBeatmapSetCover(onlineInfo)
|
2021-10-22 20:03:37 +00:00
|
|
|
{
|
2021-11-02 23:07:03 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
FillMode = FillMode.Fill
|
|
|
|
};
|
2021-10-22 20:03:37 +00:00
|
|
|
|
2021-11-02 23:07:03 +00:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
{
|
|
|
|
background.Colour = colourProvider.Background2;
|
2021-10-22 20:03:37 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 23:07:03 +00:00
|
|
|
protected override void LoadComplete()
|
2021-10-22 20:03:37 +00:00
|
|
|
{
|
2021-11-02 23:07:03 +00:00
|
|
|
base.LoadComplete();
|
|
|
|
Dimmed.BindValueChanged(_ => updateState(), true);
|
|
|
|
FinishTransforms(true);
|
|
|
|
}
|
2021-10-22 20:03:37 +00:00
|
|
|
|
2021-11-02 23:07:03 +00:00
|
|
|
private void updateState() => Schedule(() =>
|
|
|
|
{
|
2021-12-21 07:26:19 +00:00
|
|
|
background.FadeColour(Dimmed.Value ? colourProvider.Background4 : colourProvider.Background2, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
2021-10-22 20:03:37 +00:00
|
|
|
|
2021-11-02 23:07:03 +00:00
|
|
|
var gradient = ColourInfo.GradientHorizontal(Colour4.White.Opacity(0), Colour4.White.Opacity(0.2f));
|
2021-12-21 07:26:19 +00:00
|
|
|
cover.FadeColour(gradient, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
2021-11-02 23:07:03 +00:00
|
|
|
});
|
2021-10-22 20:03:37 +00:00
|
|
|
}
|
|
|
|
}
|