Skip to content

Commit

Permalink
Merge pull request #4 from KSP-RO/1.8+
Browse files Browse the repository at this point in the history
1.8+
  • Loading branch information
Theysen authored Jul 25, 2020
2 parents f133013 + 21a9e09 commit ce23d7e
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 162 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Source/.idea/
Source/RSSVE.sln.DotSettings.user
Source/Builds/
RSSVE/Plugins
Binary file added RSSVE/Plugins/RSSVE.dll
Binary file not shown.
73 changes: 35 additions & 38 deletions Source/EVEConfigCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,54 +41,52 @@ public static int GetCheckConfig(List<string> szBodyLoaderNames, string szEVENod

int nEVENodeCount = 0;

if (!string.IsNullOrEmpty(szEVENodeToCheck))
if (string.IsNullOrEmpty(szEVENodeToCheck)) return nEVENodeCount;
// Scan the GameDatabase for all loaded EVE configuration files.

foreach (ConfigNode EVENode in GameDatabase.Instance.GetConfigNodes(szEVENodeToCheck))
{
// Scan the GameDatabase for all loaded EVE configuration files.
// Search for all available EVE body objects.

foreach (ConfigNode EVENode in GameDatabase.Instance.GetConfigNodes(szEVENodeToCheck))
foreach (ConfigNode EVECloudsObject in EVENode.GetNodes("OBJECT"))
{
// Search for all available EVE body objects.

foreach (ConfigNode EVECloudsObject in EVENode.GetNodes("OBJECT"))
if (EVENode != null && EVECloudsObject.HasValue("body"))
{
if (EVENode != null && EVECloudsObject.HasValue("body"))
{
// Get the raw body name from the body object.
// Get the raw body name from the body object.

string szBodyName = EVECloudsObject.GetValue("body");

string szBodyName = EVECloudsObject.GetValue("body");
// Check if the body name exists in the celestial body database.

// Check if the body name exists in the celestial body database.
if (Array.IndexOf(szBodyLoaderNames.ToArray(), szBodyName.ToLower()) < 0)
{
// Print the invalid body name (for debug purposes).

if (Array.IndexOf(szBodyLoaderNames.ToArray(), szBodyName.ToLower()) < 0)
if (Utilities.IsVerboseDebugEnabled)
{
// Print the invalid body name (for debug purposes).

if (Utilities.IsVerboseDebugEnabled)
{
Notification.Logger(Constants.AssemblyName, "Warning",
string.Format("Incompatible {0} body detected (name: {1})!", szEVENodeToCheck,
szBodyName));
}

// Remove the invalid EVE configuration file from the
// GameDatabase.
//
// Note: this actually removes the offending ConfigNode
// **completely** from the GameDatabase (and so from the
// actual .cfg file).
//
// Will need to find a better solution for this in the
// future but for now this will do the job just fine.

EVENode.ClearNodes();
Notification.Logger(Constants.AssemblyName, "Warning",
string.Format("Incompatible {0} body detected (name: {1})!", szEVENodeToCheck,
szBodyName));
}

// Remove the invalid EVE configuration file from the
// GameDatabase.
//
// Note: this actually removes the offending ConfigNode
// **completely** from the GameDatabase (and so from the
// actual .cfg file).
//
// Will need to find a better solution for this in the
// future but for now this will do the job just fine.

EVENode.ClearNodes();
}
}
}

// Increment the EVE node counter.
// Increment the EVE node counter.

nEVENodeCount++;
}
nEVENodeCount++;
}

// Return the number of EVE configuration files found (default: zero).
Expand Down Expand Up @@ -123,7 +121,7 @@ public static void GetValidateConfig(List<string> szBodyLoaderNames)
if (nEVENodesFound == 0)
{
Notification.Logger(Constants.AssemblyName, "Warning",
string.Format("No {0} configuration files found!", szEVENodeToCheck));
$"No {szEVENodeToCheck} configuration files found!");
}
else
{
Expand All @@ -132,8 +130,7 @@ public static void GetValidateConfig(List<string> szBodyLoaderNames)
if (Utilities.IsVerboseDebugEnabled)
{
Notification.Logger(Constants.AssemblyName, null,
string.Format("{0} configuration file found (count: {1})!", szEVENodeToCheck,
nEVENodesFound));
$"{szEVENodeToCheck} configuration file found (count: {nEVENodesFound})!");
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions Source/InstallationCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class InstallChecker : MonoBehaviour
/// <returns>
/// Does not return a value.
/// </returns>
void OnDestroy()
private void OnDestroy()
{
try
{
Expand Down Expand Up @@ -94,28 +94,28 @@ void Start()
// Check if the mod's assembly is placed at the correct location. This will
// also detect duplicate copies because only one can be in the right place.

var BaseAssembly = AssemblyLoader.loadedAssemblies
var baseAssembly = AssemblyLoader.loadedAssemblies
.Where(asm => asm.assembly.GetName().Name.Equals(Assembly.GetExecutingAssembly().GetName().Name))
.Where(asm => asm.url != Constants.AssemblyPath);

if (BaseAssembly.Any())
if (baseAssembly.Any())
{
var BadPaths = BaseAssembly.Select(asm => asm.path).Select(p =>
var badPaths = baseAssembly.Select(asm => asm.path).Select(p =>
Uri.UnescapeDataString(new Uri(Path.GetFullPath(KSPUtil.ApplicationRootPath))
.MakeRelativeUri(new Uri(p)).ToString().Replace('/', Path.DirectorySeparatorChar)));

var BadPathsString = string.Join("\n", BadPaths.ToArray());
var badPathsString = string.Join("\n", badPaths.ToArray());

Notification.Logger(Constants.AssemblyName, "Error",
string.Format("Incorrect installation, bad path(s): {0}", BadPathsString));
$"Incorrect installation, bad path(s): {badPathsString}");

Notification.Dialog("BaseAssemblyChecker",
string.Format("Incorrect {0} Installation", Constants.AssemblyName), "#F0F0F0",
$"Incorrect {Constants.AssemblyName} Installation", "#F0F0F0",
string.Format(
"{0} has been installed incorrectly and will not function properly. All files should be located under the GameData" +
Path.AltDirectorySeparatorChar + Constants.AssemblyName +
"folder. Do not move any files from inside that folder!\n\nIncorrect path(s):\n • {1}",
Constants.AssemblyName, BadPathsString), "#F0F0F0");
Constants.AssemblyName, badPathsString), "#F0F0F0");
}
else
{
Expand Down
8 changes: 4 additions & 4 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
// • Build Number
// • Revision

[assembly: AssemblyVersion("1.7.3.2594")]
[assembly: AssemblyFileVersion("1.7.3.1")]
[assembly: AssemblyInformationalVersion("1.7.3.2594")]
[assembly: AssemblyVersion("1.8.1.2694")]
[assembly: AssemblyFileVersion("1.8.1.1")]
[assembly: AssemblyInformationalVersion("1.8.1.2694")]

// The KSPAssembly attribute can be used to ensure that the plugin assemblies
// are loaded in the correct order.
// This attribute is not currently used but it is included here for completeness.

[assembly: KSPAssembly("RSSVE", 1, 1)]
[assembly: KSPAssembly("RSSVE", 1, 2)]
32 changes: 18 additions & 14 deletions Source/RSSVE.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RSSVE</RootNamespace>
<AssemblyName>RSSVE</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DebugType>pdbonly</DebugType>
Expand All @@ -34,23 +34,27 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>C:\Kerbal Space Program _ RO 173\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\..\Kerbal Space Program 1.8.1 RSSRO\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<Private>False</Private>
</Reference>
<Reference Include="System"/>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>C:\Kerbal Space Program _ RO 173\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
<HintPath>..\..\..\..\..\Kerbal Space Program 1.8.1 RSSRO\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\..\..\Kerbal Space Program 1.8.1 RSSRO\KSP_x64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="EVEConfigCheck.cs"/>
<Compile Include="InstallationCheck.cs"/>
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="Settings.cs"/>
<Compile Include="StartupCheck.cs"/>
<Compile Include="Utilities.cs"/>
<Compile Include="VersionCheck.cs"/>
<Compile Include="EVEConfigCheck.cs" />
<Compile Include="InstallationCheck.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
<Compile Include="StartupCheck.cs" />
<Compile Include="Utilities.cs" />
<Compile Include="VersionCheck.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
20 changes: 9 additions & 11 deletions Source/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,15 @@ public override void OnLoad(ConfigNode node)

// Log some basic information that might be of interest when debugging installations.

if (Utilities.IsVerboseDebugEnabled)
{
Notification.Logger(Constants.AssemblyName, null,
string.Format("{0} config found (count: {1})!", szConfigNodeName, nConfigNodeCount));
Notification.Logger(Constants.AssemblyName, null,
string.Format("City lights enabled: {0}", EnableCityLights));
Notification.Logger(Constants.AssemblyName, null,
string.Format("Cloud shadows enabled: {0}", EnableCloudShadows));
Notification.Logger(Constants.AssemblyName, null,
string.Format("Volumetric clouds enabled: {0}", EnableVolumetricClouds));
}
if (!Utilities.IsVerboseDebugEnabled) return;
Notification.Logger(Constants.AssemblyName, null,
string.Format("{0} config found (count: {1})!", szConfigNodeName, nConfigNodeCount));
Notification.Logger(Constants.AssemblyName, null,
string.Format("City lights enabled: {0}", EnableCityLights));
Notification.Logger(Constants.AssemblyName, null,
string.Format("Cloud shadows enabled: {0}", EnableCloudShadows));
Notification.Logger(Constants.AssemblyName, null,
string.Format("Volumetric clouds enabled: {0}", EnableVolumetricClouds));
}
catch (Exception ExceptionStack)
{
Expand Down
35 changes: 15 additions & 20 deletions Source/StartupCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,57 +24,52 @@ namespace RSSVE
/// Startup system checker. Operates only in the Loading scene.
/// </summary>
[KSPAddon(KSPAddon.Startup.Instantly, true)]
class StartupChecker : MonoBehaviour
internal class StartupChecker : MonoBehaviour
{
/// <summary>
/// Method to start the startup checker.
/// </summary>
void Start()
private void Start()
{
try
{
// Log some basic information that might be of interest when debugging installations.

Notification.Logger(Constants.AssemblyName, null,
string.Format("Assembly location: {0}", Assembly.GetExecutingAssembly().Location));
$"Assembly location: {Assembly.GetExecutingAssembly().Location}");
Notification.Logger(Constants.AssemblyName, null,
string.Format("Assembly version: {0}", Version.GetAssemblyVersion()));
$"Assembly version: {Version.GetAssemblyVersion()}");
Notification.Logger(Constants.AssemblyName, null,
string.Format("Assembly compatible: {0}", CompatibilityChecker.IsCompatible()));
$"Assembly compatible: {CompatibilityChecker.IsCompatible()}");

// The following information fields are only active if the
// "Verbose Logging" option in the KSP settings is enabled.

if (Utilities.IsVerboseDebugEnabled)
{
Notification.Logger(Constants.AssemblyName, null,
string.Format("Using Unity player: {0}", Utilities.GetPlatformType));
$"Using Unity player: {Utilities.GetPlatformType}");
Notification.Logger(Constants.AssemblyName, null,
string.Format("Using renderer: {0}", Utilities.GetGraphicsRenderer));
$"Using renderer: {Utilities.GetGraphicsRenderer}");
Notification.Logger(Constants.AssemblyName, null,
string.Format("Using Maximum Texture Size: {0}", SystemInfo.maxTextureSize));
Notification.Logger(Constants.AssemblyName, null,
string.Format("Supports cubemap textures: {0}", SystemInfo.supportsRenderToCubemap));
$"Using Maximum Texture Size: {SystemInfo.maxTextureSize}");
}

// Check if the graphics accelerator installed supports at
// least the 8K texture size required by the RSSVE assets.

if (SystemInfo.maxTextureSize < 8192 && !SystemInfo.supportsRenderToCubemap)
{
Notification.Dialog("TextureChecker", "Unsupported Graphics Accelerator", "#F0F0F0",
string.Format("{0} is not supported by the current graphics accelerator installed.",
Constants.AssemblyName), "#F0F0F0");
if (SystemInfo.maxTextureSize >= 8192) return;
Notification.Dialog("TextureChecker", "Unsupported Graphics Accelerator", "#F0F0F0",
$"{Constants.AssemblyName} is not supported by the current graphics accelerator installed.",
"#F0F0F0");

Notification.Logger(Constants.AssemblyName, "Error",
string.Format("Unsupported minimum texture size (using {0})!", SystemInfo.maxTextureSize));
}
Notification.Logger(Constants.AssemblyName, "Error",
$"Unsupported minimum texture size (using {SystemInfo.maxTextureSize})!");
}
catch (Exception ExceptionStack)
{
Notification.Logger(Constants.AssemblyName, "Error",
string.Format("StartupChecker.Start() caught an exception: {0},\n{1}\n", ExceptionStack.Message,
ExceptionStack.StackTrace));
$"StartupChecker.Start() caught an exception: {ExceptionStack.Message},\n{ExceptionStack.StackTrace}\n");
}
finally
{
Expand Down
Loading

0 comments on commit ce23d7e

Please sign in to comment.