From 304d89cd193671942fd96b2eaca31ab18f9304f1 Mon Sep 17 00:00:00 2001 From: Kris Scott Date: Mon, 22 Apr 2019 17:37:01 +0900 Subject: Reworked the unix launcher - More posix compliance and less prone to failing on bad variables - Replaced depreciated backquotes (`) with the 'which' command - Reworked the entire terminal detection code for easier editing and testing --- src/SMAPI.Installer/unix-launcher.sh | 95 +++++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 35 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/unix-launcher.sh b/src/SMAPI.Installer/unix-launcher.sh index a98d527d..d6c3a004 100644 --- a/src/SMAPI.Installer/unix-launcher.sh +++ b/src/SMAPI.Installer/unix-launcher.sh @@ -1,14 +1,14 @@ -#!/bin/bash +#!/usr/bin/env bash # MonoKickstart Shell Script # Written by Ethan "flibitijibibo" Lee # Modified for StardewModdingAPI by Viz and Pathoschild # Move to script's directory -cd "`dirname "$0"`" +cd "$(dirname "$0")" || exit $? # Get the system architecture -UNAME=`uname` -ARCH=`uname -m` +UNAME=$(uname) +ARCH=$(uname -m) # MonoKickstart picks the right libfolder, so just execute the right binary. if [ "$UNAME" == "Darwin" ]; then @@ -39,18 +39,18 @@ if [ "$UNAME" == "Darwin" ]; then # launch SMAPI cp StardewValley.bin.osx StardewModdingAPI.bin.osx - open -a Terminal ./StardewModdingAPI.bin.osx $@ + open -a Terminal ./StardewModdingAPI.bin.osx "$@" else # choose launcher LAUNCHER="" if [ "$ARCH" == "x86_64" ]; then ln -sf mcs.bin.x86_64 mcs cp StardewValley.bin.x86_64 StardewModdingAPI.bin.x86_64 - LAUNCHER="./StardewModdingAPI.bin.x86_64 $@" + LAUNCHER="./StardewModdingAPI.bin.x86_64 $*" else ln -sf mcs.bin.x86 mcs cp StardewValley.bin.x86 StardewModdingAPI.bin.x86 - LAUNCHER="./StardewModdingAPI.bin.x86 $@" + LAUNCHER="./StardewModdingAPI.bin.x86 $*" fi # get cross-distro version of POSIX command @@ -62,36 +62,61 @@ else fi # open SMAPI in terminal - if $COMMAND xterm 2>/dev/null; then - xterm -e "$LAUNCHER" - elif $COMMAND x-terminal-emulator 2>/dev/null; then - # Terminator converts -e to -x when used through x-terminal-emulator for some reason (per - # `man terminator`), which causes an "unable to find shell" error. If x-terminal-emulator - # is mapped to Terminator, invoke it directly instead. - if [[ "$(readlink -e $(which x-terminal-emulator))" == *"/terminator" ]]; then - terminator -e "sh -c 'TERM=xterm $LAUNCHER'" - else - x-terminal-emulator -e "sh -c 'TERM=xterm $LAUNCHER'" + # First let's try xterm (best compatiblity) or find a sensible default + # Setting TERMINAL should let you override this at the commandline for easier testing of other terminals. + for terminal in "$TERMINAL" xterm x-terminal-emulator kitty terminator xfce4-terminal gnome-terminal konsole terminal termite; do + if $COMMAND "$terminal" 2>/dev/null; then + # Find the true shell behind x-terminal-emulator + if [ "$(basename "$(readlink -ef which "$terminal")")" != "x-terminal-emulator" ]; then + export LAUNCHTERM=$terminal + break; + else + export LAUNCHTERM="$(basename "$(readlink -ef which x-terminal-emulator)")" + # Remember that we are using x-terminal-emulator just in case it points outside the $PATH + export XTE=1 + break; + fi fi - elif $COMMAND xfce4-terminal 2>/dev/null; then - xfce4-terminal -e "sh -c 'TERM=xterm $LAUNCHER'" - elif $COMMAND gnome-terminal 2>/dev/null; then - gnome-terminal -e "sh -c 'TERM=xterm $LAUNCHER'" - elif $COMMAND konsole 2>/dev/null; then - konsole -p Environment=TERM=xterm -e "$LAUNCHER" - elif $COMMAND terminal 2>/dev/null; then - terminal -e "sh -c 'TERM=xterm $LAUNCHER'" - elif $COMMAND termite 2>/dev/null; then - termite -e "sh -c 'TERM=xterm $LAUNCHER'" - else + done + + if [ -z "$LAUNCHTERM" ]; then + # We failed to detect a terminal, run in current shell, or with no output sh -c 'TERM=xterm $LAUNCHER' + if [ $? -eq 127 ]; then + $LAUNCHER --no-terminal + fi + exit fi - # some Linux users get error 127 (command not found) from the above block, even though - # `command -v` indicates the command is valid. As a fallback, launch SMAPI without a terminal when - # that happens and pass in an argument indicating SMAPI shouldn't try writing to the terminal - # (which can be slow if there is none). - if [ $? -eq 127 ]; then - $LAUNCHER --no-terminal - fi + # Now let's run the terminal and account for quirks, or if no terminal was found, run in the current process. + case $LAUNCHTERM in + terminator) + # Terminator converts -e to -x when used through x-terminal-emulator for some reason + if $XTE; then + terminator -e "sh -c 'TERM=xterm $LAUNCHER'" + else + terminator -x "sh -c 'TERM=xterm $LAUNCHER'" + fi + ;; + kitty) + # Kitty overrides the TERM varible unless you set it explicitly + kitty -o term=xterm $LAUNCHER + ;; + xterm) + $LAUNCHTERM -e "$LAUNCHER" + ;; + xfce4-terminal|gnome-terminal|terminal|termite) + $LAUNCHTERM -e "sh -c 'TERM=xterm $LAUNCHER'" + ;; + konsole) + konsole -p Environment=TERM=xterm -e "$LAUNCHER" + ;; + *) + # If we don't know the terminal, just try to run it in the current shell. + sh -c 'TERM=xterm $LAUNCHER' + # if THAT fails, launch with no output + if [ $? -eq 127 ]; then + $LAUNCHER --no-terminal + fi + esac fi -- cgit From d14e470ea9e2e7533fe7fc873b213bacde282258 Mon Sep 17 00:00:00 2001 From: kurumushi Date: Mon, 22 Apr 2019 08:52:18 +0000 Subject: Update unix-launcher.sh Changed the line to launch xterm, forcing TERM=xterm, as suggested by @toastal --- src/SMAPI.Installer/unix-launcher.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/unix-launcher.sh b/src/SMAPI.Installer/unix-launcher.sh index d6c3a004..09b3f830 100644 --- a/src/SMAPI.Installer/unix-launcher.sh +++ b/src/SMAPI.Installer/unix-launcher.sh @@ -102,10 +102,7 @@ else # Kitty overrides the TERM varible unless you set it explicitly kitty -o term=xterm $LAUNCHER ;; - xterm) - $LAUNCHTERM -e "$LAUNCHER" - ;; - xfce4-terminal|gnome-terminal|terminal|termite) + xterm|xfce4-terminal|gnome-terminal|terminal|termite) $LAUNCHTERM -e "sh -c 'TERM=xterm $LAUNCHER'" ;; konsole) -- cgit From 7e9cb99acb143bc34f93c08086b95af0f95639ef Mon Sep 17 00:00:00 2001 From: kurumushi Date: Mon, 22 Apr 2019 10:50:19 +0000 Subject: Update unix-launcher.sh minor formatting fixes --- src/SMAPI.Installer/unix-launcher.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/unix-launcher.sh b/src/SMAPI.Installer/unix-launcher.sh index 09b3f830..fc08577f 100644 --- a/src/SMAPI.Installer/unix-launcher.sh +++ b/src/SMAPI.Installer/unix-launcher.sh @@ -64,17 +64,17 @@ else # open SMAPI in terminal # First let's try xterm (best compatiblity) or find a sensible default # Setting TERMINAL should let you override this at the commandline for easier testing of other terminals. - for terminal in "$TERMINAL" xterm x-terminal-emulator kitty terminator xfce4-terminal gnome-terminal konsole terminal termite; do + for terminal in "$TERMINAL" xterm x-terminal-emulator kitty terminator xfce4-terminal gnome-terminal konsole terminal termite; do if $COMMAND "$terminal" 2>/dev/null; then # Find the true shell behind x-terminal-emulator if [ "$(basename "$(readlink -ef which "$terminal")")" != "x-terminal-emulator" ]; then - export LAUNCHTERM=$terminal - break; + export LAUNCHTERM=$terminal + break; else - export LAUNCHTERM="$(basename "$(readlink -ef which x-terminal-emulator)")" - # Remember that we are using x-terminal-emulator just in case it points outside the $PATH - export XTE=1 - break; + export LAUNCHTERM="$(basename "$(readlink -ef which x-terminal-emulator)")" + # Remember that we are using x-terminal-emulator just in case it points outside the $PATH + export XTE=1 + break; fi fi done -- cgit From f8e32f4433647b7bd69590b937927808168649df Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 24 Apr 2019 01:26:15 -0400 Subject: update release notes, tweak launch script comments (#640) --- src/SMAPI.Installer/unix-launcher.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/unix-launcher.sh b/src/SMAPI.Installer/unix-launcher.sh index fc08577f..0ca5c852 100644 --- a/src/SMAPI.Installer/unix-launcher.sh +++ b/src/SMAPI.Installer/unix-launcher.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # MonoKickstart Shell Script # Written by Ethan "flibitijibibo" Lee -# Modified for StardewModdingAPI by Viz and Pathoschild +# Modified for SMAPI by various contributors # Move to script's directory cd "$(dirname "$0")" || exit $? @@ -61,9 +61,7 @@ else COMMAND="type" fi - # open SMAPI in terminal - # First let's try xterm (best compatiblity) or find a sensible default - # Setting TERMINAL should let you override this at the commandline for easier testing of other terminals. + # select terminal (prefer $TERMINAL for overrides and testing, then xterm for best compatibility, then known supported terminals) for terminal in "$TERMINAL" xterm x-terminal-emulator kitty terminator xfce4-terminal gnome-terminal konsole terminal termite; do if $COMMAND "$terminal" 2>/dev/null; then # Find the true shell behind x-terminal-emulator @@ -72,15 +70,15 @@ else break; else export LAUNCHTERM="$(basename "$(readlink -ef which x-terminal-emulator)")" - # Remember that we are using x-terminal-emulator just in case it points outside the $PATH + # Remember that we're using x-terminal-emulator just in case it points outside the $PATH export XTE=1 break; fi fi done + # if no terminal was found, run in current shell or with no output if [ -z "$LAUNCHTERM" ]; then - # We failed to detect a terminal, run in current shell, or with no output sh -c 'TERM=xterm $LAUNCHER' if [ $? -eq 127 ]; then $LAUNCHER --no-terminal @@ -88,7 +86,7 @@ else exit fi - # Now let's run the terminal and account for quirks, or if no terminal was found, run in the current process. + # run in selected terminal and account for quirks case $LAUNCHTERM in terminator) # Terminator converts -e to -x when used through x-terminal-emulator for some reason -- cgit From abffdc2dab2a1c03904427b251acac9d800e0912 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 24 Apr 2019 23:45:34 -0400 Subject: simplify project names --- src/SMAPI.Installer/SMAPI.Installer.csproj | 45 ++++++++++++++++++++++ .../StardewModdingAPI.Installer.csproj | 45 ---------------------- 2 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 src/SMAPI.Installer/SMAPI.Installer.csproj delete mode 100644 src/SMAPI.Installer/StardewModdingAPI.Installer.csproj (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/SMAPI.Installer.csproj b/src/SMAPI.Installer/SMAPI.Installer.csproj new file mode 100644 index 00000000..a2e115e6 --- /dev/null +++ b/src/SMAPI.Installer/SMAPI.Installer.csproj @@ -0,0 +1,45 @@ + + + + SMAPI.Installer + SMAPI.Installer + net45 + false + latest + Exe + x86 + $(SolutionDir)\..\bin\$(Configuration)\Installer + false + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + diff --git a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj b/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj deleted file mode 100644 index ac64a774..00000000 --- a/src/SMAPI.Installer/StardewModdingAPI.Installer.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - StardewModdingAPI.Installer - StardewModdingAPI.Installer - net45 - false - latest - Exe - x86 - $(SolutionDir)\..\bin\$(Configuration)\Installer - false - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - -- cgit From c15785a68d3e99959cdcca5bfb51e8686316a33b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 24 Apr 2019 23:46:52 -0400 Subject: simplify config.json and metadata.json names --- src/SMAPI.Installer/Framework/InstallerPaths.cs | 2 +- src/SMAPI.Installer/InteractiveInstaller.cs | 3 +-- src/SMAPI.Installer/README.txt | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/Framework/InstallerPaths.cs b/src/SMAPI.Installer/Framework/InstallerPaths.cs index e5396018..9393e14f 100644 --- a/src/SMAPI.Installer/Framework/InstallerPaths.cs +++ b/src/SMAPI.Installer/Framework/InstallerPaths.cs @@ -59,7 +59,7 @@ namespace StardewModdingAPI.Installer.Framework 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", "StardewModdingAPI.config.json"); + this.ApiConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.json"); } } } diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 7148b1d9..c8d36b01 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -112,6 +112,7 @@ namespace StardewModdingApi.Installer yield return GetInstallPath("StardewModdingAPI.pdb"); // Windows only yield return GetInstallPath("StardewModdingAPI.xml"); yield return GetInstallPath("smapi-internal"); + yield return GetInstallPath("steam_appid.txt"); // obsolete yield return GetInstallPath(Path.Combine("Mods", ".cache")); // 1.3-1.4 @@ -133,11 +134,9 @@ namespace StardewModdingApi.Installer yield return GetInstallPath("StardewModdingAPI.Toolkit.CoreInterfaces.dll"); // moved in 2.8 yield return GetInstallPath("StardewModdingAPI.Toolkit.CoreInterfaces.pdb"); // moved in 2.8 yield return GetInstallPath("StardewModdingAPI.Toolkit.CoreInterfaces.xml"); // moved in 2.8 - yield return GetInstallPath("StardewModdingAPI.xml"); // moved in 2.8 yield return GetInstallPath("System.Numerics.dll"); // moved in 2.8 yield return GetInstallPath("System.Runtime.Caching.dll"); // moved in 2.8 yield return GetInstallPath("System.ValueTuple.dll"); // moved in 2.8 - yield return GetInstallPath("steam_appid.txt"); // moved in 2.8 if (modsDir.Exists) { diff --git a/src/SMAPI.Installer/README.txt b/src/SMAPI.Installer/README.txt index 79c90cc0..0da49a46 100644 --- a/src/SMAPI.Installer/README.txt +++ b/src/SMAPI.Installer/README.txt @@ -40,5 +40,5 @@ When installing on Linux or Mac: - Make sure Mono is installed (normally the installer checks for you). While it's not required, many mods won't work correctly without it. (Specifically, mods which load PNG images may crash or freeze the game.) -- To configure the color scheme, edit the `smapi-internal/StardewModdingAPI.config.json` file and - see instructions there for the 'ColorScheme' setting. +- To configure the color scheme, edit the `smapi-internal/config.json` file and see instructions + there for the 'ColorScheme' setting. -- cgit From 1b3a6a514f2812c2cd386ef787821f5418045014 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 30 May 2019 19:06:09 -0400 Subject: fix readlink commands in launcher not working in ZorinOS (#640) --- 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 0ca5c852..71ed103d 100644 --- a/src/SMAPI.Installer/unix-launcher.sh +++ b/src/SMAPI.Installer/unix-launcher.sh @@ -65,11 +65,11 @@ else for terminal in "$TERMINAL" xterm x-terminal-emulator kitty terminator xfce4-terminal gnome-terminal konsole terminal termite; do if $COMMAND "$terminal" 2>/dev/null; then # Find the true shell behind x-terminal-emulator - if [ "$(basename "$(readlink -ef which "$terminal")")" != "x-terminal-emulator" ]; then + if [ "$(basename "$(readlink -f $(which "$terminal"))")" != "x-terminal-emulator" ]; then export LAUNCHTERM=$terminal break; else - export LAUNCHTERM="$(basename "$(readlink -ef which x-terminal-emulator)")" + export LAUNCHTERM="$(basename "$(readlink -f $(which x-terminal-emulator))")" # Remember that we're using x-terminal-emulator just in case it points outside the $PATH export XTE=1 break; -- cgit From a5146daaab2ea6c4a09f68b75eb92d65a1158d4a Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 30 May 2019 19:06:23 -0400 Subject: use known working terminal before trying x-terminal-emulator (#640) --- 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 71ed103d..f81828f0 100644 --- a/src/SMAPI.Installer/unix-launcher.sh +++ b/src/SMAPI.Installer/unix-launcher.sh @@ -62,7 +62,7 @@ else fi # select terminal (prefer $TERMINAL for overrides and testing, then xterm for best compatibility, then known supported terminals) - for terminal in "$TERMINAL" xterm x-terminal-emulator kitty terminator xfce4-terminal gnome-terminal konsole terminal termite; do + for terminal in "$TERMINAL" xterm gnome-terminal kitty terminator xfce4-terminal konsole terminal termite x-terminal-emulator; do if $COMMAND "$terminal" 2>/dev/null; then # Find the true shell behind x-terminal-emulator if [ "$(basename "$(readlink -f $(which "$terminal"))")" != "x-terminal-emulator" ]; then -- cgit From a7544e5afb4ba7f12d248503106cc8d407c2bad1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 17 Jun 2019 18:51:12 -0400 Subject: move game detection into toolkit for reuse --- src/SMAPI.Installer/InteractiveInstaller.cs | 106 ++-------------------------- 1 file changed, 6 insertions(+), 100 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index c8d36b01..41400617 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -7,7 +7,6 @@ using System.Threading; using Microsoft.Win32; using StardewModdingApi.Installer.Enums; using StardewModdingAPI.Installer.Framework; -using StardewModdingAPI.Internal; using StardewModdingAPI.Internal.ConsoleWriting; using StardewModdingAPI.Toolkit; using StardewModdingAPI.Toolkit.Framework.ModScanning; @@ -37,64 +36,7 @@ namespace StardewModdingApi.Installer "SMAPI.ConsoleCommands" }; - /// The default file paths where Stardew Valley can be installed. - /// The target platform. - /// Derived from the crossplatform mod config: https://github.com/Pathoschild/Stardew.ModBuildConfig. - private IEnumerable GetDefaultInstallPaths(Platform platform) - { - switch (platform) - { - case Platform.Linux: - case Platform.Mac: - { - 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 $"{home}/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS"; - } - break; - - case Platform.Windows: - { - // Windows - foreach (string programFiles in new[] { @"C:\Program Files", @"C:\Program Files (x86)" }) - { - yield return $@"{programFiles}\GalaxyClient\Games\Stardew Valley"; - yield return $@"{programFiles}\GOG Galaxy\Games\Stardew Valley"; - yield return $@"{programFiles}\Steam\steamapps\common\Stardew Valley"; - } - - // Windows registry - IDictionary registryKeys = new Dictionary - { - [@"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; - } - - // 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; - - default: - throw new InvalidOperationException($"Unknown platform '{platform}'."); - } - } /// Get the absolute file or folder paths to remove when uninstalling SMAPI. /// The folder for Stardew Valley and SMAPI. @@ -186,8 +128,9 @@ namespace StardewModdingApi.Installer ** Step 1: initial setup *********/ /**** - ** Get platform & set window title + ** Get basic info & set window title ****/ + ModToolkit toolkit = new ModToolkit(); Platform platform = EnvironmentUtility.DetectPlatform(); Console.Title = $"SMAPI {this.GetDisplayVersion(this.GetType().Assembly.GetName().Version)} installer on {platform} {EnvironmentUtility.GetFriendlyPlatformName(platform)}"; Console.WriteLine(); @@ -323,7 +266,7 @@ namespace StardewModdingApi.Installer ****/ // get game path this.PrintInfo("Where is your game folder?"); - DirectoryInfo installDir = this.InteractivelyGetInstallPath(platform, gamePathArg); + DirectoryInfo installDir = this.InteractivelyGetInstallPath(platform, toolkit, gamePathArg); if (installDir == null) { this.PrintError("Failed finding your game path."); @@ -489,7 +432,6 @@ namespace StardewModdingApi.Installer { this.PrintDebug("Adding bundled mods..."); - ModToolkit toolkit = new ModToolkit(); ModFolder[] targetMods = toolkit.GetModFolders(paths.ModsPath).ToArray(); foreach (ModFolder sourceMod in toolkit.GetModFolders(bundledModsDir.FullName)) { @@ -597,32 +539,6 @@ namespace StardewModdingApi.Installer } } - /// 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) - { - RegistryKey localMachine = Environment.Is64BitOperatingSystem ? RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64) : Registry.LocalMachine; - RegistryKey openKey = localMachine.OpenSubKey(key); - if (openKey == null) - return null; - using (openKey) - 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 message without formatting. /// The text to print. private void PrintPlain(string text) => Console.WriteLine(text); @@ -788,8 +704,9 @@ namespace StardewModdingApi.Installer /// Interactively locate the game install path to update. /// The current platform. + /// The mod toolkit. /// The path specified as a command-line argument (if any), which should override automatic path detection. - private DirectoryInfo InteractivelyGetInstallPath(Platform platform, string specifiedPath) + private DirectoryInfo InteractivelyGetInstallPath(Platform platform, ModToolkit toolkit, string specifiedPath) { // get executable name string executableFilename = EnvironmentUtility.GetExecutableName(platform); @@ -812,18 +729,7 @@ namespace StardewModdingApi.Installer } // get installed paths - DirectoryInfo[] defaultPaths = - ( - from path in this.GetDefaultInstallPaths(platform).Distinct(StringComparer.InvariantCultureIgnoreCase) - let dir = new DirectoryInfo(path) - 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 + DirectoryInfo[] defaultPaths = toolkit.GetGameFolders().ToArray(); if (defaultPaths.Any()) { // only one path -- cgit From fd77ae93d59222d70c86aebfc044f3af11063372 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 9 Aug 2019 01:18:05 -0400 Subject: fix typos and inconsistent spelling --- src/SMAPI.Installer/InteractiveInstaller.cs | 12 ++++++------ src/SMAPI.Installer/Program.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 41400617..4d313a3b 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -106,7 +106,7 @@ namespace StardewModdingApi.Installer /// Run the install or uninstall script. /// The command line arguments. /// - /// Initialisation flow: + /// Initialization flow: /// 1. Collect information (mainly OS and install path) and validate it. /// 2. Ask the user whether to install or uninstall. /// @@ -218,7 +218,7 @@ namespace StardewModdingApi.Installer ****/ // get theme writers var lightBackgroundWriter = new ColorfulConsoleWriter(EnvironmentUtility.DetectPlatform(), MonitorColorScheme.LightBackground); - var darkDarkgroundWriter = new ColorfulConsoleWriter(EnvironmentUtility.DetectPlatform(), MonitorColorScheme.DarkBackground); + var darkBackgroundWriter = new ColorfulConsoleWriter(EnvironmentUtility.DetectPlatform(), MonitorColorScheme.DarkBackground); // print question this.PrintPlain("Which text looks more readable?"); @@ -226,7 +226,7 @@ namespace StardewModdingApi.Installer Console.Write(" [1] "); lightBackgroundWriter.WriteLine("Dark text on light background", ConsoleLogLevel.Info); Console.Write(" [2] "); - darkDarkgroundWriter.WriteLine("Light text on dark background", ConsoleLogLevel.Info); + darkBackgroundWriter.WriteLine("Light text on dark background", ConsoleLogLevel.Info); Console.WriteLine(); // handle choice @@ -239,7 +239,7 @@ namespace StardewModdingApi.Installer break; case "2": scheme = MonitorColorScheme.DarkBackground; - this.ConsoleWriter = darkDarkgroundWriter; + this.ConsoleWriter = darkBackgroundWriter; break; default: throw new InvalidOperationException($"Unexpected action key '{choice}'."); @@ -646,7 +646,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. + /// This method is mirrored from FileUtilities.ForceDelete in the toolkit. private void ForceDelete(FileSystemInfo entry) { // ignore if already deleted @@ -762,7 +762,7 @@ namespace StardewModdingApi.Installer continue; } - // normalise path + // normalize 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.Linux || platform == Platform.Mac) diff --git a/src/SMAPI.Installer/Program.cs b/src/SMAPI.Installer/Program.cs index 3c4d8593..b7fa45f5 100644 --- a/src/SMAPI.Installer/Program.cs +++ b/src/SMAPI.Installer/Program.cs @@ -36,7 +36,7 @@ namespace StardewModdingApi.Installer FileInfo zipFile = new FileInfo(Path.Combine(Program.InstallerPath, $"{(platform == PlatformID.Win32NT ? "windows" : "unix")}-install.dat")); if (!zipFile.Exists) { - Console.WriteLine($"Oops! Some of the installer files are missing; try redownloading the installer. (Missing file: {zipFile.FullName})"); + Console.WriteLine($"Oops! Some of the installer files are missing; try re-downloading the installer. (Missing file: {zipFile.FullName})"); Console.ReadLine(); return; } -- cgit From 25e4aa14d865cdf9f3616cfb0fd981aaaf0e3535 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 9 Aug 2019 17:47:53 -0400 Subject: remove legacy AssemblyInfo and GlobalAssemblyInfo files, use consistent assembly names --- src/SMAPI.Installer/Properties/AssemblyInfo.cs | 4 ---- src/SMAPI.Installer/SMAPI.Installer.csproj | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 src/SMAPI.Installer/Properties/AssemblyInfo.cs (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/Properties/AssemblyInfo.cs b/src/SMAPI.Installer/Properties/AssemblyInfo.cs deleted file mode 100644 index 9838e5a0..00000000 --- a/src/SMAPI.Installer/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyTitle("SMAPI.Installer")] -[assembly: AssemblyDescription("The SMAPI installer for players.")] diff --git a/src/SMAPI.Installer/SMAPI.Installer.csproj b/src/SMAPI.Installer/SMAPI.Installer.csproj index a2e115e6..3f01c8fe 100644 --- a/src/SMAPI.Installer/SMAPI.Installer.csproj +++ b/src/SMAPI.Installer/SMAPI.Installer.csproj @@ -1,10 +1,10 @@  - SMAPI.Installer SMAPI.Installer + StardewModdingAPI.Installer + The SMAPI installer for players. net45 - false latest Exe x86 @@ -12,10 +12,6 @@ false - - - - -- cgit From 1b5055dfaafc6dcf77b5262b8290e8ca2c8179ed Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 23 Sep 2019 17:09:35 -0400 Subject: make console colors configurable --- src/SMAPI.Installer/InteractiveInstaller.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/SMAPI.Installer') diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 4d313a3b..964300ac 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -100,7 +100,7 @@ namespace StardewModdingApi.Installer public InteractiveInstaller(string bundlePath) { this.BundlePath = bundlePath; - this.ConsoleWriter = new ColorfulConsoleWriter(EnvironmentUtility.DetectPlatform(), MonitorColorScheme.AutoDetect); + this.ConsoleWriter = new ColorfulConsoleWriter(EnvironmentUtility.DetectPlatform()); } /// Run the install or uninstall script. @@ -217,8 +217,8 @@ namespace StardewModdingApi.Installer ** show theme selector ****/ // get theme writers - var lightBackgroundWriter = new ColorfulConsoleWriter(EnvironmentUtility.DetectPlatform(), MonitorColorScheme.LightBackground); - var darkBackgroundWriter = new ColorfulConsoleWriter(EnvironmentUtility.DetectPlatform(), MonitorColorScheme.DarkBackground); + var lightBackgroundWriter = new ColorfulConsoleWriter(platform, ColorfulConsoleWriter.GetDefaultColorSchemeConfig(MonitorColorScheme.LightBackground)); + var darkBackgroundWriter = new ColorfulConsoleWriter(platform, ColorfulConsoleWriter.GetDefaultColorSchemeConfig(MonitorColorScheme.DarkBackground)); // print question this.PrintPlain("Which text looks more readable?"); @@ -470,7 +470,7 @@ namespace StardewModdingApi.Installer { string text = File .ReadAllText(paths.ApiConfigPath) - .Replace(@"""ColorScheme"": ""AutoDetect""", $@"""ColorScheme"": ""{scheme}"""); + .Replace(@"""UseScheme"": ""AutoDetect""", $@"""UseScheme"": ""{scheme}"""); File.WriteAllText(paths.ApiConfigPath, text); } -- cgit