summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2023-03-26 13:32:33 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2023-04-02 15:44:02 -0400
commitc2e9aad698774e7db9b85292da9077f8462d2f5a (patch)
treeaf5d19e7ab145dfdd4a15014b826bb5eab7d42b2 /src
parentc0ac58f2778fd70e9937a77d3af8a06ef957d871 (diff)
downloadSMAPI-c2e9aad698774e7db9b85292da9077f8462d2f5a.tar.gz
SMAPI-c2e9aad698774e7db9b85292da9077f8462d2f5a.tar.bz2
SMAPI-c2e9aad698774e7db9b85292da9077f8462d2f5a.zip
adjust ModContentManager.HandleUnknownFileTypes to let mods patch it
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/ContentManagers/ModContentManager.cs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs
index badbd766..2c068784 100644
--- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs
@@ -130,7 +130,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
".png" => this.LoadImageFile<T>(assetName, file),
".tbin" or ".tmx" => this.LoadMapFile<T>(assetName, file),
".xnb" => this.LoadXnbFile<T>(assetName),
- _ => this.HandleUnknownFileType<T>(assetName, file)
+ _ => (T)this.HandleUnknownFileType(assetName, file, typeof(T))
};
}
catch (Exception ex)
@@ -323,13 +323,15 @@ namespace StardewModdingAPI.Framework.ContentManagers
}
/// <summary>Handle a request to load a file type that isn't supported by SMAPI.</summary>
- /// <typeparam name="T">The expected file type.</typeparam>
/// <param name="assetName">The asset name relative to the loader root directory.</param>
/// <param name="file">The file to load.</param>
- private T HandleUnknownFileType<T>(IAssetName assetName, FileInfo file)
+ /// <param name="assetType">The expected file type.</param>
+ private object HandleUnknownFileType(IAssetName assetName, FileInfo file, Type assetType)
{
this.ThrowLoadError(assetName, ContentLoadErrorType.InvalidName, $"unknown file extension '{file.Extension}'; must be one of '.fnt', '.json', '.png', '.tbin', '.tmx', or '.xnb'.");
- return default;
+ return assetType.IsValueType
+ ? Activator.CreateInstance(assetType)
+ : null;
}
/// <summary>Assert that the asset type is compatible with one of the allowed types.</summary>