Skip to content

Commit 04ad415

Browse files
committed
Add ability to automatically generate TTMP files from item conversions.
1 parent 02fd894 commit 04ad415

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

xivModdingFramework/Mods/RootCloner.cs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Text.RegularExpressions;
88
using System.Threading.Tasks;
99
using xivModdingFramework.Cache;
10+
using xivModdingFramework.General.Enums;
1011
using xivModdingFramework.Helpers;
1112
using xivModdingFramework.Items.Enums;
1213
using xivModdingFramework.Materials.FileTypes;
@@ -30,7 +31,7 @@ public static class RootCloner
3031
/// <param name="Destination">Destination root to copy to.</param>
3132
/// <param name="ApplicationSource">Application to list as the source for the resulting mod entries.</param>
3233
/// <returns></returns>
33-
public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot Destination, string ApplicationSource, int singleVariant = -1, IProgress<string> ProgressReporter = null)
34+
public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot Destination, string ApplicationSource, int singleVariant = -1, string saveDirectory = null, IProgress<string> ProgressReporter = null)
3435
{
3536

3637
if (ProgressReporter != null)
@@ -408,8 +409,8 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
408409
modlist = await _modding.GetModListAsync();
409410

410411

411-
412-
var modPack = new ModPack() { author = "System", name = "Item Copy - " + srcItem.Name + " -> " + iName, url = "", version = "1.0" };
412+
var modPack = new ModPack() { author = "System", name = "Item Copy - " + srcItem.Name + " to " + iName, url = "", version = "1.0" };
413+
List<Mod> mods = new List<Mod>();
413414
foreach (var mod in modlist.Mods)
414415
{
415416
if (allFiles.Contains(mod.fullPath))
@@ -419,6 +420,8 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
419420
mod.category = iCat;
420421
mod.source = ApplicationSource;
421422
mod.modPack = modPack;
423+
424+
mods.Add(mod);
422425
}
423426
}
424427

@@ -427,6 +430,43 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
427430

428431
_modding.SaveModList(modlist);
429432

433+
if(saveDirectory != null)
434+
{
435+
436+
ProgressReporter.Report("Creating TTMP File...");
437+
var desc = "Item Converter Modpack - " + srcItem.Name + " -> " + iName + "\nCreated at: " + DateTime.Now.ToString();
438+
// Time to save the modlist to file.
439+
var dir = new DirectoryInfo(saveDirectory);
440+
var _ttmp = new TTMP(dir, ApplicationSource);
441+
var smpd = new SimpleModPackData()
442+
{
443+
Author = modPack.author,
444+
Description = desc,
445+
Url = modPack.url,
446+
Version = new Version(1, 0, 0),
447+
Name = modPack.name,
448+
SimpleModDataList = new List<SimpleModData>()
449+
};
450+
451+
foreach(var mod in mods)
452+
{
453+
var size = await _dat.GetCompressedFileSize(mod.data.modOffset, df);
454+
var smd = new SimpleModData()
455+
{
456+
Name = iName,
457+
FullPath = mod.fullPath,
458+
DatFile = df.GetDataFileName(),
459+
Category = iCat,
460+
IsDefault = false,
461+
ModSize = size,
462+
ModOffset = mod.data.modOffset
463+
};
464+
smpd.SimpleModDataList.Add(smd);
465+
}
466+
467+
await _ttmp.CreateSimpleModPack(smpd, XivCache.GameInfo.GameDirectory, null, true);
468+
}
469+
430470
if (ProgressReporter != null)
431471
{
432472
ProgressReporter.Report("Root copy complete.");

0 commit comments

Comments
 (0)