Skip to content

Commit d685f02

Browse files
Added AssemblyFileVersion, needed for new KSP 1.12 dll verification
Added InstallChecker to ensure installation into correct directory
1 parent 8333fed commit d685f02

File tree

9 files changed

+136
-9
lines changed

9 files changed

+136
-9
lines changed

Changelog.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
ChangeLog
22

3+
0.1.10.17
4+
Added AssemblyFileVersion
5+
Added InstallChecker
6+
37
0.1.10.16
48
Fixed issue on 1.11 where a uncontrolled ship would be controllable when changing scenes to it
59

@@ -13,7 +17,6 @@ ChangeLog
1317
EditorActionGroups.Instance.ClearSelection was being called every time through Update()
1418
Added global value for FocusFollowsClick or FocusFollowsMouse for all new saves
1519

16-
1720
0.1.10.13
1821
Fixed inputlocks not being cleared when canceling the window
1922
Added mode toggle on new button to allow toggling between different modes during the game

ClickThroughBlocker.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"MAJOR": 0,
1111
"MINOR": 1,
1212
"PATCH": 10,
13-
"BUILD": 16
13+
"BUILD": 17
1414
},
1515
"KSP_VERSION_MIN": {
1616
"MAJOR": 1,

ClickThroughBlocker/AssemblyVersion.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
using System.Reflection;
77

88
[assembly: AssemblyVersion("0.1.10.16")]
9+
[assembly: AssemblyFileVersion("0.1.10.16")]

ClickThroughBlocker/AssemblyVersion.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,4 @@
9898
using System.Reflection;
9999

100100
[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
101+
[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]

ClickThroughBlocker/ClickThroughBlocker.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>ClickThroughFix</RootNamespace>
1111
<AssemblyName>ClickThroughBlocker</AssemblyName>
12-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
1415
</PropertyGroup>
1516
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1617
<DebugSymbols>true</DebugSymbols>
@@ -58,6 +59,7 @@
5859
<Compile Include="ClickThroughBlocker.cs" />
5960
<Compile Include="FocusLock.cs" />
6061
<Compile Include="GlobalFlagStorage.cs" />
62+
<Compile Include="InstallChecker.cs" />
6163
<Compile Include="Log.cs" />
6264
<Compile Include="OneTimePopup.cs" />
6365
<Compile Include="OnGUILoopCount.cs" />
@@ -72,18 +74,17 @@
7274
<LastGenOutput>AssemblyVersion.cs</LastGenOutput>
7375
</Content>
7476
</ItemGroup>
75-
<ItemGroup>
76-
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
77-
</ItemGroup>
77+
7878
<ItemGroup>
7979
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\Assembly*.dll">
8080
<Private>False</Private>
8181
</Reference>
8282
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\UnityEngine*.dll">
8383
<Private>False</Private>
8484
</Reference>
85+
<Reference Include="System" />
8586
<Reference Include="ToolbarControl">
86-
<HintPath>R:\KSP_1.9.1_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
87+
<HintPath>$(KSPDIR)\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
8788
</Reference>
8889
</ItemGroup>
8990
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
@@ -115,4 +116,4 @@ if $(ConfigurationName) == Release (
115116
<PreBuildEvent>
116117
"$(DevEnvDir)\texttransform.exe" "$(ProjectDir)AssemblyVersion.tt"</PreBuildEvent>
117118
</PropertyGroup>
118-
</Project>
119+
</Project>
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 ClickThroughFix
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 = "ClickThroughBlocker";
44+
internal const string FOLDERNAME = "000_ClickThroughBlocker";
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+

ClickThroughBlocker/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
//[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
36+
//[assembly: AssemblyFileVersion("1.0.0.0")]
3737
[assembly: KSPAssembly("ClickThroughBlocker",1, 8, 0)]
3838
//[assembly: AssemblyVersion("0.1.7.0")]
3939

GameData/000_ClickThroughBlocker/changelog.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ KERBALCHANGELOG
66
author = Linuxgurugamer
77

88

9+
10+
VERSION
11+
{
12+
version = 0.1.10.17
13+
CHANGE
14+
{
15+
change - Added AssemblyFileVersion, needed for new KSP 1.12 dll verification
16+
change = Added InstallChecker to ensure installation into correct directory
17+
type = update
18+
}
19+
}
920
VERSION
1021
{
1122
version = 0.1.10.16

changelog.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ KERBALCHANGELOG
66
author = Linuxgurugamer
77

88

9+
10+
VERSION
11+
{
12+
version = 0.1.10.17
13+
CHANGE
14+
{
15+
change - Added AssemblyFileVersion, needed for new KSP 1.12 dll verification
16+
change = Added InstallChecker to ensure installation into correct directory
17+
type = update
18+
}
19+
}
920
VERSION
1021
{
1122
version = 0.1.10.16

0 commit comments

Comments
 (0)