summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Mod.cs
diff options
context:
space:
mode:
authorGormogon <Gormogon@users.noreply.github.com>2016-05-29 18:23:01 -0400
committerGormogon <Gormogon@users.noreply.github.com>2016-05-29 18:23:01 -0400
commit27dece2cf445147c5e2848f9ec26f38a101f50fc (patch)
tree2579d0979dd9f295972e5ba2a81f4177589f7395 /src/StardewModdingAPI/Mod.cs
parent85142935b63324f7c6131a8855acea0a2d534879 (diff)
downloadSMAPI-27dece2cf445147c5e2848f9ec26f38a101f50fc.tar.gz
SMAPI-27dece2cf445147c5e2848f9ec26f38a101f50fc.tar.bz2
SMAPI-27dece2cf445147c5e2848f9ec26f38a101f50fc.zip
Attempt to migrate to new directory structure.
Diffstat (limited to 'src/StardewModdingAPI/Mod.cs')
-rw-r--r--src/StardewModdingAPI/Mod.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Mod.cs b/src/StardewModdingAPI/Mod.cs
new file mode 100644
index 00000000..8edfcf7e
--- /dev/null
+++ b/src/StardewModdingAPI/Mod.cs
@@ -0,0 +1,51 @@
+using System.IO;
+
+namespace StardewModdingAPI
+{
+ public class Mod
+ {
+ /// <summary>
+ /// The mod's manifest
+ /// </summary>
+ public Manifest Manifest { get; internal set; }
+
+ /// <summary>
+ /// Where the mod is located on the disk.
+ /// </summary>
+ public string PathOnDisk { get; internal set; }
+
+ /// <summary>
+ /// A basic path to store your mod's config at.
+ /// </summary>
+ public string BaseConfigPath => PathOnDisk + "\\config.json";
+
+ /// <summary>
+ /// A basic path to where per-save configs are stored
+ /// </summary>
+ public string PerSaveConfigFolder => GetPerSaveConfigFolder();
+
+ /// <summary>
+ /// A basic path to store your mod's config at, dependent on the current save.
+ /// The Manifest must allow for per-save configs. This is to keep from having an
+ /// empty directory in every mod folder.
+ /// </summary>
+ public string PerSaveConfigPath => Constants.CurrentSavePathExists ? Path.Combine(PerSaveConfigFolder, Constants.SaveFolderName + ".json") : "";
+
+ /// <summary>
+ /// A basic method that is the entry-point of your mod. It will always be called once when the mod loads.
+ /// </summary>
+ public virtual void Entry(params object[] objects)
+ {
+ }
+
+ private string GetPerSaveConfigFolder()
+ {
+ if (Manifest.PerSaveConfigs)
+ {
+ return Path.Combine(PathOnDisk, "psconfigs");
+ }
+ Log.AsyncR($"The mod [{Manifest.Name}] is not configured to use per-save configs.");
+ return "";
+ }
+ }
+} \ No newline at end of file