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/IContentPackHelper.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/SMAPI/IContentPackHelper.cs (limited to 'src/SMAPI/IContentPackHelper.cs') diff --git a/src/SMAPI/IContentPackHelper.cs b/src/SMAPI/IContentPackHelper.cs new file mode 100644 index 00000000..0c734432 --- /dev/null +++ b/src/SMAPI/IContentPackHelper.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace StardewModdingAPI +{ + /// Provides an API for managing content packs. + public interface IContentPackHelper : IModLinked + { + /********* + ** Public methods + *********/ + /// Get all content packs loaded for this mod. + IEnumerable GetOwned(); + + /// 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. + IContentPack CreateFake(string directoryPath); + + /// 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 CreateFake(string directoryPath, string id, string name, string description, string author, ISemanticVersion version); + } +} -- 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/IContentPackHelper.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 From 95b1dedb667d1fe2fd9ee89ece342bacbdd3be48 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 13 Dec 2018 02:11:06 -0500 Subject: clarify docblock --- src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs | 2 +- src/SMAPI/IContentPackHelper.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/SMAPI/IContentPackHelper.cs') diff --git a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs index 4bd28b36..26c4648c 100644 --- a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs @@ -38,7 +38,7 @@ namespace StardewModdingAPI.Framework.ModHelpers return this.ContentPacks.Value; } - /// Create a temporary content pack to read files from a directory. This will generate fake manifest data; any manifest.json in the directory will be ignored. Temporary content packs will not appear in the SMAPI log and update checks will not be performed. + /// Create a temporary content pack to read files from a directory, using randomised manifest fields. This will generate fake manifest data; any manifest.json in the directory will be ignored. 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. public IContentPack CreateFake(string directoryPath) { diff --git a/src/SMAPI/IContentPackHelper.cs b/src/SMAPI/IContentPackHelper.cs index 6cce964c..e4949f58 100644 --- a/src/SMAPI/IContentPackHelper.cs +++ b/src/SMAPI/IContentPackHelper.cs @@ -11,7 +11,7 @@ namespace StardewModdingAPI /// Get all content packs loaded for this mod. IEnumerable GetOwned(); - /// 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. + /// Create a temporary content pack to read files from a directory, using randomised manifest fields. 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. IContentPack CreateFake(string directoryPath); -- cgit