Merge branch 'master' into realm-migration-operation-blocking

This commit is contained in:
Dean Herbert
2021-03-26 17:07:31 +09:00
127 changed files with 1510 additions and 526 deletions

View File

@ -1,34 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using osuTK;
namespace osu.Game.IO.Serialization.Converters
{
/// <summary>
/// A type of <see cref="JsonConverter"/> that serializes only the X and Y coordinates of a <see cref="Vector2"/>.
/// </summary>
public class Vector2Converter : JsonConverter<Vector2>
{
public override Vector2 ReadJson(JsonReader reader, Type objectType, Vector2 existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var obj = JObject.Load(reader);
return new Vector2((float)obj["x"], (float)obj["y"]);
}
public override void WriteJson(JsonWriter writer, Vector2 value, JsonSerializer serializer)
{
writer.WriteStartObject();
writer.WritePropertyName("x");
writer.WriteValue(value.X);
writer.WritePropertyName("y");
writer.WriteValue(value.Y);
writer.WriteEndObject();
}
}
}

View File

@ -1,8 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.IO.Serialization.Converters;
using osu.Framework.IO.Serialization;
namespace osu.Game.IO.Serialization
{
@ -28,7 +29,7 @@ namespace osu.Game.IO.Serialization
Formatting = Formatting.Indented,
ObjectCreationHandling = ObjectCreationHandling.Replace,
DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
Converters = new JsonConverter[] { new Vector2Converter() },
Converters = new List<JsonConverter> { new Vector2Converter() },
ContractResolver = new KeyContractResolver()
};
}