@@ -1554,42 +1554,58 @@ public async Task WritePmp(string targetPath, bool zip = true, bool saveExtraFil
1554
1554
// their file identifier and internal path information
1555
1555
var identifiers = await FileIdentifier . IdentifierListFromDictionaries ( allFiles ) ;
1556
1556
1557
- bool defaultModOnly = false ;
1557
+ WizardGroupEntry defaultModGroup = null ;
1558
1558
1559
- if ( optionCount = = 1 )
1559
+ if ( optionCount > = 1 )
1560
1560
{
1561
- WizardGroupEntry firstGroup = DataPages . First ( x => x . Groups . Count > 0 ) ? . Groups ? . First ( x => x . Options . Count > 0 ) ;
1562
-
1563
- if ( firstGroup != null && firstGroup . ImcData == null )
1561
+ // Synthesize a PMP default mod from wizard data if an appropriate looking single-option mod group is present.
1562
+ foreach ( var p in DataPages )
1564
1563
{
1565
- var sg = await firstGroup . ToPmpGroup ( tempFolder , identifiers , 0 , true ) ;
1566
- var so = sg . Options [ 0 ] as PmpStandardOptionJson ;
1567
-
1568
- if ( so != null )
1564
+ foreach ( var g in p . Groups )
1569
1565
{
1570
- pmp . DefaultMod . Files = so . Files ;
1571
- pmp . DefaultMod . FileSwaps = so . FileSwaps ;
1572
- pmp . DefaultMod . Manipulations = so . Manipulations ;
1573
- defaultModOnly = true ;
1566
+ if ( g . GroupType == EGroupType . Standard
1567
+ && ( g . Name == "Default" || g . Name == "Default Group" )
1568
+ && g . Options . Count == 1
1569
+ && ( g . Options [ 0 ] . Name == "Default" || g . Options [ 0 ] . Name == "Default Option" ) )
1570
+ {
1571
+ var sg = await g . ToPmpGroup ( tempFolder , identifiers , 0 , true ) ;
1572
+ var so = sg . Options [ 0 ] as PmpStandardOptionJson ;
1573
+
1574
+ if ( so != null )
1575
+ {
1576
+ pmp . DefaultMod . Files = so . Files ;
1577
+ pmp . DefaultMod . FileSwaps = so . FileSwaps ;
1578
+ pmp . DefaultMod . Manipulations = so . Manipulations ;
1579
+ defaultModGroup = g ;
1580
+ break ;
1581
+ }
1582
+ }
1574
1583
}
1584
+
1585
+ if ( defaultModGroup != null )
1586
+ break ;
1575
1587
}
1576
1588
}
1577
1589
1578
- if ( ! defaultModOnly )
1590
+ // This both constructs the JSON structure and writes our files to their
1591
+ // real location in the folder tree in the temp folder.
1592
+ var page = 0 ;
1593
+ foreach ( var p in DataPages )
1579
1594
{
1580
- // This both constructs the JSON structure and writes our files to their
1581
- // real location in the folder tree in the temp folder.
1582
- var page = 0 ;
1583
- foreach ( var p in DataPages )
1595
+ var numGroupsThisPage = 0 ;
1596
+ foreach ( var g in p . Groups )
1584
1597
{
1585
- foreach ( var g in p . Groups )
1586
- {
1587
- var gPrefix = MakeGroupPrefix ( p , g ) ;
1588
- var pg = await g . ToPmpGroup ( tempFolder , identifiers , page ) ;
1589
- pmp . Groups . Add ( pg ) ;
1590
- }
1591
- page ++ ;
1598
+ // Skip the group that was used to generate DefaultMod, if any
1599
+ if ( g == defaultModGroup )
1600
+ continue ;
1601
+
1602
+ var gPrefix = MakeGroupPrefix ( p , g ) ;
1603
+ var pg = await g . ToPmpGroup ( tempFolder , identifiers , page ) ;
1604
+ pmp . Groups . Add ( pg ) ;
1605
+ ++ numGroupsThisPage ;
1592
1606
}
1607
+ if ( numGroupsThisPage > 0 )
1608
+ page ++ ;
1593
1609
}
1594
1610
1595
1611
0 commit comments