summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-02-19 11:07:26 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-02-19 11:07:26 -0500
commit2d52681b1034d314d8d56c561a5aa72e54e34576 (patch)
tree8c7e87bb6130166ee31b3a659229218f0cedf56b /src
parenta2190df08cc3f1b4a8dcb394056d65921d10702e (diff)
downloadSMAPI-2d52681b1034d314d8d56c561a5aa72e54e34576.tar.gz
SMAPI-2d52681b1034d314d8d56c561a5aa72e54e34576.tar.bz2
SMAPI-2d52681b1034d314d8d56c561a5aa72e54e34576.zip
add Constants.GamePath & deprecate Constants.ExecutionPath
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs6
-rw-r--r--src/SMAPI.Mods.SaveBackup/ModEntry.cs2
-rw-r--r--src/SMAPI/Constants.cs14
-rw-r--r--src/SMAPI/Framework/ContentCoordinator.cs2
-rw-r--r--src/SMAPI/Framework/ContentManagers/BaseContentManager.cs2
-rw-r--r--src/SMAPI/Program.cs10
6 files changed, 20 insertions, 16 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs
index 71093184..b97cb3e6 100644
--- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs
+++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/ShowGameFilesCommand.cs
@@ -1,4 +1,4 @@
-using System.Diagnostics;
+using System.Diagnostics;
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
{
@@ -18,8 +18,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
/// <param name="args">The command arguments.</param>
public override void Handle(IMonitor monitor, string command, ArgumentParser args)
{
- Process.Start(Constants.ExecutionPath);
- monitor.Log($"OK, opening {Constants.ExecutionPath}.", LogLevel.Info);
+ Process.Start(Constants.GamePath);
+ monitor.Log($"OK, opening {Constants.GamePath}.", LogLevel.Info);
}
}
}
diff --git a/src/SMAPI.Mods.SaveBackup/ModEntry.cs b/src/SMAPI.Mods.SaveBackup/ModEntry.cs
index d6414e9c..b89bb9c3 100644
--- a/src/SMAPI.Mods.SaveBackup/ModEntry.cs
+++ b/src/SMAPI.Mods.SaveBackup/ModEntry.cs
@@ -19,7 +19,7 @@ namespace StardewModdingAPI.Mods.SaveBackup
private readonly int BackupsToKeep = 10;
/// <summary>The absolute path to the folder in which to store save backups.</summary>
- private readonly string BackupFolder = Path.Combine(Constants.ExecutionPath, "save-backups");
+ private readonly string BackupFolder = Path.Combine(Constants.GamePath, "save-backups");
/// <summary>A unique label for the save backup to create.</summary>
private readonly string BackupLabel = $"{DateTime.UtcNow:yyyy-MM-dd} - SMAPI {Constants.ApiVersion} with Stardew Valley {Game1.version}";
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index 667491d6..810dfe48 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -31,10 +31,10 @@ namespace StardewModdingAPI
** Accessors
*********/
/// <summary>The path to the game folder.</summary>
- public static string ExecutionPath { get; } = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ public static string GamePath { get; } = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
/// <summary>The absolute path to the folder containing SMAPI's internal files.</summary>
- public static readonly string InternalFilesPath = Path.Combine(EarlyConstants.ExecutionPath, "smapi-internal");
+ public static readonly string InternalFilesPath = Path.Combine(EarlyConstants.GamePath, "smapi-internal");
/// <summary>The target game platform.</summary>
internal static GamePlatform Platform { get; } = (GamePlatform)Enum.Parse(typeof(GamePlatform), LowLevelEnvironmentUtility.DetectPlatform());
@@ -77,7 +77,11 @@ namespace StardewModdingAPI
public static GameFramework GameFramework { get; } = EarlyConstants.GameFramework;
/// <summary>The path to the game folder.</summary>
- public static string ExecutionPath { get; } = EarlyConstants.ExecutionPath;
+ [Obsolete($"Use {nameof(GamePath)} instead.")]
+ public static string ExecutionPath => Constants.GamePath;
+
+ /// <summary>The path to the game folder.</summary>
+ public static string GamePath { get; } = EarlyConstants.GamePath;
/// <summary>The directory path containing Stardew Valley's app data.</summary>
public static string DataPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley");
@@ -139,7 +143,7 @@ namespace StardewModdingAPI
internal static string UpdateMarker => Path.Combine(Constants.InternalFilesPath, "StardewModdingAPI.update.marker");
/// <summary>The default full path to search for mods.</summary>
- internal static string DefaultModsPath { get; } = Path.Combine(Constants.ExecutionPath, "Mods");
+ internal static string DefaultModsPath { get; } = Path.Combine(Constants.GamePath, "Mods");
/// <summary>The actual full path to search for mods.</summary>
internal static string ModsPath { get; set; }
@@ -222,7 +226,7 @@ namespace StardewModdingAPI
internal static void ConfigureAssemblyResolver(AssemblyDefinitionResolver resolver)
{
// add search paths
- resolver.AddSearchDirectory(Constants.ExecutionPath);
+ resolver.AddSearchDirectory(Constants.GamePath);
resolver.AddSearchDirectory(Constants.InternalFilesPath);
// add SMAPI explicitly
diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs
index 97a37b3f..00f9439c 100644
--- a/src/SMAPI/Framework/ContentCoordinator.cs
+++ b/src/SMAPI/Framework/ContentCoordinator.cs
@@ -107,7 +107,7 @@ namespace StardewModdingAPI.Framework
this.Reflection = reflection;
this.JsonHelper = jsonHelper;
this.OnLoadingFirstAsset = onLoadingFirstAsset;
- this.FullRootDirectory = Path.Combine(Constants.ExecutionPath, rootDirectory);
+ this.FullRootDirectory = Path.Combine(Constants.GamePath, rootDirectory);
this.ContentManagers.Add(
this.MainContentManager = new GameContentManager(
name: "Game1.content",
diff --git a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs
index be892b33..26f0921d 100644
--- a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs
@@ -56,7 +56,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
public LanguageCode Language => this.GetCurrentLanguage();
/// <inheritdoc />
- public string FullRootDirectory => Path.Combine(Constants.ExecutionPath, this.RootDirectory);
+ public string FullRootDirectory => Path.Combine(Constants.GamePath, this.RootDirectory);
/// <inheritdoc />
public bool IsNamespaced { get; }
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index 0c90f2aa..f2f65287 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -66,7 +66,7 @@ namespace StardewModdingAPI
{
Program.AssemblyPathsByName = new(StringComparer.OrdinalIgnoreCase);
- foreach (string searchPath in new[] { EarlyConstants.ExecutionPath, Program.DllSearchPath })
+ foreach (string searchPath in new[] { EarlyConstants.GamePath, Program.DllSearchPath })
{
foreach (string dllPath in Directory.EnumerateFiles(searchPath, "*.dll"))
{
@@ -110,7 +110,7 @@ namespace StardewModdingAPI
catch (Exception ex)
{
// file doesn't exist
- if (!File.Exists(Path.Combine(EarlyConstants.ExecutionPath, $"{EarlyConstants.GameAssemblyName}.exe")))
+ if (!File.Exists(Path.Combine(EarlyConstants.GamePath, $"{EarlyConstants.GameAssemblyName}.exe")))
Program.PrintErrorAndExit("Oops! SMAPI can't find the game. Make sure you're running StardewModdingAPI.exe in your game folder.");
// can't load file
@@ -160,8 +160,8 @@ namespace StardewModdingAPI
/// <remarks>This is needed to resolve native DLLs like libSkiaSharp.</remarks>
private static void AssertDepsJson()
{
- string sourcePath = Path.Combine(Constants.ExecutionPath, "Stardew Valley.deps.json");
- string targetPath = Path.Combine(Constants.ExecutionPath, "StardewModdingAPI.deps.json");
+ string sourcePath = Path.Combine(Constants.GamePath, "Stardew Valley.deps.json");
+ string targetPath = Path.Combine(Constants.GamePath, "StardewModdingAPI.deps.json");
if (!File.Exists(targetPath) || FileUtilities.GetFileHash(sourcePath) != FileUtilities.GetFileHash(targetPath))
{
@@ -194,7 +194,7 @@ namespace StardewModdingAPI
// normalise
modsPath = !string.IsNullOrWhiteSpace(rawModsPath)
- ? Path.Combine(Constants.ExecutionPath, rawModsPath)
+ ? Path.Combine(Constants.GamePath, rawModsPath)
: Constants.DefaultModsPath;
}