summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md3
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentHelper.cs9
-rw-r--r--src/SMAPI/IContentHelper.cs6
3 files changed, 17 insertions, 1 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 53ec07c6..1e89667a 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -12,7 +12,8 @@
* Slightly improved the [log parser][] UI.
* For modders:
- * Added `DaysSinceStart` property to `SDate` dates.
+ * Added `helper.Content.NormaliseAssetName` method.
+ * Added `SDate.DaysSinceStart` property.
* Fixed input events' `e.SuppressButton(button)` method ignoring specified button.
* Fixed input events' `e.SuppressButton()` method not working with mouse buttons.
diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
index 7665eb78..4a1d3853 100644
--- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework.Content;
@@ -134,6 +135,14 @@ namespace StardewModdingAPI.Framework.ModHelpers
}
}
+ /// <summary>Normalise an asset name so it's consistent with those generated by the game. This is mainly useful for string comparisons like <see cref="string.StartsWith(string)"/> on generated asset names, and isn't necessary when passing asset names into other content helper methods.</summary>
+ /// <param name="assetName">The asset key.</param>
+ [Pure]
+ public string NormaliseAssetName(string assetName)
+ {
+ return this.ContentManager.NormaliseAssetName(assetName);
+ }
+
/// <summary>Get the underlying key in the game's content cache for an asset. This can be used to load custom map tilesheets, but should be avoided when you can use the content API instead. This does not validate whether the asset exists.</summary>
/// <param name="key">The asset key to fetch (if the <paramref name="source"/> is <see cref="ContentSource.GameContent"/>), or the local path to a content file relative to the mod folder.</param>
/// <param name="source">Where to search for a matching content asset.</param>
diff --git a/src/SMAPI/IContentHelper.cs b/src/SMAPI/IContentHelper.cs
index e3362502..1b87183d 100644
--- a/src/SMAPI/IContentHelper.cs
+++ b/src/SMAPI/IContentHelper.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.Contracts;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using StardewValley;
@@ -37,6 +38,11 @@ namespace StardewModdingAPI
/// <exception cref="ContentLoadException">The content asset couldn't be loaded (e.g. because it doesn't exist).</exception>
T Load<T>(string key, ContentSource source = ContentSource.ModFolder);
+ /// <summary>Normalise an asset name so it's consistent with those generated by the game. This is mainly useful for string comparisons like <see cref="string.StartsWith(string)"/> on generated asset names, and isn't necessary when passing asset names into other content helper methods.</summary>
+ /// <param name="assetName">The asset key.</param>
+ [Pure]
+ string NormaliseAssetName(string assetName);
+
/// <summary>Get the underlying key in the game's content cache for an asset. This can be used to load custom map tilesheets, but should be avoided when you can use the content API instead. This does not validate whether the asset exists.</summary>
/// <param name="key">The asset key to fetch (if the <paramref name="source"/> is <see cref="ContentSource.GameContent"/>), or the local path to a content file relative to the mod folder.</param>
/// <param name="source">Where to search for a matching content asset.</param>