From af6ea83268a506f2b39aa04fb5da44edc6c3faa8 Mon Sep 17 00:00:00 2001 From: NathanKell Date: Thu, 8 Sep 2022 22:14:25 -0700 Subject: [PATCH] Fix missing attribute for MultipleModulePartAPI, refactor WriteValue for better support for other mods, update release script to behave correctly with new versioning bump version (only fileversion and KSPAssembly). --- .../KSPCommunityFixes.version | 2 +- KSPCommunityFixes/KSPCommunityFixes.csproj | 6 +- .../Modding/PersistentIConfigNode.cs | 87 ++++++++----------- KSPCommunityFixes/Properties/AssemblyInfo.cs | 7 +- .../MultipleModuleInPartAPI.csproj | 4 + .../Properties/AssemblyInfo.cs | 2 + README.md | 5 ++ 7 files changed, 56 insertions(+), 57 deletions(-) diff --git a/GameData/KSPCommunityFixes/KSPCommunityFixes.version b/GameData/KSPCommunityFixes/KSPCommunityFixes.version index 1db8d34..87560fc 100644 --- a/GameData/KSPCommunityFixes/KSPCommunityFixes.version +++ b/GameData/KSPCommunityFixes/KSPCommunityFixes.version @@ -2,7 +2,7 @@ "NAME": "KSPCommunityFixes", "URL": "https://raw.githubusercontent.com/KSPModdingLibs/KSPCommunityFixes/master/GameData/KSPCommunityFixes/KSPCommunityFixes.version", "DOWNLOAD": "https://github.com/KSPModdingLibs/KSPCommunityFixes/releases", - "VERSION": {"MAJOR": 1, "MINOR": 22, "PATCH": 0, "BUILD": 0}, + "VERSION": {"MAJOR": 1, "MINOR": 22, "PATCH": 1, "BUILD": 0}, "KSP_VERSION": {"MAJOR": 1, "MINOR": 12, "PATCH": 3}, "KSP_VERSION_MIN": {"MAJOR": 1, "MINOR": 8, "PATCH": 0}, "KSP_VERSION_MAX": {"MAJOR": 1, "MINOR": 12, "PATCH": 3} diff --git a/KSPCommunityFixes/KSPCommunityFixes.csproj b/KSPCommunityFixes/KSPCommunityFixes.csproj index 8279960..4101877 100644 --- a/KSPCommunityFixes/KSPCommunityFixes.csproj +++ b/KSPCommunityFixes/KSPCommunityFixes.csproj @@ -347,8 +347,10 @@ diff --git a/KSPCommunityFixes/Modding/PersistentIConfigNode.cs b/KSPCommunityFixes/Modding/PersistentIConfigNode.cs index 70370c6..1923854 100644 --- a/KSPCommunityFixes/Modding/PersistentIConfigNode.cs +++ b/KSPCommunityFixes/Modding/PersistentIConfigNode.cs @@ -654,86 +654,71 @@ public static object ReadValue(string value, DataType dataType, Type fieldType) } public static bool WriteValue(string fieldName, object value, DataType dataType, ConfigNode node) + { + string v = WriteValue(value, dataType); + if (v == null) + return false; + + node._values.values.Add(new Value(fieldName, v)); + return true; + } + + public static string WriteValue(object value, DataType dataType) { switch (dataType) { case DataType.ValueString: - node._values.values.Add(new Value(fieldName, (string)value)); - return true; + return (string)value; case DataType.ValueGuid: - node._values.values.Add(new Value(fieldName, ((Guid)value).ToString())); - return true; + return ((Guid)value).ToString(); case DataType.ValueBool: - node._values.values.Add(new Value(fieldName, ((bool)value).ToString(_Invariant))); - return true; + return ((bool)value).ToString(_Invariant); case DataType.ValueDouble: - node._values.values.Add(new Value(fieldName, ((double)value).ToString("G17"))); - return true; + return ((double)value).ToString("G17"); case DataType.ValueFloat: - node._values.values.Add(new Value(fieldName, ((float)value).ToString("G9"))); - return true; + return ((float)value).ToString("G9"); case DataType.ValueDecimal: - node._values.values.Add(new Value(fieldName, ((decimal)value).ToString(_Invariant))); - return true; + return ((decimal)value).ToString(_Invariant); case DataType.ValueInt: - node._values.values.Add(new Value(fieldName, ((int)value).ToString(_Invariant))); - return true; + return ((int)value).ToString(_Invariant); case DataType.ValueUInt: - node._values.values.Add(new Value(fieldName, ((uint)value).ToString(_Invariant))); - return true; + return ((uint)value).ToString(_Invariant); case DataType.ValueChar: - node._values.values.Add(new Value(fieldName, ((char)value).ToString(_Invariant))); - return true; + return ((char)value).ToString(_Invariant); case DataType.ValueShort: - node._values.values.Add(new Value(fieldName, ((short)value).ToString(_Invariant))); - return true; + return ((short)value).ToString(_Invariant); case DataType.ValueUShort: - node._values.values.Add(new Value(fieldName, ((ushort)value).ToString(_Invariant))); - return true; + return ((ushort)value).ToString(_Invariant); case DataType.ValueLong: - node._values.values.Add(new Value(fieldName, ((long)value).ToString(_Invariant))); - return true; + return ((long)value).ToString(_Invariant); case DataType.ValueULong: - node._values.values.Add(new Value(fieldName, ((ulong)value).ToString(_Invariant))); - return true; + return ((ulong)value).ToString(_Invariant); case DataType.ValueByte: - node._values.values.Add(new Value(fieldName, ((byte)value).ToString(_Invariant))); - return true; + return ((byte)value).ToString(_Invariant); case DataType.ValueSByte: - node._values.values.Add(new Value(fieldName, ((sbyte)value).ToString(_Invariant))); - return true; + return ((sbyte)value).ToString(_Invariant); case DataType.ValueEnum: - node._values.values.Add(new Value(fieldName, ((System.Enum)value).ToString())); - return true; + return ((System.Enum)value).ToString(); case DataType.ValueVector2: - node._values.values.Add(new Value(fieldName, WriteVector((Vector2)value))); - return true; + return WriteVector((Vector2)value); case DataType.ValueVector3: - node._values.values.Add(new Value(fieldName, WriteVector((Vector3)value))); - return true; + return WriteVector((Vector3)value); case DataType.ValueVector3d: - node._values.values.Add(new Value(fieldName, WriteVector((Vector3)value))); - return true; + return WriteVector((Vector3)value); case DataType.ValueVector4: - node._values.values.Add(new Value(fieldName, WriteVector((Vector4)value))); - return true; + return WriteVector((Vector4)value); case DataType.ValueQuaternion: - node._values.values.Add(new Value(fieldName, WriteQuaternion((Quaternion)value))); - return true; + return WriteQuaternion((Quaternion)value); case DataType.ValueQuaternionD: - node._values.values.Add(new Value(fieldName, WriteQuaternion((QuaternionD)value))); - return true; + return WriteQuaternion((QuaternionD)value); case DataType.ValueMatrix4x4: - node._values.values.Add(new Value(fieldName, WriteMatrix4x4((Matrix4x4)value))); - return true; + return WriteMatrix4x4((Matrix4x4)value); case DataType.ValueColor: - node._values.values.Add(new Value(fieldName, WriteColor((Color)value))); - return true; + return WriteColor((Color)value); case DataType.ValueColor32: - node._values.values.Add(new Value(fieldName, WriteColor((Color32)value))); - return true; + return WriteColor((Color32)value); } - return false; + return null; } public static DataType ValueDataType(Type fieldType) diff --git a/KSPCommunityFixes/Properties/AssemblyInfo.cs b/KSPCommunityFixes/Properties/AssemblyInfo.cs index 20a6590..b74e34f 100644 --- a/KSPCommunityFixes/Properties/AssemblyInfo.cs +++ b/KSPCommunityFixes/Properties/AssemblyInfo.cs @@ -29,7 +29,8 @@ // Build Number // Revision // -[assembly: AssemblyVersion("1.22.0.0")] -[assembly: AssemblyFileVersion("1.22.0.0")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.22.1.0")] -[assembly: KSPAssembly("KSPCommunityFixes", 1, 22, 0)] +[assembly: KSPAssembly("KSPCommunityFixes", 1, 22, 1)] +[assembly: KSPAssemblyDependency("MultipleModulePartAPI", 1, 0, 0)] diff --git a/MultipleModuleInPartAPI/MultipleModuleInPartAPI.csproj b/MultipleModuleInPartAPI/MultipleModuleInPartAPI.csproj index 444a3ae..08970b5 100644 --- a/MultipleModuleInPartAPI/MultipleModuleInPartAPI.csproj +++ b/MultipleModuleInPartAPI/MultipleModuleInPartAPI.csproj @@ -49,6 +49,10 @@ System.Core (KSP/Mono) False + + Assembly-CSharp + False + diff --git a/MultipleModuleInPartAPI/Properties/AssemblyInfo.cs b/MultipleModuleInPartAPI/Properties/AssemblyInfo.cs index 798e83c..c0cf57e 100644 --- a/MultipleModuleInPartAPI/Properties/AssemblyInfo.cs +++ b/MultipleModuleInPartAPI/Properties/AssemblyInfo.cs @@ -34,3 +34,5 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: KSPAssembly("MultipleModulePartAPI", 1, 0, 0)] \ No newline at end of file diff --git a/README.md b/README.md index c6e02d0..1667a00 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,11 @@ If doing so in the `Debug` configuration and if your KSP install is modified to ### Changelog +##### 1.22.1 +- Add KSPAssembly attribute to MultipleModulePartAPI as well, and add the KSPAssemblyDependency to KSPCommunityFixes just in case. +- Set AssemblyVersion to 1.0 and only increment AssemblyFileVersion and KSPAssembly +- Refactor FieldData.WriteValue for ease in use by other mods. + ##### 1.22.0 - New modding patch : [ModUpgradePipeline](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/91) (@NathanKell) - Further improve ConfigNode performance. The tunable settings blocks have been removed since base performance is high enough now. They've been replaced by a single setting that enables not indenting save games and craft files on save, which offers a slight performance boost reading and writing and a fair amount of savings on disk. See https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/90 for full details. Note that some of this rewrite is done via PersistentIConfigNode. (@NathanKell)