1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-29 02:52:54 +08:00

Add play button for card preview

This commit is contained in:
Bartłomiej Dach 2021-10-23 18:26:28 +02:00
parent b44db9f5e5
commit 5d13686cdf
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
2 changed files with 37 additions and 0 deletions

View File

@ -17,6 +17,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
private readonly APIBeatmapSet beatmapSetInfo;
private readonly UpdateableOnlineBeatmapSetCover cover;
private readonly PlayButton playButton;
private readonly Container content;
protected override Container<Drawable> Content => content;
@ -32,6 +33,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
RelativeSizeAxes = Axes.Both,
OnlineInfo = beatmapSetInfo
},
playButton = new PlayButton(),
content = new Container
{
RelativeSizeAxes = Axes.Both
@ -48,6 +50,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
private void updateState()
{
playButton.FadeTo(Dimmed.Value ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
cover.FadeColour(Dimmed.Value ? OsuColour.Gray(0.2f) : Color4.White, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
}
}

View File

@ -0,0 +1,34 @@
// 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.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osuTK;
namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
{
public class PlayButton : OsuHoverContainer
{
public PlayButton()
{
Anchor = Origin = Anchor.Centre;
Child = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.Solid.Play,
Size = new Vector2(14)
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
HoverColour = colours.Yellow;
}
}
}