2021-10-24 00:26:28 +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.Allocation;
|
2021-10-24 00:41:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
2021-10-24 00:26:28 +08:00
|
|
|
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
|
|
|
|
{
|
2021-10-24 00:41:31 +08:00
|
|
|
public BindableBool Playing { get; } = new BindableBool();
|
|
|
|
|
|
|
|
private readonly BeatmapSetInfo beatmapSetInfo;
|
|
|
|
|
|
|
|
private readonly SpriteIcon icon;
|
|
|
|
|
|
|
|
public PlayButton(BeatmapSetInfo beatmapSetInfo)
|
2021-10-24 00:26:28 +08:00
|
|
|
{
|
2021-10-24 00:41:31 +08:00
|
|
|
this.beatmapSetInfo = beatmapSetInfo;
|
|
|
|
|
2021-10-24 00:26:28 +08:00
|
|
|
Anchor = Origin = Anchor.Centre;
|
|
|
|
|
2021-10-24 00:41:31 +08:00
|
|
|
Children = new Drawable[]
|
2021-10-24 00:26:28 +08:00
|
|
|
{
|
2021-10-24 00:41:31 +08:00
|
|
|
icon = new SpriteIcon
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Icon = FontAwesome.Solid.Play,
|
|
|
|
Size = new Vector2(14)
|
|
|
|
},
|
2021-10-24 00:26:28 +08:00
|
|
|
};
|
2021-10-24 00:41:31 +08:00
|
|
|
|
|
|
|
Action = () => Playing.Toggle();
|
2021-10-24 00:26:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
HoverColour = colours.Yellow;
|
|
|
|
}
|
2021-10-24 00:41:31 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
Playing.BindValueChanged(_ => updateState(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState()
|
|
|
|
{
|
|
|
|
icon.Icon = Playing.Value ? FontAwesome.Solid.Stop : FontAwesome.Solid.Play;
|
|
|
|
}
|
2021-10-24 00:26:28 +08:00
|
|
|
}
|
|
|
|
}
|