mod reordering, deleting, conflict resolution, some other fixes

This commit is contained in:
Adam 2020-12-25 22:50:31 +11:00
parent fbb39a8626
commit 7f1fd95a78
10 changed files with 605 additions and 203 deletions

View file

@ -0,0 +1,54 @@
using System.Collections.Generic;
using System.IO;
using Dalamud.Plugin;
using Penumbra.Models;
namespace Penumbra.Mods
{
public class ResourceMod
{
public ModMeta Meta { get; set; }
public DirectoryInfo ModBasePath { get; set; }
public List< FileInfo > ModFiles { get; } = new();
public Dictionary< string, List< string > > FileConflicts { get; set; } = new();
public void RefreshModFiles()
{
if( ModBasePath == null )
{
PluginLog.LogError( "no basepath has been set on {ResourceModName}", Meta.Name );
return;
}
// we don't care about any _files_ in the root dir, but any folders should be a game folder/file combo
foreach( var dir in ModBasePath.EnumerateDirectories() )
{
foreach( var file in dir.EnumerateFiles( "*.*", SearchOption.AllDirectories ) )
{
ModFiles.Add( file );
}
}
}
public void AddConflict( string modName, string path )
{
if( FileConflicts.TryGetValue( modName, out var arr ) )
{
if( !arr.Contains( path ) )
{
arr.Add( path );
}
return;
}
FileConflicts[ modName ] = new List< string >
{
path
};
}
}
}