summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-09-24 02:33:33 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-09-24 02:33:33 -0400
commit0c06b129cadd17ba1e9533319326d8aac8a88ed6 (patch)
treeaf37e8c4aeca9d96902247c35d312ecc822506e5 /src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
parent8e0d1b8682f0898e941fee16c6649f1165fde499 (diff)
downloadSMAPI-0c06b129cadd17ba1e9533319326d8aac8a88ed6.tar.gz
SMAPI-0c06b129cadd17ba1e9533319326d8aac8a88ed6.tar.bz2
SMAPI-0c06b129cadd17ba1e9533319326d8aac8a88ed6.zip
add support for specifying default update fields, migrate mods already in mod list (#361)
Diffstat (limited to 'src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs')
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
index 31ba5bc5..4d20e7c8 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
@@ -53,17 +53,22 @@ namespace StardewModdingAPI.Framework.ModLoading
error = $"parsing its manifest failed:\n{ex.GetLogSummary()}";
}
- // validate metadata
+ // get internal data record (if any)
ModDataRecord dataRecord = null;
if (manifest != null)
{
- // get unique key for lookups
string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll;
-
- // get data record
dataRecord = dataRecords.FirstOrDefault(record => record.ID.Matches(key, manifest));
}
+ // apply defaults
+ if (dataRecord?.Defaults != null)
+ {
+ manifest.ChucklefishID = manifest.ChucklefishID ?? dataRecord.Defaults.ChucklefishID;
+ manifest.GitHubProject = manifest.GitHubProject ?? dataRecord.Defaults.GitHubProject;
+ manifest.NexusID = manifest.NexusID ?? dataRecord.Defaults.NexusID;
+ }
+
// build metadata
string displayName = !string.IsNullOrWhiteSpace(manifest?.Name)
? manifest.Name
@@ -100,13 +105,27 @@ namespace StardewModdingAPI.Framework.ModLoading
case ModStatus.AssumeBroken:
{
+ // get reason
string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible";
+
+ // get update URLs
+ List<string> updateUrls = new List<string>();
+ if (!string.IsNullOrWhiteSpace(mod.Manifest.ChucklefishID))
+ updateUrls.Add($"https://community.playstarbound.com/resources/{mod.Manifest.ChucklefishID}");
+ if (!string.IsNullOrWhiteSpace(mod.Manifest.NexusID))
+ updateUrls.Add($"http://nexusmods.com/stardewvalley/mods/{mod.Manifest.NexusID}");
+ if (!string.IsNullOrWhiteSpace(mod.Manifest.GitHubProject))
+ updateUrls.Add($"https://github.com/{mod.Manifest.GitHubProject}/releases");
+ if (mod.DataRecord.AlternativeUrl != null)
+ updateUrls.Add(mod.DataRecord.AlternativeUrl);
+
+ // build error
string error = $"{reasonPhrase}. Please check for a ";
if (mod.Manifest.Version.Equals(compatibility.UpperVersion))
error += "newer version";
else
error += $"version newer than {compatibility.UpperVersion}";
- error += " at " + string.Join(" or ", mod.DataRecord.UpdateUrls);
+ error += " at " + string.Join(" or ", updateUrls);
mod.SetStatus(ModMetadataStatus.Failed, error);
}