diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-12-05 19:10:39 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-12-05 19:10:39 -0500 |
commit | 8a2618d812e4e2f36161907af5af5c484eb37abf (patch) | |
tree | c164325cf57fb43e4375e94dc584fbc3ab3ceeb5 /src/SMAPI.Installer | |
parent | 42e878e77d58569be81e34ca206a78e0ebe0604d (diff) | |
parent | 5b5dd47c22a1332a4c432d6a1cd414b5c83388d7 (diff) | |
download | SMAPI-8a2618d812e4e2f36161907af5af5c484eb37abf.tar.gz SMAPI-8a2618d812e4e2f36161907af5af5c484eb37abf.tar.bz2 SMAPI-8a2618d812e4e2f36161907af5af5c484eb37abf.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Installer')
-rw-r--r-- | src/SMAPI.Installer/Framework/InstallerContext.cs | 7 | ||||
-rw-r--r-- | src/SMAPI.Installer/InteractiveInstaller.cs | 63 | ||||
-rw-r--r-- | src/SMAPI.Installer/SMAPI.Installer.csproj | 1 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/README.txt | 18 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/install on Linux.sh | 4 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/install on Windows.bat (renamed from src/SMAPI.Installer/assets/windows-install.bat) | 37 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/install on macOS.command | 6 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/runtimeconfig.json (renamed from src/SMAPI.Installer/assets/runtimeconfig.unix.json) | 6 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/runtimeconfig.windows.json | 12 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/unix-install.sh | 14 | ||||
-rw-r--r-- | src/SMAPI.Installer/assets/unix-launcher.sh | 9 |
11 files changed, 90 insertions, 87 deletions
diff --git a/src/SMAPI.Installer/Framework/InstallerContext.cs b/src/SMAPI.Installer/Framework/InstallerContext.cs index 95df32ca..bb973230 100644 --- a/src/SMAPI.Installer/Framework/InstallerContext.cs +++ b/src/SMAPI.Installer/Framework/InstallerContext.cs @@ -54,5 +54,12 @@ namespace StardewModdingAPI.Installer.Framework { return this.GameScanner.LooksLikeGameFolder(dir); } + + /// <summary>Get whether a folder seems to contain the game, and which version it contains if so.</summary> + /// <param name="dir">The folder to check.</param> + public GameFolderType GetGameFolderType(DirectoryInfo dir) + { + return this.GameScanner.GetGameFolderType(dir); + } } } diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index d8c27a2d..1257f12b 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -10,6 +10,7 @@ using StardewModdingAPI.Installer.Framework; using StardewModdingAPI.Internal.ConsoleWriting; using StardewModdingAPI.Toolkit; using StardewModdingAPI.Toolkit.Framework; +using StardewModdingAPI.Toolkit.Framework.GameScanning; using StardewModdingAPI.Toolkit.Framework.ModScanning; using StardewModdingAPI.Toolkit.Utilities; @@ -633,18 +634,39 @@ namespace StardewModdingApi.Installer // use specified path if (specifiedPath != null) { + string errorPrefix = $"You specified --game-path \"{specifiedPath}\", but"; + var dir = new DirectoryInfo(specifiedPath); if (!dir.Exists) { - this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't exist."); + this.PrintError($"{errorPrefix} that folder doesn't exist."); return null; } - if (!context.LooksLikeGameFolder(dir)) + + switch (context.GetGameFolderType(dir)) { - this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't contain the Stardew Valley executable."); - return null; + case GameFolderType.Valid: + return dir; + + case GameFolderType.Legacy154OrEarlier: + this.PrintWarning($"{errorPrefix} that directory seems to have Stardew Valley 1.5.4 or earlier."); + this.PrintWarning("Please update your game to the latest version to use SMAPI."); + return null; + + case GameFolderType.LegacyCompatibilityBranch: + this.PrintWarning($"{errorPrefix} that directory seems to have the Stardew Valley legacy 'compatibility' branch."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the modern version of the game."); + this.PrintWarning("Please update your game to the main branch to use SMAPI."); + return null; + + case GameFolderType.NoGameFound: + this.PrintWarning($"{errorPrefix} that directory doesn't contain a Stardew Valley executable."); + return null; + + default: + this.PrintWarning($"{errorPrefix} that directory doesn't seem to contain a valid game install."); + return null; } - return dir; } // let user choose detected path @@ -702,15 +724,32 @@ namespace StardewModdingApi.Installer this.PrintWarning("That directory doesn't seem to exist."); continue; } - if (!context.LooksLikeGameFolder(directory)) + + switch (context.GetGameFolderType(directory)) { - this.PrintWarning("That directory doesn't contain a Stardew Valley executable."); - continue; - } + case GameFolderType.Valid: + this.PrintInfo(" OK!"); + return directory; + + case GameFolderType.Legacy154OrEarlier: + this.PrintWarning("That directory seems to have Stardew Valley 1.5.4 or earlier."); + this.PrintWarning("Please update your game to the latest version to use SMAPI."); + continue; - // looks OK - this.PrintInfo(" OK!"); - return directory; + case GameFolderType.LegacyCompatibilityBranch: + this.PrintWarning("That directory seems to have the Stardew Valley legacy 'compatibility' branch."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the modern version of the game."); + this.PrintWarning("Please update your game to the main branch to use SMAPI."); + continue; + + case GameFolderType.NoGameFound: + this.PrintWarning("That directory doesn't contain a Stardew Valley executable."); + continue; + + default: + this.PrintWarning("That directory doesn't seem to contain a valid game install."); + continue; + } } } diff --git a/src/SMAPI.Installer/SMAPI.Installer.csproj b/src/SMAPI.Installer/SMAPI.Installer.csproj index e3e01467..928e5c18 100644 --- a/src/SMAPI.Installer/SMAPI.Installer.csproj +++ b/src/SMAPI.Installer/SMAPI.Installer.csproj @@ -17,5 +17,4 @@ <Import Project="..\SMAPI.Internal\SMAPI.Internal.projitems" Label="Shared" /> <Import Project="..\..\build\common.targets" /> - <Import Project="..\..\build\prepare-install-package.targets" /> </Project> diff --git a/src/SMAPI.Installer/assets/README.txt b/src/SMAPI.Installer/assets/README.txt index 5c20529a..08e99887 100644 --- a/src/SMAPI.Installer/assets/README.txt +++ b/src/SMAPI.Installer/assets/README.txt @@ -14,22 +14,27 @@ SMAPI lets you run Stardew Valley with mods. Don't forget to download mods separately. -Player's guide +Automated install -------------------------------- See https://stardewvalleywiki.com/Modding:Player_Guide for help installing SMAPI, adding mods, etc. Manual install -------------------------------- -THIS IS NOT RECOMMENDED FOR MOST PLAYERS. See instructions above instead. +THIS IS NOT RECOMMENDED FOR MOST PLAYERS. See the instructions above instead. If you really want to install SMAPI manually, here's how. -1. Unzip "internal/windows/install.dat" (on Windows) or "internal/unix/install.dat" (on - Linux/macOS). You can change '.dat' to '.zip', it's just a normal zip file renamed to prevent +1. Unzip "internal/windows/install.dat" (on Windows) or "internal/unix/install.dat" (on Linux or + macOS). You can change '.dat' to '.zip', it's just a normal zip file renamed to prevent confusion. + 2. Copy the files from the folder you just unzipped into your game folder. The `StardewModdingAPI.exe` file should be right next to the game's executable. -3. + +3. Copy `Stardew Valley.deps.json` in the game folder, and rename the copy to + `StardewModdingAPI.deps.json`. + +4. - Windows only: if you use Steam, see the install guide above to enable achievements and overlay. Otherwise, just run StardewModdingAPI.exe in your game folder to play with mods. @@ -38,8 +43,5 @@ If you really want to install SMAPI manually, here's how. play with mods. When installing on Linux or macOS: -- 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/config.json` file and see instructions there for the 'ColorScheme' setting. diff --git a/src/SMAPI.Installer/assets/install on Linux.sh b/src/SMAPI.Installer/assets/install on Linux.sh new file mode 100644 index 00000000..3b7eae9c --- /dev/null +++ b/src/SMAPI.Installer/assets/install on Linux.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd "`dirname "$0"`" +internal/linux/SMAPI.Installer diff --git a/src/SMAPI.Installer/assets/windows-install.bat b/src/SMAPI.Installer/assets/install on Windows.bat index e34b9554..b0d9ae81 100644 --- a/src/SMAPI.Installer/assets/windows-install.bat +++ b/src/SMAPI.Installer/assets/install on Windows.bat @@ -12,47 +12,24 @@ if %ERRORLEVEL% EQU 0 ( exit ) -REM make sure .NET 5 is installed -SET hasNet5=1 -WHERE dotnet /q -if !ERRORLEVEL! NEQ 0 ( - SET hasNet5=0 -) else ( - dotnet --info | findstr /C:"Microsoft.WindowsDesktop.App 5." 1>nul - if !ERRORLEVEL! NEQ 0 ( - SET hasNet5=0 - ) -) -if "%hasNet5%" == "0" ( - echo Oops! You don't have the required .NET version installed. - echo. - echo To install it: - echo 1. Go to https://dotnet.microsoft.com/download/dotnet/5.0/runtime - - if "%PROCESSOR_ARCHITECTURE%" == "ARM64" ( - echo 2. Under "Run desktop apps", click "Download Arm64". - ) else ( - echo 2. Under "Run desktop apps", click "Download x64". - ) - - echo 3. Run the downloaded installer. - echo 4. Restart your computer. +REM make sure an antivirus hasn't deleted the installer DLL +if not exist %installerDir%"internal\windows\SMAPI.Installer.dll" ( + echo Oops! SMAPI is missing one of its files. Your antivirus might have deleted it. + echo Missing file: %installerDir%internal\windows\SMAPI.Installer.dll echo. pause exit ) - -REM make sure an antivirus hasn't deleted the installer DLL -if not exist %installerDir%"internal\windows\SMAPI.Installer.dll" ( +if not exist %installerDir%"internal\windows\SMAPI.Installer.exe" ( echo Oops! SMAPI is missing one of its files. Your antivirus might have deleted it. - echo Missing file: %installerDir%internal\windows\SMAPI.Installer.dll + echo Missing file: %installerDir%internal\windows\SMAPI.Installer.exe echo. pause exit ) REM start installer -dotnet internal\windows\SMAPI.Installer.dll +internal\windows\SMAPI.Installer.exe REM keep window open if it failed if %ERRORLEVEL% NEQ 0 ( diff --git a/src/SMAPI.Installer/assets/install on macOS.command b/src/SMAPI.Installer/assets/install on macOS.command new file mode 100644 index 00000000..abd21dc8 --- /dev/null +++ b/src/SMAPI.Installer/assets/install on macOS.command @@ -0,0 +1,6 @@ +#!/bin/bash + +cd "`dirname "$0"`" + +xattr -r -d com.apple.quarantine internal +internal/macOS/SMAPI.Installer diff --git a/src/SMAPI.Installer/assets/runtimeconfig.unix.json b/src/SMAPI.Installer/assets/runtimeconfig.json index 8a01ceb1..34018b8a 100644 --- a/src/SMAPI.Installer/assets/runtimeconfig.unix.json +++ b/src/SMAPI.Installer/assets/runtimeconfig.json @@ -4,11 +4,13 @@ "includedFrameworks": [ { "name": "Microsoft.NETCore.App", - "version": "5.0.7" + "version": "5.0.0", + "rollForward": "latestMinor" } ], "configProperties": { - "System.Runtime.TieredCompilation": false + "System.Runtime.TieredCompilation": false, + "System.Reflection.Metadata.MetadataUpdater.IsSupported": false } } } diff --git a/src/SMAPI.Installer/assets/runtimeconfig.windows.json b/src/SMAPI.Installer/assets/runtimeconfig.windows.json deleted file mode 100644 index b693d809..00000000 --- a/src/SMAPI.Installer/assets/runtimeconfig.windows.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "runtimeOptions": { - "tfm": "net5.0", - "framework": { - "name": "Microsoft.NETCore.App", - "version": "5.0.0" - }, - "configProperties": { - "System.Runtime.TieredCompilation": false - } - } -} diff --git a/src/SMAPI.Installer/assets/unix-install.sh b/src/SMAPI.Installer/assets/unix-install.sh deleted file mode 100644 index 07df4e6c..00000000 --- a/src/SMAPI.Installer/assets/unix-install.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Move to script's directory -cd "`dirname "$0"`" - -# make sure .NET 5 is installed -if ! command -v dotnet >/dev/null 2>&1; then - echo "Oops! You must have .NET 5 installed to use SMAPI: https://dotnet.microsoft.com/download"; - read - exit 1 -fi - -# run installer -dotnet internal/unix/SMAPI.Installer.dll diff --git a/src/SMAPI.Installer/assets/unix-launcher.sh b/src/SMAPI.Installer/assets/unix-launcher.sh index 58f7a5ae..e8b9ae62 100644 --- a/src/SMAPI.Installer/assets/unix-launcher.sh +++ b/src/SMAPI.Installer/assets/unix-launcher.sh @@ -49,20 +49,13 @@ if [ ! -f "Stardew Valley.dll" ]; then exit 1 fi -# .NET 5 must be installed -if ! command -v dotnet >/dev/null 2>&1; then - echo "Oops! You must have .NET 5 installed to use SMAPI: https://dotnet.microsoft.com/download"; - read - exit 1 -fi - ########## ## Launch SMAPI ########## # macOS if [ "$(uname)" == "Darwin" ]; then - dotnet StardewModdingAPI.dll "$@" + ./StardewModdingAPI "$@" # Linux else |