1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 22:22:53 +08:00
osu-lazer/osu.Game/Screens/Utility/SampleComponents/LatencyCursorContainer.cs

52 lines
1.8 KiB
C#
Raw Normal View History

// 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.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Utility.SampleComponents
{
2022-11-24 13:32:20 +08:00
public partial class LatencyCursorContainer : CursorContainer
{
protected override Drawable CreateCursor() => new LatencyCursor();
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
public LatencyCursorContainer()
{
State.Value = Visibility.Hidden;
}
protected override bool OnMouseMove(MouseMoveEvent e)
{
// Scheduling is required to ensure updating of cursor position happens in limited rate.
// We can alternatively solve this by a PassThroughInputManager layer inside LatencyArea,
// but that would mean including input lag to this test, which may not be desired.
Schedule(() => base.OnMouseMove(e));
return false;
}
2022-11-24 13:32:20 +08:00
private partial class LatencyCursor : LatencySampleComponent
{
public LatencyCursor()
{
AutoSizeAxes = Axes.Both;
Origin = Anchor.Centre;
InternalChild = new Circle { Size = new Vector2(40) };
}
protected override void UpdateAtLimitedRate(InputState inputState)
{
Colour = inputState.Mouse.IsPressed(MouseButton.Left) ? OverlayColourProvider.Content1 : OverlayColourProvider.Colour2;
}
}
}
}