Add an input source toggle on manual input test scenes (#4945)

Add an input source toggle on manual input test scenes
This commit is contained in:
Dean Herbert 2019-06-07 20:26:26 +09:00 committed by GitHub
commit 011ccffde7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 9 deletions

View File

@ -84,7 +84,6 @@ public TestSceneCursors()
testLocalCursor();
testUserCursorOverride();
testMultipleLocalCursors();
ReturnUserInput();
}
/// <summary>

View File

@ -3,8 +3,13 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing.Input;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual
{
@ -15,21 +20,92 @@ public abstract class ManualInputManagerTestScene : OsuTestScene
protected readonly ManualInputManager InputManager;
private readonly TriangleButton buttonTest;
private readonly TriangleButton buttonLocal;
protected ManualInputManagerTestScene()
{
base.Content.Add(InputManager = new ManualInputManager
base.Content.AddRange(new Drawable[]
{
UseParentInput = true,
Child = content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both },
InputManager = new ManualInputManager
{
UseParentInput = true,
Child = content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both },
},
new Container
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Margin = new MarginPadding(5),
CornerRadius = 5,
Masking = true,
Children = new Drawable[]
{
new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
Alpha = 0.5f,
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Margin = new MarginPadding(5),
Spacing = new Vector2(5),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Input Priority"
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding(5),
Spacing = new Vector2(5),
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
buttonLocal = new TriangleButton
{
Text = "local",
Size = new Vector2(50, 30),
Action = returnUserInput
},
buttonTest = new TriangleButton
{
Text = "test",
Size = new Vector2(50, 30),
Action = returnTestInput
},
}
},
}
},
}
},
});
}
/// <summary>
/// Returns input back to the user.
/// </summary>
protected void ReturnUserInput()
protected override void Update()
{
AddStep("Return user input", () => InputManager.UseParentInput = true);
base.Update();
buttonTest.Enabled.Value = InputManager.UseParentInput;
buttonLocal.Enabled.Value = !InputManager.UseParentInput;
}
private void returnUserInput() =>
InputManager.UseParentInput = true;
private void returnTestInput() =>
InputManager.UseParentInput = false;
}
}