mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:12:54 +08:00
Merge pull request #18736 from frenzibyte/latency-certifier/hidden-cursor
Refactor `LatencyCursorContainer` to display menu cursor when inactive
This commit is contained in:
commit
3105e04839
@ -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,
|
||||||
},
|
},
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
{
|
||||||
|
public LatencyCursor()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
InternalChild = new Circle { Size = new Vector2(40) };
|
||||||
|
}
|
||||||
|
|
||||||
protected override void UpdateAtLimitedRate(InputState inputState)
|
protected override void UpdateAtLimitedRate(InputState inputState)
|
||||||
{
|
{
|
||||||
cursor.Colour = inputState.Mouse.IsPressed(MouseButton.Left) ? overlayColourProvider.Content1 : overlayColourProvider.Colour2;
|
Colour = inputState.Mouse.IsPressed(MouseButton.Left) ? OverlayColourProvider.Content1 : OverlayColourProvider.Colour2;
|
||||||
|
|
||||||
if (IsActive.Value)
|
|
||||||
{
|
|
||||||
cursor.Position = ToLocalSpace(inputState.Mouse.Position);
|
|
||||||
cursor.Alpha = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cursor.Alpha = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user