2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-07-17 13:56:10 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2019-06-07 11:53:51 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Testing.Input;
|
2019-04-23 12:32:44 +08:00
|
|
|
|
using osu.Game.Graphics.Cursor;
|
2019-06-07 11:53:51 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-01-27 11:21:17 +08:00
|
|
|
|
using osu.Game.Input.Bindings;
|
2019-06-07 11:53:51 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
|
|
|
{
|
2020-03-23 09:01:33 +08:00
|
|
|
|
public abstract class OsuManualInputManagerTestScene : OsuTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-04-23 12:32:44 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected readonly ManualInputManager InputManager;
|
|
|
|
|
|
2019-06-07 11:53:51 +08:00
|
|
|
|
private readonly TriangleButton buttonTest;
|
|
|
|
|
private readonly TriangleButton buttonLocal;
|
|
|
|
|
|
2021-04-06 14:05:34 +08:00
|
|
|
|
/// <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.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual bool CreateNestedActionContainer => true;
|
|
|
|
|
|
2020-03-23 09:01:33 +08:00
|
|
|
|
protected OsuManualInputManagerTestScene()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-03-30 18:15:44 +08:00
|
|
|
|
MenuCursorContainer cursorContainer;
|
|
|
|
|
|
2021-07-17 16:26:11 +08:00
|
|
|
|
CompositeDrawable mainContent = new PopoverContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = cursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both, }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cursorContainer.Child = content = new OsuTooltipContainer(cursorContainer.Cursor)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
};
|
2021-04-06 14:05:34 +08:00
|
|
|
|
|
|
|
|
|
if (CreateNestedActionContainer)
|
|
|
|
|
{
|
2021-04-08 14:17:53 +08:00
|
|
|
|
mainContent = new GlobalActionContainer(null).WithChild(mainContent);
|
2021-04-06 14:05:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-07 11:53:51 +08:00
|
|
|
|
base.Content.AddRange(new Drawable[]
|
2019-04-23 12:32:44 +08:00
|
|
|
|
{
|
2019-06-07 11:53:51 +08:00
|
|
|
|
InputManager = new ManualInputManager
|
|
|
|
|
{
|
|
|
|
|
UseParentInput = true,
|
2021-06-14 12:18:52 +08:00
|
|
|
|
Child = mainContent
|
2019-06-07 11:53:51 +08:00
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-04-23 12:32:44 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-07 11:53:51 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
buttonTest.Enabled.Value = InputManager.UseParentInput;
|
|
|
|
|
buttonLocal.Enabled.Value = !InputManager.UseParentInput;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-06-07 11:53:51 +08:00
|
|
|
|
|
|
|
|
|
private void returnUserInput() =>
|
|
|
|
|
InputManager.UseParentInput = true;
|
|
|
|
|
|
|
|
|
|
private void returnTestInput() =>
|
|
|
|
|
InputManager.UseParentInput = false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|