summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Installer
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-11-07 16:16:53 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-11-07 16:16:53 -0500
commitba4237f7a3e9672bdeb31f791bba65faf338bc7c (patch)
tree0f532fd11daccd1d99d961325fb8abdb66aba4ab /src/StardewModdingAPI.Installer
parentc69e45bfbaff9b634898c9c6d9a6a05537d99720 (diff)
downloadSMAPI-ba4237f7a3e9672bdeb31f791bba65faf338bc7c.tar.gz
SMAPI-ba4237f7a3e9672bdeb31f791bba65faf338bc7c.tar.bz2
SMAPI-ba4237f7a3e9672bdeb31f791bba65faf338bc7c.zip
group installer's path variables
Diffstat (limited to 'src/StardewModdingAPI.Installer')
-rw-r--r--src/StardewModdingAPI.Installer/InteractiveInstaller.cs31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
index dd2d1bf5..5be9b14c 100644
--- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
+++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
@@ -57,10 +57,13 @@ namespace StardewModdingApi.Installer
Platform platform = this.DetectPlatform();
DirectoryInfo packageDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), platform.ToString()));
DirectoryInfo installDir = this.InteractivelyGetInstallPath(platform);
- string executablePath = Path.Combine(installDir.FullName, platform == Platform.Mono ? "StardewValley.exe" : "Stardew Valley.exe");
- string unixGameLauncherPath = Path.Combine(installDir.FullName, "StardewValley");
- string unixGameLauncherBackupPath = Path.Combine(installDir.FullName, "StardewValley-original");
- string unixSmapiLauncherPath = Path.Combine(installDir.FullName, "StardewModdingAPI");
+ var paths = new
+ {
+ executable = Path.Combine(installDir.FullName, platform == Platform.Mono ? "StardewValley.exe" : "Stardew Valley.exe"),
+ unixSmapiLauncher = Path.Combine(installDir.FullName, "StardewModdingAPI"),
+ unixLauncher = Path.Combine(installDir.FullName, "StardewValley"),
+ unixLauncherBackup = Path.Combine(installDir.FullName, "StardewValley-original")
+ };
this.PrintDebug($"Detected {(platform == Platform.Windows ? "Windows" : "Linux or Mac")} with game in {installDir}.");
@@ -72,7 +75,7 @@ namespace StardewModdingApi.Installer
this.ExitError($"The '{platform}' package directory is missing (should be at {packageDir}).");
return;
}
- if (!File.Exists(executablePath))
+ if (!File.Exists(paths.executable))
{
this.ExitError("The detected game install path doesn't contain a Stardew Valley executable.");
return;
@@ -114,12 +117,12 @@ namespace StardewModdingApi.Installer
case ScriptAction.Uninstall:
{
// restore game launcher
- if (platform == Platform.Mono && File.Exists(unixGameLauncherBackupPath))
+ if (platform == Platform.Mono && File.Exists(paths.unixLauncherBackup))
{
this.PrintDebug("Restoring game launcher...");
- if (File.Exists(unixGameLauncherPath))
- File.Delete(unixGameLauncherPath);
- File.Move(unixGameLauncherBackupPath, unixGameLauncherPath);
+ if (File.Exists(paths.unixLauncher))
+ File.Delete(paths.unixLauncher);
+ File.Move(paths.unixLauncherBackup, paths.unixLauncher);
}
// remove SMAPI files
@@ -149,12 +152,12 @@ namespace StardewModdingApi.Installer
if (platform == Platform.Mono)
{
this.PrintDebug("Safely replacing game launcher...");
- if (!File.Exists(unixGameLauncherBackupPath))
- File.Move(unixGameLauncherPath, unixGameLauncherBackupPath);
- else if (File.Exists(unixGameLauncherPath))
- File.Delete(unixGameLauncherPath);
+ if (!File.Exists(paths.unixLauncherBackup))
+ File.Move(paths.unixLauncher, paths.unixLauncherBackup);
+ else if (File.Exists(paths.unixLauncher))
+ File.Delete(paths.unixLauncher);
- File.Move(unixSmapiLauncherPath, unixGameLauncherPath);
+ File.Move(paths.unixSmapiLauncher, paths.unixLauncher);
}
// create mods directory (if needed)