summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/StardewModdingAPI/Program.cs19
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.csproj1
2 files changed, 19 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index ebeefe96..360f75f0 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -4,6 +4,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Management;
using System.Reflection;
using System.Threading;
#if SMAPI_FOR_WINDOWS
@@ -87,7 +88,7 @@ namespace StardewModdingAPI
{
// initialise logging
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); // for consistent log formatting
- this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {Environment.OSVersion}", LogLevel.Info);
+ this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {this.GetFriendlyPlatformName()}", LogLevel.Info);
Console.Title = $"SMAPI {Constants.ApiVersion} - running Stardew Valley {Constants.GameVersion}";
// inject compatibility shims
@@ -582,5 +583,21 @@ namespace StardewModdingAPI
{
return new Monitor(name, this.ConsoleManager, this.LogFile, this.ExitGameImmediately) { WriteToConsole = this.Monitor.WriteToConsole, ShowTraceInConsole = this.Settings.DeveloperMode };
}
+
+ /// <summary>Get a human-readable name for the current platform.</summary>
+ private string GetFriendlyPlatformName()
+ {
+ try
+ {
+ return (
+ from entry in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast<ManagementObject>()
+ select entry.GetPropertyValue("Caption").ToString()
+ ).FirstOrDefault();
+ }
+ catch
+ {
+ return Environment.OSVersion.ToString();
+ }
+ }
}
}
diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj
index 9b86adac..2340a431 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.csproj
+++ b/src/StardewModdingAPI/StardewModdingAPI.csproj
@@ -97,6 +97,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
+ <Reference Include="System.Management" />
<Reference Include="System.Numerics">
<Private>True</Private>
</Reference>