summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Toolkit
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI.Toolkit')
-rw-r--r--src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs1
-rw-r--r--src/StardewModdingAPI.Toolkit/Serialisation/Models/Manifest.cs37
-rw-r--r--src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestContentPackFor.cs8
-rw-r--r--src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestDependency.cs8
4 files changed, 44 insertions, 10 deletions
diff --git a/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs b/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs
index 2ddaa1bf..eff95d1f 100644
--- a/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs
+++ b/src/StardewModdingAPI.Toolkit/Serialisation/Converters/SemanticVersionConverter.cs
@@ -1,5 +1,4 @@
using Newtonsoft.Json.Linq;
-using StardewModdingAPI.Toolkit.Serialisation.Models;
namespace StardewModdingAPI.Toolkit.Serialisation.Converters
{
diff --git a/src/StardewModdingAPI.Toolkit/Serialisation/Models/Manifest.cs b/src/StardewModdingAPI.Toolkit/Serialisation/Models/Manifest.cs
index 68987dd1..6ec57258 100644
--- a/src/StardewModdingAPI.Toolkit/Serialisation/Models/Manifest.cs
+++ b/src/StardewModdingAPI.Toolkit/Serialisation/Models/Manifest.cs
@@ -5,7 +5,7 @@ using StardewModdingAPI.Toolkit.Serialisation.Converters;
namespace StardewModdingAPI.Toolkit.Serialisation.Models
{
/// <summary>A manifest which describes a mod for SMAPI.</summary>
- public class Manifest
+ public class Manifest : IManifest
{
/*********
** Accessors
@@ -20,21 +20,23 @@ namespace StardewModdingAPI.Toolkit.Serialisation.Models
public string Author { get; set; }
/// <summary>The mod version.</summary>
- public SemanticVersion Version { get; set; }
+ [JsonConverter(typeof(SemanticVersionConverter))]
+ public ISemanticVersion Version { get; set; }
/// <summary>The minimum SMAPI version required by this mod, if any.</summary>
- public SemanticVersion MinimumApiVersion { get; set; }
+ [JsonConverter(typeof(SemanticVersionConverter))]
+ public ISemanticVersion MinimumApiVersion { get; set; }
/// <summary>The name of the DLL in the directory that has the <c>Entry</c> method. Mutually exclusive with <see cref="ContentPackFor"/>.</summary>
public string EntryDll { get; set; }
/// <summary>The mod which will read this as a content pack. Mutually exclusive with <see cref="Manifest.EntryDll"/>.</summary>
[JsonConverter(typeof(ManifestContentPackForConverter))]
- public ManifestContentPackFor ContentPackFor { get; set; }
+ public IManifestContentPackFor ContentPackFor { get; set; }
/// <summary>The other mods that must be loaded before this mod.</summary>
[JsonConverter(typeof(ManifestDependencyArrayConverter))]
- public ManifestDependency[] Dependencies { get; set; }
+ public IManifestDependency[] Dependencies { get; set; }
/// <summary>The namespaced mod IDs to query for updates (like <c>Nexus:541</c>).</summary>
public string[] UpdateKeys { get; set; }
@@ -45,5 +47,30 @@ namespace StardewModdingAPI.Toolkit.Serialisation.Models
/// <summary>Any manifest fields which didn't match a valid field.</summary>
[JsonExtensionData]
public IDictionary<string, object> ExtraFields { get; set; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public Manifest() { }
+
+ /// <summary>Construct an instance for a transitional content pack.</summary>
+ /// <param name="uniqueID">The unique mod ID.</param>
+ /// <param name="name">The mod name.</param>
+ /// <param name="author">The mod author's name.</param>
+ /// <param name="description">A brief description of the mod.</param>
+ /// <param name="version">The mod version.</param>
+ /// <param name="contentPackFor">The modID which will read this as a content pack.</param>
+ public Manifest(string uniqueID, string name, string author, string description, ISemanticVersion version, string contentPackFor = null)
+ {
+ this.Name = name;
+ this.Author = author;
+ this.Description = description;
+ this.Version = version;
+ this.UniqueID = uniqueID;
+ this.UpdateKeys = new string[0];
+ this.ContentPackFor = new ManifestContentPackFor { UniqueID = contentPackFor };
+ }
}
}
diff --git a/src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestContentPackFor.cs b/src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestContentPackFor.cs
index 00546533..64808dcf 100644
--- a/src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestContentPackFor.cs
+++ b/src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestContentPackFor.cs
@@ -1,7 +1,10 @@
+using Newtonsoft.Json;
+using StardewModdingAPI.Toolkit.Serialisation.Converters;
+
namespace StardewModdingAPI.Toolkit.Serialisation.Models
{
/// <summary>Indicates which mod can read the content pack represented by the containing manifest.</summary>
- public class ManifestContentPackFor
+ public class ManifestContentPackFor : IManifestContentPackFor
{
/*********
** Accessors
@@ -10,6 +13,7 @@ namespace StardewModdingAPI.Toolkit.Serialisation.Models
public string UniqueID { get; set; }
/// <summary>The minimum required version (if any).</summary>
- public SemanticVersion MinimumVersion { get; set; }
+ [JsonConverter(typeof(SemanticVersionConverter))]
+ public ISemanticVersion MinimumVersion { get; set; }
}
}
diff --git a/src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestDependency.cs b/src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestDependency.cs
index d902f9ac..67e733dd 100644
--- a/src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestDependency.cs
+++ b/src/StardewModdingAPI.Toolkit/Serialisation/Models/ManifestDependency.cs
@@ -1,7 +1,10 @@
+using Newtonsoft.Json;
+using StardewModdingAPI.Toolkit.Serialisation.Converters;
+
namespace StardewModdingAPI.Toolkit.Serialisation.Models
{
/// <summary>A mod dependency listed in a mod manifest.</summary>
- public class ManifestDependency
+ public class ManifestDependency : IManifestDependency
{
/*********
** Accessors
@@ -10,7 +13,8 @@ namespace StardewModdingAPI.Toolkit.Serialisation.Models
public string UniqueID { get; set; }
/// <summary>The minimum required version (if any).</summary>
- public SemanticVersion MinimumVersion { get; set; }
+ [JsonConverter(typeof(SemanticVersionConverter))]
+ public ISemanticVersion MinimumVersion { get; set; }
/// <summary>Whether the dependency must be installed to use the mod.</summary>
public bool IsRequired { get; set; }