diff --git a/Anamnesis/Serialization/Converters/VectorConverter.cs b/Anamnesis/Serialization/Converters/VectorConverter.cs index 497b07ee..ab87e66a 100644 --- a/Anamnesis/Serialization/Converters/VectorConverter.cs +++ b/Anamnesis/Serialization/Converters/VectorConverter.cs @@ -9,15 +9,25 @@ namespace Anamnesis.Serialization.Converters; using System.Text.Json.Serialization; using XivToolsWpf.Math3D.Extensions; -public class VectorConverter : JsonConverter +public class Vector2Converter : JsonConverter { - public override Vector3 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override Vector2 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - string? str = reader.GetString(); + string? str = reader.GetString() ?? throw new Exception("Cannot convert null to Vector2"); + return VectorExtensions.FromString2D(str); + } - if (str == null) - throw new Exception("Cannot convert null to Vector"); + public override void Write(Utf8JsonWriter writer, Vector2 value, JsonSerializerOptions options) + { + writer.WriteStringValue(value.ToInvariantString()); + } +} +public class Vector3Converter : JsonConverter +{ + public override Vector3 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? str = reader.GetString() ?? throw new Exception("Cannot convert null to Vector3"); return VectorExtensions.FromString3D(str); } diff --git a/Anamnesis/Serialization/SerializerService.cs b/Anamnesis/Serialization/SerializerService.cs index 4ba01fc5..e3e7467e 100644 --- a/Anamnesis/Serialization/SerializerService.cs +++ b/Anamnesis/Serialization/SerializerService.cs @@ -3,11 +3,11 @@ namespace Anamnesis.Serialization; +using Anamnesis.Serialization.Converters; using System; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; -using Anamnesis.Serialization.Converters; public class SerializerService : ServiceBase { @@ -26,7 +26,8 @@ static SerializerService() Options.Converters.Add(new Color4Converter()); Options.Converters.Add(new ColorConverter()); Options.Converters.Add(new QuaternionConverter()); - Options.Converters.Add(new VectorConverter()); + Options.Converters.Add(new Vector2Converter()); + Options.Converters.Add(new Vector3Converter()); Options.Converters.Add(new IItemConverter()); Options.Converters.Add(new IDyeConverter()); Options.Converters.Add(new ItemCategoriesConverter()); diff --git a/Lib/XivToolsWpf b/Lib/XivToolsWpf index 05adb4f3..92e4d41c 160000 --- a/Lib/XivToolsWpf +++ b/Lib/XivToolsWpf @@ -1 +1 @@ -Subproject commit 05adb4f37f0867490265ccf510a44bcb35859799 +Subproject commit 92e4d41c0bf23b8365ad369821019e889ac9dd37