Add empty option for single select groups with empty options. More Editor stuff.

This commit is contained in:
Ottermandias 2022-05-01 18:06:21 +02:00
parent 81e93e0664
commit e2a6274b33
21 changed files with 937 additions and 336 deletions

View file

@ -109,7 +109,8 @@ public partial class TexToolsImporter
.Sum( page => page.ModGroups
.Where( g => g.GroupName.Length > 0 && g.OptionList.Length > 0 )
.Sum( group => group.OptionList
.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 ) ) );
// Extended V2 mod packs contain multiple options that need to be handled separately.
private DirectoryInfo ImportExtendedV2ModPack( ZipFile extractedModPack, string modRaw )
@ -173,6 +174,18 @@ public partial class TexToolsImporter
++_currentOptionIdx;
}
// Handle empty options for single select groups without creating a folder for them.
// We only want one of those at most, and it should usually be the first option.
if( group.SelectionType == SelectType.Single )
{
var empty = group.OptionList.FirstOrDefault( o => o.Name.Length > 0 && o.ModsJsons.Length == 0 );
if( empty != null )
{
_currentOptionName = empty.Name;
options.Insert( 0, Mod.CreateEmptySubMod( empty.Name ) );
}
}
Mod.CreateOptionGroup( _currentModDirectory, group, groupPriority, groupPriority, description.ToString(), options );
++groupPriority;
}