mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-21 15:27:51 +01:00
Add event for changing mod directory.
This commit is contained in:
parent
c0542d0e94
commit
5b07245cd9
8 changed files with 75 additions and 21 deletions
|
|
@ -13,6 +13,7 @@ public sealed partial class Mod
|
|||
|
||||
public event Action? ModDiscoveryStarted;
|
||||
public event Action? ModDiscoveryFinished;
|
||||
public event Action< string, bool > ModDirectoryChanged;
|
||||
|
||||
// Change the mod base directory and discover available mods.
|
||||
public void DiscoverMods( string newDir )
|
||||
|
|
@ -35,6 +36,10 @@ public sealed partial class Mod
|
|||
{
|
||||
Valid = false;
|
||||
BasePath = new DirectoryInfo( "." );
|
||||
if( Penumbra.Config.ModDirectory != BasePath.FullName )
|
||||
{
|
||||
ModDirectoryChanged.Invoke( string.Empty, false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -56,13 +61,19 @@ public sealed partial class Mod
|
|||
Valid = Directory.Exists( newDir.FullName );
|
||||
if( Penumbra.Config.ModDirectory != BasePath.FullName )
|
||||
{
|
||||
PluginLog.Information( "Set new mod base directory from {OldDirectory:l} to {NewDirectory:l}.", Penumbra.Config.ModDirectory, BasePath.FullName );
|
||||
Penumbra.Config.ModDirectory = BasePath.FullName;
|
||||
Penumbra.Config.Save();
|
||||
ModDirectoryChanged.Invoke( BasePath.FullName, Valid );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnModDirectoryChange( string newPath, bool _ )
|
||||
{
|
||||
PluginLog.Information( "Set new mod base directory from {OldDirectory:l} to {NewDirectory:l}.",
|
||||
Penumbra.Config.ModDirectory, newPath );
|
||||
Penumbra.Config.ModDirectory = newPath;
|
||||
Penumbra.Config.Save();
|
||||
}
|
||||
|
||||
// Discover new mods.
|
||||
public void DiscoverMods()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public sealed partial class Mod
|
|||
|
||||
public Manager( string modDirectory )
|
||||
{
|
||||
ModDirectoryChanged += OnModDirectoryChange;
|
||||
SetBaseDirectory( modDirectory, true );
|
||||
ModOptionChanged += OnModOptionChange;
|
||||
ModPathChanged += OnModPathChange;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue