diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-09-27 00:36:31 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-09-27 00:36:31 -0400 |
commit | 074f730329659d0db4be3a99fa8e5c09383ca3e6 (patch) | |
tree | 292625c9c44d55f1a17a87b69aed124ab3dbb853 /src/StardewModdingAPI.Toolkit/Framework | |
parent | 43e935b01761b657ed361d3ae67c7ca001cde623 (diff) | |
download | SMAPI-074f730329659d0db4be3a99fa8e5c09383ca3e6.tar.gz SMAPI-074f730329659d0db4be3a99fa8e5c09383ca3e6.tar.bz2 SMAPI-074f730329659d0db4be3a99fa8e5c09383ca3e6.zip |
add separate error when player puts an XNB mod in Mods
Diffstat (limited to 'src/StardewModdingAPI.Toolkit/Framework')
-rw-r--r-- | src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs b/src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs index 7512d5cb..2c23a3ce 100644 --- a/src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs +++ b/src/StardewModdingAPI.Toolkit/Framework/ModScanning/ModScanner.cs @@ -24,6 +24,15 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning "Thumbs.db" }; + /// <summary>The extensions for files which an XNB mod may contain. If a mod contains *only* these file extensions, it should be considered an XNB mod.</summary> + private readonly HashSet<string> PotentialXnbModExtensions = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase) + { + ".md", + ".png", + ".txt", + ".xnb" + }; + /********* ** Public methods @@ -50,11 +59,15 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning { // find manifest.json FileInfo manifestFile = this.FindManifest(searchFolder); + + // set appropriate invalid-mod error if (manifestFile == null) { - bool isEmpty = !searchFolder.GetFileSystemInfos().Where(this.IsRelevant).Any(); - if (isEmpty) + FileInfo[] files = searchFolder.GetFiles("*", SearchOption.AllDirectories).Where(this.IsRelevant).ToArray(); + if (!files.Any()) return new ModFolder(root, searchFolder, null, "it's an empty folder."); + if (files.All(file => this.PotentialXnbModExtensions.Contains(file.Extension))) + return new ModFolder(root, searchFolder, null, "it's an older XNB mod which replaces game files (not run through SMAPI)."); return new ModFolder(root, searchFolder, null, "it contains files, but none of them are manifest.json."); } |