1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 02:33:02 +08:00

Implement disjoint (old style) cursor trails

This commit is contained in:
smoogipoo 2019-09-09 19:23:02 +09:00
parent 292d50aacf
commit a200485fbd

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Osu.UI.Cursor; using osu.Game.Rulesets.Osu.UI.Cursor;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -10,6 +11,11 @@ namespace osu.Game.Rulesets.Osu.Skinning
{ {
public class LegacyCursorTrail : CursorTrail public class LegacyCursorTrail : CursorTrail
{ {
private const double disjoint_trail_time_separation = 1000 / 60.0;
private bool disjointTrail;
private double lastTrailTime;
public LegacyCursorTrail() public LegacyCursorTrail()
{ {
Blending = BlendingParameters.Additive; Blending = BlendingParameters.Additive;
@ -19,6 +25,31 @@ namespace osu.Game.Rulesets.Osu.Skinning
private void load(ISkinSource skin) private void load(ISkinSource skin)
{ {
Texture = skin.GetTexture("cursortrail"); Texture = skin.GetTexture("cursortrail");
disjointTrail = skin.GetTexture("cursormiddle") == null;
if (disjointTrail && Texture != null)
{
// stable "magic ratio". see OsuPlayfieldAdjustmentContainer for full explanation.
Texture.ScaleAdjust *= 1.6f;
}
}
protected override double FadeDuration => disjointTrail ? 150 : 500;
protected override bool InterpolateMovements => !disjointTrail;
protected override bool OnMouseMove(MouseMoveEvent e)
{
if (!disjointTrail)
return base.OnMouseMove(e);
if (Time.Current - lastTrailTime >= disjoint_trail_time_separation)
{
lastTrailTime = Time.Current;
return base.OnMouseMove(e);
}
return false;
} }
} }
} }