1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
using System;
using System.IO;
using StardewModdingAPI.Framework;
namespace StardewModdingAPI
{
/// <summary>The base class for a mod.</summary>
public class Mod
{
/*********
** Properties
*********/
/// <summary>The backing field for <see cref="Mod.PathOnDisk"/>.</summary>
private string _pathOnDisk;
/*********
** Accessors
*********/
/// <summary>Provides simplified APIs for writing mods.</summary>
public IModHelper Helper { get; internal set; }
/// <summary>Writes messages to the console and log file.</summary>
public IMonitor Monitor { get; internal set; }
/// <summary>The mod's manifest.</summary>
public Manifest Manifest { get; internal set; }
/// <summary>The full path to the mod's directory on the disk.</summary>
[Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.DirectoryPath) + " instead")]
public string PathOnDisk
{
get
{
Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0", DeprecationLevel.Notice);
return this._pathOnDisk;
}
internal set { this._pathOnDisk = value; }
}
/// <summary>The full path to the mod's <c>config.json</c> file on the disk.</summary>
[Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadConfig) + " instead")]
public string BaseConfigPath
{
get
{
Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.BaseConfigPath)}", "1.0", DeprecationLevel.Notice);
Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0"); // avoid redundant warnings
return Path.Combine(this.PathOnDisk, "config.json");
}
}
/// <summary>The full path to the per-save configs folder (if <see cref="StardewModdingAPI.Manifest.PerSaveConfigs"/> is <c>true</c>).</summary>
[Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadJsonFile) + " instead")]
public string PerSaveConfigFolder => this.GetPerSaveConfigFolder();
/// <summary>The full path to the per-save configuration file for the current save (if <see cref="StardewModdingAPI.Manifest.PerSaveConfigs"/> is <c>true</c>).</summary>
[Obsolete("Use " + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadJsonFile) + " instead")]
public string PerSaveConfigPath
{
get
{
Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigPath)}", "1.0", DeprecationLevel.Notice);
Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigFolder)}", "1.0"); // avoid redundant warnings
return Constants.CurrentSavePathExists ? Path.Combine(this.PerSaveConfigFolder, Constants.SaveFolderName + ".json") : "";
}
}
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
[Obsolete("This overload is obsolete since SMAPI 1.0.")]
public virtual void Entry(params object[] objects) { }
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
[Obsolete("This overload is obsolete since SMAPI 1.1.")]
public virtual void Entry(ModHelper helper) { }
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public virtual void Entry(IModHelper helper) { }
/*********
** Private methods
*********/
/// <summary>Get the full path to the per-save configuration file for the current save (if <see cref="StardewModdingAPI.Manifest.PerSaveConfigs"/> is <c>true</c>).</summary>
[Obsolete]
private string GetPerSaveConfigFolder()
{
Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigFolder)}", "1.0", DeprecationLevel.Notice);
Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0"); // avoid redundant warnings
if (!this.Manifest.PerSaveConfigs)
{
this.Monitor.Log("Tried to fetch the per-save config folder, but this mod isn't configured to use per-save config files.", LogLevel.Error);
return "";
}
return Path.Combine(this.PathOnDisk, "psconfigs");
}
}
}
|