From 5f620e14fa331b0721bd4044011363477dc79ef5 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 15 Dec 2018 00:18:51 -0500 Subject: add SMAPI 3.0 readiness to API data (#606) --- .../Clients/WebApi/ModExtendedMetadataModel.cs | 12 ++++++++++++ .../Framework/Clients/Wiki/WikiClient.cs | 21 ++++++++++++++------- .../Framework/Clients/Wiki/WikiModEntry.cs | 6 ++++++ .../Framework/Clients/Wiki/WikiSmapi3Status.cs | 18 ++++++++++++++++++ 4 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiSmapi3Status.cs (limited to 'src/StardewModdingAPI.Toolkit') diff --git a/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs index c9d9f916..45b46ea6 100644 --- a/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs +++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModExtendedMetadataModel.cs @@ -40,6 +40,15 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi /// The custom mod page URL (if applicable). public string CustomUrl { get; set; } + /**** + ** SMAPI 3.0 readiness + ****/ + /// Whether the mod is ready for the upcoming SMAPI 3.0. + public WikiSmapi3Status Smapi3Status { get; set; } + + /// A URL related to the . + public string Smapi3Url { get; set; } + /**** ** Stable compatibility ****/ @@ -85,6 +94,9 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi this.CustomSourceUrl = wiki.CustomSourceUrl; this.CustomUrl = wiki.CustomUrl; + this.Smapi3Status = wiki.Smapi3Status; + this.Smapi3Url = wiki.Smapi3Url; + this.CompatibilityStatus = wiki.Compatibility.Status; this.CompatibilitySummary = wiki.Compatibility.Summary; diff --git a/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs index 91078b08..19a4292f 100644 --- a/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs +++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiClient.cs @@ -102,7 +102,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki // parse stable compatibility WikiCompatibilityInfo compatibility = new WikiCompatibilityInfo { - Status = this.GetAttributeAsStatus(node, "data-status") ?? WikiCompatibilityStatus.Ok, + Status = this.GetAttributeAsEnum(node, "data-status") ?? WikiCompatibilityStatus.Ok, BrokeIn = this.GetAttribute(node, "data-broke-in"), UnofficialVersion = this.GetAttributeAsSemanticVersion(node, "data-unofficial-version"), UnofficialUrl = this.GetAttribute(node, "data-unofficial-url"), @@ -112,7 +112,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki // parse beta compatibility WikiCompatibilityInfo betaCompatibility = null; { - WikiCompatibilityStatus? betaStatus = this.GetAttributeAsStatus(node, "data-beta-status"); + WikiCompatibilityStatus? betaStatus = this.GetAttributeAsEnum(node, "data-beta-status"); if (betaStatus.HasValue) { betaCompatibility = new WikiCompatibilityInfo @@ -126,6 +126,10 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki } } + // parse SMAPI 3.0 readiness status + WikiSmapi3Status smapi3Status = this.GetAttributeAsEnum(node, "data-smapi-3-status") ?? WikiSmapi3Status.Unknown; + string smapi3Url = this.GetAttribute(node, "data-smapi-3-url"); + // yield model yield return new WikiModEntry { @@ -140,6 +144,8 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki CustomUrl = customUrl, Compatibility = compatibility, BetaCompatibility = betaCompatibility, + Smapi3Status = smapi3Status, + Smapi3Url = smapi3Url, Warnings = warnings, Anchor = anchor }; @@ -169,17 +175,18 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki : new string[0]; } - /// Get an attribute value and parse it as a compatibility status. + /// Get an attribute value and parse it as an enum value. + /// The enum type. /// The element whose attributes to read. /// The attribute name. - private WikiCompatibilityStatus? GetAttributeAsStatus(HtmlNode element, string name) + private TEnum? GetAttributeAsEnum(HtmlNode element, string name) where TEnum : struct { string raw = this.GetAttribute(element, name); if (raw == null) return null; - if (!Enum.TryParse(raw, true, out WikiCompatibilityStatus status)) - throw new InvalidOperationException($"Unknown status '{raw}' when parsing compatibility list."); - return status; + if (!Enum.TryParse(raw, true, out TEnum value) && Enum.IsDefined(typeof(TEnum), value)) + throw new InvalidOperationException($"Unknown {typeof(TEnum).Name} value '{raw}' when parsing compatibility list."); + return value; } /// Get an attribute value and parse it as a semantic version. diff --git a/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs index f7b7839b..b71269fe 100644 --- a/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs +++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiModEntry.cs @@ -39,6 +39,12 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki /// The mod's compatibility with the latest beta version of the game (if any). public WikiCompatibilityInfo BetaCompatibility { get; set; } + /// Whether the mod is ready for the upcoming SMAPI 3.0. + public WikiSmapi3Status Smapi3Status { get; set; } + + /// A URL related to the . + public string Smapi3Url { get; set; } + /// Whether a Stardew Valley or SMAPI beta which affects mod compatibility is in progress. If this is true, should be used for beta versions of SMAPI instead of . public bool HasBetaInfo => this.BetaCompatibility != null; diff --git a/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiSmapi3Status.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiSmapi3Status.cs new file mode 100644 index 00000000..879cfd8a --- /dev/null +++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/Wiki/WikiSmapi3Status.cs @@ -0,0 +1,18 @@ +namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki +{ + /// Whether a mod is ready for the upcoming SMAPI 3.0. + public enum WikiSmapi3Status + { + /// The mod's compatibility status is unknown. + Unknown = 0, + + /// The mod is compatible with the upcoming SMAPI 3.0. + Ok = 1, + + /// The mod will break in SMAPI 3.0. + Broken = 2, + + /// The mod has a pull request submitted for SMAPI 3.0 compatibility. + Soon = 3 + } +} -- cgit From 7cbc716b85d950d8deb5d9aeadeb2d2f267aea79 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 16 Dec 2018 17:12:44 -0500 Subject: remove default SMAPI 3.0 strict mode in debug builds --- src/SMAPI/StardewModdingAPI.csproj | 2 +- .../StardewModdingAPI.Toolkit.CoreInterfaces.csproj | 4 ---- src/StardewModdingAPI.Toolkit/StardewModdingAPI.Toolkit.csproj | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) (limited to 'src/StardewModdingAPI.Toolkit') diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj index 3f1a273d..9b00e777 100644 --- a/src/SMAPI/StardewModdingAPI.csproj +++ b/src/SMAPI/StardewModdingAPI.csproj @@ -32,7 +32,7 @@ x86 false - DEBUG;TRACE;SMAPI_3_0_STRICT + DEBUG;TRACE true false $(SolutionDir)\..\bin\Debug\SMAPI diff --git a/src/StardewModdingAPI.Toolkit.CoreInterfaces/StardewModdingAPI.Toolkit.CoreInterfaces.csproj b/src/StardewModdingAPI.Toolkit.CoreInterfaces/StardewModdingAPI.Toolkit.CoreInterfaces.csproj index 539cb5d8..525931e5 100644 --- a/src/StardewModdingAPI.Toolkit.CoreInterfaces/StardewModdingAPI.Toolkit.CoreInterfaces.csproj +++ b/src/StardewModdingAPI.Toolkit.CoreInterfaces/StardewModdingAPI.Toolkit.CoreInterfaces.csproj @@ -8,10 +8,6 @@ ..\..\bin\$(Configuration)\SMAPI.Toolkit.CoreInterfaces\$(TargetFramework)\StardewModdingAPI.Toolkit.CoreInterfaces.xml - - $(DefineConstants);SMAPI_3_0_STRICT - - diff --git a/src/StardewModdingAPI.Toolkit/StardewModdingAPI.Toolkit.csproj b/src/StardewModdingAPI.Toolkit/StardewModdingAPI.Toolkit.csproj index 29667b1e..3fa28d19 100644 --- a/src/StardewModdingAPI.Toolkit/StardewModdingAPI.Toolkit.csproj +++ b/src/StardewModdingAPI.Toolkit/StardewModdingAPI.Toolkit.csproj @@ -7,10 +7,6 @@ ..\..\bin\$(Configuration)\SMAPI.Toolkit\$(TargetFramework)\StardewModdingAPI.Toolkit.xml - - $(DefineConstants);SMAPI_3_0_STRICT - - -- cgit