Skip to content

Commit 02fdec6

Browse files
Added InstallChecker
Updated AssemblyVersion.tt
1 parent 2964cb9 commit 02fdec6

File tree

8 files changed

+101
-40
lines changed

8 files changed

+101
-40
lines changed

Changelog.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@
2727
Component inspector field and properties also show base class properties (BindingFlags.FlattenHierarchy)
2828

2929
1.1.7.1
30-
Version bump for 1.5 rebuild
30+
Version bump for 1.5 rebuild
31+
32+
1.1.7.3
33+
Added InstallChecker
34+
Updated AssemblyVersion.tt

KerbalObjectInspector.version

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
"MAJOR": 1,
1111
"MINOR": 1,
1212
"PATCH": 7,
13-
"BUILD": 2
14-
},
15-
"KSP_VERSION": {
16-
"MAJOR": 1,
17-
"MINOR": 5,
18-
"PATCH": 1
13+
"BUILD": 3
1914
},
2015
"KSP_VERSION_MIN": {
2116
"MAJOR": 1,

KerbalObjectInspector.version.old

Lines changed: 0 additions & 25 deletions
This file was deleted.

KerbalObjectInspector/AssemblyVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
using System.Reflection;
77

8-
[assembly: AssemblyVersion("1.1.7.1")]
8+
[assembly: AssemblyVersion("1.1.7.3")]

KerbalObjectInspector/AssemblyVersion.tt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@
2727
int i2 = 0;
2828
string s;
2929

30-
string versionfile = @"D:\Users\jbb\github\KerbalObjectInspector\KerbalObjectInspector.version";
30+
31+
// For Visual Studio / MSBuild Build-Time Template Resolution
32+
string RootDirectory = System.IO.Path.GetDirectoryName(Host.TemplateFile) + @"\..\";
33+
34+
//
35+
// Update the following with the name of the .version file which is in the root directory
36+
//
37+
string versionfile = RootDirectory + "KerbalObjectInspector.version";
38+
3139
if (!File.Exists(versionfile))
3240
{
3341
Write("File: " + versionfile + " missing\n");
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Based on the InstallChecker from the Kethane mod for Kerbal Space Program.
3+
* https://github.com/Majiir/Kethane/blob/b93b1171ec42b4be6c44b257ad31c7efd7ea1702/Plugin/InstallChecker.cs
4+
*
5+
* Original is (C) Copyright Majiir.
6+
* CC0 Public Domain (http://creativecommons.org/publicdomain/zero/1.0/)
7+
* http://forum.kerbalspaceprogram.com/threads/65395-CompatibilityChecker-Discussion-Thread?p=899895&viewfull=1#post899895
8+
*
9+
* This file has been modified extensively and is released under the same license.
10+
*/
11+
using System;
12+
using System.IO;
13+
using System.Linq;
14+
using System.Reflection;
15+
using UnityEngine;
16+
17+
namespace KerbalObjectInspector
18+
{
19+
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
20+
internal class InstallChecker : MonoBehaviour
21+
{
22+
private const string MODNAME = "Kerbal Object Inspector";
23+
private const string FOLDERNAME = "KerbalObjectInspector";
24+
private const string EXPECTEDPATH = FOLDERNAME + "/Plugins";
25+
26+
protected void Start()
27+
{
28+
// Search for this mod's DLL existing in the wrong location. This will also detect duplicate copies because only one can be in the right place.
29+
var assemblies = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == Assembly.GetExecutingAssembly().GetName().Name).Where(a => a.url != EXPECTEDPATH);
30+
if (assemblies.Any())
31+
{
32+
var badPaths = assemblies.Select(a => a.path).Select(p => Uri.UnescapeDataString(new Uri(Path.GetFullPath(KSPUtil.ApplicationRootPath)).MakeRelativeUri(new Uri(p)).ToString().Replace('/', Path.DirectorySeparatorChar)));
33+
PopupDialog.SpawnPopupDialog
34+
(
35+
new Vector2(0.5f, 0.5f),
36+
new Vector2(0.5f, 0.5f),
37+
"test",
38+
"Incorrect " + MODNAME + " Installation",
39+
MODNAME + " has been installed incorrectly and will not function properly. All files should be located in KSP/GameData/" + FOLDERNAME + ". Do not move any files from inside that folder.\n\nIncorrect path(s):\n" + String.Join("\n", badPaths.ToArray()),
40+
"OK",
41+
false,
42+
HighLogic.UISkin
43+
);
44+
Debug.Log("Incorrect " + MODNAME + " Installation: " + MODNAME + " has been installed incorrectly and will not function properly. All files should be located in KSP/GameData/" + EXPECTEDPATH + ". Do not move any files from inside that folder.\n\nIncorrect path(s):\n" + String.Join("\n", badPaths.ToArray())
45+
46+
);
47+
48+
}
49+
50+
//// Check for Module Manager
51+
//if (!AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.StartsWith("ModuleManager") && a.url == ""))
52+
//{
53+
// PopupDialog.SpawnPopupDialog("Missing Module Manager",
54+
// modName + " requires the Module Manager mod in order to function properly.\n\nPlease download from http://forum.kerbalspaceprogram.com/threads/55219 and copy to the KSP/GameData/ directory.",
55+
// "OK", false, HighLogic.Skin);
56+
//}
57+
58+
CleanupOldVersions();
59+
}
60+
61+
/*
62+
* Tries to fix the install if it was installed over the top of a previous version
63+
*/
64+
void CleanupOldVersions()
65+
{
66+
try
67+
{
68+
}
69+
catch (Exception ex)
70+
{
71+
Debug.LogError("-ERROR- " + this.GetType().FullName + "[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " +
72+
"Exception caught while cleaning up old files.\n" + ex.Message + "\n" + ex.StackTrace);
73+
74+
}
75+
}
76+
}
77+
}
78+

KerbalObjectInspector/KerbalObjectInspector.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
</Compile>
3939
<Compile Include="Hierarchy.cs" />
4040
<Compile Include="Inspector.cs" />
41+
<Compile Include="InstallChecker.cs" />
4142
<Compile Include="Properties\AssemblyInfo.cs" />
4243
<Compile Include="ToolbarRegistration.cs" />
4344
<Compile Include="WireFrame.cs" />
@@ -54,23 +55,23 @@
5455
<ItemGroup>
5556
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
5657
<SpecificVersion>False</SpecificVersion>
57-
<HintPath>R:\KSP_1.6.1_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
58+
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
5859
</Reference>
5960
<Reference Include="ClickThroughBlocker, Version=0.1.6.2, Culture=neutral, processorArchitecture=MSIL">
6061
<SpecificVersion>False</SpecificVersion>
61-
<HintPath>R:\KSP_1.6.1_dev\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll</HintPath>
62+
<HintPath>R:\KSP_1.7.2_dev\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll</HintPath>
6263
</Reference>
6364
<Reference Include="System" />
6465
<Reference Include="ToolbarControl">
65-
<HintPath>R:\KSP_1.6.1_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
66+
<HintPath>R:\KSP_1.7.2_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
6667
</Reference>
6768
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
6869
<SpecificVersion>False</SpecificVersion>
69-
<HintPath>R:\KSP_1.6.1_dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
70+
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
7071
</Reference>
7172
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
7273
<SpecificVersion>False</SpecificVersion>
73-
<HintPath>R:\KSP_1.6.1_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
74+
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
7475
</Reference>
7576
</ItemGroup>
7677
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

deploy.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ rem GAMEDATA is the name of the local GameData
77
rem VERSIONFILE is the name of the version file, usually the same as GAMEDATA,
88
rem but not always
99

10-
set H=R:\KSP_1.6.1_dev
10+
set H=R:\KSP_1.7.2_dev
1111
set GAMEDIR=KerbalObjectInspector
1212
set GAMEDATA="GameData\"
1313
set VERSIONFILE=%GAMEDIR%.version

0 commit comments

Comments
 (0)