diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-27 20:09:43 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-27 20:09:43 -0400 |
commit | d7d8cdaa5a4bc01001e3538a9189b04d1130d3bb (patch) | |
tree | 5fb993cd855ae1e6f26e61d78543fef168da7ddf | |
parent | 8425c8203394c436645828fcd11976078d04a1f7 (diff) | |
download | SMAPI-d7d8cdaa5a4bc01001e3538a9189b04d1130d3bb.tar.gz SMAPI-d7d8cdaa5a4bc01001e3538a9189b04d1130d3bb.tar.bz2 SMAPI-d7d8cdaa5a4bc01001e3538a9189b04d1130d3bb.zip |
add backwards compatibility for loading content assets with .xnb extension
-rw-r--r-- | src/SMAPI/Framework/Content/ContentCache.cs | 2 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModHelpers/ContentHelper.cs | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/Content/ContentCache.cs b/src/SMAPI/Framework/Content/ContentCache.cs index cbb6c1e9..736ee5da 100644 --- a/src/SMAPI/Framework/Content/ContentCache.cs +++ b/src/SMAPI/Framework/Content/ContentCache.cs @@ -76,7 +76,7 @@ namespace StardewModdingAPI.Framework.Content { key = this.NormalizePathSeparators(key); return key.EndsWith(".xnb", StringComparison.OrdinalIgnoreCase) - ? key.Substring(0, key.Length - 4) + ? key[..^4] : key; } diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs index 94a30bf1..3c2441e8 100644 --- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs @@ -118,6 +118,17 @@ namespace StardewModdingAPI.Framework.ModHelpers switch (source) { case ContentSource.GameContent: + if (assetName.Name.EndsWith(".xnb", StringComparison.OrdinalIgnoreCase)) + { + assetName = this.ContentCore.ParseAssetName(assetName.Name[..^4], allowLocales: true); + SCore.DeprecationManager.Warn( + this.Mod, + "loading assets from the Content folder with a .xnb file extension", + "3.14.0", + DeprecationLevel.Notice + ); + } + return this.GameContentManager.LoadLocalized<T>(assetName, this.CurrentLocaleConstant, useCache: false); case ContentSource.ModFolder: |