summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-09-03 00:00:39 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-09-03 00:00:39 -0400
commitb86d9f7c0ebdd3bc1200836137f92eaa3c9910ec (patch)
tree88b5f73e23cb118c37ff65467de4972702c7c544 /src/StardewModdingAPI
parent3e820b82bccf7cab390bc43d9156fdeb4ab08cd9 (diff)
downloadSMAPI-b86d9f7c0ebdd3bc1200836137f92eaa3c9910ec.tar.gz
SMAPI-b86d9f7c0ebdd3bc1200836137f92eaa3c9910ec.tar.bz2
SMAPI-b86d9f7c0ebdd3bc1200836137f92eaa3c9910ec.zip
handle maps referencing a non-spring seasonal variation (#352)
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r--src/StardewModdingAPI/Framework/ModHelpers/ContentHelper.cs15
1 files changed, 11 insertions, 4 deletions
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