From b86d9f7c0ebdd3bc1200836137f92eaa3c9910ec Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 3 Sep 2017 00:00:39 -0400 Subject: handle maps referencing a non-spring seasonal variation (#352) --- .../Framework/ModHelpers/ContentHelper.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/StardewModdingAPI/Framework/ModHelpers') diff --git a/src/StardewModdingAPI/Framework/ModHelpers/ContentHelper.cs b/src/StardewModdingAPI/Framework/ModHelpers/ContentHelper.cs index a3beaedf..9f236823 100644 --- a/src/StardewModdingAPI/Framework/ModHelpers/ContentHelper.cs +++ b/src/StardewModdingAPI/Framework/ModHelpers/ContentHelper.cs @@ -240,12 +240,19 @@ namespace StardewModdingAPI.Framework.ModHelpers // get seasonal name (if applicable) string seasonalImageSource = null; - if (Game1.currentSeason != null && Game1.currentSeason != "spring") + if (Game1.currentSeason != null) { string filename = Path.GetFileName(imageSource); - string dirPath = imageSource.Substring(0, imageSource.LastIndexOf(filename)); - if (filename.StartsWith("spring_")) - seasonalImageSource = dirPath + Game1.currentSeason + "_" + filename.Substring("spring_".Length); + bool hasSeasonalPrefix = + filename.StartsWith("spring_", StringComparison.CurrentCultureIgnoreCase) + || filename.StartsWith("summer_", StringComparison.CurrentCultureIgnoreCase) + || filename.StartsWith("fall_", StringComparison.CurrentCultureIgnoreCase) + || filename.StartsWith("winter_", StringComparison.CurrentCultureIgnoreCase); + if (hasSeasonalPrefix && !filename.StartsWith(Game1.currentSeason + "_")) + { + string dirPath = imageSource.Substring(0, imageSource.LastIndexOf(filename, StringComparison.CurrentCultureIgnoreCase)); + seasonalImageSource = $"{dirPath}{Game1.currentSeason}_{filename.Substring(filename.IndexOf("_", StringComparison.CurrentCultureIgnoreCase) + 1)}"; + } } // load best match -- cgit