mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 00:02:56 +08:00
Reorder CursorTrail members
This commit is contained in:
parent
f51ff55328
commit
7adfae3784
@ -22,28 +22,14 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
{
|
{
|
||||||
internal class CursorTrail : Drawable, IRequireHighFrequencyMousePosition
|
internal class CursorTrail : Drawable, IRequireHighFrequencyMousePosition
|
||||||
{
|
{
|
||||||
private int currentIndex;
|
|
||||||
|
|
||||||
private IShader shader;
|
|
||||||
private Texture texture;
|
|
||||||
|
|
||||||
private Vector2 size => texture.Size * Scale;
|
|
||||||
|
|
||||||
private double timeOffset;
|
|
||||||
|
|
||||||
private float time;
|
|
||||||
|
|
||||||
public override bool IsPresent => true;
|
|
||||||
|
|
||||||
private const int max_sprites = 2048;
|
private const int max_sprites = 2048;
|
||||||
|
|
||||||
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
||||||
|
private int currentIndex;
|
||||||
private Vector2? lastPosition;
|
private IShader shader;
|
||||||
|
private Texture texture;
|
||||||
private readonly InputResampler resampler = new InputResampler();
|
private double timeOffset;
|
||||||
|
private float time;
|
||||||
protected override DrawNode CreateDrawNode() => new TrailDrawNode(this);
|
|
||||||
|
|
||||||
public CursorTrail()
|
public CursorTrail()
|
||||||
{
|
{
|
||||||
@ -60,8 +46,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ShaderManager shaders, TextureStore textures)
|
private void load(ShaderManager shaders, TextureStore textures)
|
||||||
{
|
{
|
||||||
@ -76,6 +60,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
resetTime();
|
resetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool IsPresent => true;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -101,6 +87,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
timeOffset = Time.Current;
|
timeOffset = Time.Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector2 size => texture.Size * Scale;
|
||||||
|
|
||||||
|
private Vector2? lastPosition;
|
||||||
|
private readonly InputResampler resampler = new InputResampler();
|
||||||
|
|
||||||
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
{
|
{
|
||||||
Vector2 pos = e.ScreenSpaceMousePosition;
|
Vector2 pos = e.ScreenSpaceMousePosition;
|
||||||
@ -127,21 +120,19 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
|||||||
for (float d = interval; d < distance; d += interval)
|
for (float d = interval; d < distance; d += interval)
|
||||||
{
|
{
|
||||||
lastPosition = pos1 + direction * d;
|
lastPosition = pos1 + direction * d;
|
||||||
addPosition(lastPosition.Value);
|
|
||||||
|
parts[currentIndex].Position = lastPosition.Value;
|
||||||
|
parts[currentIndex].Time = time;
|
||||||
|
++parts[currentIndex].InvalidationID;
|
||||||
|
|
||||||
|
currentIndex = (currentIndex + 1) % max_sprites;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnMouseMove(e);
|
return base.OnMouseMove(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPosition(Vector2 pos)
|
protected override DrawNode CreateDrawNode() => new TrailDrawNode(this);
|
||||||
{
|
|
||||||
parts[currentIndex].Position = pos;
|
|
||||||
parts[currentIndex].Time = time;
|
|
||||||
++parts[currentIndex].InvalidationID;
|
|
||||||
|
|
||||||
currentIndex = (currentIndex + 1) % max_sprites;
|
|
||||||
}
|
|
||||||
|
|
||||||
private struct TrailPart
|
private struct TrailPart
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user