diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-09-07 13:06:27 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-09-07 13:06:27 -0400 |
commit | 5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83 (patch) | |
tree | 0a42305174eb84561a584549cd685c5e95670f36 /src/SMAPI/Framework/ContentPack.cs | |
parent | 8da88b8fe5b41739c5cd0df3280b9770fc7f10a4 (diff) | |
parent | f9fac11028354f15d786d5b854608edb10716f79 (diff) | |
download | SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.tar.gz SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.tar.bz2 SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/ContentPack.cs')
-rw-r--r-- | src/SMAPI/Framework/ContentPack.cs | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/src/SMAPI/Framework/ContentPack.cs b/src/SMAPI/Framework/ContentPack.cs index 9c0bb9d1..55c1a0b2 100644 --- a/src/SMAPI/Framework/ContentPack.cs +++ b/src/SMAPI/Framework/ContentPack.cs @@ -1,10 +1,7 @@ using System; using System.IO; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI.Toolkit.Serialization; using StardewModdingAPI.Toolkit.Utilities; -using xTile; namespace StardewModdingAPI.Framework { @@ -24,13 +21,13 @@ namespace StardewModdingAPI.Framework /********* ** Accessors *********/ - /// <summary>The full path to the content pack's folder.</summary> + /// <inheritdoc /> public string DirectoryPath { get; } - /// <summary>The content pack's manifest.</summary> + /// <inheritdoc /> public IManifest Manifest { get; } - /// <summary>Provides translations stored in the content pack's <c>i18n</c> folder. See <see cref="IModHelper.Translation"/> for more info.</summary> + /// <inheritdoc /> public ITranslationHelper Translation { get; } @@ -52,8 +49,7 @@ namespace StardewModdingAPI.Framework this.JsonHelper = jsonHelper; } - /// <summary>Get whether a given file exists in the content pack.</summary> - /// <param name="path">The file path to check.</param> + /// <inheritdoc /> public bool HasFile(string path) { this.AssertRelativePath(path, nameof(this.HasFile)); @@ -61,11 +57,7 @@ namespace StardewModdingAPI.Framework return File.Exists(Path.Combine(this.DirectoryPath, path)); } - /// <summary>Read a JSON file from the content pack folder.</summary> - /// <typeparam name="TModel">The model type.</typeparam> - /// <param name="path">The file path relative to the content directory.</param> - /// <returns>Returns the deserialized model, or <c>null</c> if the file doesn't exist or is empty.</returns> - /// <exception cref="InvalidOperationException">The <paramref name="path"/> is not relative or contains directory climbing (../).</exception> + /// <inheritdoc /> public TModel ReadJsonFile<TModel>(string path) where TModel : class { this.AssertRelativePath(path, nameof(this.ReadJsonFile)); @@ -76,11 +68,7 @@ namespace StardewModdingAPI.Framework : null; } - /// <summary>Save data to a JSON file in the content pack's folder.</summary> - /// <typeparam name="TModel">The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types.</typeparam> - /// <param name="path">The file path relative to the mod folder.</param> - /// <param name="data">The arbitrary data to save.</param> - /// <exception cref="InvalidOperationException">The <paramref name="path"/> is not relative or contains directory climbing (../).</exception> + /// <inheritdoc /> public void WriteJsonFile<TModel>(string path, TModel data) where TModel : class { this.AssertRelativePath(path, nameof(this.WriteJsonFile)); @@ -89,19 +77,13 @@ namespace StardewModdingAPI.Framework this.JsonHelper.WriteJsonFile(path, data); } - /// <summary>Load content from the content pack folder (if not already cached), and return it. When loading a <c>.png</c> file, this must be called outside the game's draw loop.</summary> - /// <typeparam name="T">The expected data type. The main supported types are <see cref="Map"/>, <see cref="Texture2D"/>, and dictionaries; other types may be supported by the game's content pipeline.</typeparam> - /// <param name="key">The local path to a content file relative to the content pack folder.</param> - /// <exception cref="ArgumentException">The <paramref name="key"/> is empty or contains invalid characters.</exception> - /// <exception cref="ContentLoadException">The content asset couldn't be loaded (e.g. because it doesn't exist).</exception> + /// <inheritdoc /> public T LoadAsset<T>(string key) { return this.Content.Load<T>(key, ContentSource.ModFolder); } - /// <summary>Get the underlying key in the game's content cache for an asset. This can be used to load custom map tilesheets, but should be avoided when you can use the content API instead. This does not validate whether the asset exists.</summary> - /// <param name="key">The the local path to a content file relative to the content pack folder.</param> - /// <exception cref="ArgumentException">The <paramref name="key"/> is empty or contains invalid characters.</exception> + /// <inheritdoc /> public string GetActualAssetKey(string key) { return this.Content.GetActualAssetKey(key, ContentSource.ModFolder); |