1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 14:32:55 +08:00

Fix incorrect cursor trail size + scale

This commit is contained in:
smoogipoo 2019-09-09 19:30:31 +09:00
parent a200485fbd
commit e3b972187e

View File

@ -5,6 +5,7 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Caching;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Batches; using osu.Framework.Graphics.Batches;
using osu.Framework.Graphics.OpenGL.Vertices; using osu.Framework.Graphics.OpenGL.Vertices;
@ -72,6 +73,20 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
} }
} }
private readonly Cached<Vector2> partSizeCache = new Cached<Vector2>();
private Vector2 partSize => partSizeCache.IsValid
? partSizeCache.Value
: (partSizeCache.Value = new Vector2(Texture.DisplayWidth, Texture.DisplayHeight) * DrawInfo.Matrix.ExtractScale().Xy);
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
{
if ((invalidation & (Invalidation.DrawInfo | Invalidation.RequiredParentSizeToFit | Invalidation.Presence)) > 0)
partSizeCache.Invalidate();
return base.Invalidate(invalidation, source, shallPropagate);
}
/// <summary> /// <summary>
/// The amount of time to fade the cursor trail pieces. /// The amount of time to fade the cursor trail pieces.
/// </summary> /// </summary>
@ -104,8 +119,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
timeOffset = Time.Current; timeOffset = Time.Current;
} }
private Vector2 size => texture.Size * Scale;
/// <summary> /// <summary>
/// Whether to interpolate mouse movements and add trail pieces at intermediate points. /// Whether to interpolate mouse movements and add trail pieces at intermediate points.
/// </summary> /// </summary>
@ -139,7 +152,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
float distance = diff.Length; float distance = diff.Length;
Vector2 direction = diff / distance; Vector2 direction = diff / distance;
float interval = size.X / 2 * 0.9f; float interval = partSize.X / 2 * 0.9f;
for (float d = interval; d < distance; d += interval) for (float d = interval; d < distance; d += interval)
{ {
@ -202,7 +215,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
shader = Source.shader; shader = Source.shader;
texture = Source.texture; texture = Source.texture;
size = Source.size; size = Source.partSize;
time = Source.time; time = Source.time;
for (int i = 0; i < Source.parts.Length; ++i) for (int i = 0; i < Source.parts.Length; ++i)