mirror of
https://github.com/ppy/osu
synced 2025-01-09 07:39:46 +00:00
Merge pull request #27896 from bdach/fix-pause-overlay-missing-in-osu
Fix resume overlay not appearing after pausing when mouse cursor is inside window but outside of actual playfield area
This commit is contained in:
commit
3bd2bb0ed6
69
osu.Game.Rulesets.Osu.Tests/TestSceneResume.cs
Normal file
69
osu.Game.Rulesets.Osu.Tests/TestSceneResume.cs
Normal file
@ -0,0 +1,69 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
public partial class TestSceneResume : PlayerTestScene
|
||||
{
|
||||
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||
|
||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(true, false, AllowBackwardsSeeks);
|
||||
|
||||
[Test]
|
||||
public void TestPauseViaKeyboard()
|
||||
{
|
||||
AddStep("move mouse to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre));
|
||||
AddUntilStep("wait for gameplay start", () => Player.LocalUserPlaying.Value);
|
||||
AddStep("press escape", () => InputManager.PressKey(Key.Escape));
|
||||
AddUntilStep("wait for pause overlay", () => Player.ChildrenOfType<PauseOverlay>().Single().State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
AddStep("release escape", () => InputManager.ReleaseKey(Key.Escape));
|
||||
AddStep("resume", () =>
|
||||
{
|
||||
InputManager.Key(Key.Down);
|
||||
InputManager.Key(Key.Space);
|
||||
});
|
||||
AddUntilStep("pause overlay present", () => Player.DrawableRuleset.ResumeOverlay.State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseViaKeyboardWhenMouseOutsidePlayfield()
|
||||
{
|
||||
AddStep("move mouse outside playfield", () => InputManager.MoveMouseTo(Player.DrawableRuleset.Playfield.ScreenSpaceDrawQuad.BottomRight + new Vector2(1)));
|
||||
AddUntilStep("wait for gameplay start", () => Player.LocalUserPlaying.Value);
|
||||
AddStep("press escape", () => InputManager.PressKey(Key.Escape));
|
||||
AddUntilStep("wait for pause overlay", () => Player.ChildrenOfType<PauseOverlay>().Single().State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
AddStep("release escape", () => InputManager.ReleaseKey(Key.Escape));
|
||||
AddStep("resume", () =>
|
||||
{
|
||||
InputManager.Key(Key.Down);
|
||||
InputManager.Key(Key.Space);
|
||||
});
|
||||
AddUntilStep("pause overlay present", () => Player.DrawableRuleset.ResumeOverlay.State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseViaKeyboardWhenMouseOutsideScreen()
|
||||
{
|
||||
AddStep("move mouse outside playfield", () => InputManager.MoveMouseTo(new Vector2(-20)));
|
||||
AddUntilStep("wait for gameplay start", () => Player.LocalUserPlaying.Value);
|
||||
AddStep("press escape", () => InputManager.PressKey(Key.Escape));
|
||||
AddUntilStep("wait for pause overlay", () => Player.ChildrenOfType<PauseOverlay>().Single().State.Value, () => Is.EqualTo(Visibility.Visible));
|
||||
AddStep("release escape", () => InputManager.ReleaseKey(Key.Escape));
|
||||
AddStep("resume", () =>
|
||||
{
|
||||
InputManager.Key(Key.Down);
|
||||
InputManager.Key(Key.Space);
|
||||
});
|
||||
AddUntilStep("pause overlay not present", () => Player.DrawableRuleset.ResumeOverlay.State.Value, () => Is.EqualTo(Visibility.Hidden));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
@ -12,6 +10,7 @@ using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -19,15 +18,18 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
public partial class OsuResumeOverlay : ResumeOverlay
|
||||
{
|
||||
private Container cursorScaleContainer;
|
||||
private OsuClickToResumeCursor clickToResumeCursor;
|
||||
private Container cursorScaleContainer = null!;
|
||||
private OsuClickToResumeCursor clickToResumeCursor = null!;
|
||||
|
||||
private OsuCursorContainer localCursorContainer;
|
||||
private OsuCursorContainer? localCursorContainer;
|
||||
|
||||
public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
|
||||
public override CursorContainer? LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null;
|
||||
|
||||
protected override LocalisableString Message => "Click the orange cursor to resume";
|
||||
|
||||
[Resolved]
|
||||
private DrawableRuleset? drawableRuleset { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -40,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
protected override void PopIn()
|
||||
{
|
||||
// Can't display if the cursor is outside the window.
|
||||
if (GameplayCursor.LastFrameState == Visibility.Hidden || !Contains(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre))
|
||||
if (GameplayCursor.LastFrameState == Visibility.Hidden || drawableRuleset?.Contains(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre) == false)
|
||||
{
|
||||
Resume();
|
||||
return;
|
||||
@ -71,8 +73,8 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
public override bool HandlePositionalInput => true;
|
||||
|
||||
public Action ResumeRequested;
|
||||
private Container scaleTransitionContainer;
|
||||
public Action? ResumeRequested;
|
||||
private Container scaleTransitionContainer = null!;
|
||||
|
||||
public OsuClickToResumeCursor()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user