2019-09-09 08:53:51 +00:00
|
|
|
// 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.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
2019-09-09 10:23:02 +00:00
|
|
|
using osu.Framework.Input.Events;
|
2019-09-09 08:53:51 +00:00
|
|
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning
|
|
|
|
{
|
|
|
|
public class LegacyCursorTrail : CursorTrail
|
|
|
|
{
|
2019-09-09 10:23:02 +00:00
|
|
|
private const double disjoint_trail_time_separation = 1000 / 60.0;
|
|
|
|
|
|
|
|
private bool disjointTrail;
|
|
|
|
private double lastTrailTime;
|
|
|
|
|
2019-09-09 08:53:51 +00:00
|
|
|
public LegacyCursorTrail()
|
|
|
|
{
|
|
|
|
Blending = BlendingParameters.Additive;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(ISkinSource skin)
|
|
|
|
{
|
|
|
|
Texture = skin.GetTexture("cursortrail");
|
2019-09-09 10:23:02 +00:00
|
|
|
disjointTrail = skin.GetTexture("cursormiddle") == null;
|
|
|
|
|
2019-09-11 04:28:36 +00:00
|
|
|
if (Texture != null)
|
2019-09-09 10:23:02 +00:00
|
|
|
{
|
|
|
|
// 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;
|
2019-09-09 08:53:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|