Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix context menu not closing when placing freehand slider #31058

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions osu.Game.Rulesets.Osu.Tests/Editor/TestSceneContextMenuClose.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.UI;
using osuTK.Input;

namespace osu.Game.Rulesets.Osu.Tests.Editor
{
public partial class TestSceneContextMenuClose : TestSceneOsuEditor
{
private ContextMenuContainer contextMenuContainer
=> Editor.ChildrenOfType<ContextMenuContainer>().First();

[Test]
public void TestDrawnSliderClosesMenu()
{
Playfield playfield = null!;

AddStep("select circle placement tool", () => InputManager.Key(Key.Number2));
AddStep("move mouse to top left of playfield", () =>
{
playfield = this.ChildrenOfType<Playfield>().Single();
var location = (3 * playfield.ScreenSpaceDrawQuad.TopLeft + playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
InputManager.MoveMouseTo(location);
});
AddStep("place circle", () => InputManager.Click(MouseButton.Left));
AddStep("right click circle", () => InputManager.Click(MouseButton.Right));
AddUntilStep("context menu is visible", () => contextMenuContainer.ChildrenOfType<OsuContextMenu>().Single().State == MenuState.Open);
AddStep("move mouse to bottom right of playfield", () =>
{
var location = (playfield.ScreenSpaceDrawQuad.TopLeft + 3 * playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
InputManager.MoveMouseTo(location);
});
AddStep("select slider placement tool", () => InputManager.Key(Key.Number3));
AddStep("begin placement", () => InputManager.PressButton(MouseButton.Left));
AddStep("move mouse to top right of playfield", () =>
{
var location = (playfield.ScreenSpaceDrawQuad.TopRight + playfield.ScreenSpaceDrawQuad.BottomLeft) / 4;
InputManager.MoveMouseTo(location);
});
AddStep("end placement", () => InputManager.ReleaseButton(MouseButton.Left));
AddUntilStep("context menu is not visible", () => contextMenuContainer.ChildrenOfType<OsuContextMenu>().Single().State == MenuState.Closed);
}

[Test]
public void TestCircleClosesMenu()
{
Playfield playfield = null!;

AddStep("select circle placement tool", () => InputManager.Key(Key.Number2));
AddStep("move mouse to top left of playfield", () =>
{
playfield = this.ChildrenOfType<Playfield>().Single();
var location = (3 * playfield.ScreenSpaceDrawQuad.TopLeft + playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
InputManager.MoveMouseTo(location);
});
AddStep("place circle", () => InputManager.Click(MouseButton.Left));
AddStep("right click circle", () => InputManager.Click(MouseButton.Right));
AddUntilStep("context menu is visible", () => contextMenuContainer.ChildrenOfType<OsuContextMenu>().Single().State == MenuState.Open);
AddStep("move mouse to bottom right of playfield", () =>
{
var location = (playfield.ScreenSpaceDrawQuad.TopLeft + 3 * playfield.ScreenSpaceDrawQuad.BottomRight) / 4;
InputManager.MoveMouseTo(location);
});
AddStep("place circle", () => InputManager.Click(MouseButton.Left));
AddUntilStep("context menu is not visible", () => contextMenuContainer.ChildrenOfType<OsuContextMenu>().Single().State == MenuState.Closed);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public partial class SliderPlacementBlueprint : HitObjectPlacementBlueprint
private int currentSegmentLength;
private bool usingCustomSegmentType;

public override bool DragBlocksClick => false;

[Resolved]
private IPositionSnapProvider? positionSnapProvider { get; set; }

Expand Down
Loading