1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Merge branch 'fix-category-serialisation' into realtime-multiplayer-2

This commit is contained in:
smoogipoo 2020-12-21 16:57:22 +09:00
commit 04af072da7
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,16 @@
// 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 Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
namespace osu.Game.IO.Serialization.Converters
{
public class SnakeCaseStringEnumConverter : StringEnumConverter
{
public SnakeCaseStringEnumConverter()
{
NamingStrategy = new SnakeCaseNamingStrategy();
}
}
}

View File

@ -6,6 +6,7 @@ using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.IO.Serialization.Converters;
using osu.Game.Online.Multiplayer.GameTypes; using osu.Game.Online.Multiplayer.GameTypes;
using osu.Game.Online.Multiplayer.RoomStatuses; using osu.Game.Online.Multiplayer.RoomStatuses;
using osu.Game.Users; using osu.Game.Users;
@ -35,9 +36,18 @@ namespace osu.Game.Online.Multiplayer
public readonly Bindable<int> ChannelId = new Bindable<int>(); public readonly Bindable<int> ChannelId = new Bindable<int>();
[Cached] [Cached]
[JsonProperty("category")] [JsonIgnore]
public readonly Bindable<RoomCategory> Category = new Bindable<RoomCategory>(); public readonly Bindable<RoomCategory> Category = new Bindable<RoomCategory>();
// Todo: osu-framework bug (https://github.com/ppy/osu-framework/issues/4106)
[JsonProperty("category")]
[JsonConverter(typeof(SnakeCaseStringEnumConverter))]
private RoomCategory category
{
get => Category.Value;
set => Category.Value = value;
}
[Cached] [Cached]
[JsonIgnore] [JsonIgnore]
public readonly Bindable<TimeSpan?> Duration = new Bindable<TimeSpan?>(); public readonly Bindable<TimeSpan?> Duration = new Bindable<TimeSpan?>();