diff --git a/Assets/Plugins/Essgee.Unity/Emulation/Configuration/GameBoy.cs b/Assets/Plugins/Essgee.Unity/Emulation/Configuration/GameBoy.cs index 7f548ff..eccca2e 100644 --- a/Assets/Plugins/Essgee.Unity/Emulation/Configuration/GameBoy.cs +++ b/Assets/Plugins/Essgee.Unity/Emulation/Configuration/GameBoy.cs @@ -1,7 +1,6 @@ using Essgee.Emulation.Cartridges.Nintendo; using Essgee.Emulation.ExtDevices.Nintendo; using Essgee.Utilities; -using Newtonsoft.Json; using System; namespace Essgee.Emulation.Configuration @@ -26,7 +25,7 @@ namespace Essgee.Emulation.Configuration //todo Unity [FileBrowserControl("General", "Bootstrap Path", "Game Boy Bootstrap ROM (*.gb;*.bin;*.zip)|*.gb;*.bin;*.zip")] public string BootstrapRom { get; set; } //todo Unity [DropDownControl("General", "Serial Device", typeof(ISerialDevice))] - [JsonConverter(typeof(TypeNameJsonConverter), "Essgee.Emulation.ExtDevices.Nintendo")] + //[JsonConverter(typeof(TypeNameJsonConverter), "Essgee.Emulation.ExtDevices.Nintendo")] public Type SerialDevice { get; set; } //todo Unity [DropDownControl("GB Camera", "Camera Source", typeof(GBCameraCartridge.ImageSources))] diff --git a/Assets/Plugins/Essgee.Unity/Emulation/Configuration/GameBoyColor.cs b/Assets/Plugins/Essgee.Unity/Emulation/Configuration/GameBoyColor.cs index 6c9ec40..bdc7f50 100644 --- a/Assets/Plugins/Essgee.Unity/Emulation/Configuration/GameBoyColor.cs +++ b/Assets/Plugins/Essgee.Unity/Emulation/Configuration/GameBoyColor.cs @@ -1,7 +1,6 @@ using Essgee.Emulation.Cartridges.Nintendo; using Essgee.Emulation.ExtDevices.Nintendo; using Essgee.Utilities; -using Newtonsoft.Json; using System; namespace Essgee.Emulation.Configuration @@ -15,7 +14,7 @@ namespace Essgee.Emulation.Configuration //todo Unity [FileBrowserControl("General", "Bootstrap Path", "Game Boy Color Bootstrap ROM (*.gbc;*.bin;*.zip)|*.gbc;*.bin;*.zip")] public string BootstrapRom { get; set; } //todo Unity [DropDownControl("General", "Serial Device", typeof(ISerialDevice))] - [JsonConverter(typeof(TypeNameJsonConverter), "Essgee.Emulation.ExtDevices.Nintendo")] + //[JsonConverter(typeof(TypeNameJsonConverter), "Essgee.Emulation.ExtDevices.Nintendo")] public Type SerialDevice { get; set; } //todo Unity [DropDownControl("GB Camera", "Camera Source", typeof(GBCameraCartridge.ImageSources))] diff --git a/Assets/Plugins/Essgee.Unity/Extensions/SerializationExtensionMethods.cs b/Assets/Plugins/Essgee.Unity/Extensions/SerializationExtensionMethods.cs index 385154c..5e977d0 100644 --- a/Assets/Plugins/Essgee.Unity/Extensions/SerializationExtensionMethods.cs +++ b/Assets/Plugins/Essgee.Unity/Extensions/SerializationExtensionMethods.cs @@ -1,34 +1,33 @@ -using Newtonsoft.Json; -using System.IO; +//using System.IO; -namespace Essgee.Extensions -{ - public static class SerializationExtensionMethods - { - public static void SerializeToFile(this object obj, string jsonFileName) - { - SerializeToFile(obj, jsonFileName, new JsonSerializerSettings()); - } +//namespace Essgee.Extensions +//{ +// public static class SerializationExtensionMethods +// { +// public static void SerializeToFile(this object obj, string jsonFileName) +// { +// SerializeToFile(obj, jsonFileName, new JsonSerializerSettings()); +// } - static void SerializeToFile(this object obj, string jsonFileName, JsonSerializerSettings serializerSettings) - { - using (var writer = new StreamWriter(jsonFileName)) - { - writer.Write(JsonConvert.SerializeObject(obj, Formatting.Indented, serializerSettings)); - } - } +// static void SerializeToFile(this object obj, string jsonFileName, JsonSerializerSettings serializerSettings) +// { +// using (var writer = new StreamWriter(jsonFileName)) +// { +// writer.Write(JsonConvert.SerializeObject(obj, Formatting.Indented, serializerSettings)); +// } +// } - public static T DeserializeFromFile<T>(this string jsonFileName) - { - using (var reader = new StreamReader(jsonFileName)) - { - return (T)JsonConvert.DeserializeObject(reader.ReadToEnd(), typeof(T), new JsonSerializerSettings() { Formatting = Formatting.Indented }); - } - } +// public static T DeserializeFromFile<T>(this string jsonFileName) +// { +// using (var reader = new StreamReader(jsonFileName)) +// { +// return (T)JsonConvert.DeserializeObject(reader.ReadToEnd(), typeof(T), new JsonSerializerSettings() { Formatting = Formatting.Indented }); +// } +// } - public static T DeserializeObject<T>(this string jsonString) - { - return (T)JsonConvert.DeserializeObject(jsonString, typeof(T), new JsonSerializerSettings() { Formatting = Formatting.Indented }); - } - } -} +// public static T DeserializeObject<T>(this string jsonString) +// { +// return (T)JsonConvert.DeserializeObject(jsonString, typeof(T), new JsonSerializerSettings() { Formatting = Formatting.Indented }); +// } +// } +//} diff --git a/Assets/Plugins/Essgee.Unity/Metadata/GameMetadataHandler.cs b/Assets/Plugins/Essgee.Unity/Metadata/GameMetadataHandler.cs index 3eba71b..995d081 100644 --- a/Assets/Plugins/Essgee.Unity/Metadata/GameMetadataHandler.cs +++ b/Assets/Plugins/Essgee.Unity/Metadata/GameMetadataHandler.cs @@ -1,14 +1,11 @@ using Essgee.Emulation; using Essgee.Exceptions; -using Essgee.Utilities; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Linq; using System.Xml.Serialization; +using UnityEngine.Timeline; namespace Essgee.Metadata { @@ -37,11 +34,305 @@ namespace Essgee.Metadata { gameMetaReources = metaresources; - if (!gameMetaReources.GetCartMetadataDatabase(out string loadedData)) - throw new HandlerException("CartMetadataDatabase file not found"); - - cartMetadataDatabase = JsonConvert.DeserializeObject<List<CartridgeJSON>>(loadedData); + //if (!gameMetaReources.GetCartMetadataDatabase(out string loadedData)) + // throw new HandlerException("CartMetadataDatabase file not found"); + //cartMetadataDatabase = JsonConvert.DeserializeObject<List<CartridgeJSON>>(loadedData); + cartMetadataDatabase = new List<CartridgeJSON>() + { + new CartridgeJSON(){ + Name = "The Castle (SG-1000)", + Notes = "8k volatile RAM", + Crc32 = 0x092F29D6, + RomSize = 32768, + RamSize = 8192 + }, + new CartridgeJSON(){ + Name = "Othello (SG-1000)", + Notes = "2k volatile RAM", + Crc32 = 0xAF4F14BC, + RomSize = 32768, + RamSize = 2048 + }, + new CartridgeJSON(){ + Name = "Sega Basic Level II (SC-3000)", + Notes = "2k volatile RAM (for Level IIb)", + Crc32 = 0xF691F9C7, + RomSize = 32768, + RamSize = 2048 + }, + new CartridgeJSON(){ + Name = "Sega Basic Level III (SC-3000)", + Notes = "32k volatile RAM (for Level IIIb)", + Crc32 = 0x5D9F11CA, + RomSize = 32768, + RamSize = 32768 + }, + new CartridgeJSON(){ + Name = "Back to the Future 2 (SMS)", + Notes = "PAL only", + Crc32 = 0xE5FF50D8, + RomSize = 262144, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Back to the Future 3 (SMS)", + Notes = "PAL only", + Crc32 = 0x2D48C1D3, + RomSize = 262144, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "California Games 2 (SMS, Europe)", + Notes = "PAL only", + Crc32 = 0xC0E25D62, + RomSize = 262144, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Chase HQ (SMS)", + Notes = "PAL only", + Crc32 = 0x85CFC9C9, + RomSize = 262144, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Cosmic Spacehead (SMS)", + Notes = "Codemasters mapper & PAL only", + Crc32 = 0x29822980, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Dinobasher (SMS)", + Notes = "Codemasters mapper", + Crc32 = 0xEA5C3A6F, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Excellent Dizzy Collection (SMS)", + Notes = "Codemasters mapper & PAL only", + Crc32 = 0x8813514B, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Fantastic Dizzy (SMS)", + Notes = "Codemasters mapper & PAL only", + Crc32 = 0xB9664AE1, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Home Alone (SMS)", + Notes = "PAL only", + Crc32 = 0xC9DBF936, + RomSize = 262144, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Micro Machines (SMS)", + Notes = "Codemasters mapper & PAL only", + Crc32 = 0xA577CE46, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "NewZealand Story (SMS)", + Notes = "PAL only", + Crc32 = 0xC660FF34, + RomSize = 262144, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Power Strike 2 (SMS)", + Notes = "PAL only", + Crc32 = 0xA109A6FE, + RomSize = 524288, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Predator 2 (SMS, Europe)", + Notes = "PAL only", + Crc32 = 0x0047B615, + RomSize = 262144, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Sonic the Hedgehog 2 (SMS)", + Notes = "PAL only", + Crc32 = 0x5B3B922C, + RomSize = 524288, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Sonic the Hedgehog 2 (SMS, Revision 1)", + Notes = "PAL only", + Crc32 = 0xD6F2BFCA, + RomSize = 524288, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Space Harrier (SMS, Europe)", + Notes = "PAL only", + Crc32 = 0xCA1D3752, + RomSize = 262144, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "CJ Elephant Fugitive (GG)", + Notes = "Codemasters mapper", + Crc32 = 0x72981057, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Cosmic Spacehead (GG)", + Notes = "Codemasters mapper", + Crc32 = 0x6CAA625B, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Dropzone (GG)", + Notes = "Codemasters mapper", + Crc32 = 0x152F0DCC, + RomSize = 131072, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Ernie Els Golf (GG)", + Notes = "Codemasters mapper & 8k volatile RAM", + Crc32 = 0x5E53C7F7, + RomSize = 262144, + RamSize = 8192, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Micro Machines (GG)", + Notes = "Codemasters mapper", + Crc32 = 0xF7C524F6, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Micro Machines 2: Turbo Tournament (GG)", + Notes = "Codemasters mapper", + Crc32 = 0xDBE8895C, + RomSize = 524288, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Pete Sampras Tennis (GG)", + Notes = "Codemasters mapper", + Crc32 = 0xC1756BEE, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Pop Breaker (GG, Japan)", + Notes = "Domestic/Japan only", + Crc32 = 0x71DEBA5A, + RomSize = 131072, + PreferredRegion = Region.Domestic + }, + new CartridgeJSON(){ + Name = "S.S. Lucifer: Man Overboard (GG)", + Notes = "Codemasters mapper", + Crc32 = 0xD9A7F170, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.CodemastersCartridge), + }, + new CartridgeJSON(){ + Name = "Sonic Chaos (SMS, Jun 30 1993 Prototype)", + Notes = "Disallow memory control", + Crc32 = 0xD3AD67FA, + RomSize = 524288, + AllowMemoryControl = false + }, + new CartridgeJSON(){ + Name = "94 Super World Cup Soccer (SMS)", + Notes = "Korean mapper", + Crc32 = 0x060D6A7C, + RomSize = 262144, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.KoreanMapperCartridge), + }, + new CartridgeJSON(){ + Name = "Jang Pung II (SMS)", + Notes = "Korean mapper", + Crc32 = 0x929222C4, + RomSize = 524288, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.KoreanMapperCartridge), + }, + new CartridgeJSON(){ + Name = "Jang Pung 3 (SMS)", + Notes = "Korean mapper", + Crc32 = 0x18FB98A3, + RomSize = 1048576, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.KoreanMapperCartridge), + }, + new CartridgeJSON(){ + Name = "Janggun-ui Adeul (SMS)", + Notes = "Korean sprite-flip mapper", + Crc32 = 0x192949D5, + RomSize = 524288, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.KoreanSpriteMapperCartridge), + }, + new CartridgeJSON(){ + Name = "Sangokushi 3 (SMS)", + Notes = "Korean mapper", + Crc32 = 0x97D03541, + RomSize = 1048576, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.KoreanMapperCartridge), + }, + new CartridgeJSON(){ + Name = "4 Pak All Action (SMS)", + Notes = "4 Pak mapper", + Crc32 = 0xA67F2A5C, + RomSize = 1048576, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.Multicart4PakAllActionCartridge), + }, + new CartridgeJSON(){ + Name = "Cyborg Z (SMS)", + Notes = "Korean MSX 8k mapper", + Crc32 = 0x77EFE84A, + RomSize = 131072, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.KoreanMSX8kMapperCartridge), + }, + new CartridgeJSON(){ + Name = "Street Master (SMS)", + Notes = "Korean MSX 8k mapper", + Crc32 = 0x83F0EEDE, + RomSize = 131072, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.KoreanMSX8kMapperCartridge), + }, + new CartridgeJSON(){ + Name = "Wonsiin (SMS)", + Notes = "Korean MSX 8k mapper", + Crc32 = 0xA05258F5, + RomSize = 131072, + Mapper = typeof(Essgee.Emulation.Cartridges.Sega.KoreanMSX8kMapperCartridge), + }, + new CartridgeJSON(){ + Name = "SMS Bad Apple 1.00 (SMS)", + Notes = "PAL only", + Crc32 = 0x38434560, + RomSize = 4194304, + PreferredTVStandard = TVStandard.PAL + }, + new CartridgeJSON(){ + Name = "Be No Sqr 1.01 (SMS)", + Notes = "PAL only", + Crc32 = 0xEE701BE6, + RomSize = 524288, + PreferredTVStandard = TVStandard.PAL + } + }; //改为接口直接读取 //XmlRootAttribute root; @@ -126,34 +417,34 @@ namespace Essgee.Metadata public class CartridgeJSON { - [JsonProperty(Required = Required.Always)] + //[JsonProperty(Required = Required.Always)] public string Name { get; set; } = string.Empty; - [JsonProperty(Required = Required.Always)] + //[JsonProperty(Required = Required.Always)] public string Notes { get; set; } = string.Empty; - [JsonProperty(Required = Required.Always), JsonConverter(typeof(HexadecimalJsonConverter))] + //[JsonProperty(Required = Required.Always), JsonConverter(typeof(HexadecimalJsonConverter))] public uint Crc32 { get; set; } = 0xFFFFFFFF; - [JsonProperty(Required = Required.Always)] + //[JsonProperty(Required = Required.Always)] public int RomSize { get; set; } = 0; - [JsonProperty(Required = Required.Default), DefaultValue(0)] + //[JsonProperty(Required = Required.Default), DefaultValue(0)] public int RamSize { get; set; } = 0; - [JsonProperty(Required = Required.Default), JsonConverter(typeof(TypeNameJsonConverter), "Essgee.Emulation.Cartridges"), DefaultValue(null)] + //[JsonProperty(Required = Required.Default), JsonConverter(typeof(TypeNameJsonConverter), "Essgee.Emulation.Cartridges"), DefaultValue(null)] public Type Mapper { get; set; } = null; - [JsonProperty(Required = Required.Default), DefaultValue(false)] + //[JsonProperty(Required = Required.Default), DefaultValue(false)] public bool HasNonVolatileRam { get; set; } = false; - [JsonProperty(Required = Required.Default), JsonConverter(typeof(StringEnumConverter)), DefaultValue(TVStandard.Auto)] + //[JsonProperty(Required = Required.Default), JsonConverter(typeof(StringEnumConverter)), DefaultValue(TVStandard.Auto)] public TVStandard PreferredTVStandard { get; set; } = TVStandard.Auto; - [JsonProperty(Required = Required.Default), JsonConverter(typeof(StringEnumConverter)), DefaultValue(Region.Auto)] + //[JsonProperty(Required = Required.Default), JsonConverter(typeof(StringEnumConverter)), DefaultValue(Region.Auto)] public Region PreferredRegion { get; set; } = Region.Auto; - [JsonProperty(Required = Required.Default), DefaultValue(true)] + //[JsonProperty(Required = Required.Default), DefaultValue(true)] public bool AllowMemoryControl { get; set; } = true; } diff --git a/Assets/Plugins/Essgee.Unity/Utilities/HexadecimalJsonConverter.cs b/Assets/Plugins/Essgee.Unity/Utilities/HexadecimalJsonConverter.cs index deff333..469f708 100644 --- a/Assets/Plugins/Essgee.Unity/Utilities/HexadecimalJsonConverter.cs +++ b/Assets/Plugins/Essgee.Unity/Utilities/HexadecimalJsonConverter.cs @@ -1,47 +1,47 @@ -using Newtonsoft.Json; -using System; +//using Newtonsoft.Json; +//using System; -namespace Essgee.Utilities -{ - public class HexadecimalJsonConverter : JsonConverter - { - public override bool CanConvert(Type objectType) - { - // TODO: maybe actually check things? - return true; - } +//namespace Essgee.Utilities +//{ +// public class HexadecimalJsonConverter : JsonConverter +// { +// public override bool CanConvert(Type objectType) +// { +// // TODO: maybe actually check things? +// return true; +// } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - switch (Type.GetTypeCode(value.GetType())) - { - case TypeCode.Byte: - case TypeCode.SByte: - writer.WriteValue($"0x{value:X2}"); - break; - case TypeCode.UInt16: - case TypeCode.Int16: - writer.WriteValue($"0x{value:X4}"); - break; - case TypeCode.UInt32: - case TypeCode.Int32: - writer.WriteValue($"0x{value:X8}"); - break; - case TypeCode.UInt64: - case TypeCode.Int64: - writer.WriteValue($"0x{value:X16}"); - break; - default: - throw new JsonSerializationException(); - } - } +// public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) +// { +// switch (Type.GetTypeCode(value.GetType())) +// { +// case TypeCode.Byte: +// case TypeCode.SByte: +// writer.WriteValue($"0x{value:X2}"); +// break; +// case TypeCode.UInt16: +// case TypeCode.Int16: +// writer.WriteValue($"0x{value:X4}"); +// break; +// case TypeCode.UInt32: +// case TypeCode.Int32: +// writer.WriteValue($"0x{value:X8}"); +// break; +// case TypeCode.UInt64: +// case TypeCode.Int64: +// writer.WriteValue($"0x{value:X16}"); +// break; +// default: +// throw new JsonSerializationException(); +// } +// } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - if ((reader.Value is string value) && value.StartsWith("0x")) - return Convert.ChangeType(Convert.ToUInt64(value, 16), objectType); - else - throw new JsonSerializationException(); - } - } -} +// public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) +// { +// if ((reader.Value is string value) && value.StartsWith("0x")) +// return Convert.ChangeType(Convert.ToUInt64(value, 16), objectType); +// else +// throw new JsonSerializationException(); +// } +// } +//} diff --git a/Assets/Plugins/Essgee.Unity/Utilities/InterfaceDictionaryConverter.cs b/Assets/Plugins/Essgee.Unity/Utilities/InterfaceDictionaryConverter.cs index 39dba13..92d41ea 100644 --- a/Assets/Plugins/Essgee.Unity/Utilities/InterfaceDictionaryConverter.cs +++ b/Assets/Plugins/Essgee.Unity/Utilities/InterfaceDictionaryConverter.cs @@ -1,44 +1,42 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Reflection; -namespace Essgee.Utilities -{ - public class InterfaceDictionaryConverter<TInterface> : JsonConverter - { - public override bool CanConvert(Type objectType) - { - return (objectType == typeof(TInterface)); - } +//namespace Essgee.Utilities +//{ +// public class InterfaceDictionaryConverter<TInterface> : JsonConverter +// { +// public override bool CanConvert(Type objectType) +// { +// return (objectType == typeof(TInterface)); +// } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - if (!objectType.IsGenericType || objectType.GetGenericTypeDefinition() != typeof(Dictionary<,>)) throw new InvalidOperationException("Can only deserialize dictionaries"); +// public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) +// { +// if (!objectType.IsGenericType || objectType.GetGenericTypeDefinition() != typeof(Dictionary<,>)) throw new InvalidOperationException("Can only deserialize dictionaries"); - var dictionary = (System.Collections.IDictionary)Activator.CreateInstance(objectType); - //不再读取配置 - var jObject = JObject.Load(reader); - foreach (var child in jObject.Children()) - { - Type type = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(y => typeof(TInterface).IsAssignableFrom(y) && !y.IsInterface && !y.IsAbstract && y.Name == child.Path); - if (type != null) - dictionary.Add(child.Path, JsonConvert.DeserializeObject(child.First.ToString(), type)); - } +// var dictionary = (System.Collections.IDictionary)Activator.CreateInstance(objectType); +// //不再读取配置 +// var jObject = JObject.Load(reader); +// foreach (var child in jObject.Children()) +// { +// Type type = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(y => typeof(TInterface).IsAssignableFrom(y) && !y.IsInterface && !y.IsAbstract && y.Name == child.Path); +// if (type != null) +// dictionary.Add(child.Path, JsonConvert.DeserializeObject(child.First.ToString(), type)); +// } - return dictionary; - } +// return dictionary; +// } - public override bool CanWrite - { - get { return false; } - } +// public override bool CanWrite +// { +// get { return false; } +// } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotImplementedException(); - } - } -} +// public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) +// { +// throw new NotImplementedException(); +// } +// } +//} diff --git a/Assets/Plugins/Essgee.Unity/Utilities/TypeNameJsonConverter.cs b/Assets/Plugins/Essgee.Unity/Utilities/TypeNameJsonConverter.cs index c1c100e..a93145b 100644 --- a/Assets/Plugins/Essgee.Unity/Utilities/TypeNameJsonConverter.cs +++ b/Assets/Plugins/Essgee.Unity/Utilities/TypeNameJsonConverter.cs @@ -1,40 +1,40 @@ -using Newtonsoft.Json; -using System; +//using Newtonsoft.Json; +//using System; -namespace Essgee.Utilities -{ - public class TypeNameJsonConverter : JsonConverter - { - readonly string searchNamespace; +//namespace Essgee.Utilities +//{ +// public class TypeNameJsonConverter : JsonConverter +// { +// readonly string searchNamespace; - public TypeNameJsonConverter(string searchNamespace) - { - this.searchNamespace = searchNamespace; - } +// public TypeNameJsonConverter(string searchNamespace) +// { +// this.searchNamespace = searchNamespace; +// } - public override bool CanConvert(Type objectType) - { - // TODO: maybe actually check things? - return true; - } +// public override bool CanConvert(Type objectType) +// { +// // TODO: maybe actually check things? +// return true; +// } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - if (value is Type) - { - var type = (value as Type); - if (type.Namespace != searchNamespace) throw new JsonSerializationException(); - writer.WriteValue(type.Name); - } - else - throw new JsonSerializationException(); - } +// public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) +// { +// if (value is Type) +// { +// var type = (value as Type); +// if (type.Namespace != searchNamespace) throw new JsonSerializationException(); +// writer.WriteValue(type.Name); +// } +// else +// throw new JsonSerializationException(); +// } - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - var type = Type.GetType($"{searchNamespace}.{reader.Value}"); - if (type != null) return type; - else throw new JsonSerializationException(); - } - } -} +// public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) +// { +// var type = Type.GetType($"{searchNamespace}.{reader.Value}"); +// if (type != null) return type; +// else throw new JsonSerializationException(); +// } +// } +//} diff --git a/Assets/Plugins/Newtonsoft.Json.dll b/Assets/Plugins/Newtonsoft.Json.dll deleted file mode 100644 index 341d08f..0000000 Binary files a/Assets/Plugins/Newtonsoft.Json.dll and /dev/null differ diff --git a/Assets/Plugins/Newtonsoft.Json.dll.meta b/Assets/Plugins/Newtonsoft.Json.dll.meta deleted file mode 100644 index 7124f76..0000000 --- a/Assets/Plugins/Newtonsoft.Json.dll.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 1a58e3ab1bbec0a4998d14ae26c5651d \ No newline at end of file diff --git a/Assets/Scripts/UEssgee.cs b/Assets/Scripts/UEssgee.cs index d5a6556..c6246f5 100644 --- a/Assets/Scripts/UEssgee.cs +++ b/Assets/Scripts/UEssgee.cs @@ -306,7 +306,8 @@ public class Essgeeinit : MonoBehaviour } public static void SaveConfiguration() { - EmuStandInfo.Configuration.SerializeToFile(EmuStandInfo.programConfigPath); + //����Ҫ�洢 + //EmuStandInfo.Configuration.SerializeToFile(EmuStandInfo.programConfigPath); } #endregion