Implement disjoint (old style) cursor trails

This commit is contained in:
smoogipoo 2019-09-09 19:23:02 +09:00
parent 292d50aacf
commit a200485fbd
1 changed files with 31 additions and 0 deletions

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Osu.UI.Cursor;
using osu.Game.Skinning;
@ -10,6 +11,11 @@ namespace osu.Game.Rulesets.Osu.Skinning
{
public class LegacyCursorTrail : CursorTrail
{
private const double disjoint_trail_time_separation = 1000 / 60.0;
private bool disjointTrail;
private double lastTrailTime;
public LegacyCursorTrail()
{
Blending = BlendingParameters.Additive;
@ -19,6 +25,31 @@ public LegacyCursorTrail()
private void load(ISkinSource skin)
{
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;
}
}
}