Skip to content

Commit

Permalink
Added InstallChecker
Browse files Browse the repository at this point in the history
 Updated AssemblyVersion
 Updated for KSP 1.8
  • Loading branch information
linuxgurugamer committed Nov 11, 2019
1 parent 295bf4c commit f9d3733
Show file tree
Hide file tree
Showing 12 changed files with 360 additions and 36 deletions.
Binary file modified .vs/ThroughTheEyes/v15/sqlite3/storage.ide
Binary file not shown.
7 changes: 7 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
ChangeLog

2.0.3
Added InstallChecker
Updated AssemblyVersion
Updated for KSP 1.8

2.0.2.5
Removed the useBlizzy option from the settings page as it wasn't being used

Expand Down
13 changes: 4 additions & 9 deletions GameData/ThroughTheEyes/ThroughTheEyes.version
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@
"VERSION": {
"MAJOR": 2,
"MINOR": 0,
"PATCH": 2,
"BUILD": 4
},
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 4,
"PATCH": 1
"PATCH": 3,
"BUILD": 0
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
"MINOR": 4,
"PATCH": 1
"MINOR": 8,
"PATCH": 0
}
}
13 changes: 4 additions & 9 deletions ThroughTheEyes.version
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@
"VERSION": {
"MAJOR": 2,
"MINOR": 0,
"PATCH": 2,
"BUILD": 5
},
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 4,
"PATCH": 1
"PATCH": 3,
"BUILD": 0
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
"MINOR": 4,
"PATCH": 1
"MINOR": 8,
"PATCH": 0
}
}
25 changes: 25 additions & 0 deletions ThroughTheEyes.version.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"NAME": "ThroughTheEyes",
"URL": "http://ksp.spacetux.net/avc/ThroughTheEyes",
"DOWNLOAD": "https://spacedock.info/mod/1560/",
"GITHUB": {
"USERNAME": "linuxgurugamer",
"REPOSITORY": "Through-The-Eyes"
},
"VERSION": {
"MAJOR": 2,
"MINOR": 0,
"PATCH": 2,
"BUILD": 5
},
"KSP_VERSION": {
"MAJOR": 1,
"MINOR": 4,
"PATCH": 1
},
"KSP_VERSION_MIN": {
"MAJOR": 1,
"MINOR": 4,
"PATCH": 1
}
}
2 changes: 1 addition & 1 deletion ThroughTheEyes/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

using System.Reflection;

[assembly: AssemblyVersion("2.0.2.4")]
[assembly: AssemblyVersion("2.0.3.0")]
8 changes: 7 additions & 1 deletion ThroughTheEyes/AssemblyVersion.tt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@
int i = 0;
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 name of the .version file which is in the root directory
//
string versionfile = RootDirectory + "ThroughTheEyes.version";

string versionfile = @"D:\Users\jbb\github\Through-The-Eyes\ThroughTheEyes.version";
if (!File.Exists(versionfile))
{
Write("File: " + versionfile + " missing\n");
Expand Down
99 changes: 99 additions & 0 deletions ThroughTheEyes/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 ThroughTheEyes
{
[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
{
private const string MODNAME = "Through-The-Eyes";
private const string FOLDERNAME = "ThroughTheEyes";
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("[PlaneraryDiversity] 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("[PlaneraryDiversity] -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);

}
}
}
}

23 changes: 8 additions & 15 deletions ThroughTheEyes/ThroughTheEyes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<OutputType>Library</OutputType>
<RootNamespace>ThroughTheEyes</RootNamespace>
<AssemblyName>ThroughTheEyes</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -17,6 +17,7 @@
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand All @@ -25,6 +26,7 @@
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
Expand All @@ -34,6 +36,7 @@
<DependentUpon>AssemblyVersion.tt</DependentUpon>
</Compile>
<Compile Include="FirstPersonCameraManager.cs" />
<Compile Include="InstallChecker.cs" />
<Compile Include="Log.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CameraState.cs" />
Expand Down Expand Up @@ -64,23 +67,13 @@
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\Assembly*.dll">
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.2_dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<Reference Include="$(KSPDIR)\KSP_x64_Data\Managed\UnityEngine*.dll">
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<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.2_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
102 changes: 102 additions & 0 deletions ThroughTheEyes/ThroughTheEyes.csproj.173
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7490BCE5-BAC8-44E3-BE55-6E6694583BC8}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>ThroughTheEyes</RootNamespace>
<AssemblyName>ThroughTheEyes</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyVersion.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AssemblyVersion.tt</DependentUpon>
</Compile>
<Compile Include="FirstPersonCameraManager.cs" />
<Compile Include="Log.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CameraState.cs" />
<Compile Include="ConfigUtil.cs" />
<Compile Include="DebugUtils.cs" />
<Compile Include="FPGUI.cs" />
<Compile Include="KeyControls.cs" />
<Compile Include="Settings.cs" />
<Compile Include="ThroughTheEyes.cs" />
<Compile Include="FirstPersonEVA.cs" />
<Compile Include="KeyDisabler.cs" />
<Compile Include="EVAIVAState.cs" />
<Compile Include="ReflectedMembers.cs" />
<Compile Include="HookedKerbalFSMState.cs" />
<Compile Include="FPNavBall.cs" />
<Compile Include="FPStateFloating.cs" />
<Compile Include="Helpers.cs" />
<Compile Include="FPStateWalkRun.cs" />
<Compile Include="EVABoundFix.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="AssemblyVersion.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AssemblyVersion.cs</LastGenOutput>
</Content>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.3_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.3_dev\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>R:\KSP_1.7.3_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.3_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
start /D D:\Users\jbb\github\Through-The-Eyes /WAIT deploy.bat $(TargetDir) $(TargetFileName)

if $(ConfigurationName) == Release (
start /D D:\Users\jbb\github\Through-The-Eyes /WAIT buildRelease.bat $(TargetDir) $(TargetFileName)
)</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>
set textTemplatingPath="%25ProgramFiles(x86)%25\Microsoft Visual Studio\2017\Community\Common7\IDE \texttransform.exe"



%25textTemplatingPath%25 "$(ProjectDir)AssemblyVersion.tt"</PreBuildEvent>
</PropertyGroup>
</Project>
Loading

0 comments on commit f9d3733

Please sign in to comment.