2021-10-23 23:59:52 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-10-24 00:41:31 +08:00
|
|
|
using osu.Game.Beatmaps.Drawables.Cards.Buttons;
|
2021-10-23 23:59:52 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Drawables.Cards
|
|
|
|
{
|
|
|
|
public class BeatmapCardThumbnail : Container
|
|
|
|
{
|
|
|
|
public BindableBool Dimmed { get; } = new BindableBool();
|
|
|
|
|
|
|
|
private readonly APIBeatmapSet beatmapSetInfo;
|
|
|
|
|
|
|
|
private readonly UpdateableOnlineBeatmapSetCover cover;
|
2021-10-24 00:26:28 +08:00
|
|
|
private readonly PlayButton playButton;
|
2021-10-23 23:59:52 +08:00
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
public BeatmapCardThumbnail(APIBeatmapSet beatmapSetInfo)
|
|
|
|
{
|
|
|
|
this.beatmapSetInfo = beatmapSetInfo;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
cover = new UpdateableOnlineBeatmapSetCover(BeatmapSetCoverType.List)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
OnlineInfo = beatmapSetInfo
|
|
|
|
},
|
2021-10-24 00:41:31 +08:00
|
|
|
playButton = new PlayButton(beatmapSetInfo)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
},
|
2021-10-23 23:59:52 +08:00
|
|
|
content = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2021-10-24 00:41:31 +08:00
|
|
|
Dimmed.BindValueChanged(_ => updateState());
|
|
|
|
playButton.Playing.BindValueChanged(_ => updateState(), true);
|
2021-10-23 23:59:52 +08:00
|
|
|
FinishTransforms(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState()
|
|
|
|
{
|
2021-10-24 00:41:31 +08:00
|
|
|
bool shouldDim = Dimmed.Value || playButton.Playing.Value;
|
|
|
|
|
|
|
|
playButton.FadeTo(shouldDim ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
|
|
|
cover.FadeColour(shouldDim ? OsuColour.Gray(0.2f) : Color4.White, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
2021-10-23 23:59:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|