Add unsolved conflicts to both mods, add button to auto-generate groups based on folders, misc. fixes.

This commit is contained in:
Ottermandias 2021-10-18 16:12:32 +02:00
parent 795d605d3f
commit 4a82e6faf1
7 changed files with 102 additions and 12 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
@ -478,5 +479,46 @@ namespace Penumbra.Mod
RemoveUselessGroups( meta );
ClearEmptySubDirectories( baseDir );
}
public static void AutoGenerateGroups( DirectoryInfo baseDir, ModMeta meta )
{
meta.Groups.Clear();
ClearEmptySubDirectories( baseDir );
foreach( var groupDir in baseDir.EnumerateDirectories() )
{
var group = new OptionGroup
{
GroupName = groupDir.Name,
SelectionType = SelectType.Single,
Options = new List< Option >(),
};
foreach( var optionDir in groupDir.EnumerateDirectories() )
{
var option = new Option
{
OptionDesc = string.Empty,
OptionName = optionDir.Name,
OptionFiles = new Dictionary< RelPath, HashSet< GamePath > >(),
};
foreach( var file in optionDir.EnumerateFiles( "*.*", SearchOption.AllDirectories ) )
{
var relPath = new RelPath( file, baseDir );
var gamePath = new GamePath( file, optionDir );
option.OptionFiles[ relPath ] = new HashSet< GamePath > { gamePath };
}
if( option.OptionFiles.Any() )
{
group.Options.Add( option );
}
}
if( group.Options.Any() )
{
meta.Groups.Add( groupDir.Name, @group );
}
}
}
}
}