Added a bunch of logging, small fix.

This commit is contained in:
Ottermandias 2022-04-29 15:30:08 +02:00
parent 9af4406c8c
commit e8ee729ec5
16 changed files with 86 additions and 38 deletions

View file

@ -33,6 +33,7 @@ public partial class Mod
try
{
Directory.Delete( mod.BasePath.FullName, true );
PluginLog.Debug( "Deleted directory {Directory:l} for {Name:l}.", mod.BasePath.FullName, mod.Name );
}
catch( Exception e )
{
@ -47,6 +48,7 @@ public partial class Mod
}
ModPathChanged.Invoke( ModPathChangeType.Deleted, mod, mod.BasePath, null );
PluginLog.Debug( "Deleted mod {Name:l}.", mod.Name );
}
// Load a new mod and add it to the manager if successful.
@ -66,6 +68,7 @@ public partial class Mod
mod.Index = _mods.Count;
_mods.Add( mod );
ModPathChanged.Invoke( ModPathChangeType.Added, mod, null, mod.BasePath );
PluginLog.Debug( "Added new mod {Name:l} from {Directory:l}.", mod.Name, modFolder.FullName );
}
// Add new mods to NewMods and remove deleted mods from NewMods.

View file

@ -56,6 +56,7 @@ 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();
}
@ -86,6 +87,7 @@ public sealed partial class Mod
}
ModDiscoveryFinished?.Invoke();
PluginLog.Information( "Rediscovered mods." );
}
}
}

View file

@ -67,7 +67,7 @@ public partial class Mod
{
var group = new MultiModGroup()
{
Name = groupData.GroupName!,
Name = groupData.GroupName,
Description = desc,
Priority = priority,
};
@ -79,7 +79,7 @@ public partial class Mod
{
var group = new SingleModGroup()
{
Name = groupData.GroupName!,
Name = groupData.GroupName,
Description = desc,
Priority = priority,
};
@ -97,9 +97,9 @@ public partial class Mod
.Select( f => ( Utf8GamePath.FromFile( f, optionFolder, out var gamePath, true ), gamePath, new FullPath( f ) ) )
.Where( t => t.Item1 );
var mod = new SubMod()
var mod = new SubMod
{
Name = option.Name!,
Name = option.Name,
};
foreach( var (_, gamePath, file) in list )
{

View file

@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Dalamud.Logging;
using OtterGui.Filesystem;
namespace Penumbra.Mods;
@ -14,8 +15,11 @@ public sealed class ModFileSystem : FileSystem< Mod >, IDisposable
// Save the current sort order.
// Does not save or copy the backup in the current mod directory,
// as this is done on mod directory changes only.
public void Save()
=> SaveToFile( new FileInfo( ModFileSystemFile ), SaveMod, true );
private void Save()
{
SaveToFile( new FileInfo( ModFileSystemFile ), SaveMod, true );
PluginLog.Verbose( "Saved mod filesystem." );
}
// Create a new ModFileSystem from the currently loaded mods and the current sort order file.
public static ModFileSystem Load()
@ -46,6 +50,7 @@ public sealed class ModFileSystem : FileSystem< Mod >, IDisposable
{
Save();
}
PluginLog.Debug( "Reloaded mod filesystem." );
}
// Save the filesystem on every filesystem change except full reloading.

View file

@ -48,6 +48,7 @@ public interface IModGroup : IEnumerable< ISubMod >
try
{
File.Delete( file );
PluginLog.Debug( "Deleted group file {File:l} for {GroupName:l}.", file, Name );
}
catch( Exception e )
{
@ -81,6 +82,7 @@ public interface IModGroup : IEnumerable< ISubMod >
j.WriteEndArray();
j.WriteEndObject();
PluginLog.Debug( "Saved group file {File:l} for {GroupName:l}.", file, group.Name );
}
public IModGroup Convert( SelectType type );