change mod registry to return a container interface (#534)

This commit is contained in:
Jesse Plamondon-Willard 2018-08-22 23:03:09 -04:00
parent 046c6be68a
commit ceac1de6ec
6 changed files with 18 additions and 10 deletions

View File

@ -13,6 +13,7 @@
* Added `IContentPack.WriteJsonFile` method.
* Added IntelliSense documentation when not using the 'for developers' version of SMAPI.
* Fixed `IContentPack.ReadJsonFile` allowing non-relative paths.
* **Breaking change:** `helper.ModRegistry` returns a new `IModInfo` interface instead of `IManifest` directly. This lets SMAPI return more metadata about mods in future versions.
* **Breaking change:** most SMAPI files have been moved into a `smapi-internal` subfolder. This won't affect compiled mods, but you'll need to update the mod build config NuGet package when compiling mods.
* For SMAPI developers:

View File

@ -5,7 +5,7 @@ using StardewModdingAPI.Toolkit.Framework.ModData;
namespace StardewModdingAPI.Framework
{
/// <summary>Metadata for a mod.</summary>
internal interface IModMetadata
internal interface IModMetadata : IModInfo
{
/*********
** Accessors
@ -16,9 +16,6 @@ namespace StardewModdingAPI.Framework
/// <summary>The mod's full directory path.</summary>
string DirectoryPath { get; }
/// <summary>The mod manifest.</summary>
IManifest Manifest { get; }
/// <summary>Metadata about the mod from SMAPI's internal data (if any).</summary>
ModDataRecordVersionedFields DataRecord { get; }

View File

@ -40,17 +40,17 @@ namespace StardewModdingAPI.Framework.ModHelpers
}
/// <summary>Get metadata for all loaded mods.</summary>
public IEnumerable<IManifest> GetAll()
public IEnumerable<IModInfo> GetAll()
{
return this.Registry.GetAll().Select(p => p.Manifest);
return this.Registry.GetAll();
}
/// <summary>Get metadata for a loaded mod.</summary>
/// <param name="uniqueID">The mod's unique ID.</param>
/// <returns>Returns the matching mod's metadata, or <c>null</c> if not found.</returns>
public IManifest Get(string uniqueID)
public IModInfo Get(string uniqueID)
{
return this.Registry.Get(uniqueID)?.Manifest;
return this.Registry.Get(uniqueID);
}
/// <summary>Get whether a mod has been loaded.</summary>

9
src/SMAPI/IModInfo.cs Normal file
View File

@ -0,0 +1,9 @@
namespace StardewModdingAPI
{
/// <summary>Metadata for a loaded mod.</summary>
public interface IModInfo
{
/// <summary>The mod manifest.</summary>
IManifest Manifest { get; }
}
}

View File

@ -6,12 +6,12 @@ namespace StardewModdingAPI
public interface IModRegistry : IModLinked
{
/// <summary>Get metadata for all loaded mods.</summary>
IEnumerable<IManifest> GetAll();
IEnumerable<IModInfo> GetAll();
/// <summary>Get metadata for a loaded mod.</summary>
/// <param name="uniqueID">The mod's unique ID.</param>
/// <returns>Returns the matching mod's metadata, or <c>null</c> if not found.</returns>
IManifest Get(string uniqueID);
IModInfo Get(string uniqueID);
/// <summary>Get whether a mod has been loaded.</summary>
/// <param name="uniqueID">The mod's unique ID.</param>

View File

@ -186,6 +186,7 @@
<Compile Include="Framework\StateTracking\PlayerTracker.cs" />
<Compile Include="Framework\Utilities\ContextHash.cs" />
<Compile Include="IContentPack.cs" />
<Compile Include="IModInfo.cs" />
<Compile Include="IMultiplayerHelper.cs" />
<Compile Include="IReflectedField.cs" />
<Compile Include="IReflectedMethod.cs" />