Redesign "local input" toggle in manual input tests to be more user-friendly

- Only displays when required (there's literally zero case we want to
  return input to the test, as this is automatic on next action)
- No longer hugs the right side of the screen (blocking visibility of
  some tests).
This commit is contained in:
Dean Herbert 2023-07-07 13:32:15 +09:00
parent 0b5a3d6a91
commit 04a1550215
1 changed files with 22 additions and 33 deletions

View File

@ -8,6 +8,7 @@
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Framework.Testing.Input; using osu.Framework.Testing.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
@ -25,9 +26,10 @@ public abstract partial class OsuManualInputManagerTestScene : OsuTestScene
protected readonly ManualInputManager InputManager; protected readonly ManualInputManager InputManager;
private readonly RoundedButton buttonTest;
private readonly RoundedButton buttonLocal; private readonly RoundedButton buttonLocal;
private readonly Container takeControlOverlay;
/// <summary> /// <summary>
/// Whether to create a nested container to handle <see cref="GlobalAction"/>s that result from local (manual) test input. /// Whether to create a nested container to handle <see cref="GlobalAction"/>s that result from local (manual) test input.
/// This should be disabled when instantiating an <see cref="OsuGame"/> instance else actions will be lost. /// This should be disabled when instantiating an <see cref="OsuGame"/> instance else actions will be lost.
@ -66,12 +68,12 @@ protected OsuManualInputManagerTestScene()
UseParentInput = true, UseParentInput = true,
Child = mainContent Child = mainContent
}, },
new Container takeControlOverlay = new Container
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopRight, Anchor = Anchor.BottomCentre,
Origin = Anchor.TopRight, Origin = Anchor.BottomCentre,
Margin = new MarginPadding(5), Margin = new MarginPadding(40),
CornerRadius = 5, CornerRadius = 5,
Masking = true, Masking = true,
Children = new Drawable[] Children = new Drawable[]
@ -80,28 +82,28 @@ protected OsuManualInputManagerTestScene()
{ {
Colour = Color4.Black, Colour = Color4.Black,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 0.5f, Alpha = 0.4f,
}, },
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Margin = new MarginPadding(5), Margin = new MarginPadding(10),
Spacing = new Vector2(5), Spacing = new Vector2(10),
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText new OsuSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Text = "Input Priority" Font = OsuFont.Default.With(weight: FontWeight.Bold),
Text = "The test is currently overriding local input",
}, },
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Margin = new MarginPadding(5),
Spacing = new Vector2(5), Spacing = new Vector2(5),
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
@ -109,15 +111,9 @@ protected OsuManualInputManagerTestScene()
{ {
buttonLocal = new RoundedButton buttonLocal = new RoundedButton
{ {
Text = "local", Text = "Take control back",
Size = new Vector2(50, 30), Size = new Vector2(180, 30),
Action = returnUserInput Action = () => InputManager.UseParentInput = true
},
buttonTest = new RoundedButton
{
Text = "test",
Size = new Vector2(50, 30),
Action = returnTestInput
}, },
} }
}, },
@ -128,6 +124,13 @@ protected OsuManualInputManagerTestScene()
}); });
} }
protected override void Update()
{
base.Update();
takeControlOverlay.Alpha = InputManager.UseParentInput ? 0 : 1;
}
/// <summary> /// <summary>
/// Wait for a button to become enabled, then click it. /// Wait for a button to become enabled, then click it.
/// </summary> /// </summary>
@ -146,19 +149,5 @@ protected void ClickButtonWhenEnabled<T>()
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
} }
protected override void Update()
{
base.Update();
buttonTest.Enabled.Value = InputManager.UseParentInput;
buttonLocal.Enabled.Value = !InputManager.UseParentInput;
}
private void returnUserInput() =>
InputManager.UseParentInput = true;
private void returnTestInput() =>
InputManager.UseParentInput = false;
} }
} }