1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-29 23:22:55 +08:00

Minor refactorings and xmldoc additions

This commit is contained in:
Dan Balasescu 2025-01-16 14:00:27 +09:00
parent 2eb63e6fe0
commit 920648c267
No known key found for this signature in database
2 changed files with 34 additions and 16 deletions

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private void load(OsuConfigManager config, ISkinSource skinSource)
{
cursorSize = config.GetBindable<float>(OsuSetting.GameplayCursorSize).GetBoundCopy();
Spin = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorTrailRotate)?.Value ?? true;
AllowPartRotation = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorTrailRotate)?.Value ?? true;
Texture = skin.GetTexture("cursortrail");

View File

@ -34,21 +34,24 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
/// </summary>
protected virtual float FadeExponent => 1.7f;
private readonly TrailPart[] parts = new TrailPart[max_sprites];
private int currentIndex;
private IShader shader;
private double timeOffset;
private float time;
protected bool Spin { get; set; }
public float PartRotation { get; set; }
/// <summary>
/// The scale used on creation of a new trail part.
/// </summary>
public Vector2 NewPartScale = Vector2.One;
public Vector2 NewPartScale { get; set; } = Vector2.One;
private Anchor trailOrigin = Anchor.Centre;
/// <summary>
/// The rotation (in degrees) to apply to trail parts when <see cref="AllowPartRotation"/> is <c>true</c>.
/// </summary>
public float PartRotation { get; set; }
/// <summary>
/// Whether to rotate trail parts based on the value of <see cref="PartRotation"/>.
/// </summary>
protected bool AllowPartRotation { get; set; }
/// <summary>
/// The trail part texture origin.
/// </summary>
protected Anchor TrailOrigin
{
get => trailOrigin;
@ -59,6 +62,13 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
}
}
private readonly TrailPart[] parts = new TrailPart[max_sprites];
private Anchor trailOrigin = Anchor.Centre;
private int currentIndex;
private IShader shader;
private double timeOffset;
private float time;
public CursorTrail()
{
// as we are currently very dependent on having a running clock, let's make our own clock for the time being.
@ -242,7 +252,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
texture = Source.texture;
time = Source.time;
fadeExponent = Source.FadeExponent;
angle = Source.Spin ? float.DegreesToRadians(Source.PartRotation) : 0;
angle = Source.AllowPartRotation ? float.DegreesToRadians(Source.PartRotation) : 0;
originPosition = Vector2.Zero;
@ -296,7 +306,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
vertexBatch.Add(new TexturedTrailVertex
{
Position = rotateAround(new Vector2(part.Position.X - texture.DisplayWidth * originPosition.X * part.Scale.X, part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y) * part.Scale.Y), part.Position, sin, cos),
Position = rotateAround(
new Vector2(part.Position.X - texture.DisplayWidth * originPosition.X * part.Scale.X, part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y) * part.Scale.Y),
part.Position, sin, cos),
TexturePosition = textureRect.BottomLeft,
TextureRect = new Vector4(0, 0, 1, 1),
Colour = DrawColourInfo.Colour.BottomLeft.Linear,
@ -305,7 +317,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
vertexBatch.Add(new TexturedTrailVertex
{
Position = rotateAround(new Vector2(part.Position.X + texture.DisplayWidth * (1 - originPosition.X) * part.Scale.X, part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y) * part.Scale.Y), part.Position, sin, cos),
Position = rotateAround(
new Vector2(part.Position.X + texture.DisplayWidth * (1 - originPosition.X) * part.Scale.X,
part.Position.Y + texture.DisplayHeight * (1 - originPosition.Y) * part.Scale.Y), part.Position, sin, cos),
TexturePosition = textureRect.BottomRight,
TextureRect = new Vector4(0, 0, 1, 1),
Colour = DrawColourInfo.Colour.BottomRight.Linear,
@ -314,7 +328,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
vertexBatch.Add(new TexturedTrailVertex
{
Position = rotateAround(new Vector2(part.Position.X + texture.DisplayWidth * (1 - originPosition.X) * part.Scale.X, part.Position.Y - texture.DisplayHeight * originPosition.Y * part.Scale.Y), part.Position, sin, cos),
Position = rotateAround(
new Vector2(part.Position.X + texture.DisplayWidth * (1 - originPosition.X) * part.Scale.X, part.Position.Y - texture.DisplayHeight * originPosition.Y * part.Scale.Y),
part.Position, sin, cos),
TexturePosition = textureRect.TopRight,
TextureRect = new Vector4(0, 0, 1, 1),
Colour = DrawColourInfo.Colour.TopRight.Linear,
@ -323,7 +339,9 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
vertexBatch.Add(new TexturedTrailVertex
{
Position = rotateAround(new Vector2(part.Position.X - texture.DisplayWidth * originPosition.X * part.Scale.X, part.Position.Y - texture.DisplayHeight * originPosition.Y * part.Scale.Y), part.Position, sin, cos),
Position = rotateAround(
new Vector2(part.Position.X - texture.DisplayWidth * originPosition.X * part.Scale.X, part.Position.Y - texture.DisplayHeight * originPosition.Y * part.Scale.Y),
part.Position, sin, cos),
TexturePosition = textureRect.TopLeft,
TextureRect = new Vector4(0, 0, 1, 1),
Colour = DrawColourInfo.Colour.TopLeft.Linear,