7
7
using System . Text . RegularExpressions ;
8
8
using System . Threading . Tasks ;
9
9
using xivModdingFramework . Cache ;
10
+ using xivModdingFramework . General . Enums ;
10
11
using xivModdingFramework . Helpers ;
11
12
using xivModdingFramework . Items . Enums ;
12
13
using xivModdingFramework . Materials . FileTypes ;
@@ -30,7 +31,7 @@ public static class RootCloner
30
31
/// <param name="Destination">Destination root to copy to.</param>
31
32
/// <param name="ApplicationSource">Application to list as the source for the resulting mod entries.</param>
32
33
/// <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 )
34
35
{
35
36
36
37
if ( ProgressReporter != null )
@@ -408,8 +409,8 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
408
409
modlist = await _modding . GetModListAsync ( ) ;
409
410
410
411
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 > ( ) ;
413
414
foreach ( var mod in modlist . Mods )
414
415
{
415
416
if ( allFiles . Contains ( mod . fullPath ) )
@@ -419,6 +420,8 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
419
420
mod . category = iCat ;
420
421
mod . source = ApplicationSource ;
421
422
mod . modPack = modPack ;
423
+
424
+ mods . Add ( mod ) ;
422
425
}
423
426
}
424
427
@@ -427,6 +430,43 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
427
430
428
431
_modding . SaveModList ( modlist ) ;
429
432
433
+ if ( saveDirectory != null )
434
+ {
435
+
436
+ ProgressReporter . Report ( "Creating TTMP File..." ) ;
437
+ var desc = "Item Converter Modpack - " + srcItem . Name + " -> " + iName + "\n Created 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
+
430
470
if ( ProgressReporter != null )
431
471
{
432
472
ProgressReporter . Report ( "Root copy complete." ) ;
0 commit comments