mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Complete refactoring of most code, indiscriminate application of .editorconfig and general cleanup.
This commit is contained in:
parent
5332119a63
commit
a19ec226c5
84 changed files with 3168 additions and 1709 deletions
|
|
@ -1,14 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Plugin;
|
||||
using Penumbra.Util;
|
||||
|
||||
namespace Penumbra
|
||||
{
|
||||
[Serializable]
|
||||
public class Configuration : IPluginConfiguration
|
||||
{
|
||||
public int Version { get; set; } = 0;
|
||||
private const int CurrentVersion = 1;
|
||||
|
||||
public int Version { get; set; } = CurrentVersion;
|
||||
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
|
|
@ -18,25 +20,39 @@ namespace Penumbra
|
|||
|
||||
public bool EnableHttpApi { get; set; }
|
||||
|
||||
public string CurrentCollection { get; set; } = @"D:/ffxiv/fs_mods/";
|
||||
public string ModDirectory { get; set; } = @"D:/ffxiv/fs_mods/";
|
||||
|
||||
public List< string > ModCollections { get; set; } = new();
|
||||
public string CurrentCollection { get; set; } = "Default";
|
||||
|
||||
public bool InvertModListOrder { get; set; }
|
||||
public bool InvertModListOrder { internal get; set; }
|
||||
|
||||
// the below exist just to make saving less cumbersome
|
||||
|
||||
[NonSerialized]
|
||||
private DalamudPluginInterface? _pluginInterface;
|
||||
|
||||
public void Initialize( DalamudPluginInterface pluginInterface )
|
||||
public static Configuration Load( DalamudPluginInterface pi )
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
var configuration = pi.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
if( configuration.Version == CurrentVersion )
|
||||
{
|
||||
return configuration;
|
||||
}
|
||||
|
||||
MigrateConfiguration.Version0To1( configuration );
|
||||
configuration.Save( pi );
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public void Save( DalamudPluginInterface pi )
|
||||
{
|
||||
try
|
||||
{
|
||||
pi.SavePluginConfig( this );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Could not save plugin configuration:\n{e}" );
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_pluginInterface?.SavePluginConfig( this );
|
||||
}
|
||||
=> Save( Service< DalamudPluginInterface >.Get() );
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue