Skip to content

Commit

Permalink
Merge pull request #10 from NathanKell/master
Browse files Browse the repository at this point in the history
Add support for "-ignore" which will ignore specified modules, update to .25
  • Loading branch information
Biotronic committed Oct 10, 2014
2 parents 72ec6c3 + d280283 commit bdb1f60
Show file tree
Hide file tree
Showing 22 changed files with 222 additions and 437 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
/Scale_Editor/bin
/Scale_Editor/obj
/lib
/Releases
/Releases
Gamedata/TweakScale/TweakScaleInteraction/TweakScale_RealFuels.dll
167 changes: 119 additions & 48 deletions Checker.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -30,45 +31,56 @@
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.
//
// 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;

/*-----------------------------------------------*\
Expand All @@ -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()
{
Expand Down Expand Up @@ -113,23 +125,82 @@ 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;
}
})
.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<Type> getAllTypes()
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
Expand All @@ -151,4 +222,4 @@ private static IEnumerable<Type> getAllTypes()
}
}
}
}
}
Binary file removed Gamedata/ModuleManager.2.2.1.dll
Binary file not shown.
1 change: 1 addition & 0 deletions Gamedata/TweakScale/ScaleExponents.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ TWEAKSCALEEXPONENTS
{
!amount = 3
maxAmount = 3
-ignore = ModuleFuelTanks
}

attachNodes
Expand Down
Binary file modified Gamedata/TweakScale/plugins/KSPAPIExtensions.dll
Binary file not shown.
Binary file modified Gamedata/TweakScale/plugins/Scale.dll
Binary file not shown.
Binary file added Gamedata/TweakScale/plugins/Scale_Editor.dll
Binary file not shown.
Binary file modified Gamedata/TweakScale/plugins/Scale_Redist.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
48 changes: 22 additions & 26 deletions Scale.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="KSPAPIExtensions">
<HintPath>lib\KSPAPIExtensions.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Scale_Redist, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Scale_Redist.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Checker.cs" />
<Compile Include="ExtensionMethods.cs" />
Expand All @@ -66,10 +41,31 @@
<Compile Include="Tuple.cs" />
<Compile Include="Updater.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="Scale_Redist\Scale_Redist.csproj">
<Project>{2be63d8b-350e-4edd-959c-4b7397984364}</Project>
<Name>Scale_Redist</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\Games\KSP_025clean\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="KSPAPIExtensions">
<HintPath>..\KSPAPIExtensions\KSPAPIExtensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\Games\KSP_025clean\KSP_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "$(ProjectDir)\Gamedata\TweakScale\plugins"
copy "$(ProjectDir)lib\KSPAPIExtensions.dll" "$(ProjectDir)\Gamedata\TweakScale\plugins"</PostBuildEvent>
copy "$(ProjectDir)\..\KSPAPIExtensions\KSPAPIExtensions.dll" "$(ProjectDir)\Gamedata\TweakScale\plugins"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
16 changes: 1 addition & 15 deletions Scale.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio Express 2012 for Windows Desktop
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale", "Scale.csproj", "{70D38878-43DB-4F6E-8002-45ADA5391AF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweakScale_ModularFuelTanks", "TweakScale_ModularFuelTanks\TweakScale_ModularFuelTanks.csproj", "{55A34EE4-430D-4DA8-BCBA-60ECE7AED344}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TweakScale_RealFuels", "TweakScale_RealFuels\TweakScale_RealFuels.csproj", "{2C855B01-7389-4D45-A424-74F3A4CABB8C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_Redist", "Scale_Redist\Scale_Redist.csproj", "{2BE63D8B-350E-4EDD-959C-4B7397984364}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_Editor", "Scale_Editor\Scale_Editor.csproj", "{609C9905-6B3A-44AF-9E10-2B1A594CDEE4}"
Expand All @@ -23,14 +17,6 @@ Global
{70D38878-43DB-4F6E-8002-45ADA5391AF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70D38878-43DB-4F6E-8002-45ADA5391AF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70D38878-43DB-4F6E-8002-45ADA5391AF7}.Release|Any CPU.Build.0 = Release|Any CPU
{55A34EE4-430D-4DA8-BCBA-60ECE7AED344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55A34EE4-430D-4DA8-BCBA-60ECE7AED344}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55A34EE4-430D-4DA8-BCBA-60ECE7AED344}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55A34EE4-430D-4DA8-BCBA-60ECE7AED344}.Release|Any CPU.Build.0 = Release|Any CPU
{2C855B01-7389-4D45-A424-74F3A4CABB8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C855B01-7389-4D45-A424-74F3A4CABB8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C855B01-7389-4D45-A424-74F3A4CABB8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C855B01-7389-4D45-A424-74F3A4CABB8C}.Release|Any CPU.Build.0 = Release|Any CPU
{2BE63D8B-350E-4EDD-959C-4B7397984364}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BE63D8B-350E-4EDD-959C-4B7397984364}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BE63D8B-350E-4EDD-959C-4B7397984364}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Loading

0 comments on commit bdb1f60

Please sign in to comment.