2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-04-18 15:04:02 +08:00
|
|
|
|
namespace osu.Game.Overlays.BeatmapSet.Buttons
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public class FavouriteButton : HeaderButton
|
|
|
|
|
{
|
|
|
|
|
public readonly Bindable<bool> Favourited = new Bindable<bool>();
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Container pink;
|
|
|
|
|
SpriteIcon icon;
|
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
pink = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0f,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = OsuColour.FromHex(@"9f015f"),
|
|
|
|
|
},
|
|
|
|
|
new Triangles
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColourLight = OsuColour.FromHex(@"cb2187"),
|
|
|
|
|
ColourDark = OsuColour.FromHex(@"9f015f"),
|
|
|
|
|
TriangleScale = 1.5f,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
icon = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-04-02 18:55:24 +08:00
|
|
|
|
Icon = FontAwesome.Regular.Heart,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Size = new Vector2(18),
|
|
|
|
|
Shadow = false,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2019-02-22 16:51:39 +08:00
|
|
|
|
Favourited.ValueChanged += favourited =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-02-22 16:51:39 +08:00
|
|
|
|
if (favourited.NewValue)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
pink.FadeIn(200);
|
2019-04-02 18:55:24 +08:00
|
|
|
|
icon.Icon = FontAwesome.Solid.Heart;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pink.FadeOut(200);
|
2019-04-02 18:55:24 +08:00
|
|
|
|
icon.Icon = FontAwesome.Regular.Heart;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Action = () => Favourited.Value = !Favourited.Value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
|
|
|
|
Width = DrawHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|