From 45f4f85b7e74e0cffd345310d6aabc95c12dac26 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 13 Apr 2018 23:47:24 -0400 Subject: add MacOS detection --- src/SMAPI.Installer/Enums/Platform.cs | 12 ---------- src/SMAPI.Installer/InteractiveInstaller.cs | 28 ++++++---------------- .../StardewModdingAPI.Installer.csproj | 1 - 3 files changed, 7 insertions(+), 34 deletions(-) delete mode 100644 src/SMAPI.Installer/Enums/Platform.cs (limited to 'src/SMAPI.Installer') 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 -{ - /// The game's platform version. - internal enum Platform - { - /// The Linux/Mac version of the game. - Mono, - - /// The Windows version of the game. - 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 *********/ - /// Detect the game's platform. - /// The platform is not supported. - private Platform DetectPlatform() - { - switch (Environment.OSVersion.Platform) - { - case PlatformID.MacOSX: - case PlatformID.Unix: - return Platform.Mono; - - default: - return Platform.Windows; - } - } - /// Test whether the current console supports color formatting. 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 @@ Properties\GlobalAssemblyInfo.cs - -- cgit From 6d269621b28240a0da6de5fd5faa4c35553c15bb Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 14 Apr 2018 00:18:19 -0400 Subject: make crossplatform handling more consistent --- src/SMAPI.Installer/InteractiveInstaller.cs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 01076573..0d602b57 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -142,7 +142,7 @@ namespace StardewModdingApi.Installer ** Get platform & set window title ****/ Platform platform = EnvironmentUtility.DetectPlatform(); - Console.Title = $"SMAPI {new SemanticVersionImpl(this.GetType().Assembly.GetName().Version)} installer on {platform}"; + Console.Title = $"SMAPI {new SemanticVersionImpl(this.GetType().Assembly.GetName().Version)} installer on {platform} {EnvironmentUtility.GetFriendlyPlatformName(platform)}"; Console.WriteLine(); /**** @@ -179,11 +179,11 @@ namespace StardewModdingApi.Installer } // get folders - DirectoryInfo packageDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "internal", platform.ToString())); + DirectoryInfo packageDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "internal", platform.IsMono() ? "Mono" : "Windows")); DirectoryInfo modsDir = new DirectoryInfo(Path.Combine(installDir.FullName, "Mods")); var paths = new { - executable = Path.Combine(installDir.FullName, platform == Platform.Windows ? "Stardew Valley.exe" : "StardewValley.exe"), + executable = Path.Combine(installDir.FullName, EnvironmentUtility.GetExecutableName(platform)), unixSmapiLauncher = Path.Combine(installDir.FullName, "StardewModdingAPI"), unixLauncher = Path.Combine(installDir.FullName, "StardewValley"), unixLauncherBackup = Path.Combine(installDir.FullName, "StardewValley-original") @@ -199,7 +199,7 @@ namespace StardewModdingApi.Installer { this.PrintError(platform == Platform.Windows && packageDir.FullName.Contains(Path.GetTempPath()) && packageDir.FullName.Contains(".zip") ? "The installer is missing some files. It looks like you're running the installer from inside the downloaded zip; make sure you unzip the downloaded file first, then run the installer from the unzipped folder." - : $"The 'internal/{platform}' package folder is missing (should be at {packageDir})." + : $"The 'internal/{packageDir.Name}' package folder is missing (should be at {packageDir})." ); Console.ReadLine(); return; @@ -272,7 +272,7 @@ namespace StardewModdingApi.Installer ** Always uninstall old files ****/ // restore game launcher - if ((platform == Platform.Linux || platform == Platform.Mac) && File.Exists(paths.unixLauncherBackup)) + if (platform.IsMono() && File.Exists(paths.unixLauncherBackup)) { this.PrintDebug("Removing SMAPI launcher..."); this.InteractivelyDelete(paths.unixLauncher); @@ -305,7 +305,7 @@ namespace StardewModdingApi.Installer } // replace mod launcher (if possible) - if (platform == Platform.Linux || platform == Platform.Mac) + if (platform.IsMono()) { this.PrintDebug("Safely replacing game launcher..."); if (!File.Exists(paths.unixLauncherBackup)) @@ -554,9 +554,7 @@ namespace StardewModdingApi.Installer private DirectoryInfo InteractivelyGetInstallPath(Platform platform, string specifiedPath) { // get executable name - string executableFilename = platform == Platform.Windows - ? "Stardew Valley.exe" - : "StardewValley.exe"; + string executableFilename = EnvironmentUtility.GetExecutableName(platform); // validate specified path if (specifiedPath != null) @@ -662,10 +660,7 @@ namespace StardewModdingApi.Installer string[] packagedModNames = packagedModsDir.GetDirectories().Select(p => p.Name).ToArray(); // get path - string homePath = platform == Platform.Windows - ? Environment.GetEnvironmentVariable("APPDATA") - : Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config"); - string appDataPath = Path.Combine(homePath, "StardewValley"); + string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley"); DirectoryInfo modDir = new DirectoryInfo(Path.Combine(appDataPath, "Mods")); // check if migration needed -- cgit From 6257fdf57def0f07a7970f9fb232879ed4c524f6 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 28 Apr 2018 22:39:29 -0400 Subject: update wiki links --- src/SMAPI.Installer/readme.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/readme.txt b/src/SMAPI.Installer/readme.txt index a03ad6a4..12053a8c 100644 --- a/src/SMAPI.Installer/readme.txt +++ b/src/SMAPI.Installer/readme.txt @@ -14,15 +14,9 @@ SMAPI lets you run Stardew Valley with mods. Don't forget to download mods separately. -Install guide +Player's guide -------------------------------- -See http://stardewvalleywiki.com/Modding:Installing_SMAPI. - - -Need help? --------------------------------- -- FAQs: http://stardewvalleywiki.com/Modding:Player_FAQs -- Ask for help: https://discord.gg/kH55QXP +See https://stardewvalleywiki.com/Modding:Player_Guide. Manual install -- cgit From 009a387526ee10b18d0ed3030d6e8868edf17203 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 1 May 2018 18:44:39 -0400 Subject: unify SMAPI.AssemblyRewriters and SMAPI.Common projects --- src/SMAPI.Installer/InteractiveInstaller.cs | 5 +++-- src/SMAPI.Installer/StardewModdingAPI.Installer.csproj | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 0d602b57..c0bc8f2c 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -7,7 +7,7 @@ using System.Reflection; using System.Threading; using Microsoft.Win32; using StardewModdingApi.Installer.Enums; -using StardewModdingAPI.Common; +using StardewModdingAPI.Internal; namespace StardewModdingApi.Installer { @@ -83,7 +83,7 @@ namespace StardewModdingApi.Installer yield return GetInstallPath("StardewModdingAPI.exe"); yield return GetInstallPath("StardewModdingAPI.config.json"); yield return GetInstallPath("StardewModdingAPI.data.json"); - yield return GetInstallPath("StardewModdingAPI.AssemblyRewriters.dll"); + yield return GetInstallPath("StardewModdingAPI.Internal.dll"); yield return GetInstallPath("System.ValueTuple.dll"); yield return GetInstallPath("steam_appid.txt"); @@ -102,6 +102,7 @@ namespace StardewModdingApi.Installer yield return GetInstallPath(Path.Combine("Mods", "TrainerMod")); // *–2.0 (renamed to ConsoleCommands) yield return GetInstallPath("Mono.Cecil.Rocks.dll"); // 1.3–1.8 yield return GetInstallPath("StardewModdingAPI-settings.json"); // 1.0-1.4 + yield return GetInstallPath("StardewModdingAPI.AssemblyRewriters.dll"); // 1.3-2.5.5 if (modsDir.Exists) { foreach (DirectoryInfo modDir in modsDir.EnumerateDirectories()) diff --git a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj index 7a71bef9..4f849b9b 100644 --- a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj +++ b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj @@ -9,7 +9,7 @@ Properties StardewModdingAPI.Installer StardewModdingAPI.Installer - v4.0 + v4.5 512 true @@ -57,7 +57,12 @@ PreserveNewest - + + + {10db0676-9fc1-4771-a2c8-e2519f091e49} + StardewModdingAPI.Internal + + -- cgit From b3e8f957e27839a1392b63689e7daf03862540c4 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 2 May 2018 21:04:46 -0400 Subject: reorganise to avoid errors deploying web app, fix WMI error in Linux installer --- src/SMAPI.Installer/StardewModdingAPI.Installer.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj index 4f849b9b..dd349e09 100644 --- a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj +++ b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj @@ -64,6 +64,7 @@ - + + \ No newline at end of file -- cgit From ff55901025365a342e0794df86f6122603e614c8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 2 May 2018 21:51:06 -0400 Subject: compile separate Linux/Mac installer to avoid WMI reference errors (#485) --- src/SMAPI.Installer/InteractiveInstaller.cs | 12 ++++++++++-- src/SMAPI.Installer/unix-install.sh | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index c0bc8f2c..3ce71673 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -17,6 +17,9 @@ namespace StardewModdingApi.Installer /********* ** Properties *********/ + /// The name of the installer file in the package. + private readonly string InstallerFileName = "install.exe"; + /// The value that represents Windows 7. private readonly Version Windows7Version = new Version(6, 1); @@ -82,7 +85,7 @@ namespace StardewModdingApi.Installer yield return GetInstallPath("Newtonsoft.Json.dll"); yield return GetInstallPath("StardewModdingAPI.exe"); yield return GetInstallPath("StardewModdingAPI.config.json"); - yield return GetInstallPath("StardewModdingAPI.data.json"); + yield return GetInstallPath("StardewModdingAPI.metadata.json"); yield return GetInstallPath("StardewModdingAPI.Internal.dll"); yield return GetInstallPath("System.ValueTuple.dll"); yield return GetInstallPath("steam_appid.txt"); @@ -180,7 +183,9 @@ namespace StardewModdingApi.Installer } // get folders - DirectoryInfo packageDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "internal", platform.IsMono() ? "Mono" : "Windows")); + DirectoryInfo packageDir = platform.IsMono() + ? new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) // installer runs from internal folder on Mono + : new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "internal", "Windows")); DirectoryInfo modsDir = new DirectoryInfo(Path.Combine(installDir.FullName, "Mods")); var paths = new { @@ -300,6 +305,9 @@ namespace StardewModdingApi.Installer this.PrintDebug("Adding SMAPI files..."); foreach (FileInfo sourceFile in packageDir.EnumerateFiles().Where(this.ShouldCopyFile)) { + if (sourceFile.Name == this.InstallerFileName) + continue; + string targetPath = Path.Combine(installDir.FullName, sourceFile.Name); this.InteractivelyDelete(targetPath); sourceFile.CopyTo(targetPath); diff --git a/src/SMAPI.Installer/unix-install.sh b/src/SMAPI.Installer/unix-install.sh index a0bd9346..df02bb37 100644 --- a/src/SMAPI.Installer/unix-install.sh +++ b/src/SMAPI.Installer/unix-install.sh @@ -14,7 +14,7 @@ fi # validate Mono & run installer if $COMMAND mono >/dev/null 2>&1; then - mono install.exe + mono internal/Mono/install.exe else echo "Oops! Looks like Mono isn't installed. Please install Mono from http://mono-project.com, reboot, and run this installer again." read -- cgit From 60040854a3b95ab220a42c087bda7f9011dda8ca Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 3 May 2018 01:38:08 -0400 Subject: switch back to shared project due to installer issues --- src/SMAPI.Installer/StardewModdingAPI.Installer.csproj | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj index dd349e09..2ad7e82a 100644 --- a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj +++ b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj @@ -57,14 +57,8 @@ PreserveNewest - - - {10db0676-9fc1-4771-a2c8-e2519f091e49} - StardewModdingAPI.Internal - - + - - + \ No newline at end of file -- cgit From a65a49a62201cc897e73c265a0a808ef0baad002 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 4 May 2018 20:54:15 -0400 Subject: fix install error on Linux/Mac in some cases --- src/SMAPI.Installer/InteractiveInstaller.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 3ce71673..2b9dd95e 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -233,7 +233,7 @@ namespace StardewModdingApi.Installer Console.ReadLine(); return; } - if (!this.HasXNA(platform)) + if (!this.HasXna(platform)) { this.PrintError("You don't seem to have XNA Framework installed. Please run the game at least once before installing SMAPI, so it can perform its first-time setup."); Console.ReadLine(); @@ -317,10 +317,13 @@ namespace StardewModdingApi.Installer if (platform.IsMono()) { this.PrintDebug("Safely replacing game launcher..."); - if (!File.Exists(paths.unixLauncherBackup)) - File.Move(paths.unixLauncher, paths.unixLauncherBackup); - else if (File.Exists(paths.unixLauncher)) - this.InteractivelyDelete(paths.unixLauncher); + if (File.Exists(paths.unixLauncher)) + { + if (!File.Exists(paths.unixLauncherBackup)) + File.Move(paths.unixLauncher, paths.unixLauncherBackup); + else + this.InteractivelyDelete(paths.unixLauncher); + } File.Move(paths.unixSmapiLauncher, paths.unixLauncher); } @@ -471,7 +474,7 @@ namespace StardewModdingApi.Installer /// Get whether the current system has XNA Framework installed. This only applies on Windows. /// The current platform. /// The current platform is not Windows. - private bool HasXNA(Platform platform) + private bool HasXna(Platform platform) { switch (platform) { @@ -514,8 +517,7 @@ namespace StardewModdingApi.Installer return; // delete children - var folder = entry as DirectoryInfo; - if (folder != null) + if (entry is DirectoryInfo folder) { foreach (FileSystemInfo child in folder.GetFileSystemInfos()) this.ForceDelete(child); -- cgit From 52a0231defb5bc65a4b2431610998045e0c98da6 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 6 May 2018 23:31:24 -0400 Subject: add error when running Windows installer on Linux/Mac --- src/SMAPI.Installer/InteractiveInstaller.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 2b9dd95e..b4ed2c92 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -149,6 +149,15 @@ namespace StardewModdingApi.Installer Console.Title = $"SMAPI {new SemanticVersionImpl(this.GetType().Assembly.GetName().Version)} installer on {platform} {EnvironmentUtility.GetFriendlyPlatformName(platform)}"; Console.WriteLine(); +#if SMAPI_FOR_WINDOWS + if (platform == Platform.Linux || platform == Platform.Mac) + { + this.PrintError($"This is the installer for Windows. Run the 'install on {platform}.{(platform == Platform.Linux ? "sh" : "command")}' file instead."); + Console.ReadLine(); + return; + } +#endif + /**** ** read command-line arguments ****/ -- cgit From 995a6fcca4a64d414d93e442419b31c89a2ce20f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 10 May 2018 00:49:29 -0400 Subject: use SMAPI's console color scheme logic in installer too (#495) --- src/SMAPI.Installer/InteractiveInstaller.cs | 78 +++++++++-------------------- 1 file changed, 25 insertions(+), 53 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index b4ed2c92..5249355b 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -8,6 +8,7 @@ using System.Threading; using Microsoft.Win32; using StardewModdingApi.Installer.Enums; using StardewModdingAPI.Internal; +using StardewModdingAPI.Internal.ConsoleWriting; namespace StardewModdingApi.Installer { @@ -114,13 +115,19 @@ namespace StardewModdingApi.Installer yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "ErrorLogs"); // remove old log files } - /// Whether the current console supports color formatting. - private static readonly bool ConsoleSupportsColor = InteractiveInstaller.GetConsoleSupportsColor(); + /// Handles writing color-coded text to the console. + private readonly ColorfulConsoleWriter ConsoleWriter; /********* ** Public methods *********/ + /// Construct an instance. + public InteractiveInstaller() + { + this.ConsoleWriter = new ColorfulConsoleWriter(EnvironmentUtility.DetectPlatform(), MonitorColorScheme.AutoDetect); + } + /// Run the install or uninstall script. /// The command line arguments. /// @@ -366,7 +373,7 @@ namespace StardewModdingApi.Installer } // remove obsolete appdata mods - this.InteractivelyRemoveAppDataMods(platform, modsDir, packagedModsDir); + this.InteractivelyRemoveAppDataMods(modsDir, packagedModsDir); } Console.WriteLine(); Console.WriteLine(); @@ -378,20 +385,20 @@ namespace StardewModdingApi.Installer { if (action == ScriptAction.Install) { - this.PrintColor("SMAPI is installed! If you use Steam, set your launch options to enable achievements (see smapi.io/install):", ConsoleColor.DarkGreen); - this.PrintColor($" \"{Path.Combine(installDir.FullName, "StardewModdingAPI.exe")}\" %command%", ConsoleColor.DarkGreen); + this.PrintSuccess("SMAPI is installed! If you use Steam, set your launch options to enable achievements (see smapi.io/install):"); + this.PrintSuccess($" \"{Path.Combine(installDir.FullName, "StardewModdingAPI.exe")}\" %command%"); Console.WriteLine(); - this.PrintColor("If you don't use Steam, launch StardewModdingAPI.exe in your game folder to play with mods.", ConsoleColor.DarkGreen); + this.PrintSuccess("If you don't use Steam, launch StardewModdingAPI.exe in your game folder to play with mods."); } else - this.PrintColor("SMAPI is removed! If you configured Steam to launch SMAPI, don't forget to clear your launch options.", ConsoleColor.DarkGreen); + this.PrintSuccess("SMAPI is removed! If you configured Steam to launch SMAPI, don't forget to clear your launch options."); } else { - if (action == ScriptAction.Install) - this.PrintColor("SMAPI is installed! Launch the game the same way as before to play with mods.", ConsoleColor.DarkGreen); - else - this.PrintColor("SMAPI is removed! Launch the game the same way as before to play without mods.", ConsoleColor.DarkGreen); + this.PrintSuccess(action == ScriptAction.Install + ? "SMAPI is installed! Launch the game the same way as before to play with mods." + : "SMAPI is removed! Launch the game the same way as before to play without mods." + ); } Console.ReadKey(); @@ -401,20 +408,6 @@ namespace StardewModdingApi.Installer /********* ** Private methods *********/ - /// Test whether the current console supports color formatting. - private static bool GetConsoleSupportsColor() - { - try - { - Console.ForegroundColor = Console.ForegroundColor; - return true; - } - catch (Exception) - { - return false; // Mono bug - } - } - /// Get the value of a key in the Windows registry. /// The full path of the registry key relative to HKLM. /// The name of the value. @@ -430,39 +423,19 @@ namespace StardewModdingApi.Installer /// Print a debug message. /// The text to print. - private void PrintDebug(string text) - { - this.PrintColor(text, ConsoleColor.DarkGray); - } + private void PrintDebug(string text) => this.ConsoleWriter.WriteLine(text, ConsoleLogLevel.Debug); /// Print a warning message. /// The text to print. - private void PrintWarning(string text) - { - this.PrintColor(text, ConsoleColor.DarkYellow); - } + private void PrintWarning(string text) => this.ConsoleWriter.WriteLine(text, ConsoleLogLevel.Warn); /// Print a warning message. /// The text to print. - private void PrintError(string text) - { - this.PrintColor(text, ConsoleColor.Red); - } + private void PrintError(string text) => this.ConsoleWriter.WriteLine(text, ConsoleLogLevel.Error); - /// Print a message to the console. - /// The message text. - /// The text foreground color. - private void PrintColor(string text, ConsoleColor color) - { - if (InteractiveInstaller.ConsoleSupportsColor) - { - Console.ForegroundColor = color; - Console.WriteLine(text); - Console.ResetColor(); - } - else - Console.WriteLine(text); - } + /// Print a success message. + /// The text to print. + private void PrintSuccess(string text) => this.ConsoleWriter.WriteLine(text, ConsoleLogLevel.Success); /// Get whether the current system has .NET Framework 4.5 or later installed. This only applies on Windows. /// The current platform. @@ -671,10 +644,9 @@ namespace StardewModdingApi.Installer } /// Interactively move mods out of the appdata directory. - /// The current platform. /// The directory which should contain all mods. /// The installer directory containing packaged mods. - private void InteractivelyRemoveAppDataMods(Platform platform, DirectoryInfo properModsDir, DirectoryInfo packagedModsDir) + private void InteractivelyRemoveAppDataMods(DirectoryInfo properModsDir, DirectoryInfo packagedModsDir) { // get packaged mods to delete string[] packagedModNames = packagedModsDir.GetDirectories().Select(p => p.Name).ToArray(); -- cgit From f83a3bf7a44b41efd1c4b8d1426400b94668deae Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 10 May 2018 00:56:08 -0400 Subject: fix references to removed file --- src/SMAPI.Installer/InteractiveInstaller.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 5249355b..64dcc00e 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -87,7 +87,6 @@ namespace StardewModdingApi.Installer yield return GetInstallPath("StardewModdingAPI.exe"); yield return GetInstallPath("StardewModdingAPI.config.json"); yield return GetInstallPath("StardewModdingAPI.metadata.json"); - yield return GetInstallPath("StardewModdingAPI.Internal.dll"); yield return GetInstallPath("System.ValueTuple.dll"); yield return GetInstallPath("steam_appid.txt"); -- cgit From c05836040a7145c56f6af2dbc8fe4722efdf79c9 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 10 May 2018 01:13:10 -0400 Subject: fix some installer messages not using color scheme (#495) --- src/SMAPI.Installer/InteractiveInstaller.cs | 32 ++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 64dcc00e..ba7a143c 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -211,7 +211,7 @@ namespace StardewModdingApi.Installer }; // show output - Console.WriteLine($"Your game folder: {installDir}."); + this.PrintInfo($"Your game folder: {installDir}."); /**** ** validate assumptions @@ -269,9 +269,9 @@ namespace StardewModdingApi.Installer action = ScriptAction.Uninstall; else { - Console.WriteLine("You can...."); - Console.WriteLine("[1] Install SMAPI."); - Console.WriteLine("[2] Uninstall SMAPI."); + this.PrintInfo("You can...."); + this.PrintInfo("[1] Install SMAPI."); + this.PrintInfo("[2] Uninstall SMAPI."); Console.WriteLine(); string choice = this.InteractivelyChoose("What do you want to do? Type 1 or 2, then press enter.", "1", "2"); @@ -424,6 +424,10 @@ namespace StardewModdingApi.Installer /// The text to print. private void PrintDebug(string text) => this.ConsoleWriter.WriteLine(text, ConsoleLogLevel.Debug); + /// Print a debug message. + /// The text to print. + private void PrintInfo(string text) => this.ConsoleWriter.WriteLine(text, ConsoleLogLevel.Info); + /// Print a warning message. /// The text to print. private void PrintWarning(string text) => this.ConsoleWriter.WriteLine(text, ConsoleLogLevel.Warn); @@ -529,11 +533,11 @@ namespace StardewModdingApi.Installer { while (true) { - Console.WriteLine(message); + this.PrintInfo(message); string input = Console.ReadLine()?.Trim().ToLowerInvariant(); if (!options.Contains(input)) { - Console.WriteLine("That's not a valid option."); + this.PrintInfo("That's not a valid option."); continue; } return input; @@ -584,9 +588,9 @@ namespace StardewModdingApi.Installer // let user choose path Console.WriteLine(); - Console.WriteLine("Found multiple copies of the game:"); + this.PrintInfo("Found multiple copies of the game:"); for (int i = 0; i < defaultPaths.Length; i++) - Console.WriteLine($"[{i + 1}] {defaultPaths[i].FullName}"); + this.PrintInfo($"[{i + 1}] {defaultPaths[i].FullName}"); Console.WriteLine(); string[] validOptions = Enumerable.Range(1, defaultPaths.Length).Select(p => p.ToString(CultureInfo.InvariantCulture)).ToArray(); @@ -596,15 +600,15 @@ namespace StardewModdingApi.Installer } // ask user - Console.WriteLine("Oops, couldn't find the game automatically."); + this.PrintInfo("Oops, couldn't find the game automatically."); while (true) { // get path from user - Console.WriteLine($"Type the file path to the game directory (the one containing '{executableFilename}'), then press enter."); + this.PrintInfo($"Type the file path to the game directory (the one containing '{executableFilename}'), then press enter."); string path = Console.ReadLine()?.Trim(); if (string.IsNullOrWhiteSpace(path)) { - Console.WriteLine(" You must specify a directory path to continue."); + this.PrintInfo(" You must specify a directory path to continue."); continue; } @@ -627,17 +631,17 @@ namespace StardewModdingApi.Installer // validate path if (!directory.Exists) { - Console.WriteLine(" That directory doesn't seem to exist."); + this.PrintInfo(" That directory doesn't seem to exist."); continue; } if (!directory.EnumerateFiles(executableFilename).Any()) { - Console.WriteLine(" That directory doesn't contain a Stardew Valley executable."); + this.PrintInfo(" That directory doesn't contain a Stardew Valley executable."); continue; } // looks OK - Console.WriteLine(" OK!"); + this.PrintInfo(" OK!"); return directory; } } -- cgit From 75af88cf0d09b0ebc9275968c9e5abd3ea179ea6 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 16 May 2018 01:45:02 -0400 Subject: fix installer deleting Omegasis' SaveBackup mod (#513) --- src/SMAPI.Installer/InteractiveInstaller.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index ba7a143c..4d9bc984 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -351,11 +351,25 @@ namespace StardewModdingApi.Installer } // add or replace bundled mods - Directory.CreateDirectory(Path.Combine(installDir.FullName, "Mods")); + modsDir.Create(); DirectoryInfo packagedModsDir = new DirectoryInfo(Path.Combine(packageDir.FullName, "Mods")); if (packagedModsDir.Exists && packagedModsDir.EnumerateDirectories().Any()) { this.PrintDebug("Adding bundled mods..."); + + // special case: rename Omegasis' SaveBackup mod + { + DirectoryInfo oldFolder = new DirectoryInfo(Path.Combine(modsDir.FullName, "SaveBackup")); + DirectoryInfo newFolder = new DirectoryInfo(Path.Combine(modsDir.FullName, "SaveBackup (Omegasis)")); + FileInfo manifest = new FileInfo(Path.Combine(oldFolder.FullName, "manifest.json")); + if (manifest.Exists && !newFolder.Exists && File.ReadLines(manifest.FullName).Any(p => p.IndexOf("Omegasis", StringComparison.InvariantCultureIgnoreCase) != -1)) + { + this.PrintDebug($" moving {oldFolder.Name} to {newFolder.Name}..."); + this.Move(oldFolder, newFolder.FullName); + } + } + + // add bundled mods foreach (DirectoryInfo sourceDir in packagedModsDir.EnumerateDirectories()) { this.PrintDebug($" adding {sourceDir.Name}..."); -- cgit From 28986e76b81fe4505574e4fada3d86ffa457f085 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 16 May 2018 02:01:21 -0400 Subject: tweak renamed folder per discussion with Omegasis (#513) --- src/SMAPI.Installer/InteractiveInstaller.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 4d9bc984..ace560e5 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -360,7 +360,7 @@ namespace StardewModdingApi.Installer // special case: rename Omegasis' SaveBackup mod { DirectoryInfo oldFolder = new DirectoryInfo(Path.Combine(modsDir.FullName, "SaveBackup")); - DirectoryInfo newFolder = new DirectoryInfo(Path.Combine(modsDir.FullName, "SaveBackup (Omegasis)")); + DirectoryInfo newFolder = new DirectoryInfo(Path.Combine(modsDir.FullName, "AdvancedSaveBackup")); FileInfo manifest = new FileInfo(Path.Combine(oldFolder.FullName, "manifest.json")); if (manifest.Exists && !newFolder.Exists && File.ReadLines(manifest.FullName).Any(p => p.IndexOf("Omegasis", StringComparison.InvariantCultureIgnoreCase) != -1)) { -- cgit From a4f644e3c7d4e86a5164099bfc9050b4b164ae0e Mon Sep 17 00:00:00 2001 From: kurumushi Date: Sun, 20 May 2018 16:49:43 +0900 Subject: Change konsole launch options for newer ncurses This makes konsole tell mono that it is xterm, allowing it to avoid mono/mono#6752 and providing a workaround for #489. --- src/SMAPI.Installer/unix-launcher.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/unix-launcher.sh b/src/SMAPI.Installer/unix-launcher.sh index 6e796461..f16cc317 100644 --- a/src/SMAPI.Installer/unix-launcher.sh +++ b/src/SMAPI.Installer/unix-launcher.sh @@ -78,7 +78,7 @@ else elif $COMMAND gnome-terminal 2>/dev/null; then gnome-terminal -e "$LAUNCHER" elif $COMMAND konsole 2>/dev/null; then - konsole -e "$LAUNCHER" + konsole -p Environment=TERM=xterm -e "$LAUNCHER" elif $COMMAND terminal 2>/dev/null; then terminal -e "$LAUNCHER" else -- cgit From b942c89dcf5b9e150c9aef51edac79d0890b8b9e Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 23 May 2018 00:35:43 -0400 Subject: fix launch issue for Linux players with some terminals (#489, #526) --- src/SMAPI.Installer/unix-launcher.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/unix-launcher.sh b/src/SMAPI.Installer/unix-launcher.sh index f16cc317..1e969c20 100644 --- a/src/SMAPI.Installer/unix-launcher.sh +++ b/src/SMAPI.Installer/unix-launcher.sh @@ -74,9 +74,9 @@ else elif $COMMAND xterm 2>/dev/null; then xterm -e "$LAUNCHER" elif $COMMAND xfce4-terminal 2>/dev/null; then - xfce4-terminal -e "$LAUNCHER" + xfce4-terminal -e "env TERM=xterm; $LAUNCHER" elif $COMMAND gnome-terminal 2>/dev/null; then - gnome-terminal -e "$LAUNCHER" + gnome-terminal -e "env TERM=xterm; $LAUNCHER" elif $COMMAND konsole 2>/dev/null; then konsole -p Environment=TERM=xterm -e "$LAUNCHER" elif $COMMAND terminal 2>/dev/null; then -- cgit From 3129f67eb1f162e06d96854f319b10ccf583f0aa Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 25 May 2018 01:14:40 -0400 Subject: add semantic version to toolkit (#532) --- src/SMAPI.Installer/InteractiveInstaller.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index ace560e5..6e4cb95d 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -152,7 +152,7 @@ namespace StardewModdingApi.Installer ** Get platform & set window title ****/ Platform platform = EnvironmentUtility.DetectPlatform(); - Console.Title = $"SMAPI {new SemanticVersionImpl(this.GetType().Assembly.GetName().Version)} installer on {platform} {EnvironmentUtility.GetFriendlyPlatformName(platform)}"; + Console.Title = $"SMAPI {this.GetDisplayVersion(this.GetType().Assembly.GetName().Version)} installer on {platform} {EnvironmentUtility.GetFriendlyPlatformName(platform)}"; Console.WriteLine(); #if SMAPI_FOR_WINDOWS @@ -421,6 +421,16 @@ namespace StardewModdingApi.Installer /********* ** Private methods *********/ + /// Get the display text for an assembly version. + /// The assembly version. + private string GetDisplayVersion(Version version) + { + string str = $"{version.Major}.{version.Minor}"; + if (version.Build != 0) + str += $".{version.Build}"; + return str; + } + /// Get the value of a key in the Windows registry. /// The full path of the registry key relative to HKLM. /// The name of the value. -- cgit From 9bc53145150d9209fb5b13e82857afb6c155b7a5 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 6 Jun 2018 21:42:09 -0400 Subject: add Harmony DLL (#541) --- src/SMAPI.Installer/InteractiveInstaller.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 6e4cb95d..412c82a5 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -82,6 +82,8 @@ namespace StardewModdingApi.Installer string GetInstallPath(string path) => Path.Combine(installDir.FullName, path); // common + yield return GetInstallPath("0Harmony.dll"); + yield return GetInstallPath("0Harmony.pdb"); yield return GetInstallPath("Mono.Cecil.dll"); yield return GetInstallPath("Newtonsoft.Json.dll"); yield return GetInstallPath("StardewModdingAPI.exe"); -- cgit From 9e525533e10ade49c733a34373e0fb749748918e Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 6 Jun 2018 21:42:20 -0400 Subject: fix a few missing uninstall paths --- src/SMAPI.Installer/InteractiveInstaller.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 412c82a5..d3db4d72 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -89,6 +89,9 @@ namespace StardewModdingApi.Installer yield return GetInstallPath("StardewModdingAPI.exe"); yield return GetInstallPath("StardewModdingAPI.config.json"); yield return GetInstallPath("StardewModdingAPI.metadata.json"); + yield return GetInstallPath("StardewModdingAPI.Toolkit.dll"); + yield return GetInstallPath("StardewModdingAPI.Toolkit.pdb"); + yield return GetInstallPath("StardewModdingAPI.xml"); yield return GetInstallPath("System.ValueTuple.dll"); yield return GetInstallPath("steam_appid.txt"); -- cgit From 86a3f8dd460f329fad903770231016813e750168 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 8 Jun 2018 18:46:58 -0400 Subject: allow launching multiple instances without manually changing log path (#494) --- src/SMAPI.Installer/InteractiveInstaller.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 6e4cb95d..02dd6891 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -518,6 +518,7 @@ namespace StardewModdingApi.Installer /// Delete a file or folder regardless of file permissions, and block until deletion completes. /// The file or folder to reset. + /// This method is mirred from FileUtilities.ForceDelete in the toolkit. private void ForceDelete(FileSystemInfo entry) { // ignore if already deleted -- cgit From a6741cce9bb408c44b94f9a8d814856a9cfc806f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 8 Jun 2018 19:10:42 -0400 Subject: detect game install path via Steam library path (#512) Thanks to InkyQuill! --- src/SMAPI.Installer/InteractiveInstaller.cs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 02dd6891..30cb10b4 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -66,6 +66,11 @@ namespace StardewModdingApi.Installer if (!string.IsNullOrWhiteSpace(path)) yield return path; } + + // via Steam library path + string steampath = this.GetCurrentUserRegistryValue(@"Software\Valve\Steam", "SteamPath"); + if (steampath != null) + yield return Path.Combine(steampath.Replace('/', '\\'), @"steamapps\common\Stardew Valley"); } break; @@ -133,11 +138,11 @@ namespace StardewModdingApi.Installer /// Initialisation flow: /// 1. Collect information (mainly OS and install path) and validate it. /// 2. Ask the user whether to install or uninstall. - /// + /// /// Uninstall logic: /// 1. On Linux/Mac: if a backup of the launcher exists, delete the launcher and restore the backup. /// 2. Delete all files and folders in the game directory matching one of the values returned by . - /// + /// /// Install flow: /// 1. Run the uninstall flow. /// 2. Copy the SMAPI files from package/Windows or package/Mono into the game directory. @@ -431,7 +436,7 @@ namespace StardewModdingApi.Installer return str; } - /// Get the value of a key in the Windows registry. + /// Get the value of a key in the Windows HKLM registry. /// The full path of the registry key relative to HKLM. /// The name of the value. private string GetLocalMachineRegistryValue(string key, string name) @@ -444,6 +449,19 @@ namespace StardewModdingApi.Installer return (string)openKey.GetValue(name); } + /// Get the value of a key in the Windows HKCU registry. + /// The full path of the registry key relative to HKCU. + /// The name of the value. + private string GetCurrentUserRegistryValue(string key, string name) + { + RegistryKey currentuser = Environment.Is64BitOperatingSystem ? RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64) : Registry.CurrentUser; + RegistryKey openKey = currentuser.OpenSubKey(key); + if (openKey == null) + return null; + using (openKey) + return (string)openKey.GetValue(name); + } + /// Print a debug message. /// The text to print. private void PrintDebug(string text) => this.ConsoleWriter.WriteLine(text, ConsoleLogLevel.Debug); @@ -602,6 +620,8 @@ namespace StardewModdingApi.Installer where dir.Exists && dir.EnumerateFiles(executableFilename).Any() select dir ) + .GroupBy(p => p.FullName, StringComparer.InvariantCultureIgnoreCase) // ignore duplicate paths + .Select(p => p.First()) .ToArray(); // choose where to install -- cgit From ec0caf6a4afaeb8908d69d46dbc73b70771f91f2 Mon Sep 17 00:00:00 2001 From: David Camp Date: Mon, 11 Jun 2018 12:34:58 -0700 Subject: Update readme.txt to work better with some text editors Some Text editors (such as Notepad++ and Sublime) allow you to click on a URL in a .txt file and then your default browser will navigate to it just fine. However, these same editors will sometimes get confused by a period at the end of a link and will add it, often leading to a 404. This change simply removes the periods at the end of the two links in the text file allowing these readers to navigate properly. --- src/SMAPI.Installer/readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/readme.txt b/src/SMAPI.Installer/readme.txt index 12053a8c..2ee5473c 100644 --- a/src/SMAPI.Installer/readme.txt +++ b/src/SMAPI.Installer/readme.txt @@ -16,7 +16,7 @@ SMAPI lets you run Stardew Valley with mods. Don't forget to download mods separ Player's guide -------------------------------- -See https://stardewvalleywiki.com/Modding:Player_Guide. +See https://stardewvalleywiki.com/Modding:Player_Guide Manual install @@ -24,7 +24,7 @@ Manual install THIS IS NOT RECOMMENDED FOR MOST PLAYERS. See instructions above instead. If you really want to install SMAPI manually, here's how. -1. Download the latest version of SMAPI: https://github.com/Pathoschild/SMAPI/releases. +1. Download the latest version of SMAPI: https://github.com/Pathoschild/SMAPI/releases 2. Unzip the .zip file somewhere (not in your game folder). 3. Copy the files from the "internal/Windows" folder (on Windows) or "internal/Mono" folder (on Linux/Mac) into your game folder. The `StardewModdingAPI.exe` file should be right next to the -- cgit From 71efadf2322a622bc5a74614b1575d2680a84165 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 24 Jun 2018 21:26:42 -0400 Subject: add project for toolkit interfaces visible to SMAPI mods (#532) --- src/SMAPI.Installer/InteractiveInstaller.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index f9239604..1221f659 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -96,6 +96,8 @@ namespace StardewModdingApi.Installer yield return GetInstallPath("StardewModdingAPI.metadata.json"); yield return GetInstallPath("StardewModdingAPI.Toolkit.dll"); yield return GetInstallPath("StardewModdingAPI.Toolkit.pdb"); + yield return GetInstallPath("StardewModdingAPI.Toolkit.CoreInterfaces.dll"); + yield return GetInstallPath("StardewModdingAPI.Toolkit.CoreInterfaces.pdb"); yield return GetInstallPath("StardewModdingAPI.xml"); yield return GetInstallPath("System.ValueTuple.dll"); yield return GetInstallPath("steam_appid.txt"); -- cgit From 357b392ca239d1cc9000dbf9283f431a32d4c36d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 9 Jul 2018 23:03:22 -0400 Subject: fix installer removing SaveBackup's config.json and previous backups --- src/SMAPI.Installer/InteractiveInstaller.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 1221f659..a5d5055f 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -21,6 +21,12 @@ namespace StardewModdingApi.Installer /// The name of the installer file in the package. private readonly string InstallerFileName = "install.exe"; + /// Mod files which shouldn't be deleted when deploying bundled mods (mod folder name => file names). + private readonly IDictionary> ProtectBundledFiles = new Dictionary>(StringComparer.InvariantCultureIgnoreCase) + { + ["SaveBackup"] = new HashSet(new[] { "backups", "config.json" }, StringComparer.InvariantCultureIgnoreCase) + }; + /// The value that represents Windows 7. private readonly Version Windows7Version = new Version(6, 1); @@ -386,10 +392,19 @@ namespace StardewModdingApi.Installer { this.PrintDebug($" adding {sourceDir.Name}..."); - // initialise target dir + // init/clear target dir DirectoryInfo targetDir = new DirectoryInfo(Path.Combine(modsDir.FullName, sourceDir.Name)); - this.InteractivelyDelete(targetDir.FullName); - targetDir.Create(); + if (targetDir.Exists) + { + this.ProtectBundledFiles.TryGetValue(targetDir.Name, out HashSet protectedFiles); + foreach (FileSystemInfo entry in targetDir.EnumerateFileSystemInfos()) + { + if (protectedFiles == null || !protectedFiles.Contains(entry.Name)) + this.InteractivelyDelete(entry.FullName); + } + } + else + targetDir.Create(); // copy files foreach (FileInfo sourceFile in sourceDir.EnumerateFiles().Where(this.ShouldCopyFile)) -- cgit From ea6a82f9ee453f6f41f41f93fb452745670c2d20 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 9 Jul 2018 23:14:47 -0400 Subject: add new files to uninstaller --- src/SMAPI.Installer/InteractiveInstaller.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index a5d5055f..f39486e1 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -102,8 +102,10 @@ namespace StardewModdingApi.Installer yield return GetInstallPath("StardewModdingAPI.metadata.json"); yield return GetInstallPath("StardewModdingAPI.Toolkit.dll"); yield return GetInstallPath("StardewModdingAPI.Toolkit.pdb"); + yield return GetInstallPath("StardewModdingAPI.Toolkit.xml"); yield return GetInstallPath("StardewModdingAPI.Toolkit.CoreInterfaces.dll"); yield return GetInstallPath("StardewModdingAPI.Toolkit.CoreInterfaces.pdb"); + yield return GetInstallPath("StardewModdingAPI.Toolkit.CoreInterfaces.xml"); yield return GetInstallPath("StardewModdingAPI.xml"); yield return GetInstallPath("System.ValueTuple.dll"); yield return GetInstallPath("steam_appid.txt"); -- cgit