From 99f70f963459912ce66f5a586eb4fc36e561b69d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 1 May 2021 12:33:09 -0400 Subject: match tilesheets without extension to .png files automatically if possible --- docs/release-notes.md | 1 + .../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 /// The language code for language-agnostic mod assets. private readonly LanguageCode DefaultLanguage = Constants.DefaultLanguage; + /// If a map tilesheet's image source has no file extensions, the file extensions to check for in the local mod folder. + 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; -- cgit