diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-18 17:02:34 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-18 17:02:34 -0400 |
commit | def73fceaf2bff12b899d76a862ead6eb0f42199 (patch) | |
tree | 1b0d0186725ed999be29a9ffc03e4ffb66da0fdd /src/StardewModdingAPI.Installer/InteractiveInstaller.cs | |
parent | 1b1f37d082ea9dbea39bc13aade9d5fd8e6c5f7c (diff) | |
download | SMAPI-def73fceaf2bff12b899d76a862ead6eb0f42199.tar.gz SMAPI-def73fceaf2bff12b899d76a862ead6eb0f42199.tar.bz2 SMAPI-def73fceaf2bff12b899d76a862ead6eb0f42199.zip |
improve game install path detection
Diffstat (limited to 'src/StardewModdingAPI.Installer/InteractiveInstaller.cs')
-rw-r--r-- | src/StardewModdingAPI.Installer/InteractiveInstaller.cs | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs index 52294c2e..01f7a01f 100644 --- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs +++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs @@ -27,31 +27,39 @@ namespace StardewModdingApi.Installer switch (platform) { case Platform.Mono: - // Linux - yield return $"{Environment.GetEnvironmentVariable("HOME")}/GOG Games/Stardew Valley/game"; - yield return $"{Environment.GetEnvironmentVariable("HOME")}/.local/share/Steam/steamapps/common/Stardew Valley"; + { + string home = Environment.GetEnvironmentVariable("HOME"); + + // Linux + yield return $"{home}/GOG Games/Stardew Valley/game"; + yield return Directory.Exists($"{home}/.steam/steam/steamapps/common/Stardew Valley") + ? $"{home}/.steam/steam/steamapps/common/Stardew Valley" + : $"{home}/.local/share/Steam/steamapps/common/Stardew Valley"; - // Mac - yield return "/Applications/Stardew Valley.app/Contents/MacOS"; - yield return $"{Environment.GetEnvironmentVariable("HOME")}/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS"; + // Mac + yield return "/Applications/Stardew Valley.app/Contents/MacOS"; + yield return $"{home}/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS"; + } break; case Platform.Windows: - // Windows - yield return @"C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley"; - yield return @"C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley"; - - // Windows registry - IDictionary<string, string> registryKeys = new Dictionary<string, string> - { - [@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150"] = "InstallLocation", // Steam - [@"SOFTWARE\WOW6432Node\GOG.com\Games\1453375253"] = "PATH", // GOG on 64-bit Windows - }; - foreach (var pair in registryKeys) { - string path = this.GetLocalMachineRegistryValue(pair.Key, pair.Value); - if (!string.IsNullOrWhiteSpace(path)) - yield return path; + // Windows + yield return @"C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley"; + yield return @"C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley"; + + // Windows registry + IDictionary<string, string> registryKeys = new Dictionary<string, string> + { + [@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150"] = "InstallLocation", // Steam + [@"SOFTWARE\WOW6432Node\GOG.com\Games\1453375253"] = "PATH", // GOG on 64-bit Windows + }; + foreach (var pair in registryKeys) + { + string path = this.GetLocalMachineRegistryValue(pair.Key, pair.Value); + if (!string.IsNullOrWhiteSpace(path)) + yield return path; + } } break; @@ -510,7 +518,7 @@ namespace StardewModdingApi.Installer // get installed paths DirectoryInfo[] defaultPaths = ( - from path in this.GetDefaultInstallPaths(platform).Distinct() + from path in this.GetDefaultInstallPaths(platform).Distinct(StringComparer.InvariantCultureIgnoreCase) let dir = new DirectoryInfo(path) where dir.Exists && dir.EnumerateFiles(executableFilename).Any() select dir |