mirror of
https://github.com/osukey/osukey.git
synced 2025-05-17 11:37:32 +09:00
Merge pull request #16678 from peppy/hold-for-menu-always-fade
Ensure hold for menu button fades out if the cursor is never moved
This commit is contained in:
commit
b94984bd2d
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -19,28 +19,35 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
protected override double TimePerAction => 100; // required for the early exit test, since hold-to-confirm delay is 200ms
|
protected override double TimePerAction => 100; // required for the early exit test, since hold-to-confirm delay is 200ms
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
private HoldForMenuButton holdForMenuButton;
|
||||||
private void load()
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
HoldForMenuButton holdForMenuButton;
|
AddStep("create button", () =>
|
||||||
|
|
||||||
Add(holdForMenuButton = new HoldForMenuButton
|
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomRight,
|
exitAction = false;
|
||||||
Anchor = Anchor.BottomRight,
|
|
||||||
Action = () => exitAction = true
|
Child = holdForMenuButton = new HoldForMenuButton
|
||||||
|
{
|
||||||
|
Scale = new Vector2(2),
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Action = () => exitAction = true
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var text = holdForMenuButton.Children.OfType<SpriteText>().First();
|
[Test]
|
||||||
|
public void TestMovementAndTrigger()
|
||||||
|
{
|
||||||
AddStep("Trigger text fade in", () => InputManager.MoveMouseTo(holdForMenuButton));
|
AddStep("Trigger text fade in", () => InputManager.MoveMouseTo(holdForMenuButton));
|
||||||
AddUntilStep("Text visible", () => text.IsPresent && !exitAction);
|
AddUntilStep("Text visible", () => getSpriteText().IsPresent && !exitAction);
|
||||||
AddStep("Trigger text fade out", () => InputManager.MoveMouseTo(Vector2.One));
|
AddStep("Trigger text fade out", () => InputManager.MoveMouseTo(Vector2.One));
|
||||||
AddUntilStep("Text is not visible", () => !text.IsPresent && !exitAction);
|
AddUntilStep("Text is not visible", () => !getSpriteText().IsPresent && !exitAction);
|
||||||
|
|
||||||
AddStep("Trigger exit action", () =>
|
AddStep("Trigger exit action", () =>
|
||||||
{
|
{
|
||||||
exitAction = false;
|
|
||||||
InputManager.MoveMouseTo(holdForMenuButton);
|
InputManager.MoveMouseTo(holdForMenuButton);
|
||||||
InputManager.PressButton(MouseButton.Left);
|
InputManager.PressButton(MouseButton.Left);
|
||||||
});
|
});
|
||||||
@ -50,6 +57,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddStep("Trigger exit action", () => InputManager.PressButton(MouseButton.Left));
|
AddStep("Trigger exit action", () => InputManager.PressButton(MouseButton.Left));
|
||||||
AddUntilStep($"{nameof(holdForMenuButton.Action)} was triggered", () => exitAction);
|
AddUntilStep($"{nameof(holdForMenuButton.Action)} was triggered", () => exitAction);
|
||||||
|
AddStep("Release", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFadeOnNoInput()
|
||||||
|
{
|
||||||
|
AddStep("move mouse away", () => InputManager.MoveMouseTo(Vector2.One));
|
||||||
|
AddUntilStep("wait for text fade out", () => !getSpriteText().IsPresent);
|
||||||
|
AddUntilStep("wait for button fade out", () => holdForMenuButton.Alpha < 0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SpriteText getSpriteText() => holdForMenuButton.Children.OfType<SpriteText>().First();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private float positionalAdjust;
|
private float positionalAdjust = 1; // Start at 1 to handle the case where a user never send positional input.
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user