summaryrefslogtreecommitdiff
path: root/src/SMAPI/IContentPack.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-02-24 17:54:31 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-02-24 17:54:31 -0500
commit414cf5c197b5b59776d3dda914eb15710efb0868 (patch)
tree0393a95194ad78cf4440c68657b0488b7db6d68b /src/SMAPI/IContentPack.cs
parent5da8b707385b9851ff3f6442de58519125f5c96f (diff)
parentf2e8450706d1971d774f870081deffdb0c6b92eb (diff)
downloadSMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.tar.gz
SMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.tar.bz2
SMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/IContentPack.cs')
-rw-r--r--src/SMAPI/IContentPack.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/SMAPI/IContentPack.cs b/src/SMAPI/IContentPack.cs
new file mode 100644
index 00000000..15a2b7dd
--- /dev/null
+++ b/src/SMAPI/IContentPack.cs
@@ -0,0 +1,42 @@
+using System;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.Graphics;
+using xTile;
+
+namespace StardewModdingAPI
+{
+ /// <summary>An API that provides access to a content pack.</summary>
+ public interface IContentPack
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The full path to the content pack's folder.</summary>
+ string DirectoryPath { get; }
+
+ /// <summary>The content pack's manifest.</summary>
+ IManifest Manifest { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <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 pack directory.</param>
+ /// <returns>Returns the deserialised model, or <c>null</c> if the file doesn't exist or is empty.</returns>
+ TModel ReadJsonFile<TModel>(string path) where TModel : class;
+
+ /// <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>
+ T LoadAsset<T>(string key);
+
+ /// <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>
+ string GetActualAssetKey(string key);
+ }
+}