summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-12 00:21:52 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-05-12 00:21:52 -0400
commita9cadc7f32fd9fd244fc3e22c62a35e7c257c084 (patch)
treed07a8b34608f46948505755a599c07da65a7fde7 /src/SMAPI/Framework/ModHelpers/ContentHelper.cs
parent09f69d986f4f44521d8a2cd745269dce4b83320e (diff)
parente943ae84136d46432e04e577041850d2aa7db43e (diff)
downloadSMAPI-a9cadc7f32fd9fd244fc3e22c62a35e7c257c084.tar.gz
SMAPI-a9cadc7f32fd9fd244fc3e22c62a35e7c257c084.tar.bz2
SMAPI-a9cadc7f32fd9fd244fc3e22c62a35e7c257c084.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers/ContentHelper.cs')
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentHelper.cs31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
index 6a92da24..427adac2 100644
--- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
@@ -132,15 +132,40 @@ namespace StardewModdingAPI.Framework.ModHelpers
return this.GameContentManager.LoadLocalized<T>(assetName, this.CurrentLocaleConstant, useCache: false);
case ContentSource.ModFolder:
- return this.ModContentManager.LoadExact<T>(assetName, useCache: false);
+ try
+ {
+ return this.ModContentManager.LoadExact<T>(assetName, useCache: false);
+ }
+ catch (SContentLoadException ex) when (ex.ErrorType == ContentLoadErrorType.AssetDoesNotExist)
+ {
+ // legacy behavior: you can load a .xnb file without the file extension
+ try
+ {
+ IAssetName newName = this.ContentCore.ParseAssetName(assetName.Name + ".xnb", allowLocales: false);
+ if (this.ModContentManager.DoesAssetExist<T>(newName))
+ {
+ T data = this.ModContentManager.LoadExact<T>(newName, useCache: false);
+ SCore.DeprecationManager.Warn(
+ this.Mod,
+ "loading XNB files from the mod folder without the .xnb file extension",
+ "3.14.0",
+ DeprecationLevel.Notice
+ );
+ return data;
+ }
+ }
+ catch { /* legacy behavior failed, rethrow original error */ }
+
+ throw;
+ }
default:
- throw new SContentLoadException($"{this.Mod.DisplayName} failed loading content asset '{key}' from {source}: unknown content source '{source}'.");
+ throw new SContentLoadException(ContentLoadErrorType.Other, $"{this.Mod.DisplayName} failed loading content asset '{key}' from {source}: unknown content source '{source}'.");
}
}
catch (Exception ex) when (ex is not SContentLoadException)
{
- throw new SContentLoadException($"{this.Mod.DisplayName} failed loading content asset '{key}' from {source}.", ex);
+ throw new SContentLoadException(ContentLoadErrorType.Other, $"{this.Mod.DisplayName} failed loading content asset '{key}' from {source}.", ex);
}
}