summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModHelpers
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-08 20:18:06 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-08 20:18:06 -0400
commit09f69d986f4f44521d8a2cd745269dce4b83320e (patch)
tree9397ece62492cb7d8d95dc01f665c5dca08b5086 /src/SMAPI/Framework/ModHelpers
parente7e6327b3c85d52ab666aad2a054fbbdbd9431da (diff)
parentcbe8b597cb55285dea2bb2c34ab26f148a76bc17 (diff)
downloadSMAPI-09f69d986f4f44521d8a2cd745269dce4b83320e.tar.gz
SMAPI-09f69d986f4f44521d8a2cd745269dce4b83320e.tar.bz2
SMAPI-09f69d986f4f44521d8a2cd745269dce4b83320e.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers')
-rw-r--r--src/SMAPI/Framework/ModHelpers/CommandHelper.cs2
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentHelper.cs2
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs10
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModContentHelper.cs16
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModHelper.cs6
5 files changed, 16 insertions, 20 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/CommandHelper.cs b/src/SMAPI/Framework/ModHelpers/CommandHelper.cs
index 226a8d69..f39ed42e 100644
--- a/src/SMAPI/Framework/ModHelpers/CommandHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/CommandHelper.cs
@@ -33,7 +33,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
}
/// <inheritdoc />
- [Obsolete]
+ [Obsolete("Use mod-provided APIs to integrate with mods instead. This method will be removed in SMAPI 4.0.0.")]
public bool Trigger(string name, string[] arguments)
{
SCore.DeprecationManager.Warn(
diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
index 3c2441e8..6a92da24 100644
--- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
@@ -15,7 +15,7 @@ using StardewValley;
namespace StardewModdingAPI.Framework.ModHelpers
{
/// <summary>Provides an API for loading content assets.</summary>
- [Obsolete]
+ [Obsolete($"Use {nameof(IMod.Helper)}.{nameof(IModHelper.GameContent)} or {nameof(IMod.Helper)}.{nameof(IModHelper.ModContent)} instead. This interface will be removed in SMAPI 4.0.0.")]
internal class ContentHelper : BaseHelper, IContentHelper
{
/*********
diff --git a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs
index 9f4a7ceb..6bc091fa 100644
--- a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs
@@ -42,7 +42,15 @@ namespace StardewModdingAPI.Framework.ModHelpers
public IContentPack CreateFake(string directoryPath)
{
string id = Guid.NewGuid().ToString("N");
- return this.CreateTemporary(directoryPath, id, id, id, id, new SemanticVersion(1, 0, 0));
+ string relativePath = Path.GetRelativePath(Constants.ModsPath, directoryPath);
+ return this.CreateTemporary(
+ directoryPath: directoryPath,
+ id: id,
+ name: $"{this.Mod.DisplayName} (fake content pack: {relativePath})",
+ description: $"A temporary content pack created by the {this.Mod.DisplayName} mod.",
+ author: "???",
+ new SemanticVersion(1, 0, 0)
+ );
}
/// <inheritdoc />
diff --git a/src/SMAPI/Framework/ModHelpers/ModContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ModContentHelper.cs
index 74ea73de..6429f9bf 100644
--- a/src/SMAPI/Framework/ModHelpers/ModContentHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ModContentHelper.cs
@@ -1,10 +1,8 @@
using System;
-using Microsoft.Xna.Framework.Content;
using StardewModdingAPI.Framework.Content;
using StardewModdingAPI.Framework.ContentManagers;
using StardewModdingAPI.Framework.Exceptions;
using StardewModdingAPI.Framework.Reflection;
-using StardewModdingAPI.Toolkit.Utilities.PathLookups;
namespace StardewModdingAPI.Framework.ModHelpers
{
@@ -23,9 +21,6 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <summary>The friendly mod name for use in errors.</summary>
private readonly string ModName;
- /// <summary>A lookup for relative paths within the <see cref="ContentManager.RootDirectory"/>.</summary>
- private readonly IFilePathLookup RelativePathLookup;
-
/// <summary>Simplifies access to private code.</summary>
private readonly Reflector Reflection;
@@ -39,9 +34,8 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <param name="mod">The mod using this instance.</param>
/// <param name="modName">The friendly mod name for use in errors.</param>
/// <param name="gameContentManager">The game content manager used for map tilesheets not provided by the mod.</param>
- /// <param name="relativePathLookup">A lookup for relative paths within the <paramref name="relativePathLookup"/>.</param>
/// <param name="reflection">Simplifies access to private code.</param>
- public ModContentHelper(ContentCoordinator contentCore, string modFolderPath, IModMetadata mod, string modName, IContentManager gameContentManager, IFilePathLookup relativePathLookup, Reflector reflection)
+ public ModContentHelper(ContentCoordinator contentCore, string modFolderPath, IModMetadata mod, string modName, IContentManager gameContentManager, Reflector reflection)
: base(mod)
{
string managedAssetPrefix = contentCore.GetManagedAssetPrefix(mod.Manifest.UniqueID);
@@ -49,7 +43,6 @@ namespace StardewModdingAPI.Framework.ModHelpers
this.ContentCore = contentCore;
this.ModContentManager = contentCore.CreateModContentManager(managedAssetPrefix, modName, modFolderPath, gameContentManager);
this.ModName = modName;
- this.RelativePathLookup = relativePathLookup;
this.Reflection = reflection;
}
@@ -57,8 +50,6 @@ namespace StardewModdingAPI.Framework.ModHelpers
public T Load<T>(string relativePath)
where T : notnull
{
- relativePath = this.RelativePathLookup.GetAssetName(relativePath);
-
IAssetName assetName = this.ContentCore.ParseAssetName(relativePath, allowLocales: false);
try
@@ -74,7 +65,6 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <inheritdoc />
public IAssetName GetInternalAssetName(string relativePath)
{
- relativePath = this.RelativePathLookup.GetAssetName(relativePath);
return this.ModContentManager.GetInternalAssetKey(relativePath);
}
@@ -85,9 +75,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
if (data == null)
throw new ArgumentNullException(nameof(data), "Can't get a patch helper for a null value.");
- relativePath = relativePath != null
- ? this.RelativePathLookup.GetAssetName(relativePath)
- : $"temp/{Guid.NewGuid():N}";
+ relativePath ??= $"temp/{Guid.NewGuid():N}";
return new AssetDataForObject(
locale: this.ContentCore.GetLocale(),
diff --git a/src/SMAPI/Framework/ModHelpers/ModHelper.cs b/src/SMAPI/Framework/ModHelpers/ModHelper.cs
index a23a9beb..008195d9 100644
--- a/src/SMAPI/Framework/ModHelpers/ModHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ModHelper.cs
@@ -13,7 +13,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
** Fields
*********/
/// <summary>The backing field for <see cref="Content"/>.</summary>
- [Obsolete]
+ [Obsolete("This only exists to support legacy code and will be removed in SMAPI 4.0.0.")]
private readonly ContentHelper ContentImpl;
@@ -27,7 +27,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
public IModEvents Events { get; }
/// <inheritdoc />
- [Obsolete]
+ [Obsolete($"Use {nameof(IGameContentHelper)} or {nameof(IModContentHelper)} instead.")]
public IContentHelper Content
{
get
@@ -128,7 +128,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
}
/// <summary>Get the underlying instance for <see cref="IContentHelper"/>.</summary>
- [Obsolete]
+ [Obsolete("This only exists to support legacy code and will be removed in SMAPI 4.0.0.")]
public ContentHelper GetLegacyContentHelper()
{
return this.ContentImpl;