From a96bfea205ab855913726cad58d63191fbf24399 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 25 Jan 2020 18:37:17 -0500 Subject: back up config.user.json when installing (#693) --- src/SMAPI.Installer/Framework/InstallerPaths.cs | 18 ++++++++++++++++++ src/SMAPI.Installer/InteractiveInstaller.cs | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/SMAPI.Installer/Framework/InstallerPaths.cs b/src/SMAPI.Installer/Framework/InstallerPaths.cs index 9393e14f..ac6c3a8e 100644 --- a/src/SMAPI.Installer/Framework/InstallerPaths.cs +++ b/src/SMAPI.Installer/Framework/InstallerPaths.cs @@ -8,6 +8,9 @@ namespace StardewModdingAPI.Installer.Framework /********* ** Accessors *********/ + /**** + ** Main folders + ****/ /// The directory path containing the files to copy into the game folder. public DirectoryInfo BundleDir { get; } @@ -17,9 +20,18 @@ namespace StardewModdingAPI.Installer.Framework /// The directory into which to install mods. public DirectoryInfo ModsDir { get; } + /**** + ** Installer paths + ****/ /// The full path to directory path containing the files to copy into the game folder. public string BundlePath => this.BundleDir.FullName; + /// The full path to the backup API user settings folder, if applicable. + public string BundleApiUserConfigPath { get; } + + /**** + ** Game paths + ****/ /// The full path to the directory containing the installed game. public string GamePath => this.GameDir.FullName; @@ -29,6 +41,9 @@ namespace StardewModdingAPI.Installer.Framework /// The full path to SMAPI's internal configuration file. public string ApiConfigPath { get; } + /// The full path to the user's config overrides file. + public string ApiUserConfigPath { get; } + /// The full path to the installed SMAPI executable file. public string ExecutablePath { get; } @@ -55,11 +70,14 @@ namespace StardewModdingAPI.Installer.Framework this.GameDir = gameDir; this.ModsDir = new DirectoryInfo(Path.Combine(gameDir.FullName, "Mods")); + this.BundleApiUserConfigPath = Path.Combine(bundleDir.FullName, "smapi-internal", "config.user.json"); + this.ExecutablePath = Path.Combine(gameDir.FullName, gameExecutableName); this.UnixLauncherPath = Path.Combine(gameDir.FullName, "StardewValley"); this.UnixSmapiLauncherPath = Path.Combine(gameDir.FullName, "StardewModdingAPI"); this.UnixBackupLauncherPath = Path.Combine(gameDir.FullName, "StardewValley-original"); this.ApiConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.json"); + this.ApiUserConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.user.json"); } } } diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 14f37258..2d58baf0 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -351,6 +351,12 @@ namespace StardewModdingApi.Installer this.PrintDebug("----------------------------------------------------------------------------"); Console.WriteLine(); + /**** + ** Back up user settings + ****/ + if (File.Exists(paths.ApiUserConfigPath)) + File.Copy(paths.ApiUserConfigPath, paths.BundleApiUserConfigPath); + /**** ** Always uninstall old files ****/ -- cgit