1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Make Icon rotate when clicking ShowRepliesButton

This commit is contained in:
Andrei Zavatski 2020-07-11 07:54:37 +03:00
parent da249abd19
commit 0861ee0c8e

View File

@ -2,11 +2,17 @@
// See the LICENCE file in the repository root for full licence text.
using Humanizer;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osuTK;
namespace osu.Game.Overlays.Comments.Buttons
{
public class ShowRepliesButton : CommentRepliesButton
{
public readonly BindableBool Expanded = new BindableBool(true);
private readonly int count;
public ShowRepliesButton(int count)
@ -14,6 +20,23 @@ namespace osu.Game.Overlays.Comments.Buttons
this.count = count;
}
protected override void LoadComplete()
{
base.LoadComplete();
Expanded.BindValueChanged(onExpandedChanged, true);
}
private void onExpandedChanged(ValueChangedEvent<bool> expanded)
{
Icon.ScaleTo(new Vector2(1, expanded.NewValue ? -1 : 1));
}
protected override bool OnClick(ClickEvent e)
{
Expanded.Toggle();
return base.OnClick(e);
}
protected override string GetText() => "reply".ToQuantity(count);
}
}