Skip to content

Commit

Permalink
Added AssemblyFileVersion, needed for new KSP 1.12 dll verification
Browse files Browse the repository at this point in the history
Added InstallChecker to ensure installation into correct directory
  • Loading branch information
linuxgurugamer committed Jul 13, 2021
1 parent 8333fed commit d685f02
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 9 deletions.
5 changes: 4 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ChangeLog

0.1.10.17
Added AssemblyFileVersion
Added InstallChecker

0.1.10.16
Fixed issue on 1.11 where a uncontrolled ship would be controllable when changing scenes to it

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


0.1.10.13
Fixed inputlocks not being cleared when canceling the window
Added mode toggle on new button to allow toggling between different modes during the game
Expand Down
2 changes: 1 addition & 1 deletion ClickThroughBlocker.version
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"MAJOR": 0,
"MINOR": 1,
"PATCH": 10,
"BUILD": 16
"BUILD": 17
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
Expand Down
1 change: 1 addition & 0 deletions ClickThroughBlocker/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
using System.Reflection;

[assembly: AssemblyVersion("0.1.10.16")]
[assembly: AssemblyFileVersion("0.1.10.16")]
1 change: 1 addition & 0 deletions ClickThroughBlocker/AssemblyVersion.tt
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,4 @@
using System.Reflection;

[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
[assembly: AssemblyFileVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
13 changes: 7 additions & 6 deletions ClickThroughBlocker/ClickThroughBlocker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClickThroughFix</RootNamespace>
<AssemblyName>ClickThroughBlocker</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -58,6 +59,7 @@
<Compile Include="ClickThroughBlocker.cs" />
<Compile Include="FocusLock.cs" />
<Compile Include="GlobalFlagStorage.cs" />
<Compile Include="InstallChecker.cs" />
<Compile Include="Log.cs" />
<Compile Include="OneTimePopup.cs" />
<Compile Include="OnGUILoopCount.cs" />
Expand All @@ -72,18 +74,17 @@
<LastGenOutput>AssemblyVersion.cs</LastGenOutput>
</Content>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>

<ItemGroup>
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\Assembly*.dll">
<Private>False</Private>
</Reference>
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\UnityEngine*.dll">
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="ToolbarControl">
<HintPath>R:\KSP_1.9.1_dev\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
<HintPath>$(KSPDIR)\GameData\001_ToolbarControl\Plugins\ToolbarControl.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down Expand Up @@ -115,4 +116,4 @@ if $(ConfigurationName) == Release (
<PreBuildEvent>
"$(DevEnvDir)\texttransform.exe" "$(ProjectDir)AssemblyVersion.tt"</PreBuildEvent>
</PropertyGroup>
</Project>
</Project>
99 changes: 99 additions & 0 deletions ClickThroughBlocker/InstallChecker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* 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 ClickThroughFix
{
[KSPAddon(KSPAddon.Startup.Instantly, true)]
internal class Startup : MonoBehaviour
{
private void Start()
{
string v = "n/a";
AssemblyTitleAttribute attributes = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute), false);
string title = attributes?.Title;
if (title == null)
{
title = "TitleNotAvailable";
}
v = Assembly.GetExecutingAssembly().FullName;
if (v == null)
{
v = "VersionNotAvailable";
}
Debug.Log("[" + title + "] Version " + v);
}
}

[KSPAddon(KSPAddon.Startup.MainMenu, true)]
internal class InstallChecker : MonoBehaviour
{
internal const string MODNAME = "ClickThroughBlocker";
internal const string FOLDERNAME = "000_ClickThroughBlocker";
internal 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);

}
}
}
}

2 changes: 1 addition & 1 deletion ClickThroughBlocker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: KSPAssembly("ClickThroughBlocker",1, 8, 0)]
//[assembly: AssemblyVersion("0.1.7.0")]

11 changes: 11 additions & 0 deletions GameData/000_ClickThroughBlocker/changelog.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ KERBALCHANGELOG
author = Linuxgurugamer



VERSION
{
version = 0.1.10.17
CHANGE
{
change - Added AssemblyFileVersion, needed for new KSP 1.12 dll verification
change = Added InstallChecker to ensure installation into correct directory
type = update
}
}
VERSION
{
version = 0.1.10.16
Expand Down
11 changes: 11 additions & 0 deletions changelog.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ KERBALCHANGELOG
author = Linuxgurugamer



VERSION
{
version = 0.1.10.17
CHANGE
{
change - Added AssemblyFileVersion, needed for new KSP 1.12 dll verification
change = Added InstallChecker to ensure installation into correct directory
type = update
}
}
VERSION
{
version = 0.1.10.16
Expand Down

0 comments on commit d685f02

Please sign in to comment.