Skip to content

Commit

Permalink
Added InstallChecker.cs
Browse files Browse the repository at this point in the history
 Updated AssemblyVersion.tt
  • Loading branch information
linuxgurugamer committed Jul 25, 2019
1 parent d85b0a9 commit ae70125
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 36 deletions.
Binary file modified .vs/AGExt/v15/sqlite3/storage.ide
Binary file not shown.
4 changes: 2 additions & 2 deletions AGExt.version
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"VERSION": {
"MAJOR": 2,
"MINOR": 3,
"PATCH": 4,
"BUILD": 1
"PATCH": 5,
"BUILD": 0
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
Expand Down
25 changes: 0 additions & 25 deletions AGExt.version.old

This file was deleted.

13 changes: 7 additions & 6 deletions AGExt/AGExt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</Compile>
<Compile Include="Button.cs" />
<Compile Include="CommonMethods.cs" />
<Compile Include="InstallChecker.cs" />
<Compile Include="Instantly.cs" />
<Compile Include="Editor.cs" />
<Compile Include="External.cs" />
Expand All @@ -65,27 +66,27 @@
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.0_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.0_dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="ClickThroughBlocker, Version=0.1.6.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.0_dev\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll</HintPath>
<HintPath>R:\KSP_1.7.2_dev\GameData\000_ClickThroughBlocker\Plugins\ClickThroughBlocker.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="ToolbarControl">
<HintPath>R:\KSP_1.7.0_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
<HintPath>R:\KSP_1.7.2_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
</Reference>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.0_dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.0_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
8 changes: 6 additions & 2 deletions AGExt/AssemblyVersion.tt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
int i2 = 0;
string s;


// For Visual Studio / MSBuild Build-Time Template Resolution
string RootDirectory = System.IO.Path.GetDirectoryName(Host.TemplateFile) + @"\..\";

//
// Update the following with the complete path to the .version file
// Update the following with the name of the .version file which is in the root directory
//
string versionfile = @"D:\Users\jbb\github\AGExt\AGExt.version";
string versionfile = RootDirectory + "AGExt.version";

if (!File.Exists(versionfile))
{
Expand Down
81 changes: 81 additions & 0 deletions AGExt/InstallChecker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
/**
* Based on the InstallChecker from the Kethane mod for Kerbal Space Program.
* https://github.com/Majiir/Kethane/blob/b93b1171ec42b4be6c44b257ad31c7efd7ea1702/Plugin/InstallChecker.cs
*
* Original is (C) Copyright Majiir.
* CC0 Public Domain (http://creativecommons.org/publicdomain/zero/1.0/)
* http://forum.kerbalspaceprogram.com/threads/65395-CompatibilityChecker-Discussion-Thread?p=899895&viewfull=1#post899895
*
* This file has been modified extensively and is released under the same license.
*/
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;

namespace AGExt
{
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
internal class InstallChecker : MonoBehaviour
{
private const string MODNAME = "Action Groups reExtended";
private const string FOLDERNAME = "Diazo/AGExt";
private const string EXPECTEDPATH = FOLDERNAME + "/Plugins";

protected void Start()
{
// 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.
var assemblies = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == Assembly.GetExecutingAssembly().GetName().Name).Where(a => a.url != EXPECTEDPATH);
if (assemblies.Any())
{
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)));
PopupDialog.SpawnPopupDialog
(
new Vector2(0.5f, 0.5f),
new Vector2(0.5f, 0.5f),
"test",
"Incorrect " + MODNAME + " Installation",
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()),
"OK",
false,
HighLogic.UISkin
);
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())

);

}

//// Check for Module Manager
//if (!AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.StartsWith("ModuleManager") && a.url == ""))
//{
// PopupDialog.SpawnPopupDialog("Missing Module Manager",
// 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.",
// "OK", false, HighLogic.Skin);
//}

CleanupOldVersions();
}

/*
* Tries to fix the install if it was installed over the top of a previous version
*/
void CleanupOldVersions()
{
try
{
}
catch (Exception ex)
{
Debug.LogError("-ERROR- " + this.GetType().FullName + "[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " +
"Exception caught while cleaning up old files.\n" + ex.Message + "\n" + ex.StackTrace);

}
}
}
}

4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.3.5
Added InstallChecker.cs
Updated AssemblyVersion.tt

2.3.4.1
fixed missing kOSVoidAction

Expand Down
2 changes: 1 addition & 1 deletion deploy.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rem GAMEDATA is the name of the local GameData
rem VERSIONFILE is the name of the version file, usually the same as GAMEDATA,
rem but not always

set H=R:\KSP_1.7.0_dev
set H=R:\KSP_1.7.2_dev
set GAMEDIR=AGExt
set GAMEDATA="GameData\Diazo"
set VERSIONFILE=%GAMEDIR%.version
Expand Down

0 comments on commit ae70125

Please sign in to comment.