summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModHelper.cs4
-rw-r--r--src/SMAPI/Framework/ModLoading/ModResolver.cs9
-rw-r--r--src/SMAPI/Framework/Models/Manifest.cs97
-rw-r--r--src/SMAPI/Framework/Models/ManifestContentPackFor.cs36
-rw-r--r--src/SMAPI/Framework/Models/ManifestDependency.cs40
-rw-r--r--src/SMAPI/Framework/Serialisation/SemanticVersionConverter.cs40
-rw-r--r--src/SMAPI/IManifest.cs44
-rw-r--r--src/SMAPI/IManifestContentPackFor.cs12
-rw-r--r--src/SMAPI/IManifestDependency.cs18
-rw-r--r--src/SMAPI/Metadata/InstructionMetadata.cs7
-rw-r--r--src/SMAPI/Program.cs3
-rw-r--r--src/SMAPI/StardewModdingAPI.csproj7
12 files changed, 11 insertions, 306 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/ModHelper.cs b/src/SMAPI/Framework/ModHelpers/ModHelper.cs
index 18904857..d9498e83 100644
--- a/src/SMAPI/Framework/ModHelpers/ModHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ModHelper.cs
@@ -4,8 +4,8 @@ using System.IO;
using System.Linq;
using StardewModdingAPI.Events;
using StardewModdingAPI.Framework.Input;
-using StardewModdingAPI.Framework.Models;
using StardewModdingAPI.Toolkit.Serialisation;
+using StardewModdingAPI.Toolkit.Serialisation.Models;
using StardewModdingAPI.Toolkit.Utilities;
namespace StardewModdingAPI.Framework.ModHelpers
@@ -185,7 +185,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
author: author,
description: description,
version: version,
- contentPackFor: new ManifestContentPackFor(this.ModID)
+ contentPackFor: this.ModID
);
// create content pack
diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs
index 3366e8c1..fde921e6 100644
--- a/src/SMAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs
@@ -4,10 +4,9 @@ using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using StardewModdingAPI.Framework.ModData;
-using StardewModdingAPI.Framework.Models;
using StardewModdingAPI.Toolkit.Serialisation;
+using StardewModdingAPI.Toolkit.Serialisation.Models;
using StardewModdingAPI.Toolkit.Utilities;
-using ToolkitManifest = StardewModdingAPI.Toolkit.Serialisation.Models.Manifest;
namespace StardewModdingAPI.Framework.ModLoading
{
@@ -33,15 +32,13 @@ namespace StardewModdingAPI.Framework.ModLoading
string path = Path.Combine(modDir.FullName, "manifest.json");
try
{
- ToolkitManifest rawManifest = jsonHelper.ReadJsonFile<ToolkitManifest>(path);
- if (rawManifest == null)
+ manifest = jsonHelper.ReadJsonFile<Manifest>(path);
+ if (manifest == null)
{
error = File.Exists(path)
? "its manifest is invalid."
: "it doesn't have a manifest.";
}
- else
- manifest = new Manifest(rawManifest);
}
catch (SParseException ex)
{
diff --git a/src/SMAPI/Framework/Models/Manifest.cs b/src/SMAPI/Framework/Models/Manifest.cs
deleted file mode 100644
index 92ffe0dc..00000000
--- a/src/SMAPI/Framework/Models/Manifest.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Newtonsoft.Json;
-
-namespace StardewModdingAPI.Framework.Models
-{
- /// <summary>A manifest which describes a mod for SMAPI.</summary>
- internal class Manifest : IManifest
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The mod name.</summary>
- public string Name { get; }
-
- /// <summary>A brief description of the mod.</summary>
- public string Description { get; }
-
- /// <summary>The mod author's name.</summary>
- public string Author { get; }
-
- /// <summary>The mod version.</summary>
- public ISemanticVersion Version { get; }
-
- /// <summary>The minimum SMAPI version required by this mod, if any.</summary>
- public ISemanticVersion MinimumApiVersion { get; }
-
- /// <summary>The name of the DLL in the directory that has the <see cref="IMod.Entry"/> method. Mutually exclusive with <see cref="ContentPackFor"/>.</summary>
- public string EntryDll { get; }
-
- /// <summary>The mod which will read this as a content pack. Mutually exclusive with <see cref="IManifest.EntryDll"/>.</summary>
- public IManifestContentPackFor ContentPackFor { get; }
-
- /// <summary>The other mods that must be loaded before this mod.</summary>
- public IManifestDependency[] Dependencies { get; }
-
- /// <summary>The namespaced mod IDs to query for updates (like <c>Nexus:541</c>).</summary>
- public string[] UpdateKeys { get; set; }
-
- /// <summary>The unique mod ID.</summary>
- public string UniqueID { get; }
-
- /// <summary>Any manifest fields which didn't match a valid field.</summary>
- [JsonExtensionData]
- public IDictionary<string, object> ExtraFields { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="manifest">The toolkit manifest.</param>
- public Manifest(Toolkit.Serialisation.Models.Manifest manifest)
- : this(
- uniqueID: manifest.UniqueID,
- name: manifest.Name,
- author: manifest.Author,
- description: manifest.Description,
- version: manifest.Version != null ? new SemanticVersion(manifest.Version) : null,
- entryDll: manifest.EntryDll,
- minimumApiVersion: manifest.MinimumApiVersion != null ? new SemanticVersion(manifest.MinimumApiVersion) : null,
- contentPackFor: manifest.ContentPackFor != null ? new ManifestContentPackFor(manifest.ContentPackFor) : null,
- dependencies: manifest.Dependencies?.Select(p => p != null ? (IManifestDependency)new ManifestDependency(p) : null).ToArray(),
- updateKeys: manifest.UpdateKeys,
- extraFields: manifest.ExtraFields
- )
- { }
-
- /// <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="entryDll">The name of the DLL in the directory that has the <see cref="IMod.Entry"/> method. Mutually exclusive with <paramref name="contentPackFor"/>.</param>
- /// <param name="minimumApiVersion">The minimum SMAPI version required by this mod, if any.</param>
- /// <param name="contentPackFor">The modID which will read this as a content pack. Mutually exclusive with <paramref name="entryDll"/>.</param>
- /// <param name="dependencies">The other mods that must be loaded before this mod.</param>
- /// <param name="updateKeys">The namespaced mod IDs to query for updates (like <c>Nexus:541</c>).</param>
- /// <param name="extraFields">Any manifest fields which didn't match a valid field.</param>
- public Manifest(string uniqueID, string name, string author, string description, ISemanticVersion version, string entryDll = null, ISemanticVersion minimumApiVersion = null, IManifestContentPackFor contentPackFor = null, IManifestDependency[] dependencies = null, string[] updateKeys = null, IDictionary<string, object> extraFields = null)
- {
- this.Name = name;
- this.Author = author;
- this.Description = description;
- this.Version = version;
- this.UniqueID = uniqueID;
- this.UpdateKeys = new string[0];
- this.EntryDll = entryDll;
- this.ContentPackFor = contentPackFor;
- this.MinimumApiVersion = minimumApiVersion;
- this.Dependencies = dependencies ?? new IManifestDependency[0];
- this.UpdateKeys = updateKeys ?? new string[0];
- this.ExtraFields = extraFields;
- }
- }
-}
diff --git a/src/SMAPI/Framework/Models/ManifestContentPackFor.cs b/src/SMAPI/Framework/Models/ManifestContentPackFor.cs
deleted file mode 100644
index 90e20c6a..00000000
--- a/src/SMAPI/Framework/Models/ManifestContentPackFor.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-namespace StardewModdingAPI.Framework.Models
-{
- /// <summary>Indicates which mod can read the content pack represented by the containing manifest.</summary>
- internal class ManifestContentPackFor : IManifestContentPackFor
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The unique ID of the mod which can read this content pack.</summary>
- public string UniqueID { get; }
-
- /// <summary>The minimum required version (if any).</summary>
- public ISemanticVersion MinimumVersion { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="contentPackFor">The toolkit instance.</param>
- public ManifestContentPackFor(Toolkit.Serialisation.Models.ManifestContentPackFor contentPackFor)
- {
- this.UniqueID = contentPackFor.UniqueID;
- this.MinimumVersion = contentPackFor.MinimumVersion != null ? new SemanticVersion(contentPackFor.MinimumVersion) : null;
- }
-
- /// <summary>Construct an instance.</summary>
- /// <param name="uniqueID">The unique ID of the mod which can read this content pack.</param>
- /// <param name="minimumVersion">The minimum required version (if any).</param>
- public ManifestContentPackFor(string uniqueID, ISemanticVersion minimumVersion = null)
- {
- this.UniqueID = uniqueID;
- this.MinimumVersion = minimumVersion;
- }
- }
-}
diff --git a/src/SMAPI/Framework/Models/ManifestDependency.cs b/src/SMAPI/Framework/Models/ManifestDependency.cs
deleted file mode 100644
index e92597f3..00000000
--- a/src/SMAPI/Framework/Models/ManifestDependency.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-namespace StardewModdingAPI.Framework.Models
-{
- /// <summary>A mod dependency listed in a mod manifest.</summary>
- internal class ManifestDependency : IManifestDependency
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The unique mod ID to require.</summary>
- public string UniqueID { get; }
-
- /// <summary>The minimum required version (if any).</summary>
- public ISemanticVersion MinimumVersion { get; }
-
- /// <summary>Whether the dependency must be installed to use the mod.</summary>
- public bool IsRequired { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="dependency">The toolkit instance.</param>
- public ManifestDependency(Toolkit.Serialisation.Models.ManifestDependency dependency)
- : this(dependency.UniqueID, dependency.MinimumVersion?.ToString(), dependency.IsRequired) { }
-
- /// <summary>Construct an instance.</summary>
- /// <param name="uniqueID">The unique mod ID to require.</param>
- /// <param name="minimumVersion">The minimum required version (if any).</param>
- /// <param name="required">Whether the dependency must be installed to use the mod.</param>
- public ManifestDependency(string uniqueID, string minimumVersion, bool required = true)
- {
- this.UniqueID = uniqueID;
- this.MinimumVersion = !string.IsNullOrWhiteSpace(minimumVersion)
- ? new SemanticVersion(minimumVersion)
- : null;
- this.IsRequired = required;
- }
- }
-}
diff --git a/src/SMAPI/Framework/Serialisation/SemanticVersionConverter.cs b/src/SMAPI/Framework/Serialisation/SemanticVersionConverter.cs
deleted file mode 100644
index 3e05a440..00000000
--- a/src/SMAPI/Framework/Serialisation/SemanticVersionConverter.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Newtonsoft.Json.Linq;
-using StardewModdingAPI.Toolkit.Serialisation;
-using StardewModdingAPI.Toolkit.Serialisation.Converters;
-
-namespace StardewModdingAPI.Framework.Serialisation
-{
- /// <summary>Handles deserialisation of <see cref="ISemanticVersion"/>.</summary>
- internal class SemanticVersionConverter : SimpleReadOnlyConverter<ISemanticVersion>
- {
- /*********
- ** Protected methods
- *********/
- /// <summary>Read a JSON object.</summary>
- /// <param name="obj">The JSON object to read.</param>
- /// <param name="path">The path to the current JSON node.</param>
- protected override ISemanticVersion ReadObject(JObject obj, string path)
- {
- int major = obj.ValueIgnoreCase<int>("MajorVersion");
- int minor = obj.ValueIgnoreCase<int>("MinorVersion");
- int patch = obj.ValueIgnoreCase<int>("PatchVersion");
- string build = obj.ValueIgnoreCase<string>("Build");
- if (build == "0")
- build = null; // '0' from incorrect examples in old SMAPI documentation
-
- return new SemanticVersion(major, minor, patch, build);
- }
-
- /// <summary>Read a JSON string.</summary>
- /// <param name="str">The JSON string value.</param>
- /// <param name="path">The path to the current JSON node.</param>
- protected override ISemanticVersion ReadString(string str, string path)
- {
- if (string.IsNullOrWhiteSpace(str))
- return null;
- if (!SemanticVersion.TryParse(str, out ISemanticVersion version))
- throw new SParseException($"Can't parse semantic version from invalid value '{str}', should be formatted like 1.2, 1.2.30, or 1.2.30-beta (path: {path}).");
- return version;
- }
- }
-}
diff --git a/src/SMAPI/IManifest.cs b/src/SMAPI/IManifest.cs
deleted file mode 100644
index 6c07d374..00000000
--- a/src/SMAPI/IManifest.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System.Collections.Generic;
-
-namespace StardewModdingAPI
-{
- /// <summary>A manifest which describes a mod for SMAPI.</summary>
- public interface IManifest
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The mod name.</summary>
- string Name { get; }
-
- /// <summary>A brief description of the mod.</summary>
- string Description { get; }
-
- /// <summary>The mod author's name.</summary>
- string Author { get; }
-
- /// <summary>The mod version.</summary>
- ISemanticVersion Version { get; }
-
- /// <summary>The minimum SMAPI version required by this mod, if any.</summary>
- ISemanticVersion MinimumApiVersion { get; }
-
- /// <summary>The unique mod ID.</summary>
- string UniqueID { get; }
-
- /// <summary>The name of the DLL in the directory that has the <see cref="IMod.Entry"/> method. Mutually exclusive with <see cref="EntryDll"/>.</summary>
- string EntryDll { get; }
-
- /// <summary>The mod which will read this as a content pack. Mutually exclusive with <see cref="EntryDll"/>.</summary>
- IManifestContentPackFor ContentPackFor { get; }
-
- /// <summary>The other mods that must be loaded before this mod.</summary>
- IManifestDependency[] Dependencies { get; }
-
- /// <summary>The namespaced mod IDs to query for updates (like <c>Nexus:541</c>).</summary>
- string[] UpdateKeys { get; }
-
- /// <summary>Any manifest fields which didn't match a valid field.</summary>
- IDictionary<string, object> ExtraFields { get; }
- }
-}
diff --git a/src/SMAPI/IManifestContentPackFor.cs b/src/SMAPI/IManifestContentPackFor.cs
deleted file mode 100644
index f05a3873..00000000
--- a/src/SMAPI/IManifestContentPackFor.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace StardewModdingAPI
-{
- /// <summary>Indicates which mod can read the content pack represented by the containing manifest.</summary>
- public interface IManifestContentPackFor
- {
- /// <summary>The unique ID of the mod which can read this content pack.</summary>
- string UniqueID { get; }
-
- /// <summary>The minimum required version (if any).</summary>
- ISemanticVersion MinimumVersion { get; }
- }
-}
diff --git a/src/SMAPI/IManifestDependency.cs b/src/SMAPI/IManifestDependency.cs
deleted file mode 100644
index e86cd1f4..00000000
--- a/src/SMAPI/IManifestDependency.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace StardewModdingAPI
-{
- /// <summary>A mod dependency listed in a mod manifest.</summary>
- public interface IManifestDependency
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The unique mod ID to require.</summary>
- string UniqueID { get; }
-
- /// <summary>The minimum required version (if any).</summary>
- ISemanticVersion MinimumVersion { get; }
-
- /// <summary>Whether the dependency must be installed to use the mod.</summary>
- bool IsRequired { get; }
- }
-}
diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs
index 543d44a7..c5128eb1 100644
--- a/src/SMAPI/Metadata/InstructionMetadata.cs
+++ b/src/SMAPI/Metadata/InstructionMetadata.cs
@@ -37,8 +37,11 @@ namespace StardewModdingAPI.Metadata
// rewrite for SMAPI 2.0
new VirtualEntryCallRemover(),
- // rewrite for SMAPI 2.6
- new TypeReferenceRewriter("StardewModdingAPI.ISemanticVersion", typeof(ISemanticVersion), type => type.Scope.Name == "StardewModdingAPI"), // moved to SMAPI.Toolkit.CoreInterfaces
+ // rewrite for SMAPI 2.6 (types moved into SMAPI.Toolkit.CoreInterfaces)
+ new TypeReferenceRewriter("StardewModdingAPI.IManifest", typeof(IManifest), type => type.Scope.Name == "StardewModdingAPI"),
+ new TypeReferenceRewriter("StardewModdingAPI.IManifestContentPackFor", typeof(IManifestContentPackFor), type => type.Scope.Name == "StardewModdingAPI"),
+ new TypeReferenceRewriter("StardewModdingAPI.IManifestDependency", typeof(IManifestDependency), type => type.Scope.Name == "StardewModdingAPI"),
+ new TypeReferenceRewriter("StardewModdingAPI.ISemanticVersion", typeof(ISemanticVersion), type => type.Scope.Name == "StardewModdingAPI"),
// rewrite for Stardew Valley 1.3
new StaticFieldToConstantRewriter<int>(typeof(Game1), "tileSize", Game1.tileSize),
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index a51d6380..1b276988 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -201,8 +201,7 @@ namespace StardewModdingAPI
new StringEnumConverter<SButton>(),
new ColorConverter(),
new PointConverter(),
- new RectangleConverter(),
- new Framework.Serialisation.SemanticVersionConverter()
+ new RectangleConverter()
};
foreach (JsonConverter converter in converters)
this.JsonHelper.JsonSettings.Converters.Add(converter);
diff --git a/src/SMAPI/StardewModdingAPI.csproj b/src/SMAPI/StardewModdingAPI.csproj
index c872391c..4852f70c 100644
--- a/src/SMAPI/StardewModdingAPI.csproj
+++ b/src/SMAPI/StardewModdingAPI.csproj
@@ -126,11 +126,7 @@
<Compile Include="Framework\Events\ModEvents.cs" />
<Compile Include="Framework\Events\ModInputEvents.cs" />
<Compile Include="Framework\Input\GamePadStateBuilder.cs" />
- <Compile Include="Framework\Models\Manifest.cs" />
- <Compile Include="Framework\Models\ManifestContentPackFor.cs" />
- <Compile Include="Framework\Models\ManifestDependency.cs" />
<Compile Include="Framework\ModHelpers\InputHelper.cs" />
- <Compile Include="Framework\Serialisation\SemanticVersionConverter.cs" />
<Compile Include="Framework\StateTracking\Comparers\GenericEqualsComparer.cs" />
<Compile Include="Framework\WatcherCore.cs" />
<Compile Include="IInputHelper.cs" />
@@ -186,7 +182,6 @@
<Compile Include="Framework\StateTracking\PlayerTracker.cs" />
<Compile Include="Framework\Utilities\ContextHash.cs" />
<Compile Include="IContentPack.cs" />
- <Compile Include="IManifestContentPackFor.cs" />
<Compile Include="IMultiplayerHelper.cs" />
<Compile Include="IReflectedField.cs" />
<Compile Include="IReflectedMethod.cs" />
@@ -258,7 +253,6 @@
<Compile Include="IAssetDataForDictionary.cs" />
<Compile Include="IAssetDataForImage.cs" />
<Compile Include="IContentHelper.cs" />
- <Compile Include="IManifestDependency.cs" />
<Compile Include="IModRegistry.cs" />
<Compile Include="Events\LocationEvents.cs" />
<Compile Include="Events\MenuEvents.cs" />
@@ -275,7 +269,6 @@
<Compile Include="Framework\Reflection\ReflectedField.cs" />
<Compile Include="Framework\Reflection\ReflectedMethod.cs" />
<Compile Include="Framework\Reflection\Reflector.cs" />
- <Compile Include="IManifest.cs" />
<Compile Include="IMod.cs" />
<Compile Include="IModHelper.cs" />
<Compile Include="IModLinked.cs" />