add IContentHelper.ParseAssetName (#766)

This commit is contained in:
Jesse Plamondon-Willard 2022-03-26 17:44:48 -04:00
parent 3a9ea66a20
commit bacb851d7b
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
3 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,7 @@
* Added `Constants.ContentPath`.
* Added `IAssetName` fields to the info received by `IAssetEditor` and `IAssetLoader` methods.
_This adds methods for working with asset names, parsed locales, etc._
* Added `helper.Content.ParseAssetName` to get an `IAssetName` for an arbitrary asset key.
* If an asset is loaded multiple times in the same tick, `IAssetLoader.CanLoad` and `IAssetEditor.CanEdit` are now cached unless invalidated by `helper.Content.InvalidateCache`.
* 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`).

View File

@ -103,6 +103,12 @@ namespace StardewModdingAPI.Framework.ModHelpers
this.Monitor = monitor;
}
/// <inheritdoc />
public IAssetName ParseAssetName(string rawName)
{
return this.ContentCore.ParseAssetName(rawName);
}
/// <inheritdoc />
public T Load<T>(string key, ContentSource source = ContentSource.ModFolder)
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Framework.Content;
using StardewValley;
using xTile;
@ -30,6 +31,11 @@ namespace StardewModdingAPI
/*********
** Public methods
*********/
/// <summary>Parse a raw asset name.</summary>
/// <param name="rawName">The raw asset name to parse.</param>
/// <exception cref="ArgumentException">The <paramref name="rawName"/> is null or empty.</exception>
IAssetName ParseAssetName(string rawName);
/// <summary>Load content from the game folder or mod folder (if not already cached), and return it. When loading a <c>.png</c> file, this must be called outside the game's draw loop.</summary>
/// <typeparam name="T">The expected data type. The main supported types are <see cref="Map"/>, <see cref="Texture2D"/>, dictionaries, and lists; other types may be supported by the game's content pipeline.</typeparam>
/// <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>