mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Fix skip button not being clickable after fade out (#5245)
Fix skip button not being clickable after fade out Co-authored-by: Dan Balasescu <1329837+smoogipoo@users.noreply.github.com>
This commit is contained in:
commit
a024bfd33a
@ -1,19 +1,88 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneSkipOverlay : OsuTestScene
|
public class TestSceneSkipOverlay : ManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
protected override void LoadComplete()
|
private SkipOverlay skip;
|
||||||
{
|
private int requestCount;
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
Add(new SkipOverlay(Clock.CurrentTime + 5000));
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
|
{
|
||||||
|
requestCount = 0;
|
||||||
|
Child = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Clock = new FramedOffsetClock(Clock)
|
||||||
|
{
|
||||||
|
Offset = -Clock.CurrentTime,
|
||||||
|
},
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
skip = new SkipOverlay(6000)
|
||||||
|
{
|
||||||
|
RequestSeek = _ => requestCount++
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestFadeOnIdle()
|
||||||
|
{
|
||||||
|
AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero));
|
||||||
|
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1);
|
||||||
|
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1);
|
||||||
|
|
||||||
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddUntilStep("fully visible", () => skip.Children.First().Alpha == 1);
|
||||||
|
AddUntilStep("wait for fade", () => skip.Children.First().Alpha < 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestClickableAfterFade()
|
||||||
|
{
|
||||||
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddUntilStep("wait for fade", () => skip.Children.First().Alpha == 0);
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
checkRequestCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestClickOnlyActuatesOnce()
|
||||||
|
{
|
||||||
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
|
checkRequestCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestDoesntFadeOnMouseDown()
|
||||||
|
{
|
||||||
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
|
AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
|
||||||
|
AddUntilStep("wait for overlay disapper", () => !skip.IsAlive);
|
||||||
|
AddAssert("ensure button didn't disappear", () => skip.Children.First().Alpha > 0);
|
||||||
|
AddStep("button up", () => InputManager.ReleaseButton(MouseButton.Left));
|
||||||
|
checkRequestCount(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkRequestCount(int expected) =>
|
||||||
|
AddAssert($"request count is {expected}", () => requestCount == expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,8 @@ namespace osu.Game.Screens.Play
|
|||||||
private Visibility state;
|
private Visibility state;
|
||||||
private ScheduledDelegate scheduledHide;
|
private ScheduledDelegate scheduledHide;
|
||||||
|
|
||||||
|
public override bool IsPresent => true;
|
||||||
|
|
||||||
public Visibility State
|
public Visibility State
|
||||||
{
|
{
|
||||||
get => state;
|
get => state;
|
||||||
@ -201,14 +203,15 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
{
|
{
|
||||||
|
Show();
|
||||||
scheduledHide?.Cancel();
|
scheduledHide?.Cancel();
|
||||||
return base.OnMouseDown(e);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseUp(MouseUpEvent e)
|
protected override bool OnMouseUp(MouseUpEvent e)
|
||||||
{
|
{
|
||||||
Show();
|
Show();
|
||||||
return base.OnMouseUp(e);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Hide() => State = Visibility.Hidden;
|
public override void Hide() => State = Visibility.Hidden;
|
||||||
|
Loading…
Reference in New Issue
Block a user