From 498572f02e699ba0920bba73224fa1afa24af41a Mon Sep 17 00:00:00 2001 From: Lexi Date: Thu, 2 Nov 2023 09:50:58 -0400 Subject: [PATCH 1/6] Add some logging into the asset bundle loading, and an error handler if an asset fails to load --- .../LoadingActions/FunctionalLoadingActions.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs b/SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs index 6f53e86..59e6896 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; From 30deae5980b1266dd183140e2489e7f68743c4c0 Mon Sep 17 00:00:00 2001 From: Lexi Date: Sat, 4 Nov 2023 17:38:14 -0400 Subject: [PATCH 2/6] :lifesupport: --- SpaceWarp.Core/SpaceWarpPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpaceWarp.Core/SpaceWarpPlugin.cs b/SpaceWarp.Core/SpaceWarpPlugin.cs index a4bdec4..3aede27 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(); From fa851d012fe19fcc46294dc70c5fb59a33ede448 Mon Sep 17 00:00:00 2001 From: Lexi Date: Sat, 4 Nov 2023 17:59:12 -0400 Subject: [PATCH 3/6] :lifesupport: :lifesupport: :lifesupport: --- .../API/Configuration/JsonConfigFile.cs | 20 ++++++++++++++++++- SpaceWarp.Core/SpaceWarp.Core.csproj | 2 +- SpaceWarpPatcher/SpaceWarpPatcher.csproj | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/SpaceWarp.Core/API/Configuration/JsonConfigFile.cs b/SpaceWarp.Core/API/Configuration/JsonConfigFile.cs index 34f5c95..8dd5062 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/SpaceWarp.Core.csproj b/SpaceWarp.Core/SpaceWarp.Core.csproj index a04455a..0a719d8 100644 --- a/SpaceWarp.Core/SpaceWarp.Core.csproj +++ b/SpaceWarp.Core/SpaceWarp.Core.csproj @@ -17,7 +17,7 @@ - + diff --git a/SpaceWarpPatcher/SpaceWarpPatcher.csproj b/SpaceWarpPatcher/SpaceWarpPatcher.csproj index 59b1cbf..c4f4982 100644 --- a/SpaceWarpPatcher/SpaceWarpPatcher.csproj +++ b/SpaceWarpPatcher/SpaceWarpPatcher.csproj @@ -11,6 +11,6 @@ - + \ No newline at end of file From 6d8eca80ba342b6113ae7741adf1464b1737828f Mon Sep 17 00:00:00 2001 From: cheese3660 Date: Sat, 4 Nov 2023 18:34:38 -0400 Subject: [PATCH 4/6] Update Directory.Build.props --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8e880a1..a2be5c8 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 1.5.3 + 1.5.4 netstandard2.1 SpaceWarp 11 From cffa9421fc6ef07345120550c5d755b0046883b9 Mon Sep 17 00:00:00 2001 From: cheese3660 Date: Sat, 4 Nov 2023 18:34:50 -0400 Subject: [PATCH 5/6] Update SpaceWarp.nuspec --- SpaceWarp.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpaceWarp.nuspec b/SpaceWarp.nuspec index d97225f..8b7451f 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 From 6369c877af729d066a0bfa74ace41157fc6883a1 Mon Sep 17 00:00:00 2001 From: cheese3660 Date: Sat, 4 Nov 2023 18:35:04 -0400 Subject: [PATCH 6/6] Update swinfo.json --- SpaceWarpBuildTemplate/swinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpaceWarpBuildTemplate/swinfo.json b/SpaceWarpBuildTemplate/swinfo.json index 529c2b2..5b45cfd 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",