Skip to content

Commit 110230e

Browse files
Be brave and synthesize PMP default mod data even for multi-group mods
1 parent fac6cba commit 110230e

File tree

1 file changed

+41
-25
lines changed

1 file changed

+41
-25
lines changed

xivModdingFramework/Mods/WizardData.cs

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,42 +1554,58 @@ public async Task WritePmp(string targetPath, bool zip = true, bool saveExtraFil
15541554
// their file identifier and internal path information
15551555
var identifiers = await FileIdentifier.IdentifierListFromDictionaries(allFiles);
15561556

1557-
bool defaultModOnly = false;
1557+
WizardGroupEntry defaultModGroup = null;
15581558

1559-
if (optionCount == 1)
1559+
if (optionCount >= 1)
15601560
{
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)
15641563
{
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)
15691565
{
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+
}
15741583
}
1584+
1585+
if (defaultModGroup != null)
1586+
break;
15751587
}
15761588
}
15771589

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)
15791594
{
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)
15841597
{
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;
15921606
}
1607+
if (numGroupsThisPage > 0)
1608+
page++;
15931609
}
15941610

15951611

0 commit comments

Comments
 (0)