Archived
forked from RDTKEditor/RDTKEditor
添加对 Core 的直接引用
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RhythmBase.Events;
|
||||
namespace RhythmBase.Converters
|
||||
{
|
||||
internal class TabsConverter : JsonConverter<Tabs>
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, Tabs value, JsonSerializer serializer) => writer.WriteValue(TabNames[(int)value]);
|
||||
|
||||
public override Tabs ReadJson(JsonReader reader, Type objectType, Tabs existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
string value = JToken.Load(reader).ToObject<string>()??throw new RhythmBase.Exceptions.ConvertingException("Cannot read the tab.");
|
||||
int t = TabNames.ToList().IndexOf(value);
|
||||
bool flag = t >= 0;
|
||||
Tabs ReadJson;
|
||||
if (flag)
|
||||
{
|
||||
ReadJson = (Tabs)t;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadJson = Tabs.Unknown;
|
||||
}
|
||||
return ReadJson;
|
||||
}
|
||||
|
||||
private static readonly string[] TabNames =
|
||||
[
|
||||
"Song",
|
||||
"Rows",
|
||||
"Actions",
|
||||
"Sprites",
|
||||
"Rooms"
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user