diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-08-12 21:26:10 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-11-28 00:01:42 -0500 |
commit | 8321cbf6eba7ca3fa46d6e452fd9ebff6baa99d0 (patch) | |
tree | a3040c8e84314514322bcf39f9bd277b14923c9b /src/SMAPI/Framework | |
parent | 727d75ae728ba6cc8fc070524264c454aac8404f (diff) | |
download | SMAPI-8321cbf6eba7ca3fa46d6e452fd9ebff6baa99d0.tar.gz SMAPI-8321cbf6eba7ca3fa46d6e452fd9ebff6baa99d0.tar.bz2 SMAPI-8321cbf6eba7ca3fa46d6e452fd9ebff6baa99d0.zip |
update for asset name format change
MonoGame uses Linux-style paths for assets on all platforms, which breaks the previous equivalence between path and asset name formats.
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r-- | src/SMAPI/Framework/Content/ContentCache.cs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/SMAPI/Framework/Content/ContentCache.cs b/src/SMAPI/Framework/Content/ContentCache.cs index 87d15e32..8e0c6228 100644 --- a/src/SMAPI/Framework/Content/ContentCache.cs +++ b/src/SMAPI/Framework/Content/ContentCache.cs @@ -17,9 +17,6 @@ namespace StardewModdingAPI.Framework.Content /// <summary>The underlying asset cache.</summary> private readonly IDictionary<string, object> Cache; - /// <summary>Applies platform-specific asset key normalization so it's consistent with the underlying cache.</summary> - private readonly Func<string, string> NormalizeAssetNameForPlatform; - /********* ** Accessors @@ -47,11 +44,7 @@ namespace StardewModdingAPI.Framework.Content /// <param name="reflection">Simplifies access to private game code.</param> public ContentCache(LocalizedContentManager contentManager, Reflector reflection) { - // init this.Cache = reflection.GetField<Dictionary<string, object>>(contentManager, "loadedAssets").GetValue(); - - // get key normalization logic - this.NormalizeAssetNameForPlatform = PathUtilities.NormalizePath; //this.NormalizeAssetNameForPlatform = key => key.Replace('\\', '/'); // based on MonoGame's ContentManager.Load<T> logic } /**** @@ -68,23 +61,24 @@ namespace StardewModdingAPI.Framework.Content /**** ** Normalize ****/ - /// <summary>Normalize path separators in a file path. For asset keys, see <see cref="NormalizeKey"/> instead.</summary> + /// <summary>Normalize path separators in an asset name.</summary> /// <param name="path">The file path to normalize.</param> [Pure] public string NormalizePathSeparators(string path) { - return PathUtilities.NormalizePath(path); + return PathUtilities.NormalizeAssetName(path); } /// <summary>Normalize a cache key so it's consistent with the underlying cache.</summary> /// <param name="key">The asset key.</param> + /// <remarks>This is equivalent to <see cref="NormalizePathSeparators"/> with added file extension logic.</remarks> [Pure] public string NormalizeKey(string key) { key = this.NormalizePathSeparators(key); return key.EndsWith(".xnb", StringComparison.OrdinalIgnoreCase) ? key.Substring(0, key.Length - 4) - : this.NormalizeAssetNameForPlatform(key); + : key; } /**** |