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.
|
|
|
|
|
2020-10-02 16:34:06 +00:00
|
|
|
using System;
|
2019-09-09 08:53:51 +00:00
|
|
|
using osu.Framework.Allocation;
|
2020-10-02 16:34:06 +00:00
|
|
|
using osu.Framework.Bindables;
|
2019-09-09 08:53:51 +00:00
|
|
|
using osu.Framework.Graphics;
|
2019-09-09 10:23:02 +00:00
|
|
|
using osu.Framework.Input.Events;
|
2020-10-02 16:34:06 +00:00
|
|
|
using osu.Game.Configuration;
|
2019-09-09 08:53:51 +00:00
|
|
|
using osu.Game.Rulesets.Osu.UI.Cursor;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
2020-12-04 11:21:53 +00:00
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
2019-09-09 08:53:51 +00:00
|
|
|
{
|
|
|
|
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;
|
2020-10-02 16:34:06 +00:00
|
|
|
private IBindable<float> cursorSize;
|
2019-09-09 10:23:02 +00:00
|
|
|
|
2019-09-09 08:53:51 +00:00
|
|
|
[BackgroundDependencyLoader]
|
2020-10-02 16:34:06 +00:00
|
|
|
private void load(ISkinSource skin, OsuConfigManager config)
|
2019-09-09 08:53:51 +00:00
|
|
|
{
|
|
|
|
Texture = skin.GetTexture("cursortrail");
|
2019-09-09 10:23:02 +00:00
|
|
|
disjointTrail = skin.GetTexture("cursormiddle") == null;
|
|
|
|
|
2021-04-14 05:20:18 +00:00
|
|
|
if (disjointTrail)
|
|
|
|
{
|
|
|
|
bool centre = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorCentre)?.Value ?? true;
|
|
|
|
|
|
|
|
TrailOrigin = centre ? Anchor.Centre : Anchor.TopLeft;
|
|
|
|
Blending = BlendingParameters.Inherit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Blending = BlendingParameters.Additive;
|
|
|
|
}
|
2020-12-29 01:37:57 +00:00
|
|
|
|
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;
|
|
|
|
}
|
2020-10-02 16:34:06 +00:00
|
|
|
|
|
|
|
cursorSize = config.GetBindable<float>(OsuSetting.GameplayCursorSize).GetBoundCopy();
|
2019-09-09 10:23:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override double FadeDuration => disjointTrail ? 150 : 500;
|
|
|
|
|
|
|
|
protected override bool InterpolateMovements => !disjointTrail;
|
|
|
|
|
2020-10-02 16:34:49 +00:00
|
|
|
protected override float IntervalMultiplier => 1 / Math.Max(cursorSize.Value, 1);
|
2020-10-02 16:34:06 +00:00
|
|
|
|
2019-09-09 10:23:02 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|