add Constants.GamePath & deprecate Constants.ExecutionPath
This commit is contained in:
parent
a2190df08c
commit
2d52681b10
|
@ -4,20 +4,27 @@
|
||||||
## Upcoming release
|
## Upcoming release
|
||||||
* For players:
|
* For players:
|
||||||
* Improved translations. Thanks to ChulkyBow (updated Ukrainian)!
|
* Improved translations. Thanks to ChulkyBow (updated Ukrainian)!
|
||||||
|
* Fixed `player_add` console command's handling of Journal Scraps and Secret Notes.
|
||||||
|
|
||||||
* For mod authors:
|
* For mod authors:
|
||||||
* Added `IAssetName` field to the asset info received by `IAssetEditor` and `IAssetLoader` methods.
|
* Added `IAssetName Name` field to the 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`_.
|
_This adds methods for working with asset names, parsed locales, etc._
|
||||||
* The `SDate` constructor is no longer case-sensitive for season names.
|
* Fixed the `SDate` constructor being case-sensitive.
|
||||||
* Fixed issue where suppressing `[Left|Right]Thumbstick[Down|Left]` keys would suppress the opposite direction instead.
|
|
||||||
* Fixed support for using locale codes from custom languages in asset names (e.g. `Data/Achievements.eo-EU`).
|
* 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:
|
* **Deprecation warning for mod authors:**
|
||||||
* Fixed `player_add` with Journal Scraps and Secret Notes.
|
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:
|
* For the web UI:
|
||||||
* Added `data-*` attributes to log parser page for external tools.
|
* 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
|
## 3.13.4
|
||||||
Released 16 January 2022 for Stardew Valley 1.5.6 or later.
|
Released 16 January 2022 for Stardew Valley 1.5.6 or later.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
|
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>
|
/// <param name="args">The command arguments.</param>
|
||||||
public override void Handle(IMonitor monitor, string command, ArgumentParser args)
|
public override void Handle(IMonitor monitor, string command, ArgumentParser args)
|
||||||
{
|
{
|
||||||
Process.Start(Constants.ExecutionPath);
|
Process.Start(Constants.GamePath);
|
||||||
monitor.Log($"OK, opening {Constants.ExecutionPath}.", LogLevel.Info);
|
monitor.Log($"OK, opening {Constants.GamePath}.", LogLevel.Info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace StardewModdingAPI.Mods.SaveBackup
|
||||||
private readonly int BackupsToKeep = 10;
|
private readonly int BackupsToKeep = 10;
|
||||||
|
|
||||||
/// <summary>The absolute path to the folder in which to store save backups.</summary>
|
/// <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>
|
/// <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}";
|
private readonly string BackupLabel = $"{DateTime.UtcNow:yyyy-MM-dd} - SMAPI {Constants.ApiVersion} with Stardew Valley {Game1.version}";
|
||||||
|
|
|
@ -31,10 +31,10 @@ namespace StardewModdingAPI
|
||||||
** Accessors
|
** Accessors
|
||||||
*********/
|
*********/
|
||||||
/// <summary>The path to the game folder.</summary>
|
/// <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>
|
/// <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>
|
/// <summary>The target game platform.</summary>
|
||||||
internal static GamePlatform Platform { get; } = (GamePlatform)Enum.Parse(typeof(GamePlatform), LowLevelEnvironmentUtility.DetectPlatform());
|
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;
|
public static GameFramework GameFramework { get; } = EarlyConstants.GameFramework;
|
||||||
|
|
||||||
/// <summary>The path to the game folder.</summary>
|
/// <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>
|
/// <summary>The directory path containing Stardew Valley's app data.</summary>
|
||||||
public static string DataPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley");
|
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");
|
internal static string UpdateMarker => Path.Combine(Constants.InternalFilesPath, "StardewModdingAPI.update.marker");
|
||||||
|
|
||||||
/// <summary>The default full path to search for mods.</summary>
|
/// <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>
|
/// <summary>The actual full path to search for mods.</summary>
|
||||||
internal static string ModsPath { get; set; }
|
internal static string ModsPath { get; set; }
|
||||||
|
@ -222,7 +226,7 @@ namespace StardewModdingAPI
|
||||||
internal static void ConfigureAssemblyResolver(AssemblyDefinitionResolver resolver)
|
internal static void ConfigureAssemblyResolver(AssemblyDefinitionResolver resolver)
|
||||||
{
|
{
|
||||||
// add search paths
|
// add search paths
|
||||||
resolver.AddSearchDirectory(Constants.ExecutionPath);
|
resolver.AddSearchDirectory(Constants.GamePath);
|
||||||
resolver.AddSearchDirectory(Constants.InternalFilesPath);
|
resolver.AddSearchDirectory(Constants.InternalFilesPath);
|
||||||
|
|
||||||
// add SMAPI explicitly
|
// add SMAPI explicitly
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace StardewModdingAPI.Framework
|
||||||
this.Reflection = reflection;
|
this.Reflection = reflection;
|
||||||
this.JsonHelper = jsonHelper;
|
this.JsonHelper = jsonHelper;
|
||||||
this.OnLoadingFirstAsset = onLoadingFirstAsset;
|
this.OnLoadingFirstAsset = onLoadingFirstAsset;
|
||||||
this.FullRootDirectory = Path.Combine(Constants.ExecutionPath, rootDirectory);
|
this.FullRootDirectory = Path.Combine(Constants.GamePath, rootDirectory);
|
||||||
this.ContentManagers.Add(
|
this.ContentManagers.Add(
|
||||||
this.MainContentManager = new GameContentManager(
|
this.MainContentManager = new GameContentManager(
|
||||||
name: "Game1.content",
|
name: "Game1.content",
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
||||||
public LanguageCode Language => this.GetCurrentLanguage();
|
public LanguageCode Language => this.GetCurrentLanguage();
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string FullRootDirectory => Path.Combine(Constants.ExecutionPath, this.RootDirectory);
|
public string FullRootDirectory => Path.Combine(Constants.GamePath, this.RootDirectory);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsNamespaced { get; }
|
public bool IsNamespaced { get; }
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace StardewModdingAPI
|
||||||
{
|
{
|
||||||
Program.AssemblyPathsByName = new(StringComparer.OrdinalIgnoreCase);
|
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"))
|
foreach (string dllPath in Directory.EnumerateFiles(searchPath, "*.dll"))
|
||||||
{
|
{
|
||||||
|
@ -110,7 +110,7 @@ namespace StardewModdingAPI
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// file doesn't exist
|
// 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.");
|
Program.PrintErrorAndExit("Oops! SMAPI can't find the game. Make sure you're running StardewModdingAPI.exe in your game folder.");
|
||||||
|
|
||||||
// can't load file
|
// can't load file
|
||||||
|
@ -160,8 +160,8 @@ namespace StardewModdingAPI
|
||||||
/// <remarks>This is needed to resolve native DLLs like libSkiaSharp.</remarks>
|
/// <remarks>This is needed to resolve native DLLs like libSkiaSharp.</remarks>
|
||||||
private static void AssertDepsJson()
|
private static void AssertDepsJson()
|
||||||
{
|
{
|
||||||
string sourcePath = Path.Combine(Constants.ExecutionPath, "Stardew Valley.deps.json");
|
string sourcePath = Path.Combine(Constants.GamePath, "Stardew Valley.deps.json");
|
||||||
string targetPath = Path.Combine(Constants.ExecutionPath, "StardewModdingAPI.deps.json");
|
string targetPath = Path.Combine(Constants.GamePath, "StardewModdingAPI.deps.json");
|
||||||
|
|
||||||
if (!File.Exists(targetPath) || FileUtilities.GetFileHash(sourcePath) != FileUtilities.GetFileHash(targetPath))
|
if (!File.Exists(targetPath) || FileUtilities.GetFileHash(sourcePath) != FileUtilities.GetFileHash(targetPath))
|
||||||
{
|
{
|
||||||
|
@ -194,7 +194,7 @@ namespace StardewModdingAPI
|
||||||
|
|
||||||
// normalise
|
// normalise
|
||||||
modsPath = !string.IsNullOrWhiteSpace(rawModsPath)
|
modsPath = !string.IsNullOrWhiteSpace(rawModsPath)
|
||||||
? Path.Combine(Constants.ExecutionPath, rawModsPath)
|
? Path.Combine(Constants.GamePath, rawModsPath)
|
||||||
: Constants.DefaultModsPath;
|
: Constants.DefaultModsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue