diff options
| author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-07 23:20:36 -0400 | 
|---|---|---|
| committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-07 23:20:36 -0400 | 
| commit | d0dd2f7ba729de6be749d326a2fed78988ba9d7b (patch) | |
| tree | a22127da6a8900e9f29bbb847bfd5d3347f6b952 /src/SMAPI/IModHelper.cs | |
| parent | 7889676ea24cafc945899bf25608784e3f5bc9e0 (diff) | |
| parent | 5928f5f86c4493ddb6b89bce0b7d0fb73a884c09 (diff) | |
| download | SMAPI-d0dd2f7ba729de6be749d326a2fed78988ba9d7b.tar.gz SMAPI-d0dd2f7ba729de6be749d326a2fed78988ba9d7b.tar.bz2 SMAPI-d0dd2f7ba729de6be749d326a2fed78988ba9d7b.zip | |
Merge branch 'add-mod-build-config' into develop
Diffstat (limited to 'src/SMAPI/IModHelper.cs')
| -rw-r--r-- | src/SMAPI/IModHelper.cs | 58 | 
1 files changed, 58 insertions, 0 deletions
| diff --git a/src/SMAPI/IModHelper.cs b/src/SMAPI/IModHelper.cs new file mode 100644 index 00000000..116e8508 --- /dev/null +++ b/src/SMAPI/IModHelper.cs @@ -0,0 +1,58 @@ +namespace StardewModdingAPI +{ +    /// <summary>Provides simplified APIs for writing mods.</summary> +    public interface IModHelper +    { +        /********* +        ** Accessors +        *********/ +        /// <summary>The full path to the mod's folder.</summary> +        string DirectoryPath { get; } + +        /// <summary>An API for loading content assets.</summary> +        IContentHelper Content { get; } + +        /// <summary>Simplifies access to private game code.</summary> +        IReflectionHelper Reflection { get; } + +        /// <summary>Metadata about loaded mods.</summary> +        IModRegistry ModRegistry { get; } + +        /// <summary>An API for managing console commands.</summary> +        ICommandHelper ConsoleCommands { get; } + +        /// <summary>Provides translations stored in the mod's <c>i18n</c> folder, with one file per locale (like <c>en.json</c>) containing a flat key => value structure. Translations are fetched with locale fallback, so missing translations are filled in from broader locales (like <c>pt-BR.json</c> < <c>pt.json</c> < <c>default.json</c>).</summary> +        ITranslationHelper Translation { get; } + + +        /********* +        ** Public methods +        *********/ +        /**** +        ** Mod config file +        ****/ +        /// <summary>Read the mod's configuration file (and create it if needed).</summary> +        /// <typeparam name="TConfig">The config class type. This should be a plain class that has public properties for the settings you want. These can be complex types.</typeparam> +        TConfig ReadConfig<TConfig>() where TConfig : class, new(); + +        /// <summary>Save to the mod's configuration file.</summary> +        /// <typeparam name="TConfig">The config class type.</typeparam> +        /// <param name="config">The config settings to save.</param> +        void WriteConfig<TConfig>(TConfig config) where TConfig : class, new(); + +        /**** +        ** Generic JSON files +        ****/ +        /// <summary>Read a JSON file.</summary> +        /// <typeparam name="TModel">The model type.</typeparam> +        /// <param name="path">The file path relative to the mod 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>Save to a JSON file.</summary> +        /// <typeparam name="TModel">The model type.</typeparam> +        /// <param name="path">The file path relative to the mod directory.</param> +        /// <param name="model">The model to save.</param> +        void WriteJsonFile<TModel>(string path, TModel model) where TModel : class; +    } +}
\ No newline at end of file | 
