mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Allow extracting identically named options again.
This commit is contained in:
parent
f0af9f1274
commit
e85d57b094
3 changed files with 31 additions and 8 deletions
|
|
@ -112,6 +112,17 @@ public partial class TexToolsImporter
|
||||||
.Count( o => o.Name.Length > 0 && o.ModsJsons.Length > 0 )
|
.Count( o => o.Name.Length > 0 && o.ModsJsons.Length > 0 )
|
||||||
+ ( group.OptionList.Any( o => o.Name.Length > 0 && o.ModsJsons.Length == 0 ) ? 1 : 0 ) ) );
|
+ ( group.OptionList.Any( o => o.Name.Length > 0 && o.ModsJsons.Length == 0 ) ? 1 : 0 ) ) );
|
||||||
|
|
||||||
|
private static string GetGroupName( string groupName, ISet< string > names )
|
||||||
|
{
|
||||||
|
var baseName = groupName;
|
||||||
|
var i = 2;
|
||||||
|
while( !names.Add( groupName ) )
|
||||||
|
{
|
||||||
|
groupName = $"{baseName} ({i++})";
|
||||||
|
}
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
// Extended V2 mod packs contain multiple options that need to be handled separately.
|
// Extended V2 mod packs contain multiple options that need to be handled separately.
|
||||||
private DirectoryInfo ImportExtendedV2ModPack( ZipFile extractedModPack, string modRaw )
|
private DirectoryInfo ImportExtendedV2ModPack( ZipFile extractedModPack, string modRaw )
|
||||||
{
|
{
|
||||||
|
|
@ -144,14 +155,15 @@ public partial class TexToolsImporter
|
||||||
// Iterate through all pages
|
// Iterate through all pages
|
||||||
var options = new List< ISubMod >();
|
var options = new List< ISubMod >();
|
||||||
var groupPriority = 0;
|
var groupPriority = 0;
|
||||||
|
var groupNames = new HashSet< string >();
|
||||||
foreach( var page in modList.ModPackPages )
|
foreach( var page in modList.ModPackPages )
|
||||||
{
|
{
|
||||||
foreach( var group in page.ModGroups.Where( group => group.GroupName.Length > 0 && group.OptionList.Length > 0 ) )
|
foreach( var group in page.ModGroups.Where( group => group.GroupName.Length > 0 && group.OptionList.Length > 0 ) )
|
||||||
{
|
{
|
||||||
_currentGroupName = group.GroupName;
|
_currentGroupName = GetGroupName( group.GroupName, groupNames );
|
||||||
options.Clear();
|
options.Clear();
|
||||||
var description = new StringBuilder();
|
var description = new StringBuilder();
|
||||||
var groupFolder = Mod.NewSubFolderName( _currentModDirectory, group.GroupName )
|
var groupFolder = Mod.NewSubFolderName( _currentModDirectory, _currentGroupName )
|
||||||
?? new DirectoryInfo( Path.Combine( _currentModDirectory.FullName, $"Group {groupPriority + 1}" ) );
|
?? new DirectoryInfo( Path.Combine( _currentModDirectory.FullName, $"Group {groupPriority + 1}" ) );
|
||||||
|
|
||||||
var optionIdx = 1;
|
var optionIdx = 1;
|
||||||
|
|
@ -186,7 +198,7 @@ public partial class TexToolsImporter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mod.CreateOptionGroup( _currentModDirectory, group, groupPriority, groupPriority, description.ToString(), options );
|
Mod.CreateOptionGroup( _currentModDirectory, group.SelectionType, _currentGroupName, groupPriority, groupPriority, description.ToString(), options );
|
||||||
++groupPriority;
|
++groupPriority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,16 +58,16 @@ public partial class Mod
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a file for an option group from given data.
|
// Create a file for an option group from given data.
|
||||||
internal static void CreateOptionGroup( DirectoryInfo baseFolder, ModGroup groupData,
|
internal static void CreateOptionGroup( DirectoryInfo baseFolder, SelectType type, string name,
|
||||||
int priority, int index, string desc, IEnumerable< ISubMod > subMods )
|
int priority, int index, string desc, IEnumerable< ISubMod > subMods )
|
||||||
{
|
{
|
||||||
switch( groupData.SelectionType )
|
switch( type )
|
||||||
{
|
{
|
||||||
case SelectType.Multi:
|
case SelectType.Multi:
|
||||||
{
|
{
|
||||||
var group = new MultiModGroup()
|
var group = new MultiModGroup()
|
||||||
{
|
{
|
||||||
Name = groupData.GroupName,
|
Name = name,
|
||||||
Description = desc,
|
Description = desc,
|
||||||
Priority = priority,
|
Priority = priority,
|
||||||
};
|
};
|
||||||
|
|
@ -79,7 +79,7 @@ public partial class Mod
|
||||||
{
|
{
|
||||||
var group = new SingleModGroup()
|
var group = new SingleModGroup()
|
||||||
{
|
{
|
||||||
Name = groupData.GroupName,
|
Name = name,
|
||||||
Description = desc,
|
Description = desc,
|
||||||
Priority = priority,
|
Priority = priority,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -105,13 +105,24 @@ public partial class Mod
|
||||||
private void LoadAllGroups()
|
private void LoadAllGroups()
|
||||||
{
|
{
|
||||||
_groups.Clear();
|
_groups.Clear();
|
||||||
|
var changes = false;
|
||||||
foreach( var file in GroupFiles )
|
foreach( var file in GroupFiles )
|
||||||
{
|
{
|
||||||
var group = LoadModGroup( file, ModPath );
|
var group = LoadModGroup( file, ModPath );
|
||||||
if( group != null )
|
if( group != null && _groups.All( g => g.Name != group.Name ) )
|
||||||
{
|
{
|
||||||
|
changes = changes || group.FileName( ModPath, _groups.Count ) != file.FullName;
|
||||||
_groups.Add( group );
|
_groups.Add( group );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( changes )
|
||||||
|
{
|
||||||
|
SaveAllGroups();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue