add Constants.GamePath & deprecate Constants.ExecutionPath

This commit is contained in:
Jesse Plamondon-Willard 2022-02-19 11:07:26 -05:00
parent a2190df08c
commit 2d52681b10
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
7 changed files with 34 additions and 23 deletions

View File

@ -4,20 +4,27 @@
## Upcoming release
* For players:
* Improved translations. Thanks to ChulkyBow (updated Ukrainian)!
* Fixed `player_add` console command's handling of Journal Scraps and Secret Notes.
* For mod authors:
* Added `IAssetName` field to the asset info received by `IAssetEditor` and `IAssetLoader` methods.
_This provides utility methods for working with asset names, parsed locales, etc. The `asset.AssetNameEquals` method is now deprecated in favor of `asset.Name.IsEquivalentTo`_.
* The `SDate` constructor is no longer case-sensitive for season names.
* Fixed issue where suppressing `[Left|Right]Thumbstick[Down|Left]` keys would suppress the opposite direction instead.
* Added `IAssetName Name` field to the info received by `IAssetEditor` and `IAssetLoader` methods.
_This adds methods for working with asset names, parsed locales, etc._
* Fixed the `SDate` constructor being case-sensitive.
* Fixed support for using locale codes from custom languages in asset names (e.g. `Data/Achievements.eo-EU`).
* Fixed issue where suppressing `[Left|Right]Thumbstick[Down|Left]` keys would suppress the opposite direction instead.
* For console commands:
* Fixed `player_add` with Journal Scraps and Secret Notes.
* **Deprecation warning for mod authors:**
These APIs are now deprecated and will be removed in the upcoming SMAPI 4.0.0.
API | how to update code
:-- | :-----------------
`Constants.ExecutionPath` | Use `Constants.GamePath` instead.
`IAssetInfo.AssetName`<br />`IAssetData.AssetName` | Use `Name` instead, which changes the type from `string` to the new `AssetName`.
`IAssetInfo.AssetNameEquals`<br />`IAssetData.AssetNameEquals` | Use `Name.IsEquivalentTo` instead.
* For the web UI:
* Added `data-*` attributes to log parser page for external tools.
* Fixed JSON validator warning for update keys without a subkey.
* Fixed JSON validator warning shown for update keys without a subkey.
## 3.13.4
Released 16 January 2022 for Stardew Valley 1.5.6 or later.

View File

@ -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);
}
}
}

View File

@ -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}";

View File

@ -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

View File

@ -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",

View File

@ -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; }

View File

@ -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;
}