Skip to content

Commit ae70125

Browse files
Added InstallChecker.cs
Updated AssemblyVersion.tt
1 parent d85b0a9 commit ae70125

8 files changed

Lines changed: 101 additions & 36 deletions

File tree

.vs/AGExt/v15/sqlite3/storage.ide

0 Bytes
Binary file not shown.

AGExt.version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"VERSION": {
1010
"MAJOR": 2,
1111
"MINOR": 3,
12-
"PATCH": 4,
13-
"BUILD": 1
12+
"PATCH": 5,
13+
"BUILD": 0
1414
},
1515
"KSP_VERSION_MIN": {
1616
"MAJOR": 1,

AGExt.version.old

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

AGExt/AGExt.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
</Compile>
4040
<Compile Include="Button.cs" />
4141
<Compile Include="CommonMethods.cs" />
42+
<Compile Include="InstallChecker.cs" />
4243
<Compile Include="Instantly.cs" />
4344
<Compile Include="Editor.cs" />
4445
<Compile Include="External.cs" />
@@ -65,27 +66,27 @@
6566
<ItemGroup>
6667
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
6768
<SpecificVersion>False</SpecificVersion>
68-
<HintPath>R:\KSP_1.7.0_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
69+
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
6970
</Reference>
7071
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
7172
<SpecificVersion>False</SpecificVersion>
72-
<HintPath>R:\KSP_1.7.0_dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
73+
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
7374
</Reference>
7475
<Reference Include="ClickThroughBlocker, Version=0.1.6.2, Culture=neutral, processorArchitecture=MSIL">
7576
<SpecificVersion>False</SpecificVersion>
76-
<HintPath>R:\KSP_1.7.0_dev\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll</HintPath>
77+
<HintPath>R:\KSP_1.7.2_dev\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll</HintPath>
7778
</Reference>
7879
<Reference Include="System" />
7980
<Reference Include="ToolbarControl">
80-
<HintPath>R:\KSP_1.7.0_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
81+
<HintPath>R:\KSP_1.7.2_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
8182
</Reference>
8283
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
8384
<SpecificVersion>False</SpecificVersion>
84-
<HintPath>R:\KSP_1.7.0_dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
85+
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
8586
</Reference>
8687
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
8788
<SpecificVersion>False</SpecificVersion>
88-
<HintPath>R:\KSP_1.7.0_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
89+
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
8990
</Reference>
9091
</ItemGroup>
9192
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

AGExt/AssemblyVersion.tt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@
2828
int i2 = 0;
2929
string s;
3030

31+
32+
// For Visual Studio / MSBuild Build-Time Template Resolution
33+
string RootDirectory = System.IO.Path.GetDirectoryName(Host.TemplateFile) + @"\..\";
34+
3135
//
32-
// Update the following with the complete path to the .version file
36+
// Update the following with the name of the .version file which is in the root directory
3337
//
34-
string versionfile = @"D:\Users\jbb\github\AGExt\AGExt.version";
38+
string versionfile = RootDirectory + "AGExt.version";
3539

3640
if (!File.Exists(versionfile))
3741
{

AGExt/InstallChecker.cs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
/**
5+
* Based on the InstallChecker from the Kethane mod for Kerbal Space Program.
6+
* https://github.com/Majiir/Kethane/blob/b93b1171ec42b4be6c44b257ad31c7efd7ea1702/Plugin/InstallChecker.cs
7+
*
8+
* Original is (C) Copyright Majiir.
9+
* CC0 Public Domain (http://creativecommons.org/publicdomain/zero/1.0/)
10+
* http://forum.kerbalspaceprogram.com/threads/65395-CompatibilityChecker-Discussion-Thread?p=899895&viewfull=1#post899895
11+
*
12+
* This file has been modified extensively and is released under the same license.
13+
*/
14+
using System;
15+
using System.IO;
16+
using System.Linq;
17+
using System.Reflection;
18+
using UnityEngine;
19+
20+
namespace AGExt
21+
{
22+
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
23+
internal class InstallChecker : MonoBehaviour
24+
{
25+
private const string MODNAME = "Action Groups reExtended";
26+
private const string FOLDERNAME = "Diazo/AGExt";
27+
private const string EXPECTEDPATH = FOLDERNAME + "/Plugins";
28+
29+
protected void Start()
30+
{
31+
// 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.
32+
var assemblies = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == Assembly.GetExecutingAssembly().GetName().Name).Where(a => a.url != EXPECTEDPATH);
33+
if (assemblies.Any())
34+
{
35+
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)));
36+
PopupDialog.SpawnPopupDialog
37+
(
38+
new Vector2(0.5f, 0.5f),
39+
new Vector2(0.5f, 0.5f),
40+
"test",
41+
"Incorrect " + MODNAME + " Installation",
42+
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()),
43+
"OK",
44+
false,
45+
HighLogic.UISkin
46+
);
47+
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())
48+
49+
);
50+
51+
}
52+
53+
//// Check for Module Manager
54+
//if (!AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.StartsWith("ModuleManager") && a.url == ""))
55+
//{
56+
// PopupDialog.SpawnPopupDialog("Missing Module Manager",
57+
// 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.",
58+
// "OK", false, HighLogic.Skin);
59+
//}
60+
61+
CleanupOldVersions();
62+
}
63+
64+
/*
65+
* Tries to fix the install if it was installed over the top of a previous version
66+
*/
67+
void CleanupOldVersions()
68+
{
69+
try
70+
{
71+
}
72+
catch (Exception ex)
73+
{
74+
Debug.LogError("-ERROR- " + this.GetType().FullName + "[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " +
75+
"Exception caught while cleaning up old files.\n" + ex.Message + "\n" + ex.StackTrace);
76+
77+
}
78+
}
79+
}
80+
}
81+

ChangeLog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.3.5
2+
Added InstallChecker.cs
3+
Updated AssemblyVersion.tt
4+
15
2.3.4.1
26
fixed missing kOSVoidAction
37

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.7.0_dev
10+
set H=R:\KSP_1.7.2_dev
1111
set GAMEDIR=AGExt
1212
set GAMEDATA="GameData\Diazo"
1313
set VERSIONFILE=%GAMEDIR%.version

0 commit comments

Comments
 (0)