diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-01-03 14:31:27 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-01-03 14:31:27 -0500 |
commit | 04c6733adae9ce568aefb5d9dee6101097e994c5 (patch) | |
tree | c93f0650f6f79a95016c29526f8af437ad91a815 /src/SMAPI/Framework/ModLoading | |
parent | 48bb1581a6adeabfefbdd774011796e09a07aae2 (diff) | |
parent | 2b3f0506a16622b25a702aae250e10005287c4f4 (diff) | |
download | SMAPI-04c6733adae9ce568aefb5d9dee6101097e994c5.tar.gz SMAPI-04c6733adae9ce568aefb5d9dee6101097e994c5.tar.bz2 SMAPI-04c6733adae9ce568aefb5d9dee6101097e994c5.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/ModLoading')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/ModResolver.cs | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs index 08df7b76..af7d90f6 100644 --- a/src/SMAPI/Framework/ModLoading/ModResolver.cs +++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs @@ -72,7 +72,7 @@ namespace StardewModdingAPI.Framework.ModLoading switch (mod.DataRecord?.Status) { case ModStatus.Obsolete: - mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.Obsolete, $"it's obsolete: {mod.DataRecord.StatusReasonPhrase}"); + mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.Obsolete, $"it's obsolete: {mod.DataRecord.StatusReasonPhrase}", this.GetTechnicalReasonForStatusOverride(mod)); continue; case ModStatus.AssumeBroken: @@ -102,7 +102,7 @@ namespace StardewModdingAPI.Framework.ModLoading error += $"version newer than {mod.DataRecord.StatusUpperVersion}"; error += " at " + string.Join(" or ", updateUrls); - mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.Incompatible, error); + mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.Incompatible, error, this.GetTechnicalReasonForStatusOverride(mod)); } continue; } @@ -409,6 +409,38 @@ namespace StardewModdingAPI.Framework.ModLoading yield return new ModDependency(manifest.ContentPackFor.UniqueID, manifest.ContentPackFor.MinimumVersion, FindMod(manifest.ContentPackFor.UniqueID), isRequired: true); } + /// <summary>Get a technical message indicating why a mod's compatibility status was overridden, if applicable.</summary> + /// <param name="mod">The mod metadata.</param> + private string GetTechnicalReasonForStatusOverride(IModMetadata mod) + { + // get compatibility list record + var data = mod.DataRecord; + if (data == null) + return null; + + // get status label + string statusLabel = data.Status switch + { + ModStatus.AssumeBroken => "'assume broken'", + ModStatus.AssumeCompatible => "'assume compatible'", + ModStatus.Obsolete => "obsolete", + _ => data.Status.ToString() + }; + + // get reason + string[] reasons = new[] { mod.DataRecord.StatusReasonPhrase, mod.DataRecord.StatusReasonDetails } + .Where(p => !string.IsNullOrWhiteSpace(p)) + .ToArray(); + + // build message + return + $"marked {statusLabel} in SMAPI's internal compatibility list for " + + (mod.DataRecord.StatusUpperVersion != null ? $"versions up to {mod.DataRecord.StatusUpperVersion}" : "all versions") + + ": " + + (reasons.Any() ? string.Join(": ", reasons) : "no reason given") + + "."; + } + /********* ** Private models |