diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-05-01 12:33:09 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-05-01 12:33:09 -0400 |
commit | 99f70f963459912ce66f5a586eb4fc36e561b69d (patch) | |
tree | 984e083f68e9908019093b561750049b71d3aebe | |
parent | 621b989c243a8aa1ff5c4928026f2cfe087f378d (diff) | |
download | SMAPI-99f70f963459912ce66f5a586eb4fc36e561b69d.tar.gz SMAPI-99f70f963459912ce66f5a586eb4fc36e561b69d.tar.bz2 SMAPI-99f70f963459912ce66f5a586eb4fc36e561b69d.zip |
match tilesheets without extension to .png files automatically if possible
-rw-r--r-- | docs/release-notes.md | 1 | ||||
-rw-r--r-- | src/SMAPI/Framework/ContentManagers/ModContentManager.cs | 17 |
2 files changed, 14 insertions, 4 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index b6b14f97..701471ee 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -21,6 +21,7 @@ * For modders: * Added asset propagation for `Data\Concessions`. * Added SMAPI version and bitness to the console title before startup to simplify troubleshooting. + * If a map loads a tilesheet path with no file extension, SMAPI now automatically links it to a `.png` version in the map folder if possible. * Improved error-handling during asset propagation. * Fixed `Context.IsMainPlayer` returning true for a farmhand in split-screen mode before the screen is initialized. * Fixed error when editing bundle data while a split-screen player is joining. diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index 9af14cb5..0cd431e8 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -34,6 +34,9 @@ namespace StardewModdingAPI.Framework.ContentManagers /// <summary>The language code for language-agnostic mod assets.</summary> private readonly LanguageCode DefaultLanguage = Constants.DefaultLanguage; + /// <summary>If a map tilesheet's image source has no file extensions, the file extensions to check for in the local mod folder.</summary> + private readonly string[] LocalTilesheetExtensions = { ".png", ".xnb" }; + /********* ** Public methods @@ -215,11 +218,17 @@ namespace StardewModdingAPI.Framework.ContentManagers FileInfo file = new FileInfo(Path.Combine(this.FullRootDirectory, path)); // try with default extension - if (!file.Exists && file.Extension.ToLower() != ".xnb") + if (!file.Exists && file.Extension == string.Empty) { - FileInfo result = new FileInfo(file.FullName + ".xnb"); - if (result.Exists) - file = result; + foreach (string extension in this.LocalTilesheetExtensions) + { + FileInfo result = new FileInfo(file.FullName + extension); + if (result.Exists) + { + file = result; + break; + } + } } return file; |