mirror of https://github.com/ppy/osu
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:
parent
0b5a3d6a91
commit
04a1550215
|
@ -8,6 +8,7 @@
|
|||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Testing.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
|
@ -25,9 +26,10 @@ public abstract partial class OsuManualInputManagerTestScene : OsuTestScene
|
|||
|
||||
protected readonly ManualInputManager InputManager;
|
||||
|
||||
private readonly RoundedButton buttonTest;
|
||||
private readonly RoundedButton buttonLocal;
|
||||
|
||||
private readonly Container takeControlOverlay;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
|
@ -66,12 +68,12 @@ protected OsuManualInputManagerTestScene()
|
|||
UseParentInput = true,
|
||||
Child = mainContent
|
||||
},
|
||||
new Container
|
||||
takeControlOverlay = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Margin = new MarginPadding(5),
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Margin = new MarginPadding(40),
|
||||
CornerRadius = 5,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
|
@ -80,28 +82,28 @@ protected OsuManualInputManagerTestScene()
|
|||
{
|
||||
Colour = Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.5f,
|
||||
Alpha = 0.4f,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Margin = new MarginPadding(5),
|
||||
Spacing = new Vector2(5),
|
||||
Margin = new MarginPadding(10),
|
||||
Spacing = new Vector2(10),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = 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
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Margin = new MarginPadding(5),
|
||||
Spacing = new Vector2(5),
|
||||
Direction = FillDirection.Horizontal,
|
||||
|
||||
|
@ -109,15 +111,9 @@ protected OsuManualInputManagerTestScene()
|
|||
{
|
||||
buttonLocal = new RoundedButton
|
||||
{
|
||||
Text = "local",
|
||||
Size = new Vector2(50, 30),
|
||||
Action = returnUserInput
|
||||
},
|
||||
buttonTest = new RoundedButton
|
||||
{
|
||||
Text = "test",
|
||||
Size = new Vector2(50, 30),
|
||||
Action = returnTestInput
|
||||
Text = "Take control back",
|
||||
Size = new Vector2(180, 30),
|
||||
Action = () => InputManager.UseParentInput = true
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -128,6 +124,13 @@ protected OsuManualInputManagerTestScene()
|
|||
});
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
takeControlOverlay.Alpha = InputManager.UseParentInput ? 0 : 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wait for a button to become enabled, then click it.
|
||||
/// </summary>
|
||||
|
@ -146,19 +149,5 @@ protected void ClickButtonWhenEnabled<T>()
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue