Merge branch 'master' into timing-offset-adjust-seek-only-at-start

This commit is contained in:
Salman Ahmed
2022-06-19 01:27:44 +03:00
committed by GitHub
8 changed files with 53 additions and 41 deletions

View File

@ -148,7 +148,11 @@ namespace osu.Game.Tests.Visual.Navigation
private void switchToGameplayScene() private void switchToGameplayScene()
{ {
AddStep("Click gameplay scene button", () => skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text == "Gameplay").TriggerClick()); AddStep("Click gameplay scene button", () =>
{
InputManager.MoveMouseTo(skinEditor.ChildrenOfType<SkinEditorSceneLibrary.SceneButton>().First(b => b.Text == "Gameplay"));
InputManager.Click(MouseButton.Left);
});
AddUntilStep("wait for player", () => AddUntilStep("wait for player", () =>
{ {

View File

@ -108,13 +108,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary> /// </summary>
protected virtual bool AllowDeselectionDuringDrag => true; protected virtual bool AllowDeselectionDuringDrag => true;
/// <remarks>
/// Positional input must be received outside the container's bounds,
/// in order to handle blueprints which are partially offscreen.
/// </remarks>
/// <seealso cref="SelectionHandler{T}.ReceivePositionalInputAt"/>
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
bool selectionPerformed = performMouseDownActions(e); bool selectionPerformed = performMouseDownActions(e);

View File

@ -39,6 +39,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
private PlacementBlueprint currentPlacement; private PlacementBlueprint currentPlacement;
private InputManager inputManager; private InputManager inputManager;
/// <remarks>
/// Positional input must be received outside the container's bounds,
/// in order to handle composer blueprints which are partially offscreen.
/// </remarks>
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public ComposeBlueprintContainer(HitObjectComposer composer) public ComposeBlueprintContainer(HitObjectComposer composer)
: base(composer) : base(composer)
{ {

View File

@ -21,6 +21,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osuTK; using osuTK;
using osuTK.Input; using osuTK.Input;
@ -103,7 +104,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// Positional input must be received outside the container's bounds, /// Positional input must be received outside the container's bounds,
/// in order to handle blueprints which are partially offscreen. /// in order to handle blueprints which are partially offscreen.
/// </remarks> /// </remarks>
/// <seealso cref="BlueprintContainer{T}.ReceivePositionalInputAt"/> /// <seealso cref="ComposeBlueprintContainer.ReceivePositionalInputAt"/>
/// <seealso cref="TimelineBlueprintContainer.ReceivePositionalInputAt"/>
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
/// <summary> /// <summary>

View File

@ -35,6 +35,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private Bindable<HitObject> placement; private Bindable<HitObject> placement;
private SelectionBlueprint<HitObject> placementBlueprint; private SelectionBlueprint<HitObject> placementBlueprint;
/// <remarks>
/// Positional input must be received outside the container's bounds,
/// in order to handle timeline blueprints which are stacked offscreen.
/// </remarks>
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => timeline.ReceivePositionalInputAt(screenSpacePos);
public TimelineBlueprintContainer(HitObjectComposer composer) public TimelineBlueprintContainer(HitObjectComposer composer)
: base(composer) : base(composer)
{ {

View File

@ -6,8 +6,10 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.Cursor;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Screens.Utility.SampleComponents; using osu.Game.Screens.Utility.SampleComponents;
using osuTK.Input; using osuTK.Input;
@ -15,7 +17,7 @@ using osuTK.Input;
namespace osu.Game.Screens.Utility namespace osu.Game.Screens.Utility
{ {
[Cached] [Cached]
public class LatencyArea : CompositeDrawable public class LatencyArea : CompositeDrawable, IProvideCursor
{ {
[Resolved] [Resolved]
private OverlayColourProvider overlayColourProvider { get; set; } = null!; private OverlayColourProvider overlayColourProvider { get; set; } = null!;
@ -34,6 +36,10 @@ namespace osu.Game.Screens.Utility
public readonly Bindable<LatencyVisualMode> VisualMode = new Bindable<LatencyVisualMode>(); public readonly Bindable<LatencyVisualMode> VisualMode = new Bindable<LatencyVisualMode>();
public CursorContainer? Cursor { get; private set; }
public bool ProvidingUserCursor => IsActiveArea.Value;
public LatencyArea(Key key, int? targetFrameRate) public LatencyArea(Key key, int? targetFrameRate)
{ {
this.key = key; this.key = key;
@ -85,7 +91,7 @@ namespace osu.Game.Screens.Utility
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new LatencyCursorContainer Cursor = new LatencyCursorContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
@ -99,7 +105,7 @@ namespace osu.Game.Screens.Utility
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new LatencyCursorContainer Cursor = new LatencyCursorContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
@ -113,7 +119,7 @@ namespace osu.Game.Screens.Utility
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new LatencyCursorContainer Cursor = new LatencyCursorContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },

View File

@ -39,8 +39,6 @@ namespace osu.Game.Screens.Utility
public override bool HideOverlaysOnEnter => true; public override bool HideOverlaysOnEnter => true;
public override bool CursorVisible => mainArea.Count == 0;
public override float BackgroundParallaxAmount => 0; public override float BackgroundParallaxAmount => 0;
private readonly LinkFlowContainer explanatoryText; private readonly LinkFlowContainer explanatoryText;

View File

@ -1,55 +1,52 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; #nullable enable
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Input.States; using osu.Framework.Input.States;
using osu.Game.Overlays;
using osuTK; using osuTK;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Screens.Utility.SampleComponents namespace osu.Game.Screens.Utility.SampleComponents
{ {
public class LatencyCursorContainer : LatencySampleComponent public class LatencyCursorContainer : CursorContainer
{ {
private Circle cursor = null!; protected override Drawable CreateCursor() => new LatencyCursor();
[Resolved] public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
private OverlayColourProvider overlayColourProvider { get; set; } = null!;
public LatencyCursorContainer() public LatencyCursorContainer()
{ {
Masking = true; State.Value = Visibility.Hidden;
} }
protected override void LoadComplete() protected override bool OnMouseMove(MouseMoveEvent e)
{ {
base.LoadComplete(); // Scheduling is required to ensure updating of cursor position happens in limited rate.
// We can alternatively solve this by a PassThroughInputManager layer inside LatencyArea,
InternalChild = cursor = new Circle // but that would mean including input lag to this test, which may not be desired.
{ Schedule(() => base.OnMouseMove(e));
Size = new Vector2(40), return false;
Origin = Anchor.Centre,
Colour = overlayColourProvider.Colour2,
};
} }
protected override bool OnHover(HoverEvent e) => false; private class LatencyCursor : LatencySampleComponent
protected override void UpdateAtLimitedRate(InputState inputState)
{ {
cursor.Colour = inputState.Mouse.IsPressed(MouseButton.Left) ? overlayColourProvider.Content1 : overlayColourProvider.Colour2; public LatencyCursor()
if (IsActive.Value)
{ {
cursor.Position = ToLocalSpace(inputState.Mouse.Position); AutoSizeAxes = Axes.Both;
cursor.Alpha = 1; Origin = Anchor.Centre;
InternalChild = new Circle { Size = new Vector2(40) };
} }
else
protected override void UpdateAtLimitedRate(InputState inputState)
{ {
cursor.Alpha = 0; Colour = inputState.Mouse.IsPressed(MouseButton.Left) ? OverlayColourProvider.Content1 : OverlayColourProvider.Colour2;
} }
} }
} }