diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-13 23:47:24 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-13 23:47:24 -0400 |
commit | 45f4f85b7e74e0cffd345310d6aabc95c12dac26 (patch) | |
tree | 902b7a796d84060aeb9981d8b12bcd864237437e /src/SMAPI.Installer | |
parent | 504733dec7d629335b83841af38cd5da91d5231f (diff) | |
download | SMAPI-45f4f85b7e74e0cffd345310d6aabc95c12dac26.tar.gz SMAPI-45f4f85b7e74e0cffd345310d6aabc95c12dac26.tar.bz2 SMAPI-45f4f85b7e74e0cffd345310d6aabc95c12dac26.zip |
add MacOS detection
Diffstat (limited to 'src/SMAPI.Installer')
-rw-r--r-- | src/SMAPI.Installer/Enums/Platform.cs | 12 | ||||
-rw-r--r-- | src/SMAPI.Installer/InteractiveInstaller.cs | 28 | ||||
-rw-r--r-- | src/SMAPI.Installer/StardewModdingAPI.Installer.csproj | 1 |
3 files changed, 7 insertions, 34 deletions
diff --git a/src/SMAPI.Installer/Enums/Platform.cs b/src/SMAPI.Installer/Enums/Platform.cs deleted file mode 100644 index 9bcaa3c3..00000000 --- a/src/SMAPI.Installer/Enums/Platform.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace StardewModdingApi.Installer.Enums -{ - /// <summary>The game's platform version.</summary> - internal enum Platform - { - /// <summary>The Linux/Mac version of the game.</summary> - Mono, - - /// <summary>The Windows version of the game.</summary> - Windows - } -}
\ No newline at end of file diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index b7e698ad..01076573 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -27,7 +27,8 @@ namespace StardewModdingApi.Installer { switch (platform) { - case Platform.Mono: + case Platform.Linux: + case Platform.Mac: { string home = Environment.GetEnvironmentVariable("HOME"); @@ -140,7 +141,7 @@ namespace StardewModdingApi.Installer /**** ** Get platform & set window title ****/ - Platform platform = this.DetectPlatform(); + Platform platform = EnvironmentUtility.DetectPlatform(); Console.Title = $"SMAPI {new SemanticVersionImpl(this.GetType().Assembly.GetName().Version)} installer on {platform}"; Console.WriteLine(); @@ -182,7 +183,7 @@ namespace StardewModdingApi.Installer DirectoryInfo modsDir = new DirectoryInfo(Path.Combine(installDir.FullName, "Mods")); var paths = new { - executable = Path.Combine(installDir.FullName, platform == Platform.Mono ? "StardewValley.exe" : "Stardew Valley.exe"), + executable = Path.Combine(installDir.FullName, platform == Platform.Windows ? "Stardew Valley.exe" : "StardewValley.exe"), unixSmapiLauncher = Path.Combine(installDir.FullName, "StardewModdingAPI"), unixLauncher = Path.Combine(installDir.FullName, "StardewValley"), unixLauncherBackup = Path.Combine(installDir.FullName, "StardewValley-original") @@ -271,7 +272,7 @@ namespace StardewModdingApi.Installer ** Always uninstall old files ****/ // restore game launcher - if (platform == Platform.Mono && File.Exists(paths.unixLauncherBackup)) + if ((platform == Platform.Linux || platform == Platform.Mac) && File.Exists(paths.unixLauncherBackup)) { this.PrintDebug("Removing SMAPI launcher..."); this.InteractivelyDelete(paths.unixLauncher); @@ -304,7 +305,7 @@ namespace StardewModdingApi.Installer } // replace mod launcher (if possible) - if (platform == Platform.Mono) + if (platform == Platform.Linux || platform == Platform.Mac) { this.PrintDebug("Safely replacing game launcher..."); if (!File.Exists(paths.unixLauncherBackup)) @@ -379,21 +380,6 @@ namespace StardewModdingApi.Installer /********* ** Private methods *********/ - /// <summary>Detect the game's platform.</summary> - /// <exception cref="NotSupportedException">The platform is not supported.</exception> - private Platform DetectPlatform() - { - switch (Environment.OSVersion.Platform) - { - case PlatformID.MacOSX: - case PlatformID.Unix: - return Platform.Mono; - - default: - return Platform.Windows; - } - } - /// <summary>Test whether the current console supports color formatting.</summary> private static bool GetConsoleSupportsColor() { @@ -635,7 +621,7 @@ namespace StardewModdingApi.Installer // normalise path if (platform == Platform.Windows) path = path.Replace("\"", ""); // in Windows, quotes are used to escape spaces and aren't part of the file path - if (platform == Platform.Mono) + if (platform == Platform.Linux || platform == Platform.Mac) path = path.Replace("\\ ", " "); // in Linux/Mac, spaces in paths may be escaped if copied from the command line if (path.StartsWith("~/")) { diff --git a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj index a575e06f..7a71bef9 100644 --- a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj +++ b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj @@ -40,7 +40,6 @@ <Link>Properties\GlobalAssemblyInfo.cs</Link> </Compile> <Compile Include="Enums\ScriptAction.cs" /> - <Compile Include="Enums\Platform.cs" /> <Compile Include="InteractiveInstaller.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> |