@@ -418,29 +418,37 @@ public static void VerifySourcePath()
418
418
// Checks if any dependencies were not marked for download by the user, and marks them accordingly
419
419
public static bool CheckDependencies ( bool alertDepends = true )
420
420
{
421
- List < string > requiredDepends = new List < string > ( ) ;
422
- List < string > persistDepends = new List < string > ( ) ;
423
- List < string > missingDepends = new List < string > ( ) ;
421
+ List < string > requiredDepends = new List < string > ( ) ;
422
+ List < string > persistDepends = new List < string > ( ) ;
423
+ List < TreeNode > missingDepends = new List < TreeNode > ( ) ;
424
+
425
+ void AddDependencies ( string [ ] depends )
426
+ {
427
+ requiredDepends . AddRange ( depends ) ;
428
+
429
+ foreach ( string depend in depends )
430
+ {
431
+ var query = Main . ComponentList . Nodes . Find ( depend , true ) ;
432
+
433
+ if ( query . Length > 0 ) AddDependencies ( ( query [ 0 ] . Tag as Component ) . Depends ) ;
434
+ }
435
+ }
424
436
425
437
// First, fill out a list of dependencies
426
438
IterateList ( Main . ComponentList . Nodes , node =>
427
439
{
428
440
if ( node . Checked && node . Tag . GetType ( ) . ToString ( ) . EndsWith ( "Component" ) )
429
441
{
430
442
var component = node . Tag as Component ;
431
-
432
- if ( ComponentTracker . Downloaded . Exists ( c => c . ID == component . ID ) )
433
- {
434
- requiredDepends . AddRange ( File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) . Skip ( 2 ) . ToArray ( ) ) ;
435
- }
436
- else
437
- {
438
- requiredDepends . AddRange ( component . Depends ) ;
439
- }
443
+
444
+ AddDependencies ( ComponentTracker . Downloaded . Exists ( c => c . ID == component . ID )
445
+ ? File . ReadLines ( component . InfoFile ) . First ( ) . Split ( ' ' ) . Skip ( 2 ) . ToArray ( )
446
+ : component . Depends
447
+ ) ;
440
448
}
441
449
} ) ;
442
450
443
- // Then make sure they're all marked for installation
451
+ // Then make sure they're all marked accordingly
444
452
IterateList ( Main . ComponentList . Nodes , node =>
445
453
{
446
454
if ( node . Tag . GetType ( ) . ToString ( ) . EndsWith ( "Component" ) )
@@ -449,15 +457,13 @@ public static bool CheckDependencies(bool alertDepends = true)
449
457
450
458
if ( requiredDepends . Any ( depend => depend == component . ID ) && ! node . Checked )
451
459
{
452
- node . Checked = true ;
453
-
454
460
if ( ComponentTracker . Downloaded . Exists ( depend => depend . ID == component . ID ) )
455
461
{
456
462
persistDepends . Add ( component . Title ) ;
457
463
}
458
464
else
459
465
{
460
- missingDepends . Add ( component . Title ) ;
466
+ missingDepends . Add ( node ) ;
461
467
}
462
468
}
463
469
}
@@ -477,11 +483,23 @@ public static bool CheckDependencies(bool alertDepends = true)
477
483
478
484
if ( missingDepends . Count > 0 )
479
485
{
480
- MessageBox . Show (
486
+ long missingSize = missingDepends . Select ( n => ( n . Tag as Component ) . Size ) . Sum ( ) ;
487
+
488
+ var result = MessageBox . Show (
481
489
"The following dependencies will also be installed:\n \n " +
482
- string . Join ( ", " , missingDepends ) + "\n \n Click the OK button to proceed." ,
483
- "Notice" , MessageBoxButtons . OK , MessageBoxIcon . Information
490
+ string . Join ( ", " , missingDepends . Select ( n => ( n . Tag as Component ) . Title ) ) + "\n \n " +
491
+ $ "This adds an additional { GetFormattedBytes ( missingSize ) } to your download. Is this OK?",
492
+ "Notice" , MessageBoxButtons . YesNo , MessageBoxIcon . Information
484
493
) ;
494
+
495
+ if ( result == DialogResult . Yes )
496
+ {
497
+ missingDepends . ForEach ( d => d . Checked = true ) ;
498
+ }
499
+ else
500
+ {
501
+ return false ;
502
+ }
485
503
}
486
504
}
487
505
0 commit comments