summaryrefslogtreecommitdiff
path: root/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-05-01 23:31:42 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-09-14 17:50:39 -0400
commitd74b710833edd19d2df2c0847a033078fa71a06e (patch)
tree01ab382a0e7058854ceab852d5ea6c62ecd1a2e2 /src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
parenta450b0ebefbf7eb4ca5fa41947eef36fe18ca19a (diff)
downloadSMAPI-d74b710833edd19d2df2c0847a033078fa71a06e.tar.gz
SMAPI-d74b710833edd19d2df2c0847a033078fa71a06e.tar.bz2
SMAPI-d74b710833edd19d2df2c0847a033078fa71a06e.zip
add mod type to mod scanner result
Diffstat (limited to 'src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs')
-rw-r--r--src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
index 0ab73d56..507e7be2 100644
--- a/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
+++ b/src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
@@ -65,10 +65,10 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
{
FileInfo[] files = searchFolder.GetFiles("*", SearchOption.AllDirectories).Where(this.IsRelevant).ToArray();
if (!files.Any())
- return new ModFolder(root, searchFolder, null, "it's an empty folder.");
+ return new ModFolder(root, searchFolder, ModType.Invalid, null, "it's an empty folder.");
if (files.All(file => this.PotentialXnbModExtensions.Contains(file.Extension)))
- return new ModFolder(root, searchFolder, null, "it's not a SMAPI mod (see https://smapi.io/xnb for info).");
- return new ModFolder(root, searchFolder, null, "it contains files, but none of them are manifest.json.");
+ return new ModFolder(root, searchFolder, ModType.Xnb, null, "it's not a SMAPI mod (see https://smapi.io/xnb for info).");
+ return new ModFolder(root, searchFolder, ModType.Invalid, null, "it contains files, but none of them are manifest.json.");
}
// read mod info
@@ -98,7 +98,17 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
manifest.Author = this.StripNewlines(manifest.Author);
}
- return new ModFolder(root, manifestFile.Directory, manifest, manifestError);
+ // get mod type
+ ModType type = ModType.Invalid;
+ if (manifest != null)
+ {
+ type = !string.IsNullOrWhiteSpace(manifest.ContentPackFor?.UniqueID)
+ ? ModType.ContentPack
+ : ModType.Smapi;
+ }
+
+ // build result
+ return new ModFolder(root, manifestFile.Directory, type, manifest, manifestError);
}
@@ -112,7 +122,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModScanning
{
// skip
if (folder.FullName != root.FullName && folder.Name.StartsWith("."))
- yield return new ModFolder(root, folder, null, "ignored folder because its name starts with a dot.", shouldBeLoaded: false);
+ yield return new ModFolder(root, folder, ModType.Invalid, null, "ignored folder because its name starts with a dot.", shouldBeLoaded: false);
// recurse into subfolders
else if (this.IsModSearchFolder(root, folder))