@@ -29,7 +29,7 @@ public static class RootCloner
29
29
/// <param name="Destination">Destination root to copy to.</param>
30
30
/// <param name="ApplicationSource">Application to list as the source for the resulting mod entries.</param>
31
31
/// <returns></returns>
32
- public static async Task CloneRoot ( XivDependencyRoot Source , XivDependencyRoot Destination , string ApplicationSource , IProgress < string > ProgressReporter = null )
32
+ public static async Task CloneRoot ( XivDependencyRoot Source , XivDependencyRoot Destination , string ApplicationSource , int singleVariant = - 1 , IProgress < string > ProgressReporter = null )
33
33
{
34
34
35
35
if ( ProgressReporter != null )
@@ -40,7 +40,6 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
40
40
XivCache . CacheWorkerEnabled = false ;
41
41
try
42
42
{
43
-
44
43
var df = IOUtil . GetDataFileFromPath ( Source . ToString ( ) ) ;
45
44
46
45
var _imc = new Imc ( XivCache . GameInfo . GameDirectory ) ;
@@ -51,7 +50,11 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
51
50
var _modding = new Modding ( XivCache . GameInfo . GameDirectory ) ;
52
51
53
52
54
-
53
+ bool locked = _index . IsIndexLocked ( df ) ;
54
+ if ( locked )
55
+ {
56
+ throw new Exception ( "Game files currently in use." ) ;
57
+ }
55
58
56
59
57
60
if ( ProgressReporter != null )
@@ -79,10 +82,6 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
79
82
}
80
83
}
81
84
82
-
83
-
84
-
85
-
86
85
// Time to start editing things.
87
86
88
87
// First, get a new, clean copy of the metadata, pointed at the new root.
@@ -133,6 +132,7 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
133
132
}
134
133
135
134
var destItem = Destination . GetFirstItem ( ) ;
135
+ var srcItem = ( await Source . GetAllItems ( singleVariant ) ) [ 0 ] ;
136
136
var iCat = destItem . SecondaryCategory ;
137
137
var iName = destItem . Name ;
138
138
@@ -263,6 +263,32 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
263
263
newMetadata . ImcEntries . Add ( ( XivImc ) newMetadata . ImcEntries [ cloneNum ] . Clone ( ) ) ;
264
264
}
265
265
266
+
267
+ if ( singleVariant >= 0 )
268
+ {
269
+ if ( ProgressReporter != null )
270
+ {
271
+ ProgressReporter . Report ( "Setting single-variant data..." ) ;
272
+ }
273
+
274
+ if ( singleVariant < newMetadata . ImcEntries . Count )
275
+ {
276
+ var v = newMetadata . ImcEntries [ singleVariant ] ;
277
+
278
+ for ( int i = 0 ; i < newMetadata . ImcEntries . Count ; i ++ )
279
+ {
280
+ newMetadata . ImcEntries [ i ] = ( XivImc ) v . Clone ( ) ;
281
+ }
282
+ }
283
+ }
284
+
285
+ // Update Skeleton references to be for the correct set Id.
286
+ var setId = Destination . Info . SecondaryId == null ? ( ushort ) Destination . Info . PrimaryId : ( ushort ) Destination . Info . SecondaryId ;
287
+ foreach ( var entry in newMetadata . EstEntries )
288
+ {
289
+ entry . Value . SetId = setId ;
290
+ }
291
+
266
292
if ( ProgressReporter != null )
267
293
{
268
294
ProgressReporter . Report ( "Copying metdata..." ) ;
@@ -334,7 +360,7 @@ public static async Task CloneRoot(XivDependencyRoot Source, XivDependencyRoot D
334
360
}
335
361
336
362
337
- var modPack = new ModPack ( ) { author = "System" , name = "Item Copy - " + iName , url = "" , version = "1.0" } ;
363
+ var modPack = new ModPack ( ) { author = "System" , name = "Item Copy - " + srcItem . Name , url = "" , version = "1.0" } ;
338
364
foreach ( var mod in modlist . Mods )
339
365
{
340
366
if ( allFiles . Contains ( mod . fullPath ) )
0 commit comments