mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-09 23:15:41 +00:00
Fix formatting of Coordinates and Rotation
This commit is contained in:
parent
2b80c4c8c5
commit
90211f1647
@ -18,7 +18,12 @@ public readonly partial struct Coordinates
|
||||
return chars.ToString();
|
||||
}
|
||||
|
||||
public static int Serialize(in Coordinates coordinates, string format, IFormatProvider? formatProvider, Span<char> destination)
|
||||
public static int Serialize(
|
||||
in Coordinates coordinates,
|
||||
string? format,
|
||||
IFormatProvider? formatProvider,
|
||||
Span<char> destination
|
||||
)
|
||||
{
|
||||
using Utf8ValueStringBuilder builder = ZString.CreateUtf8StringBuilder();
|
||||
|
||||
@ -40,7 +45,7 @@ public readonly partial struct Coordinates
|
||||
builder.Append('+');
|
||||
}
|
||||
|
||||
builder.Append(string.Format(formatProvider, format, coordinates.Z));
|
||||
builder.Append(coordinates.Z.ToString(format, formatProvider));
|
||||
builder.Append(' ');
|
||||
|
||||
if (west)
|
||||
@ -48,7 +53,7 @@ public readonly partial struct Coordinates
|
||||
builder.Append('+');
|
||||
}
|
||||
|
||||
builder.Append(string.Format(formatProvider, format, coordinates.X));
|
||||
builder.Append(coordinates.X.ToString(format, formatProvider));
|
||||
builder.Append(' ');
|
||||
|
||||
if (up)
|
||||
@ -56,7 +61,7 @@ public readonly partial struct Coordinates
|
||||
builder.Append('+');
|
||||
}
|
||||
|
||||
builder.Append(string.Format(formatProvider, format, coordinates.Y));
|
||||
builder.Append(coordinates.Y.ToString(format, formatProvider));
|
||||
builder.Append("a ");
|
||||
|
||||
if (dir)
|
||||
@ -71,18 +76,18 @@ public readonly partial struct Coordinates
|
||||
char zChar = north ? 'n' : 's';
|
||||
char xChar = west ? 'w' : 'e';
|
||||
|
||||
builder.Append(string.Format(formatProvider, format, Math.Abs(coordinates.Z)));
|
||||
builder.Append(Math.Abs(coordinates.Z).ToString(format, formatProvider));
|
||||
builder.Append(zChar);
|
||||
builder.Append(' ');
|
||||
|
||||
builder.Append(string.Format(formatProvider, format, Math.Abs(coordinates.X)));
|
||||
builder.Append(Math.Abs(coordinates.X).ToString(format, formatProvider));
|
||||
builder.Append(xChar);
|
||||
builder.Append(' ');
|
||||
|
||||
builder.Append(string.Format(formatProvider, format, coordinates.Y));
|
||||
builder.Append(Math.Abs(coordinates.Y).ToString(format, formatProvider));
|
||||
builder.Append("a ");
|
||||
|
||||
builder.Append(string.Format(formatProvider, format, coordinates.Yaw));
|
||||
builder.Append(Math.Abs(coordinates.Yaw).ToString(format, formatProvider));
|
||||
}
|
||||
|
||||
ReadOnlySpan<byte> bytes = builder.AsSpan();
|
||||
|
@ -190,7 +190,7 @@ public readonly partial struct Coordinates : IEquatable<Coordinates>, IFormattab
|
||||
/// <returns>A <see cref="string" /> representation of these coordinates.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString("{0}", CultureInfo.InvariantCulture);
|
||||
return ToString("F", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -202,6 +202,6 @@ public readonly partial struct Coordinates : IEquatable<Coordinates>, IFormattab
|
||||
public string ToString(string? format, IFormatProvider? formatProvider = null)
|
||||
{
|
||||
format ??= "{0}";
|
||||
return Serializer.Serialize(this, format, formatProvider);
|
||||
return Serializer.Serialize(this, format, formatProvider ?? CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public readonly struct Rotation : IEquatable<Rotation>, IFormattable
|
||||
/// <returns>A <see cref="string" /> representation of these coordinates.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString("{0}", CultureInfo.CurrentCulture);
|
||||
return ToString("F", CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -194,13 +194,13 @@ public readonly struct Rotation : IEquatable<Rotation>, IFormattable
|
||||
|
||||
using var builder = ZString.CreateUtf8StringBuilder();
|
||||
builder.Append('<');
|
||||
builder.Append(string.Format(formatProvider, format, Tilt));
|
||||
builder.Append(Tilt.ToString(format, formatProvider));
|
||||
builder.Append(separator);
|
||||
builder.Append(' ');
|
||||
builder.Append(string.Format(formatProvider, format, Yaw));
|
||||
builder.Append(Yaw.ToString(format, formatProvider));
|
||||
builder.Append(separator);
|
||||
builder.Append(' ');
|
||||
builder.Append(string.Format(formatProvider, format, Roll));
|
||||
builder.Append(Roll.ToString(format, formatProvider));
|
||||
builder.Append('>');
|
||||
|
||||
return builder.ToString();
|
||||
|
Loading…
Reference in New Issue
Block a user