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.
|
|
|
|
|
|
2021-10-24 01:27:07 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-10-23 23:59:52 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2023-09-19 16:27:24 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2021-10-23 23:59:52 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-09-19 16:27:24 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-10-24 00:41:31 +08:00
|
|
|
|
using osu.Game.Beatmaps.Drawables.Cards.Buttons;
|
2021-10-24 01:27:07 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2022-12-03 21:16:21 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2021-10-24 01:27:07 +08:00
|
|
|
|
using osuTK;
|
2021-10-23 23:59:52 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Drawables.Cards
|
|
|
|
|
{
|
|
|
|
|
public partial class BeatmapCardThumbnail : Container
|
|
|
|
|
{
|
|
|
|
|
public BindableBool Dimmed { get; } = new BindableBool();
|
|
|
|
|
|
2021-10-24 01:27:07 +08:00
|
|
|
|
public new MarginPadding Padding
|
|
|
|
|
{
|
|
|
|
|
get => foreground.Padding;
|
|
|
|
|
set => foreground.Padding = value;
|
|
|
|
|
}
|
2021-10-23 23:59:52 +08:00
|
|
|
|
|
2023-09-19 16:27:24 +08:00
|
|
|
|
private readonly Box background;
|
2021-10-24 01:27:07 +08:00
|
|
|
|
private readonly Container foreground;
|
2021-10-24 00:26:28 +08:00
|
|
|
|
private readonly PlayButton playButton;
|
2022-12-03 21:16:21 +08:00
|
|
|
|
private readonly CircularProgress progress;
|
2021-10-23 23:59:52 +08:00
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2023-09-19 16:27:24 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
|
|
|
|
|
2024-05-27 19:03:46 +08:00
|
|
|
|
public BeatmapCardThumbnail(IBeatmapSetInfo beatmapSetInfo, IBeatmapSetOnlineInfo onlineInfo)
|
2021-10-23 23:59:52 +08:00
|
|
|
|
{
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2023-09-19 16:27:24 +08:00
|
|
|
|
new UpdateableOnlineBeatmapSetCover(BeatmapSetCoverType.List)
|
2021-10-23 23:59:52 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2024-05-27 19:03:46 +08:00
|
|
|
|
OnlineInfo = onlineInfo
|
2021-10-23 23:59:52 +08:00
|
|
|
|
},
|
2023-09-19 16:27:24 +08:00
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
2021-10-24 01:27:07 +08:00
|
|
|
|
foreground = new Container
|
2021-10-24 00:41:31 +08:00
|
|
|
|
{
|
2021-10-24 01:27:07 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
playButton = new PlayButton(beatmapSetInfo)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
2022-12-03 21:16:21 +08:00
|
|
|
|
progress = new CircularProgress
|
2021-10-24 01:27:07 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
InnerRadius = 0.2f
|
|
|
|
|
},
|
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-23 23:59:52 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 01:27:07 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2023-09-19 16:27:24 +08:00
|
|
|
|
private void load()
|
2021-10-24 01:27:07 +08:00
|
|
|
|
{
|
|
|
|
|
progress.Colour = colourProvider.Highlight1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-23 23:59:52 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2021-10-24 00:41:31 +08:00
|
|
|
|
Dimmed.BindValueChanged(_ => updateState());
|
2021-10-24 01:27:07 +08:00
|
|
|
|
|
2021-10-24 00:41:31 +08:00
|
|
|
|
playButton.Playing.BindValueChanged(_ => updateState(), true);
|
2021-10-23 23:59:52 +08:00
|
|
|
|
FinishTransforms(true);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-06 10:19:40 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
progress.Progress = playButton.Progress.Value;
|
2024-05-27 19:33:24 +08:00
|
|
|
|
|
|
|
|
|
playButton.Scale = new Vector2(DrawWidth / 100);
|
|
|
|
|
progress.Size = new Vector2(50 * DrawWidth / 100);
|
2024-03-06 10:19:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-23 23:59:52 +08:00
|
|
|
|
private void updateState()
|
|
|
|
|
{
|
2021-10-24 00:41:31 +08:00
|
|
|
|
bool shouldDim = Dimmed.Value || playButton.Playing.Value;
|
|
|
|
|
|
2021-12-21 15:26:19 +08:00
|
|
|
|
playButton.FadeTo(shouldDim ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
2024-07-19 18:16:37 +08:00
|
|
|
|
background.FadeColour(colourProvider.Background6.Opacity(shouldDim ? 0.6f : 0f), BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
|
2021-10-23 23:59:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|