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 --- .../Framework/ContentManagers/ModContentManager.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') 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