Skip to content

Commit

Permalink
Merge pull request #269 from SpaceWarpDev/dev
Browse files Browse the repository at this point in the history
Hotfix 1.5.4
  • Loading branch information
cheese3660 authored Nov 4, 2023
2 parents cae3c14 + 6369c87 commit d0020c2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<SpaceWarpVersion>1.5.3</SpaceWarpVersion>
<SpaceWarpVersion>1.5.4</SpaceWarpVersion>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>SpaceWarp</RootNamespace>
<LangVersion>11</LangVersion>
Expand Down
20 changes: 19 additions & 1 deletion SpaceWarp.Core/API/Configuration/JsonConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -68,6 +70,22 @@ private static bool DumpSection(bool hadPreviousSection, StringBuilder result, K
return true;
}

private static List<JsonConverter> _defaultConverters;

public static List<JsonConverter> DefaultConverters
{
get
{
if (_defaultConverters == null)
{
_defaultConverters = IOProvider.CreateDefaultConverters();
_defaultConverters.Add(new StringEnumConverter());
}

return _defaultConverters;
}
}

private static bool DumpEntry(StringBuilder result, bool hadPreviousKey, KeyValuePair<string, JsonConfigEntry> entry)
{
if (hadPreviousKey)
Expand All @@ -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)
{
Expand Down
12 changes: 10 additions & 2 deletions SpaceWarp.Core/Patching/LoadingActions/FunctionalLoadingActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion SpaceWarp.Core/SpaceWarp.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="HarmonyX" Version="2.10.1" />
<PackageReference Include="KerbalSpaceProgram2.GameLibs" Version="0.1.5" Publicize="true" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="UitkForKsp2" Version="2.0.0" />
<PackageReference Include="UnityEngine.Modules" Version="2022.3.5" Publicize="true" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion SpaceWarp.Core/SpaceWarpPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion SpaceWarp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>SpaceWarp</id>
<version>1.5.3</version>
<version>1.5.4</version>
<authors>SpaceWarp contributors</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://raw.githubusercontent.com/SpaceWarp/SpaceWarp/main/LICENSE</licenseUrl>
Expand Down
2 changes: 1 addition & 1 deletion SpaceWarpBuildTemplate/swinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion SpaceWarpPatcher/SpaceWarpPatcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

0 comments on commit d0020c2

Please sign in to comment.