mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 04:13:40 +01:00
feat: plugin file Just For Anna
This commit is contained in:
parent
438017c2b3
commit
cf1e0909c5
2 changed files with 15 additions and 4 deletions
|
|
@ -21,7 +21,7 @@ namespace Dalamud.Configuration
|
||||||
// all future saved configs, and then Load() can probably be removed entirey.
|
// all future saved configs, and then Load() can probably be removed entirey.
|
||||||
|
|
||||||
public void Save(IPluginConfiguration config, string pluginName) {
|
public void Save(IPluginConfiguration config, string pluginName) {
|
||||||
File.WriteAllText(GetPath(pluginName).FullName, JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings
|
File.WriteAllText(GetConfigFile(pluginName).FullName, JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
|
TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
|
||||||
TypeNameHandling = TypeNameHandling.Objects
|
TypeNameHandling = TypeNameHandling.Objects
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Dalamud.Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPluginConfiguration Load(string pluginName) {
|
public IPluginConfiguration Load(string pluginName) {
|
||||||
var path = GetPath(pluginName);
|
var path = GetConfigFile(pluginName);
|
||||||
|
|
||||||
if (!path.Exists)
|
if (!path.Exists)
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -60,7 +60,7 @@ namespace Dalamud.Configuration
|
||||||
// without reflection - for now this is in support of the existing plugin api
|
// without reflection - for now this is in support of the existing plugin api
|
||||||
public T LoadForType<T>(string pluginName) where T : IPluginConfiguration
|
public T LoadForType<T>(string pluginName) where T : IPluginConfiguration
|
||||||
{
|
{
|
||||||
var path = GetPath(pluginName);
|
var path = GetConfigFile(pluginName);
|
||||||
|
|
||||||
if (!path.Exists)
|
if (!path.Exists)
|
||||||
return default(T);
|
return default(T);
|
||||||
|
|
@ -70,7 +70,13 @@ namespace Dalamud.Configuration
|
||||||
return JsonConvert.DeserializeObject<T>(File.ReadAllText(path.FullName));
|
return JsonConvert.DeserializeObject<T>(File.ReadAllText(path.FullName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileInfo GetPath(string pluginName) => new FileInfo(Path.Combine(this.configDirectory.FullName, $"{pluginName}.json"));
|
/// <summary>
|
||||||
|
/// Get FileInfo to plugin config file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pluginName">InternalName of the plugin.</param>
|
||||||
|
/// <returns>FileInfo of the config file</returns>
|
||||||
|
public FileInfo GetConfigFile(string pluginName) => new FileInfo(Path.Combine(this.configDirectory.FullName, $"{pluginName}.json"));
|
||||||
|
|
||||||
private DirectoryInfo GetDirectoryPath(string pluginName) => new DirectoryInfo(Path.Combine(this.configDirectory.FullName, pluginName));
|
private DirectoryInfo GetDirectoryPath(string pluginName) => new DirectoryInfo(Path.Combine(this.configDirectory.FullName, pluginName));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,11 @@ namespace Dalamud.Plugin
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DirectoryInfo ConfigDirectory => new DirectoryInfo(GetPluginConfigDirectory());
|
public DirectoryInfo ConfigDirectory => new DirectoryInfo(GetPluginConfigDirectory());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the config file of your plugin.
|
||||||
|
/// </summary>
|
||||||
|
public FileInfo ConfigFile => this.configs.GetConfigFile(this.pluginName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The CommandManager object that allows you to add and remove custom chat commands.
|
/// The CommandManager object that allows you to add and remove custom chat commands.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue