mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Implement basic behaviour of play button
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
// 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.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
@ -12,17 +13,30 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||
{
|
||||
public class PlayButton : OsuHoverContainer
|
||||
{
|
||||
public PlayButton()
|
||||
public BindableBool Playing { get; } = new BindableBool();
|
||||
|
||||
private readonly BeatmapSetInfo beatmapSetInfo;
|
||||
|
||||
private readonly SpriteIcon icon;
|
||||
|
||||
public PlayButton(BeatmapSetInfo beatmapSetInfo)
|
||||
{
|
||||
this.beatmapSetInfo = beatmapSetInfo;
|
||||
|
||||
Anchor = Origin = Anchor.Centre;
|
||||
|
||||
Child = new SpriteIcon
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Icon = FontAwesome.Solid.Play,
|
||||
Size = new Vector2(14)
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Icon = FontAwesome.Solid.Play,
|
||||
Size = new Vector2(14)
|
||||
},
|
||||
};
|
||||
|
||||
Action = () => Playing.Toggle();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -30,5 +44,17 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
|
||||
{
|
||||
HoverColour = colours.Yellow;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Playing.BindValueChanged(_ => updateState(), true);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
icon.Icon = Playing.Value ? FontAwesome.Solid.Stop : FontAwesome.Solid.Play;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user