1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 16:02:58 +08:00

Fix back button hover sounds playing in unclickable area

This commit is contained in:
Joehu 2019-08-05 20:43:30 -07:00
parent bf0f6e1053
commit ee6a90c48d
2 changed files with 10 additions and 7 deletions

View File

@ -22,8 +22,8 @@ namespace osu.Game.Graphics.UserInterface
Child = button = new TwoLayerButton Child = button = new TwoLayerButton
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.TopLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.TopLeft,
Text = @"back", Text = @"back",
Icon = OsuIcon.LeftCircle, Icon = OsuIcon.LeftCircle,
Action = () => Action?.Invoke() Action = () => Action?.Invoke()

View File

@ -15,6 +15,7 @@ using System;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Screens.Select;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -28,7 +29,9 @@ namespace osu.Game.Graphics.UserInterface
private const int transform_time = 600; private const int transform_time = 600;
private const int pulse_length = 250; private const int pulse_length = 250;
private const float shear = 0.1f; private const float SHEAR_WIDTH = 5f;
private static readonly Vector2 shearing = new Vector2(SHEAR_WIDTH / Footer.HEIGHT, 0);
public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50); public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50);
public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50); public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50);
@ -56,7 +59,7 @@ namespace osu.Game.Graphics.UserInterface
c1.Origin = c1.Anchor = value.HasFlag(Anchor.x2) ? Anchor.TopLeft : Anchor.TopRight; c1.Origin = c1.Anchor = value.HasFlag(Anchor.x2) ? Anchor.TopLeft : Anchor.TopRight;
c2.Origin = c2.Anchor = value.HasFlag(Anchor.x2) ? Anchor.TopRight : Anchor.TopLeft; c2.Origin = c2.Anchor = value.HasFlag(Anchor.x2) ? Anchor.TopRight : Anchor.TopLeft;
X = value.HasFlag(Anchor.x2) ? SIZE_RETRACTED.X * shear * 0.5f : 0; X = value.HasFlag(Anchor.x2) ? SIZE_RETRACTED.X * shearing.X * 0.5f : 0;
Remove(c1); Remove(c1);
Remove(c2); Remove(c2);
@ -70,6 +73,7 @@ namespace osu.Game.Graphics.UserInterface
public TwoLayerButton() public TwoLayerButton()
{ {
Size = SIZE_RETRACTED; Size = SIZE_RETRACTED;
Shear = shearing;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -82,7 +86,6 @@ namespace osu.Game.Graphics.UserInterface
new Container new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Shear = new Vector2(shear, 0),
Masking = true, Masking = true,
MaskingSmoothness = 2, MaskingSmoothness = 2,
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
@ -105,6 +108,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Shear = -shearing,
}, },
} }
}, },
@ -119,7 +123,6 @@ namespace osu.Game.Graphics.UserInterface
new Container new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Shear = new Vector2(shear, 0),
Masking = true, Masking = true,
MaskingSmoothness = 2, MaskingSmoothness = 2,
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
@ -144,6 +147,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Shear = -shearing,
} }
} }
}, },
@ -188,7 +192,6 @@ namespace osu.Game.Graphics.UserInterface
var flash = new Box var flash = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Shear = new Vector2(shear, 0),
Colour = Color4.White.Opacity(0.5f), Colour = Color4.White.Opacity(0.5f),
}; };
Add(flash); Add(flash);