diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-12 21:26:10 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-11-28 00:01:41 -0500 |
commit | 727d75ae728ba6cc8fc070524264c454aac8404f (patch) | |
tree | 36d8a454723c0b615ea2a3446b2ef706dd065ddb /src/SMAPI.Installer/Framework | |
parent | 40b74398ace748a565199fb91325815804011a98 (diff) | |
download | SMAPI-727d75ae728ba6cc8fc070524264c454aac8404f.tar.gz SMAPI-727d75ae728ba6cc8fc070524264c454aac8404f.tar.bz2 SMAPI-727d75ae728ba6cc8fc070524264c454aac8404f.zip |
update to .NET 5 and official 64-bit
Diffstat (limited to 'src/SMAPI.Installer/Framework')
-rw-r--r-- | src/SMAPI.Installer/Framework/InstallerContext.cs | 45 | ||||
-rw-r--r-- | src/SMAPI.Installer/Framework/InstallerPaths.cs | 44 |
2 files changed, 22 insertions, 67 deletions
diff --git a/src/SMAPI.Installer/Framework/InstallerContext.cs b/src/SMAPI.Installer/Framework/InstallerContext.cs index 88e57760..95df32ca 100644 --- a/src/SMAPI.Installer/Framework/InstallerContext.cs +++ b/src/SMAPI.Installer/Framework/InstallerContext.cs @@ -1,6 +1,4 @@ -using System; using System.IO; -using Microsoft.Win32; using StardewModdingAPI.Toolkit; using StardewModdingAPI.Toolkit.Framework.GameScanning; using StardewModdingAPI.Toolkit.Utilities; @@ -13,9 +11,6 @@ namespace StardewModdingAPI.Installer.Framework /********* ** Fields *********/ - /// <summary>The <see cref="Environment.OSVersion"/> value that represents Windows 7.</summary> - private readonly Version Windows7Version = new Version(6, 1); - /// <summary>The underlying toolkit game scanner.</summary> private readonly GameScanner GameScanner = new GameScanner(); @@ -29,9 +24,6 @@ namespace StardewModdingAPI.Installer.Framework /// <summary>The human-readable OS name and version.</summary> public string PlatformName { get; } - /// <summary>The name of the Stardew Valley executable.</summary> - public string ExecutableName { get; } - /// <summary>Whether the installer is running on Windows.</summary> public bool IsWindows => this.Platform == Platform.Windows; @@ -47,7 +39,6 @@ namespace StardewModdingAPI.Installer.Framework { this.Platform = EnvironmentUtility.DetectPlatform(); this.PlatformName = EnvironmentUtility.GetFriendlyPlatformName(this.Platform); - this.ExecutableName = EnvironmentUtility.GetExecutableName(this.Platform); } /// <summary>Get the installer's version number.</summary> @@ -57,42 +48,6 @@ namespace StardewModdingAPI.Installer.Framework return new SemanticVersion(raw); } - /// <summary>Get whether the current system has .NET Framework 4.5 or later installed. This only applies on Windows.</summary> - /// <exception cref="NotSupportedException">The current platform is not Windows.</exception> - public bool HasNetFramework45() - { - switch (this.Platform) - { - case Platform.Windows: - using (RegistryKey versionKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full")) - return versionKey?.GetValue("Release") != null; // .NET Framework 4.5+ - - default: - throw new NotSupportedException("The installed .NET Framework version can only be checked on Windows."); - } - } - - /// <summary>Get whether the current system has XNA Framework installed. This only applies on Windows.</summary> - /// <exception cref="NotSupportedException">The current platform is not Windows.</exception> - public bool HasXna() - { - switch (this.Platform) - { - case Platform.Windows: - using (RegistryKey key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\XNA\Framework")) - return key != null; // XNA Framework 4.0+ - - default: - throw new NotSupportedException("The installed XNA Framework version can only be checked on Windows."); - } - } - - /// <summary>Whether the current OS supports newer versions of .NET Framework.</summary> - public bool CanInstallLatestNetFramework() - { - return Environment.OSVersion.Version >= this.Windows7Version; // Windows 7+ - } - /// <summary>Get whether a folder seems to contain the game files.</summary> /// <param name="dir">The folder to check.</param> public bool LooksLikeGameFolder(DirectoryInfo dir) diff --git a/src/SMAPI.Installer/Framework/InstallerPaths.cs b/src/SMAPI.Installer/Framework/InstallerPaths.cs index 6ba5fa5f..0976eceb 100644 --- a/src/SMAPI.Installer/Framework/InstallerPaths.cs +++ b/src/SMAPI.Installer/Framework/InstallerPaths.cs @@ -1,4 +1,5 @@ using System.IO; +using StardewModdingAPI.Toolkit.Framework; namespace StardewModdingAPI.Installer.Framework { @@ -44,17 +45,20 @@ namespace StardewModdingAPI.Installer.Framework /// <summary>The full path to the user's config overrides file.</summary> public string ApiUserConfigPath { get; } - /// <summary>The full path to the installed game executable file.</summary> - public string ExecutablePath { get; private set; } + /// <summary>The full path to the installed game DLL.</summary> + public string GameDllPath { get; } - /// <summary>The full path to the vanilla game launcher on Linux/macOS.</summary> - public string UnixLauncherPath { get; } + /// <summary>The full path to the installed SMAPI executable file.</summary> + public string UnixSmapiExecutablePath { get; } - /// <summary>The full path to the installed SMAPI launcher on Linux/macOS before it's renamed.</summary> - public string UnixSmapiLauncherPath { get; } + /// <summary>The full path to the vanilla game launch script on Linux/macOS.</summary> + public string VanillaLaunchScriptPath { get; } - /// <summary>The full path to the vanilla game launcher on Linux/macOS after SMAPI is installed.</summary> - public string UnixBackupLauncherPath { get; } + /// <summary>The full path to the installed SMAPI launch script on Linux/macOS before it's renamed.</summary> + public string NewLaunchScriptPath { get; } + + /// <summary>The full path to the backed up game launch script on Linux/macOS after SMAPI is installed.</summary> + public string BackupLaunchScriptPath { get; } /********* @@ -63,28 +67,24 @@ namespace StardewModdingAPI.Installer.Framework /// <summary>Construct an instance.</summary> /// <param name="bundleDir">The directory path containing the files to copy into the game folder.</param> /// <param name="gameDir">The directory path for the installed game.</param> - /// <param name="gameExecutableName">The name of the game's executable file for the current platform.</param> - public InstallerPaths(DirectoryInfo bundleDir, DirectoryInfo gameDir, string gameExecutableName) + public InstallerPaths(DirectoryInfo bundleDir, DirectoryInfo gameDir) { + // base paths this.BundleDir = bundleDir; this.GameDir = gameDir; this.ModsDir = new DirectoryInfo(Path.Combine(gameDir.FullName, "Mods")); + this.GameDllPath = Path.Combine(gameDir.FullName, Constants.GameDllName); - this.BundleApiUserConfigPath = Path.Combine(bundleDir.FullName, "smapi-internal", "config.user.json"); + // launch scripts + this.VanillaLaunchScriptPath = Path.Combine(gameDir.FullName, "StardewValley"); + this.NewLaunchScriptPath = Path.Combine(gameDir.FullName, "unix-launcher.sh"); + this.BackupLaunchScriptPath = Path.Combine(gameDir.FullName, "StardewValley-original"); + this.UnixSmapiExecutablePath = Path.Combine(gameDir.FullName, "StardewModdingAPI"); - this.ExecutablePath = Path.Combine(gameDir.FullName, gameExecutableName); - this.UnixLauncherPath = Path.Combine(gameDir.FullName, "StardewValley"); - this.UnixSmapiLauncherPath = Path.Combine(gameDir.FullName, "StardewModdingAPI"); - this.UnixBackupLauncherPath = Path.Combine(gameDir.FullName, "StardewValley-original"); + // internal files + this.BundleApiUserConfigPath = Path.Combine(bundleDir.FullName, "smapi-internal", "config.user.json"); this.ApiConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.json"); this.ApiUserConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.user.json"); } - - /// <summary>Override the filename for the <see cref="ExecutablePath"/>.</summary> - /// <param name="filename">the file name.</param> - public void SetExecutableFileName(string filename) - { - this.ExecutablePath = Path.Combine(this.GamePath, filename); - } } } |