Skip to content

Commit 770a296

Browse files
Added InstallChecker
Updated AssemblyVersion.tt Updated for KSP 1.8
1 parent 6be850c commit 770a296

15 files changed

+554
-68
lines changed
524 KB
Binary file not shown.

ChangeLog.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
ChangeLog
2+
13
1.2.2.8
24
Removed toolbar button when leaving flight scene
35

@@ -6,4 +8,9 @@
68
Added support for the ToolbarController
79

810
1.2.2.11
9-
Version bump for 1.5 rebuild
11+
Version bump for 1.5 rebuild
12+
13+
1.2.3
14+
Added InstallChecker
15+
Updated AssemblyVersion.tt
16+
Updated for KSP 1.8
Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
{
2-
"NAME": "ProbeControlRoom",
3-
"URL": "http://ksp.spacetux.net/avc/ProbeControlRoom",
4-
"DOWNLOAD": "https://github.com/linuxgurugamer/KSP-ProbeControlRoom/releases",
5-
"GITHUB": {
6-
"USERNAME": "Linuxgurugamer",
7-
"REPOSITORY": "KSP-ProbeControlRoom",
8-
"ALLOW_PRE_RELEASE": false
9-
},
10-
"VERSION": {
11-
"MAJOR": 1,
12-
"MINOR": 2,
13-
"PATCH": 2,
14-
"BUILD": 11
15-
},
16-
"KSP_VERSION": {
17-
"MAJOR": 1,
18-
"MINOR": 5,
19-
"PATCH": 1
20-
},
21-
"KSP_VERSION_MIN": {
22-
"MAJOR": 1,
23-
"MINOR": 5,
24-
"PATCH": 1
25-
},
26-
"KSP_VERSION_MAX": {
27-
"MAJOR": 1,
28-
"MINOR": 5,
29-
"PATCH": 99
30-
}
31-
}
2+
"NAME": "ProbeControlRoom",
3+
"URL": "http://ksp.spacetux.net/avc/ProbeControlRoom",
4+
"DOWNLOAD": "https://github.com/linuxgurugamer/KSP-ProbeControlRoom/releases",
5+
"GITHUB": {
6+
"USERNAME": "Linuxgurugamer",
7+
"REPOSITORY": "KSP-ProbeControlRoom",
8+
"ALLOW_PRE_RELEASE": false
9+
},
10+
"VERSION": {
11+
"MAJOR": 1,
12+
"MINOR": 2,
13+
"PATCH": 3,
14+
"BUILD": 0
15+
},
16+
"KSP_VERSION": {
17+
"MAJOR": 1,
18+
"MINOR": 5,
19+
"PATCH": 1
20+
},
21+
"KSP_VERSION_MIN": {
22+
"MAJOR": 1,
23+
"MINOR": 8,
24+
"PATCH": 0
25+
}
26+
}

ProbeControlRoom.version

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"VERSION": {
1111
"MAJOR": 1,
1212
"MINOR": 2,
13-
"PATCH": 2,
14-
"BUILD": 12
13+
"PATCH": 3,
14+
"BUILD": 0
1515
},
1616
"KSP_VERSION": {
1717
"MAJOR": 1,
@@ -20,7 +20,7 @@
2020
},
2121
"KSP_VERSION_MIN": {
2222
"MAJOR": 1,
23-
"MINOR": 5,
24-
"PATCH": 1
23+
"MINOR": 8,
24+
"PATCH": 0
2525
}
2626
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"MAJOR": 1,
1212
"MINOR": 2,
1313
"PATCH": 2,
14-
"BUILD": 11
14+
"BUILD": 12
1515
},
1616
"KSP_VERSION": {
1717
"MAJOR": 1,

ProbeControlRoom/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.2.2.11")]
8+
[assembly: AssemblyVersion("1.2.3.0")]

ProbeControlRoom/AssemblyVersion.tt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@
2828
int i2 = 0;
2929
string s;
3030

31-
string versionfile = @"D:\Users\jbb\github\KSP-ProbeControlRoom\ProbeControlRoom.version";
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 + "ProbeControlRoom.version";
38+
3239
if (!File.Exists(versionfile))
3340
{
3441
Write("File: " + versionfile + " missing\n");

ProbeControlRoom/InstallChecker.cs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 ProbeControlRoom
18+
{
19+
[KSPAddon(KSPAddon.Startup.Instantly, true)]
20+
internal class Startup : MonoBehaviour
21+
{
22+
private void Start()
23+
{
24+
string v = "n/a";
25+
AssemblyTitleAttribute attributes = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute), false);
26+
string title = attributes?.Title;
27+
if (title == null)
28+
{
29+
title = "TitleNotAvailable";
30+
}
31+
v = Assembly.GetExecutingAssembly().FullName;
32+
if (v == null)
33+
{
34+
v = "VersionNotAvailable";
35+
}
36+
Debug.Log("[" + title + "] Version " + v);
37+
}
38+
}
39+
40+
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
41+
internal class InstallChecker : MonoBehaviour
42+
{
43+
internal const string MODNAME = "Probe Control Room";
44+
internal const string FOLDERNAME = "ProbeControlRoom";
45+
internal const string EXPECTEDPATH = FOLDERNAME + "/Plugins";
46+
47+
protected void Start()
48+
{
49+
// 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.
50+
var assemblies = AssemblyLoader.loadedAssemblies.Where(a => a.assembly.GetName().Name == Assembly.GetExecutingAssembly().GetName().Name).Where(a => a.url != EXPECTEDPATH);
51+
if (assemblies.Any())
52+
{
53+
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)));
54+
PopupDialog.SpawnPopupDialog
55+
(
56+
new Vector2(0.5f, 0.5f),
57+
new Vector2(0.5f, 0.5f),
58+
"test",
59+
"Incorrect " + MODNAME + " Installation",
60+
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()),
61+
"OK",
62+
false,
63+
HighLogic.UISkin
64+
);
65+
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())
66+
67+
);
68+
69+
}
70+
71+
//// Check for Module Manager
72+
//if (!AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name.StartsWith("ModuleManager") && a.url == ""))
73+
//{
74+
// PopupDialog.SpawnPopupDialog("Missing Module Manager",
75+
// 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.",
76+
// "OK", false, HighLogic.Skin);
77+
//}
78+
79+
CleanupOldVersions();
80+
}
81+
82+
/*
83+
* Tries to fix the install if it was installed over the top of a previous version
84+
*/
85+
void CleanupOldVersions()
86+
{
87+
try
88+
{
89+
}
90+
catch (Exception ex)
91+
{
92+
Debug.LogError("-ERROR- " + this.GetType().FullName + "[" + this.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " +
93+
"Exception caught while cleaning up old files.\n" + ex.Message + "\n" + ex.StackTrace);
94+
95+
}
96+
}
97+
}
98+
}
99+

ProbeControlRoom/ProbeControlRoom.csproj

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<OutputType>Library</OutputType>
88
<RootNamespace>ProbeControlRoom</RootNamespace>
99
<AssemblyName>ProbeControlRoom</AssemblyName>
10-
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
10+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1111
</PropertyGroup>
1212
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1313
<DebugSymbols>true</DebugSymbols>
@@ -17,6 +17,7 @@
1717
<DefineConstants>DEBUG;</DefineConstants>
1818
<ErrorReport>prompt</ErrorReport>
1919
<WarningLevel>4</WarningLevel>
20+
<Prefer32Bit>false</Prefer32Bit>
2021
<ConsolePause>false</ConsolePause>
2122
<CustomCommands>
2223
<CustomCommands>
@@ -29,6 +30,7 @@
2930
<OutputPath>bin\Release</OutputPath>
3031
<ErrorReport>prompt</ErrorReport>
3132
<WarningLevel>4</WarningLevel>
33+
<Prefer32Bit>false</Prefer32Bit>
3234
<ConsolePause>false</ConsolePause>
3335
<CustomCommands>
3436
<CustomCommands>
@@ -42,6 +44,7 @@
4244
<DesignTime>True</DesignTime>
4345
<DependentUpon>AssemblyVersion.tt</DependentUpon>
4446
</Compile>
47+
<Compile Include="InstallChecker.cs" />
4548
<Compile Include="Properties\AssemblyInfo.cs" />
4649
<Compile Include="ProbeControlRoom.cs" />
4750
<Compile Include="ProbeControlRoomPart.cs" />
@@ -60,25 +63,16 @@
6063
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
6164
</ItemGroup>
6265
<ItemGroup>
63-
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
64-
<SpecificVersion>False</SpecificVersion>
65-
<HintPath>R:\KSP_1.6.1_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
66+
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\Assembly*.dll">
67+
<Private>False</Private>
6668
</Reference>
67-
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
68-
<SpecificVersion>False</SpecificVersion>
69-
<HintPath>R:\KSP_1.6.1_dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
69+
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\UnityEngine*.dll">
70+
<Private>False</Private>
7071
</Reference>
7172
<Reference Include="System" />
73+
<Reference Include="System" />
7274
<Reference Include="ToolbarControl">
73-
<HintPath>R:\KSP_1.6.1_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
74-
</Reference>
75-
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
76-
<SpecificVersion>False</SpecificVersion>
77-
<HintPath>R:\KSP_1.6.1_dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
78-
</Reference>
79-
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
80-
<SpecificVersion>False</SpecificVersion>
81-
<HintPath>R:\KSP_1.6.1_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
75+
<HintPath>$(KSPDIR)\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
8276
</Reference>
8377
</ItemGroup>
8478
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{6BB6BF04-C58F-47EE-A4BB-3CADA7850606}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>ProbeControlRoom</RootNamespace>
9+
<AssemblyName>ProbeControlRoom</AssemblyName>
10+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG;</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
<ConsolePause>false</ConsolePause>
21+
<CustomCommands>
22+
<CustomCommands>
23+
<Command type="AfterBuild" command="PostBuild.bat ${TargetFile} ${ProjectConfig}" workingdir="${ProjectDir}" pauseExternalConsole="True" />
24+
</CustomCommands>
25+
</CustomCommands>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release</OutputPath>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
<ConsolePause>false</ConsolePause>
33+
<CustomCommands>
34+
<CustomCommands>
35+
<Command type="AfterBuild" command="PostBuild.bat ${TargetFile} ${ProjectConfig}" workingdir="${ProjectDir}" pauseExternalConsole="True" />
36+
</CustomCommands>
37+
</CustomCommands>
38+
</PropertyGroup>
39+
<ItemGroup>
40+
<Compile Include="AssemblyVersion.cs">
41+
<AutoGen>True</AutoGen>
42+
<DesignTime>True</DesignTime>
43+
<DependentUpon>AssemblyVersion.tt</DependentUpon>
44+
</Compile>
45+
<Compile Include="Properties\AssemblyInfo.cs" />
46+
<Compile Include="ProbeControlRoom.cs" />
47+
<Compile Include="ProbeControlRoomPart.cs" />
48+
<Compile Include="ProbeControlRoomUtils.cs" />
49+
<Compile Include="ProbeControlRoomSettings.cs" />
50+
<Compile Include="DynamicEmitFields.cs" />
51+
<Compile Include="ToolbarRegistration.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Content Include="AssemblyVersion.tt">
55+
<Generator>TextTemplatingFileGenerator</Generator>
56+
<LastGenOutput>AssemblyVersion.cs</LastGenOutput>
57+
</Content>
58+
</ItemGroup>
59+
<ItemGroup>
60+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
61+
</ItemGroup>
62+
<ItemGroup>
63+
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
64+
<SpecificVersion>False</SpecificVersion>
65+
<HintPath>R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
66+
</Reference>
67+
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
68+
<SpecificVersion>False</SpecificVersion>
69+
<HintPath>R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
70+
</Reference>
71+
<Reference Include="System" />
72+
<Reference Include="ToolbarControl">
73+
<HintPath>R:\KSP_1.7.3_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
74+
</Reference>
75+
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
76+
<SpecificVersion>False</SpecificVersion>
77+
<HintPath>R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
78+
</Reference>
79+
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
80+
<SpecificVersion>False</SpecificVersion>
81+
<HintPath>R:\KSP_1.7.3_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
82+
</Reference>
83+
</ItemGroup>
84+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
85+
<PropertyGroup>
86+
<PostBuildEvent>
87+
start /D D:\Users\jbb\github\KSP-ProbeControlRoom/WAIT deploy.bat $(TargetDir) $(TargetFileName)
88+
89+
if $(ConfigurationName) == Release (
90+
start /D D:\Users\jbb\github\KSP-ProbeControlRoom/WAIT buildRelease.bat $(TargetDir) $(TargetFileName)
91+
)
92+
</PostBuildEvent>
93+
</PropertyGroup>
94+
<PropertyGroup>
95+
<PreBuildEvent>
96+
set textTemplatingPath="%25ProgramFiles(x86)%25\Microsoft Visual Studio\2017\Community\Common7\IDE \texttransform.exe"
97+
98+
%25textTemplatingPath%25 "$(ProjectDir)AssemblyVersion.tt"</PreBuildEvent>
99+
</PropertyGroup>
100+
</Project>

0 commit comments

Comments
 (0)