1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 14:07:27 +08:00
osu-lazer/osu.Game/Overlays/Comments/Buttons/CommentRepliesButton.cs

114 lines
4.1 KiB
C#
Raw Normal View History

2020-07-11 12:47:17 +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.
2020-07-11 13:13:11 +08:00
using System;
2020-07-11 12:47:17 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
2020-07-11 13:13:11 +08:00
using osu.Framework.Input.Events;
2020-07-11 12:47:17 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
2020-07-11 13:13:11 +08:00
using osu.Game.Graphics.UserInterface;
2020-07-11 12:47:17 +08:00
using osuTK;
namespace osu.Game.Overlays.Comments.Buttons
{
2020-07-11 13:13:11 +08:00
public abstract class CommentRepliesButton : CompositeDrawable
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
public Action Action { get; set; }
2020-07-11 12:47:17 +08:00
2020-07-11 13:13:11 +08:00
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
2020-07-11 12:47:17 +08:00
2020-07-11 13:13:11 +08:00
protected SpriteIcon Icon;
private Box background;
2020-07-11 12:47:17 +08:00
[BackgroundDependencyLoader]
2020-07-11 13:13:11 +08:00
private void load()
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
AutoSizeAxes = Axes.Both;
2020-07-11 14:03:03 +08:00
Margin = new MarginPadding
{
Vertical = 2
};
2020-07-11 13:13:11 +08:00
InternalChildren = new Drawable[]
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
new CircularContainer
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
AutoSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
background = new Box
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background2
2020-07-11 12:47:17 +08:00
},
2020-07-11 13:13:11 +08:00
new Container
2020-07-11 12:47:17 +08:00
{
AutoSizeAxes = Axes.Both,
2020-07-11 13:13:11 +08:00
Margin = new MarginPadding
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
Vertical = 5,
Horizontal = 10,
},
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(15, 0),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
Text = GetText()
},
Icon = new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(7.5f),
Icon = FontAwesome.Solid.ChevronDown,
Colour = colourProvider.Foreground1
}
2020-07-11 12:47:17 +08:00
}
}
}
}
2020-07-11 13:13:11 +08:00
},
new HoverClickSounds(),
};
2020-07-11 12:47:17 +08:00
}
protected abstract string GetText();
2020-07-11 13:13:11 +08:00
protected override bool OnHover(HoverEvent e)
2020-07-11 12:47:17 +08:00
{
2020-07-11 13:13:11 +08:00
base.OnHover(e);
background.FadeColour(colourProvider.Background1, 200, Easing.OutQuint);
Icon.FadeColour(colourProvider.Light1, 200, Easing.OutQuint);
return true;
}
2020-07-11 12:47:17 +08:00
2020-07-11 13:13:11 +08:00
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
background.FadeColour(colourProvider.Background2, 200, Easing.OutQuint);
Icon.FadeColour(colourProvider.Foreground1, 200, Easing.OutQuint);
}
protected override bool OnClick(ClickEvent e)
{
Action?.Invoke();
return base.OnClick(e);
2020-07-11 12:47:17 +08:00
}
}
}