mirror of
https://github.com/Pathoschild/SMAPI.git
synced 2026-10-12 02:08:51 +00:00
add SMAPI 3.0 readiness to API data (#606)
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
* **Deprecations:**
|
||||
* The `assetData.AsDictionary<TKey, TValue>().Set` methods are deprecated and will be removed in SMAPI 3.0. Mods should access the `Data` property directly instead.
|
||||
|
||||
* FOR SMAPI developers:
|
||||
* Added SMAPI 3.0 readiness to mod API data.
|
||||
|
||||
## 2.9.1
|
||||
* For players:
|
||||
* Fixed crash in SMAPI 2.9 when constructing certain buildings.
|
||||
|
||||
@@ -31,6 +31,12 @@ namespace StardewModdingAPI.Web.ViewModels
|
||||
/// <summary>The compatibility status for the beta version of the game.</summary>
|
||||
public ModCompatibilityModel BetaCompatibility { get; set; }
|
||||
|
||||
/// <summary>Whether the mod is ready for the upcoming SMAPI 3.0.</summary>
|
||||
public string Smapi3Status { get; set; }
|
||||
|
||||
/// <summary>A URL related to the <see cref="Smapi3Status"/>.</summary>
|
||||
public string Smapi3Url { get; set; }
|
||||
|
||||
/// <summary>Links to the available mod pages.</summary>
|
||||
public ModLinkModel[] ModPages { get; set; }
|
||||
|
||||
@@ -59,6 +65,8 @@ namespace StardewModdingAPI.Web.ViewModels
|
||||
this.SourceUrl = this.GetSourceUrl(entry);
|
||||
this.Compatibility = new ModCompatibilityModel(entry.Compatibility);
|
||||
this.BetaCompatibility = entry.BetaCompatibility != null ? new ModCompatibilityModel(entry.BetaCompatibility) : null;
|
||||
this.Smapi3Status = entry.Smapi3Status.ToString().ToLower();
|
||||
this.Smapi3Url = entry.Smapi3Url;
|
||||
this.ModPages = this.GetModPageUrls(entry).ToArray();
|
||||
this.Warnings = entry.Warnings;
|
||||
this.Slug = entry.Anchor;
|
||||
|
||||
@@ -45,7 +45,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="mod-count" v-show="showAdvanced">
|
||||
<span v-if="visibleStats.total > 0">{{visibleStats.total}} mods shown ({{Math.round((visibleStats.compatible + visibleStats.workaround) / visibleStats.total * 100)}}% compatible or have a workaround, {{Math.round((visibleStats.soon + visibleStats.broken) / visibleStats.total * 100)}}% broken, {{Math.round(visibleStats.abandoned / visibleStats.total * 100)}}% obsolete).</span>
|
||||
<div v-if="visibleStats.total > 0">
|
||||
{{visibleStats.total}} mods shown ({{Math.round((visibleStats.compatible + visibleStats.workaround) / visibleStats.total * 100)}}% compatible or have a workaround, {{Math.round((visibleStats.soon + visibleStats.broken) / visibleStats.total * 100)}}% broken, {{Math.round(visibleStats.abandoned / visibleStats.total * 100)}}% obsolete).<br />
|
||||
SMAPI 3.0 (upcoming): {{Math.round(visibleStats.smapi3_ok / visibleStats.total * 100)}}% ready, {{Math.round(visibleStats.smapi3_soon / visibleStats.total * 100)}}% soon, {{Math.round(visibleStats.smapi3_broken / visibleStats.total * 100)}}% broken, {{Math.round(visibleStats.smapi3_unknown / visibleStats.total * 100)}}% unknown.
|
||||
</div>
|
||||
<span v-else>No matching mods found.</span>
|
||||
</div>
|
||||
<table class="wikitable" id="mod-list">
|
||||
@@ -57,6 +60,7 @@
|
||||
<th>compatibility</th>
|
||||
<th v-show="showAdvanced">broke in</th>
|
||||
<th v-show="showAdvanced">code</th>
|
||||
<th v-show="showAdvanced"><a href="http://smapi.io/3.0">3.0</a></th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -88,6 +92,14 @@
|
||||
<span v-if="mod.SourceUrl"><a v-bind:href="mod.SourceUrl">source</a></span>
|
||||
<span v-else class="mod-closed-source">no source</span>
|
||||
</td>
|
||||
<td v-show="showAdvanced">
|
||||
<template v-if="(mod.BetaCompatibility || mod.Compatibility).Status == 'ok' || mod.Smapi3Status == 'ok' || mod.Smapi3Status == 'soon'">
|
||||
<small v-if="mod.Smapi3Status == 'ok'">✓</small>
|
||||
<small v-else-if="mod.Smapi3Status == 'broken'">✖</small>
|
||||
<small v-else-if="mod.Smapi3Status == 'soon' && mod.Smapi3Url"><a v-bind:href="mod.Smapi3Url">↻ soon</a></small>
|
||||
<small v-else>↻ {{mod.Smapi3Status}}</small>
|
||||
</template>
|
||||
</td>
|
||||
<td>
|
||||
<small><a v-bind:href="'#' + mod.Slug">#</a></small>
|
||||
</td>
|
||||
|
||||
@@ -11,7 +11,11 @@ smapi.modList = function (mods) {
|
||||
soon: 0,
|
||||
broken: 0,
|
||||
abandoned: 0,
|
||||
invalid: 0
|
||||
invalid: 0,
|
||||
smapi3_unknown: 0,
|
||||
smapi3_ok: 0,
|
||||
smapi3_broken: 0,
|
||||
smapi3_soon: 0
|
||||
};
|
||||
var data = {
|
||||
mods: mods,
|
||||
@@ -88,6 +92,28 @@ smapi.modList = function (mods) {
|
||||
id: "show-custom",
|
||||
value: true
|
||||
}
|
||||
},
|
||||
"SMAPI 3.0": {
|
||||
ok: {
|
||||
label: "ready",
|
||||
id: "show-smapi-3-ready",
|
||||
value: true
|
||||
},
|
||||
soon: {
|
||||
label: "soon",
|
||||
id: "show-smapi-3-soon",
|
||||
value: true
|
||||
},
|
||||
broken: {
|
||||
label: "broken",
|
||||
id: "show-smapi-3-broken",
|
||||
value: true
|
||||
},
|
||||
unknown: {
|
||||
label: "unknown",
|
||||
id: "show-smapi-3-unknown",
|
||||
value: true
|
||||
}
|
||||
}
|
||||
},
|
||||
search: ""
|
||||
@@ -154,6 +180,7 @@ smapi.modList = function (mods) {
|
||||
if (mod.Visible) {
|
||||
stats.total++;
|
||||
stats[this.getCompatibilityGroup(mod)]++;
|
||||
stats["smapi3_" + mod.Smapi3Status]++;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -179,6 +206,10 @@ smapi.modList = function (mods) {
|
||||
if (filters.status[status] && !filters.status[status].value)
|
||||
return false;
|
||||
|
||||
// check SMAPI 3.0 compatibility
|
||||
if (filters["SMAPI 3.0"][mod.Smapi3Status] && !filters["SMAPI 3.0"][mod.Smapi3Status].value)
|
||||
return false;
|
||||
|
||||
// check download sites
|
||||
var ignoreSites = [];
|
||||
|
||||
|
||||
@@ -40,6 +40,15 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
|
||||
/// <summary>The custom mod page URL (if applicable).</summary>
|
||||
public string CustomUrl { get; set; }
|
||||
|
||||
/****
|
||||
** SMAPI 3.0 readiness
|
||||
****/
|
||||
/// <summary>Whether the mod is ready for the upcoming SMAPI 3.0.</summary>
|
||||
public WikiSmapi3Status Smapi3Status { get; set; }
|
||||
|
||||
/// <summary>A URL related to the <see cref="Smapi3Status"/>.</summary>
|
||||
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;
|
||||
|
||||
|
||||
@@ -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<WikiCompatibilityStatus>(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<WikiCompatibilityStatus>(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<WikiSmapi3Status>(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];
|
||||
}
|
||||
|
||||
/// <summary>Get an attribute value and parse it as a compatibility status.</summary>
|
||||
/// <summary>Get an attribute value and parse it as an enum value.</summary>
|
||||
/// <typeparam name="TEnum">The enum type.</typeparam>
|
||||
/// <param name="element">The element whose attributes to read.</param>
|
||||
/// <param name="name">The attribute name.</param>
|
||||
private WikiCompatibilityStatus? GetAttributeAsStatus(HtmlNode element, string name)
|
||||
private TEnum? GetAttributeAsEnum<TEnum>(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;
|
||||
}
|
||||
|
||||
/// <summary>Get an attribute value and parse it as a semantic version.</summary>
|
||||
|
||||
@@ -39,6 +39,12 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki
|
||||
/// <summary>The mod's compatibility with the latest beta version of the game (if any).</summary>
|
||||
public WikiCompatibilityInfo BetaCompatibility { get; set; }
|
||||
|
||||
/// <summary>Whether the mod is ready for the upcoming SMAPI 3.0.</summary>
|
||||
public WikiSmapi3Status Smapi3Status { get; set; }
|
||||
|
||||
/// <summary>A URL related to the <see cref="Smapi3Status"/>.</summary>
|
||||
public string Smapi3Url { get; set; }
|
||||
|
||||
/// <summary>Whether a Stardew Valley or SMAPI beta which affects mod compatibility is in progress. If this is true, <see cref="BetaCompatibility"/> should be used for beta versions of SMAPI instead of <see cref="Compatibility"/>.</summary>
|
||||
public bool HasBetaInfo => this.BetaCompatibility != null;
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki
|
||||
{
|
||||
/// <summary>Whether a mod is ready for the upcoming SMAPI 3.0.</summary>
|
||||
public enum WikiSmapi3Status
|
||||
{
|
||||
/// <summary>The mod's compatibility status is unknown.</summary>
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary>The mod is compatible with the upcoming SMAPI 3.0.</summary>
|
||||
Ok = 1,
|
||||
|
||||
/// <summary>The mod will break in SMAPI 3.0.</summary>
|
||||
Broken = 2,
|
||||
|
||||
/// <summary>The mod has a pull request submitted for SMAPI 3.0 compatibility.</summary>
|
||||
Soon = 3
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user