From e447ce225f46f60131519a1ff77dfddf520696bb Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 13 Dec 2018 01:16:38 -0500 Subject: add content pack API --- src/SMAPI/IModHelper.cs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/SMAPI/IModHelper.cs') diff --git a/src/SMAPI/IModHelper.cs b/src/SMAPI/IModHelper.cs index fbe3d51f..21bc5727 100644 --- a/src/SMAPI/IModHelper.cs +++ b/src/SMAPI/IModHelper.cs @@ -22,6 +22,9 @@ namespace StardewModdingAPI /// An API for loading content assets. IContentHelper Content { get; } + /// An API for managing content packs. + IContentPackHelper ContentPacks { get; } + /// An API for reading and writing persistent mod data. IDataHelper Data { get; } @@ -73,21 +76,7 @@ namespace StardewModdingAPI /// The model to save. [Obsolete("Use " + nameof(IModHelper.Data) + "." + nameof(IDataHelper.WriteJsonFile) + " instead")] void WriteJsonFile(string path, TModel model) where TModel : class; -#endif - - /**** - ** Content packs - ****/ - /// Create a temporary content pack to read files from a directory. Temporary content packs will not appear in the SMAPI log and update checks will not be performed. - /// The absolute directory path containing the content pack files. - /// The content pack's unique ID. - /// The content pack name. - /// The content pack description. - /// The content pack author's name. - /// The content pack version. - IContentPack CreateTemporaryContentPack(string directoryPath, string id, string name, string description, string author, ISemanticVersion version); -#if !SMAPI_3_0_STRICT /// Manually create a transitional content pack to support pre-SMAPI content packs. This provides a way to access legacy content packs using the SMAPI content pack APIs, but the content pack will not be visible in the log or validated by SMAPI. /// The absolute directory path containing the content pack files. /// The content pack's unique ID. @@ -95,11 +84,12 @@ namespace StardewModdingAPI /// The content pack description. /// The content pack author's name. /// The content pack version. - [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.CreateTemporaryContentPack) + " instead")] + [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ContentPacks) + "." + nameof(IContentPackHelper.CreateFake) + " instead")] IContentPack CreateTransitionalContentPack(string directoryPath, string id, string name, string description, string author, ISemanticVersion version); -#endif /// Get all content packs loaded for this mod. + [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ContentPacks) + "." + nameof(IContentPackHelper.GetOwned) + " instead")] IEnumerable GetContentPacks(); +#endif } } -- cgit From 11787f9fea35ee8597c8a4c028b9c3be42751463 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 13 Dec 2018 01:26:54 -0500 Subject: tweak new API method name --- src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs | 4 ++-- src/SMAPI/Framework/ModHelpers/ModHelper.cs | 2 +- src/SMAPI/IContentPackHelper.cs | 2 +- src/SMAPI/IModHelper.cs | 5 ++++- 4 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/SMAPI/IModHelper.cs') diff --git a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs index c4b86cda..4bd28b36 100644 --- a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs @@ -43,7 +43,7 @@ namespace StardewModdingAPI.Framework.ModHelpers public IContentPack CreateFake(string directoryPath) { string id = Guid.NewGuid().ToString("N"); - return this.CreateFake(directoryPath, id, id, id, id, new SemanticVersion(1, 0, 0)); + return this.CreateTemporary(directoryPath, id, id, id, id, new SemanticVersion(1, 0, 0)); } /// Create a temporary content pack to read files from a directory. Temporary content packs will not appear in the SMAPI log and update checks will not be performed. @@ -53,7 +53,7 @@ namespace StardewModdingAPI.Framework.ModHelpers /// The content pack description. /// The content pack author's name. /// The content pack version. - public IContentPack CreateFake(string directoryPath, string id, string name, string description, string author, ISemanticVersion version) + public IContentPack CreateTemporary(string directoryPath, string id, string name, string description, string author, ISemanticVersion version) { // validate if (string.IsNullOrWhiteSpace(directoryPath)) diff --git a/src/SMAPI/Framework/ModHelpers/ModHelper.cs b/src/SMAPI/Framework/ModHelpers/ModHelper.cs index 87d405e9..0dbc5fd7 100644 --- a/src/SMAPI/Framework/ModHelpers/ModHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ModHelper.cs @@ -174,7 +174,7 @@ namespace StardewModdingAPI.Framework.ModHelpers /// The content pack description. /// The content pack author's name. /// The content pack version. - [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ContentPacks) + "." + nameof(IContentPackHelper.CreateFake) + " instead")] + [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ContentPacks) + "." + nameof(IContentPackHelper.CreateTemporary) + " instead")] public IContentPack CreateTransitionalContentPack(string directoryPath, string id, string name, string description, string author, ISemanticVersion version) { this.DeprecationManager.Warn($"{nameof(IModHelper)}.{nameof(IModHelper.CreateTransitionalContentPack)}", "2.5", DeprecationLevel.Notice); diff --git a/src/SMAPI/IContentPackHelper.cs b/src/SMAPI/IContentPackHelper.cs index 0c734432..6cce964c 100644 --- a/src/SMAPI/IContentPackHelper.cs +++ b/src/SMAPI/IContentPackHelper.cs @@ -22,6 +22,6 @@ namespace StardewModdingAPI /// The content pack description. /// The content pack author's name. /// The content pack version. - IContentPack CreateFake(string directoryPath, string id, string name, string description, string author, ISemanticVersion version); + IContentPack CreateTemporary(string directoryPath, string id, string name, string description, string author, ISemanticVersion version); } } diff --git a/src/SMAPI/IModHelper.cs b/src/SMAPI/IModHelper.cs index 21bc5727..0220b4f7 100644 --- a/src/SMAPI/IModHelper.cs +++ b/src/SMAPI/IModHelper.cs @@ -77,6 +77,9 @@ namespace StardewModdingAPI [Obsolete("Use " + nameof(IModHelper.Data) + "." + nameof(IDataHelper.WriteJsonFile) + " instead")] void WriteJsonFile(string path, TModel model) where TModel : class; + /**** + ** Content packs + ****/ /// Manually create a transitional content pack to support pre-SMAPI content packs. This provides a way to access legacy content packs using the SMAPI content pack APIs, but the content pack will not be visible in the log or validated by SMAPI. /// The absolute directory path containing the content pack files. /// The content pack's unique ID. @@ -84,7 +87,7 @@ namespace StardewModdingAPI /// The content pack description. /// The content pack author's name. /// The content pack version. - [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ContentPacks) + "." + nameof(IContentPackHelper.CreateFake) + " instead")] + [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ContentPacks) + "." + nameof(IContentPackHelper.CreateTemporary) + " instead")] IContentPack CreateTransitionalContentPack(string directoryPath, string id, string name, string description, string author, ISemanticVersion version); /// Get all content packs loaded for this mod. -- cgit