mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Always add cursor trail for legacy cursor with disjoint trail
This commit is contained in:
parent
9e8137c6e4
commit
1069f9d501
@ -5,10 +5,12 @@ using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shaders;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
{
|
||||
@ -21,14 +23,18 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
private double lastTrailTime;
|
||||
private IBindable<float> cursorSize;
|
||||
|
||||
private Vector2? currentPosition;
|
||||
|
||||
public LegacyCursorTrail(ISkin skin)
|
||||
{
|
||||
this.skin = skin;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
private void load(ShaderManager shaders, OsuConfigManager config)
|
||||
{
|
||||
Shader = shaders.Load(@"LegacyCursorTrail", FragmentShaderDescriptor.TEXTURE);
|
||||
|
||||
Texture = skin.GetTexture("cursortrail");
|
||||
disjointTrail = skin.GetTexture("cursormiddle") == null;
|
||||
|
||||
@ -59,18 +65,24 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
|
||||
protected override float IntervalMultiplier => 1 / Math.Max(cursorSize.Value, 1);
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
protected override void Update()
|
||||
{
|
||||
if (!disjointTrail)
|
||||
return base.OnMouseMove(e);
|
||||
base.Update();
|
||||
|
||||
if (!disjointTrail || !currentPosition.HasValue)
|
||||
return;
|
||||
|
||||
if (Time.Current - lastTrailTime >= disjoint_trail_time_separation)
|
||||
{
|
||||
lastTrailTime = Time.Current;
|
||||
return base.OnMouseMove(e);
|
||||
AddTrail(currentPosition.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
currentPosition = e.ScreenSpaceMousePosition;
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
|
||||
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
||||
private int currentIndex;
|
||||
private IShader shader;
|
||||
|
||||
protected IShader Shader;
|
||||
|
||||
private double timeOffset;
|
||||
private float time;
|
||||
|
||||
@ -63,7 +65,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ShaderManager shaders)
|
||||
{
|
||||
shader = shaders.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE);
|
||||
Shader = shaders.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -141,21 +143,32 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
Vector2 pos = e.ScreenSpaceMousePosition;
|
||||
Vector2 position = e.ScreenSpaceMousePosition;
|
||||
|
||||
if (lastPosition == null)
|
||||
{
|
||||
lastPosition = pos;
|
||||
lastPosition = position;
|
||||
resampler.AddPosition(lastPosition.Value);
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
foreach (Vector2 pos2 in resampler.AddPosition(pos))
|
||||
{
|
||||
Trace.Assert(lastPosition.HasValue);
|
||||
if (InterpolateMovements)
|
||||
AddTrail(position);
|
||||
|
||||
if (InterpolateMovements)
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected void AddTrail(Vector2 position)
|
||||
{
|
||||
if (!lastPosition.HasValue)
|
||||
return;
|
||||
|
||||
if (InterpolateMovements)
|
||||
{
|
||||
foreach (Vector2 pos2 in resampler.AddPosition(position))
|
||||
{
|
||||
Trace.Assert(lastPosition.HasValue);
|
||||
|
||||
// ReSharper disable once PossibleInvalidOperationException
|
||||
Vector2 pos1 = lastPosition.Value;
|
||||
Vector2 diff = pos2 - pos1;
|
||||
@ -170,14 +183,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
addPart(lastPosition.Value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastPosition = pos2;
|
||||
addPart(lastPosition.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnMouseMove(e);
|
||||
else
|
||||
{
|
||||
lastPosition = position;
|
||||
addPart(lastPosition.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void addPart(Vector2 screenSpacePosition)
|
||||
@ -223,7 +234,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
{
|
||||
base.ApplyState();
|
||||
|
||||
shader = Source.shader;
|
||||
shader = Source.Shader;
|
||||
texture = Source.texture;
|
||||
size = Source.partSize;
|
||||
time = Source.time;
|
||||
|
Loading…
Reference in New Issue
Block a user