From 2a3241fd487e27bdd1153d2edff8ec76d6e3bae7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 3 Apr 2025 19:19:06 +0900 Subject: [PATCH] Adjust mouse down animation in a better way (and apply to small tag buttons too) --- .../Graphics/UserInterface/OsuAnimatedButton.cs | 4 +++- osu.Game/Screens/Ranking/UserTagControl.cs | 13 ++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs b/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs index 0eec04541c..48d225de41 100644 --- a/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuAnimatedButton.cs @@ -25,6 +25,8 @@ namespace osu.Game.Graphics.UserInterface private Color4 hoverColour = Color4.White.Opacity(0.1f); + protected float ScaleOnMouseDown { get; init; } = 0.75f; + /// /// The background colour of the while it is hovered. /// @@ -119,7 +121,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnMouseDown(MouseDownEvent e) { - Content.ScaleTo(0.75f, 2000, Easing.OutQuint); + Content.ScaleTo(ScaleOnMouseDown, 2000, Easing.OutQuint); return base.OnMouseDown(e); } diff --git a/osu.Game/Screens/Ranking/UserTagControl.cs b/osu.Game/Screens/Ranking/UserTagControl.cs index 7b36077bb3..84774e8ad8 100644 --- a/osu.Game/Screens/Ranking/UserTagControl.cs +++ b/osu.Game/Screens/Ranking/UserTagControl.cs @@ -319,6 +319,8 @@ namespace osu.Game.Screens.Ranking voted.BindTo(userTag.Voted); AutoSizeAxes = Axes.Both; + + ScaleOnMouseDown = 0.95f; } [BackgroundDependencyLoader] @@ -654,6 +656,8 @@ namespace osu.Game.Screens.Ranking RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; + + ScaleOnMouseDown = 0.95f; } [Resolved] @@ -736,15 +740,6 @@ namespace osu.Game.Screens.Ranking }, true); FinishTransforms(true); } - - protected override bool OnMouseDown(MouseDownEvent e) - { - bool result = base.OnMouseDown(e); - // slightly dodgy way of overriding the amount of scale-on-click (the default is way too much in this case) - ClearTransforms(targetMember: nameof(Scale)); - Content.ScaleTo(0.95f, 2000, Easing.OutQuint); - return result; - } } } }