add separate error when player puts an XNB mod in Mods

This commit is contained in:
Jesse Plamondon-Willard 2018-09-27 00:36:31 -04:00
parent 43e935b017
commit 074f730329
2 changed files with 16 additions and 2 deletions

View File

@ -5,6 +5,7 @@
* Moved most SMAPI files into a `smapi-internal` subfolder. * Moved most SMAPI files into a `smapi-internal` subfolder.
* Moved save backups into a `save-backups` subfolder (instead of `Mods/SaveBackup/backups`). Note that previous backups will be deleted when you update. * Moved save backups into a `save-backups` subfolder (instead of `Mods/SaveBackup/backups`). Note that previous backups will be deleted when you update.
* Update checks now work even when the mod has no update keys in most cases. * Update checks now work even when the mod has no update keys in most cases.
* Improved error when you put an XNB mod in `Mods`.
* Fixed error when mods add an invalid location with no name. * Fixed error when mods add an invalid location with no name.
* Fixed compatibility issues for some Linux players. SMAPI will now always use xterm if it's available. * Fixed compatibility issues for some Linux players. SMAPI will now always use xterm if it's available.
* Fixed some game install paths not detected on Windows. * Fixed some game install paths not detected on Windows.

View File

@ -24,6 +24,15 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
"Thumbs.db" "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 ** Public methods
@ -50,11 +59,15 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
{ {
// find manifest.json // find manifest.json
FileInfo manifestFile = this.FindManifest(searchFolder); FileInfo manifestFile = this.FindManifest(searchFolder);
// set appropriate invalid-mod error
if (manifestFile == null) if (manifestFile == null)
{ {
bool isEmpty = !searchFolder.GetFileSystemInfos().Where(this.IsRelevant).Any(); FileInfo[] files = searchFolder.GetFiles("*", SearchOption.AllDirectories).Where(this.IsRelevant).ToArray();
if (isEmpty) if (!files.Any())
return new ModFolder(root, searchFolder, null, "it's an empty folder."); 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."); return new ModFolder(root, searchFolder, null, "it contains files, but none of them are manifest.json.");
} }