diff options
Diffstat (limited to 'src')
7 files changed, 51 insertions, 4 deletions
diff --git a/src/SMAPI.Toolkit/Framework/ModData/ModDataField.cs b/src/SMAPI.Toolkit/Framework/ModData/ModDataField.cs index b3954693..44422f01 100644 --- a/src/SMAPI.Toolkit/Framework/ModData/ModDataField.cs +++ b/src/SMAPI.Toolkit/Framework/ModData/ModDataField.cs @@ -71,6 +71,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData // non-manifest fields case ModDataFieldKey.AlternativeUrl: case ModDataFieldKey.StatusReasonPhrase: + case ModDataFieldKey.StatusReasonDetails: case ModDataFieldKey.Status: return false; diff --git a/src/SMAPI.Toolkit/Framework/ModData/ModDataFieldKey.cs b/src/SMAPI.Toolkit/Framework/ModData/ModDataFieldKey.cs index 09dd0cc5..068291aa 100644 --- a/src/SMAPI.Toolkit/Framework/ModData/ModDataFieldKey.cs +++ b/src/SMAPI.Toolkit/Framework/ModData/ModDataFieldKey.cs @@ -13,6 +13,9 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData Status, /// <summary>A reason phrase for the <see cref="Status"/>, or <c>null</c> to use the default reason.</summary> - StatusReasonPhrase + StatusReasonPhrase, + + /// <summary>Technical details shown in TRACE logs for the <see cref="Status"/>, or <c>null</c> to omit it.</summary> + StatusReasonDetails } } diff --git a/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs b/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs index 3201c421..f28f6afe 100644 --- a/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs +++ b/src/SMAPI.Toolkit/Framework/ModData/ModDataRecord.cs @@ -107,6 +107,11 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData case ModDataFieldKey.StatusReasonPhrase: parsed.StatusReasonPhrase = field.Value; break; + + // status technical reason + case ModDataFieldKey.StatusReasonDetails: + parsed.StatusReasonDetails = field.Value; + break; } } diff --git a/src/SMAPI.Toolkit/Framework/ModData/ModDataRecordVersionedFields.cs b/src/SMAPI.Toolkit/Framework/ModData/ModDataRecordVersionedFields.cs index 598da66a..f0282eb4 100644 --- a/src/SMAPI.Toolkit/Framework/ModData/ModDataRecordVersionedFields.cs +++ b/src/SMAPI.Toolkit/Framework/ModData/ModDataRecordVersionedFields.cs @@ -24,6 +24,9 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData /// <summary>A reason phrase for the <see cref="Status"/>, or <c>null</c> to use the default reason.</summary> public string StatusReasonPhrase { get; set; } + /// <summary>Technical details shown in TRACE logs for the <see cref="Status"/>, or <c>null</c> to omit it.</summary> + public string StatusReasonDetails { get; set; } + /// <summary>The upper version for which the <see cref="Status"/> applies (if any).</summary> public ISemanticVersion StatusUpperVersion { get; set; } } diff --git a/src/SMAPI.Web/wwwroot/SMAPI.metadata.json b/src/SMAPI.Web/wwwroot/SMAPI.metadata.json index 2a81e12a..b570a322 100644 --- a/src/SMAPI.Web/wwwroot/SMAPI.metadata.json +++ b/src/SMAPI.Web/wwwroot/SMAPI.metadata.json @@ -42,6 +42,9 @@ * - StatusReasonPhrase: a message to show to the player explaining why the mod can't be loaded * (if applicable). If blank, will default to a generic not-compatible message. * + * - StatusReasonDetails: a technical reason shown in TRACE logs, indicating why the status + * was overridden. If not provided, it defaults to the StatusReasonPhrase or 'no reason given'. + * * - AlternativeUrl: a URL where the player can find an unofficial update or alternative if the * mod is no longer compatible. */ 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 diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index e05213f0..27540442 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -1532,7 +1532,7 @@ namespace StardewModdingAPI.Framework // validate status if (mod.Status == ModMetadataStatus.Failed) { - this.Monitor.Log($" Failed: {mod.Error}"); + this.Monitor.Log($" Failed: {mod.ErrorDetails ?? mod.Error}"); failReason = mod.FailReason; errorReasonPhrase = mod.Error; return false; |