diff --git a/.gitignore b/.gitignore index 9ba34665..7fad90f1 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ /Scale_Editor/bin /Scale_Editor/obj /lib -/Releases \ No newline at end of file +/Releases +Gamedata/TweakScale/TweakScaleInteraction/TweakScale_RealFuels.dll \ No newline at end of file diff --git a/Checker.cs b/Checker.cs index b15b7085..11fa9fac 100644 --- a/Checker.cs +++ b/Checker.cs @@ -1,27 +1,28 @@ -/** -* Copyright (fundCfg) 2014, Majiir -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are permitted -* provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright notice, this list of -* conditions and the following disclaimer in the documentation and/or other materials provided -* with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*/ + +/** + * Copyright (c) 2014, Majiir + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections.Generic; @@ -30,26 +31,26 @@ using UnityEngine; /*-----------------------------------------*\ -| SUBSTITUTE YOUR MOD'S NAMESPACE HERE. | +| SUBSTITUTE YOUR MOD'S NAMESPACE HERE. | \*-----------------------------------------*/ namespace TweakScale { /** - * This utility displays destination warning with destination list of mods that determine themselves - * to be incompatible with the current running version of Kerbal Space Program. - * - * See this forum thread for details: - * http://forum.kerbalspaceprogram.com/threads/65395-Voluntarily-Locking-Plugins-to-destination-Particular-KSP-Version - */ - - [KSPAddon(KSPAddon.Startup.MainMenu, true)] + * This utility displays a warning with a list of mods that determine themselves + * to be incompatible with the current running version of Kerbal Space Program. + * + * See this forum thread for details: + * http://forum.kerbalspaceprogram.com/threads/65395-Voluntarily-Locking-Plugins-to-a-Particular-KSP-Version + */ + + [KSPAddon(KSPAddon.Startup.Instantly, true)] internal class CompatibilityChecker : MonoBehaviour { public static bool IsCompatible() { /*-----------------------------------------------*\ - | BEGIN IMPLEMENTATION-SPECIFIC EDITS HERE. | + | BEGIN IMPLEMENTATION-SPECIFIC EDITS HERE. | \*-----------------------------------------------*/ // TODO: Implement your own compatibility check. @@ -57,18 +58,29 @@ public static bool IsCompatible() // If you want to disable some behavior when incompatible, other parts of the plugin // should query this method: // - // if (!CompatibilityChecker.IsCompatible()) { - // ...disable some features... - // } + // if (!CompatibilityChecker.IsAllCompatible()) { + // ...disable some features... + // } // // Even if you don't lock down functionality, you should return true if your users - // can expect destination future update to be available. + // can expect a future update to be available. // + return Versioning.version_major == 0 && Versioning.version_minor == 25 && Versioning.Revision == 0; - if (Versioning.version_minor != 24) - { - return false; - } + /*-----------------------------------------------*\ + | IMPLEMENTERS SHOULD NOT EDIT BEYOND THIS POINT! | + \*-----------------------------------------------*/ + } + + public static bool IsUnityCompatible() + { + /*-----------------------------------------------*\ + | BEGIN IMPLEMENTATION-SPECIFIC EDITS HERE. | + \*-----------------------------------------------*/ + + // TODO: Implement your own Unity compatibility check. + // + // Not going to care about the fact that KSP .25 OSX uses a different Unity... return true; /*-----------------------------------------------*\ @@ -77,7 +89,7 @@ public static bool IsCompatible() } // Version of the compatibility checker itself. - private static int _version = 2; + private static int _version = 4; public void Start() { @@ -113,7 +125,7 @@ public void Start() } catch (Exception e) { - // If destination mod throws an exception from IsCompatible, it's not compatible. + // If a mod throws an exception from IsCompatible, it's not compatible. Debug.LogWarning(String.Format("[CompatibilityChecker] Exception while invoking IsCompatible() from '{0}':\n\n{1}", m.DeclaringType.Assembly.GetName().Name, e)); return true; } @@ -121,15 +133,74 @@ public void Start() .Select(m => m.DeclaringType.Assembly.GetName().Name) .ToArray(); + // A mod is incompatible with Unity if its compatibility checker has an IsUnityCompatible method which returns false. + String[] incompatibleUnity = + fields + .Select(f => f.DeclaringType.GetMethod("IsUnityCompatible", Type.EmptyTypes)) + .Where(m => m != null) // Mods without IsUnityCompatible() are assumed to be compatible. + .Where(m => m.IsStatic) + .Where(m => m.ReturnType == typeof(bool)) + .Where(m => + { + try + { + return !(bool)m.Invoke(null, new object[0]); + } + catch (Exception e) + { + // If a mod throws an exception from IsUnityCompatible, it's not compatible. + Debug.LogWarning(String.Format("[CompatibilityChecker] Exception while invoking IsUnityCompatible() from '{0}':\n\n{1}", m.DeclaringType.Assembly.GetName().Name, e)); + return true; + } + }) + .Select(m => m.DeclaringType.Assembly.GetName().Name) + .ToArray(); + Array.Sort(incompatible); + Array.Sort(incompatibleUnity); + + String message = String.Empty; + + if (IsWin64()) + { + message += "WARNING: You are using 64-bit KSP on Windows. This version of KSP is known to cause crashes. It's highly recommended that you use either 32-bit KSP on Windows or switch to Linux."; + } + + if ((incompatible.Length > 0) || (incompatibleUnity.Length > 0)) + { + message += ((message == String.Empty) ? "Some" : "\n\nAdditionally, some") + " installed mods may be incompatible with this version of Kerbal Space Program. Features may be broken or disabled. Please check for updates to the listed mods."; + + if (incompatible.Length > 0) + { + Debug.LogWarning("[CompatibilityChecker] Incompatible mods detected: " + String.Join(", ", incompatible)); + message += String.Format("\n\nThese mods are incompatible with KSP {0}.{1}.{2}:\n\n", Versioning.version_major, Versioning.version_minor, Versioning.Revision); + message += String.Join("\n", incompatible); + } + + if (incompatibleUnity.Length > 0) + { + Debug.LogWarning("[CompatibilityChecker] Incompatible mods (Unity) detected: " + String.Join(", ", incompatibleUnity)); + message += String.Format("\n\nThese mods are incompatible with Unity {0}:\n\n", Application.unityVersion); + message += String.Join("\n", incompatibleUnity); + } + } - if (incompatible.Length > 0) + if ((incompatible.Length > 0) || (incompatibleUnity.Length > 0) || IsWin64()) { - Debug.LogWarning("[CompatibilityChecker] Incompatible mods detected: " + String.Join(", ", incompatible)); - PopupDialog.SpawnPopupDialog("Incompatible Mods Detected", "Some installed mods are incompatible with this version of Kerbal Space Program. Some features may be broken or disabled. Please check for updates to the following mods:\n\n" + String.Join("\n", incompatible), "OK", false, HighLogic.Skin); + PopupDialog.SpawnPopupDialog("Incompatible Mods Detected", message, "OK", true, HighLogic.Skin); } } + public static bool IsWin64() + { + return (IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT); + } + + public static bool IsAllCompatible() + { + return IsCompatible() && IsUnityCompatible() && !IsWin64(); + } + private static IEnumerable getAllTypes() { foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) @@ -151,4 +222,4 @@ private static IEnumerable getAllTypes() } } } -} \ No newline at end of file +} diff --git a/Gamedata/ModuleManager.2.2.1.dll b/Gamedata/ModuleManager.2.2.1.dll deleted file mode 100644 index e691303c..00000000 Binary files a/Gamedata/ModuleManager.2.2.1.dll and /dev/null differ diff --git a/Gamedata/TweakScale/ScaleExponents.cfg b/Gamedata/TweakScale/ScaleExponents.cfg index 7f88f9ec..8a23e706 100644 --- a/Gamedata/TweakScale/ScaleExponents.cfg +++ b/Gamedata/TweakScale/ScaleExponents.cfg @@ -13,6 +13,7 @@ TWEAKSCALEEXPONENTS { !amount = 3 maxAmount = 3 + -ignore = ModuleFuelTanks } attachNodes diff --git a/Gamedata/TweakScale/plugins/KSPAPIExtensions.dll b/Gamedata/TweakScale/plugins/KSPAPIExtensions.dll index 87d70046..e8a77c24 100644 Binary files a/Gamedata/TweakScale/plugins/KSPAPIExtensions.dll and b/Gamedata/TweakScale/plugins/KSPAPIExtensions.dll differ diff --git a/Gamedata/TweakScale/plugins/Scale.dll b/Gamedata/TweakScale/plugins/Scale.dll index 664cb685..96ba5f42 100644 Binary files a/Gamedata/TweakScale/plugins/Scale.dll and b/Gamedata/TweakScale/plugins/Scale.dll differ diff --git a/Gamedata/TweakScale/plugins/Scale_Editor.dll b/Gamedata/TweakScale/plugins/Scale_Editor.dll new file mode 100644 index 00000000..1f7568bf Binary files /dev/null and b/Gamedata/TweakScale/plugins/Scale_Editor.dll differ diff --git a/Gamedata/TweakScale/plugins/Scale_Redist.dll b/Gamedata/TweakScale/plugins/Scale_Redist.dll index 0901785b..60950e4b 100644 Binary files a/Gamedata/TweakScale/plugins/Scale_Redist.dll and b/Gamedata/TweakScale/plugins/Scale_Redist.dll differ diff --git a/Gamedata/TweakScale/plugins/TweakScale_ModularFuelTanks.dll b/Gamedata/TweakScale/plugins/TweakScale_ModularFuelTanks.dll deleted file mode 100644 index e25399c5..00000000 Binary files a/Gamedata/TweakScale/plugins/TweakScale_ModularFuelTanks.dll and /dev/null differ diff --git a/Gamedata/TweakScale/plugins/TweakScale_RealFuels.dll b/Gamedata/TweakScale/plugins/TweakScale_RealFuels.dll deleted file mode 100644 index 5560644f..00000000 Binary files a/Gamedata/TweakScale/plugins/TweakScale_RealFuels.dll and /dev/null differ diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index be92d6a9..b6083dd2 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.43.0.0")] -[assembly: AssemblyFileVersion("1.43.0.0")] +[assembly: AssemblyVersion("1.44.0.0")] +[assembly: AssemblyFileVersion("1.44.0.0")] diff --git a/Scale.csproj b/Scale.csproj index 351ad917..04f55abd 100644 --- a/Scale.csproj +++ b/Scale.csproj @@ -29,31 +29,6 @@ prompt 4 - - - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll - - - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp-firstpass.dll - - - lib\KSPAPIExtensions.dll - False - - - False - lib\Scale_Redist.dll - - - - - - - - - E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll - - @@ -66,10 +41,31 @@ + + + {2be63d8b-350e-4edd-959c-4b7397984364} + Scale_Redist + False + + + + + ..\..\..\..\..\Games\KSP_025clean\KSP_Data\Managed\Assembly-CSharp.dll + False + + + ..\KSPAPIExtensions\KSPAPIExtensions.dll + + + + ..\..\..\..\..\Games\KSP_025clean\KSP_Data\Managed\UnityEngine.dll + False + + copy "$(TargetPath)" "$(ProjectDir)\Gamedata\TweakScale\plugins" -copy "$(ProjectDir)lib\KSPAPIExtensions.dll" "$(ProjectDir)\Gamedata\TweakScale\plugins" +copy "$(ProjectDir)\..\KSPAPIExtensions\KSPAPIExtensions.dll" "$(ProjectDir)\Gamedata\TweakScale\plugins" - \ No newline at end of file diff --git a/TweakScale_RealFuels/Properties/AssemblyInfo.cs b/TweakScale_RealFuels/Properties/AssemblyInfo.cs deleted file mode 100644 index ad7c1b9d..00000000 --- a/TweakScale_RealFuels/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TweakScale_RealFuels")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TweakScale_RealFuels")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access destination type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("bada1aad-3479-4798-9844-c1d551af5289")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.0.0")] -[assembly: AssemblyFileVersion("1.4.0.0")] diff --git a/TweakScale_RealFuels/TweakScale_RealFuels.cs b/TweakScale_RealFuels/TweakScale_RealFuels.cs deleted file mode 100644 index c50c3471..00000000 --- a/TweakScale_RealFuels/TweakScale_RealFuels.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Linq; -using TweakScale; - -namespace TweakScale_RealFuels -{ - class TweakScaleModularFuelTanksUpdater : IRescalable - { - private RealFuels.ModuleFuelTanks _module; - - private RealFuels.ModuleFuelTanks Module - { - get - { - return _module; - } - } - - private Part Part - { - get - { - return _module.part; - } - } - - public TweakScaleModularFuelTanksUpdater(RealFuels.ModuleFuelTanks pm) - { - _module = pm; - } - - public void OnRescale(ScalingFactor factor) - { - Module.ChangeVolume(Module.volume * factor.relative.cubic); - foreach (PartResource f in Part.Resources) - { - f.amount /= factor.relative.cubic; - f.maxAmount /= factor.relative.cubic; - } - } - } -} diff --git a/TweakScale_RealFuels/TweakScale_RealFuels.csproj b/TweakScale_RealFuels/TweakScale_RealFuels.csproj deleted file mode 100644 index 3379243c..00000000 --- a/TweakScale_RealFuels/TweakScale_RealFuels.csproj +++ /dev/null @@ -1,70 +0,0 @@ - - - - - Debug - AnyCPU - {2C855B01-7389-4D45-A424-74F3A4CABB8C} - Library - Properties - TweakScale_RealFuels - TweakScale_RealFuels - v3.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll - - - ..\lib\KSPAPIExtensions.dll - - - ..\lib\RealFuels.dll - - - ..\lib\Scale_Redist.dll - - - - - - - - - E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll - - - - - - - - - copy "$(TargetPath)" "$(ProjectDir)\..\Gamedata\TweakScale\plugins" - - - \ No newline at end of file