diff --git a/Directory.Build.props b/Directory.Build.props index 8e880a10..a2be5c89 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 1.5.3 + 1.5.4 netstandard2.1 SpaceWarp 11 diff --git a/SpaceWarp.Core/API/Configuration/JsonConfigFile.cs b/SpaceWarp.Core/API/Configuration/JsonConfigFile.cs index 34f5c959..8dd50620 100644 --- a/SpaceWarp.Core/API/Configuration/JsonConfigFile.cs +++ b/SpaceWarp.Core/API/Configuration/JsonConfigFile.cs @@ -4,6 +4,8 @@ using System.Text; using JetBrains.Annotations; using KSP.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using UnityEngine; @@ -68,6 +70,22 @@ private static bool DumpSection(bool hadPreviousSection, StringBuilder result, K return true; } + private static List _defaultConverters; + + public static List DefaultConverters + { + get + { + if (_defaultConverters == null) + { + _defaultConverters = IOProvider.CreateDefaultConverters(); + _defaultConverters.Add(new StringEnumConverter()); + } + + return _defaultConverters; + } + } + private static bool DumpEntry(StringBuilder result, bool hadPreviousKey, KeyValuePair entry) { if (hadPreviousKey) @@ -85,7 +103,7 @@ private static bool DumpEntry(StringBuilder result, bool hadPreviousKey, KeyValu } } - var serialized = IOProvider.ToJson(entry.Value.Value); + var serialized = JsonConvert.SerializeObject(entry.Value.Value,Formatting.Indented,DefaultConverters.ToArray()); var serializedLines = serialized.Split('\n').Select(x => x.TrimEnd()).ToArray(); if (serializedLines.Length > 1) { diff --git a/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs b/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs index 6f53e861..59e68969 100644 --- a/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs +++ b/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs @@ -38,8 +38,16 @@ string filename var path = internalPath + "/" + assetName; path = path.ToLower(); - var asset = assetBundle.LoadAsset(name); - assets.Add((path, asset)); + try + { + SpaceWarpPlugin.Instance.SWLogger.LogInfo($"Attempting to load asset {name} from bundle at {filename}"); + var asset = assetBundle.LoadAsset(name); + assets.Add((path, asset)); + } + catch (Exception e) + { + SpaceWarpPlugin.Instance.SWLogger.LogInfo($"Error loading asset {name} from bundle at {filename}: {e}"); + } } return assets; diff --git a/SpaceWarp.Core/SpaceWarp.Core.csproj b/SpaceWarp.Core/SpaceWarp.Core.csproj index a04455aa..0a719d84 100644 --- a/SpaceWarp.Core/SpaceWarp.Core.csproj +++ b/SpaceWarp.Core/SpaceWarp.Core.csproj @@ -17,7 +17,7 @@ - + diff --git a/SpaceWarp.Core/SpaceWarpPlugin.cs b/SpaceWarp.Core/SpaceWarpPlugin.cs index a4bdec41..3aede271 100644 --- a/SpaceWarp.Core/SpaceWarpPlugin.cs +++ b/SpaceWarp.Core/SpaceWarpPlugin.cs @@ -61,7 +61,7 @@ private static void OnLanguageSourceAssetLoaded(LanguageSourceAsset asset) public void Awake() { BepInEx.Bootstrap.Chainloader.ManagerObject.Persist(); - IOProvider.Init(); + // IOProvider.Init(); Harmony.CreateAndPatchAll(typeof(SpaceWarpPlugin).Assembly, ModGuid); ModuleManager.LoadAllModules(); diff --git a/SpaceWarp.nuspec b/SpaceWarp.nuspec index d97225ff..8b7451fd 100644 --- a/SpaceWarp.nuspec +++ b/SpaceWarp.nuspec @@ -2,7 +2,7 @@ SpaceWarp - 1.5.3 + 1.5.4 SpaceWarp contributors false https://raw.githubusercontent.com/SpaceWarp/SpaceWarp/main/LICENSE diff --git a/SpaceWarpBuildTemplate/swinfo.json b/SpaceWarpBuildTemplate/swinfo.json index 529c2b2a..5b45cfd9 100644 --- a/SpaceWarpBuildTemplate/swinfo.json +++ b/SpaceWarpBuildTemplate/swinfo.json @@ -6,7 +6,7 @@ "description": "Space-Warp is an API for KSP2 mod developers.", "source": "https://github.com/SpaceWarpDev/SpaceWarp", "version_check": "https://raw.githubusercontent.com/SpaceWarpDev/SpaceWarp/main/SpaceWarpBuildTemplate/swinfo.json", - "version": "1.5.3", + "version": "1.5.4", "dependencies": [ { "id": "UitkForKsp2", diff --git a/SpaceWarpPatcher/SpaceWarpPatcher.csproj b/SpaceWarpPatcher/SpaceWarpPatcher.csproj index 59b1cbfb..c4f49825 100644 --- a/SpaceWarpPatcher/SpaceWarpPatcher.csproj +++ b/SpaceWarpPatcher/SpaceWarpPatcher.csproj @@ -11,6 +11,6 @@ - + \ No newline at end of file