@@ -418,29 +418,37 @@ public static void VerifySourcePath()
418418 // Checks if any dependencies were not marked for download by the user, and marks them accordingly
419419 public static bool CheckDependencies ( bool alertDepends = true )
420420 {
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+ }
424436
425437 // First, fill out a list of dependencies
426438 IterateList ( Main . ComponentList . Nodes , node =>
427439 {
428440 if ( node . Checked && node . Tag . GetType ( ) . ToString ( ) . EndsWith ( "Component" ) )
429441 {
430442 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+ ) ;
440448 }
441449 } ) ;
442450
443- // Then make sure they're all marked for installation
451+ // Then make sure they're all marked accordingly
444452 IterateList ( Main . ComponentList . Nodes , node =>
445453 {
446454 if ( node . Tag . GetType ( ) . ToString ( ) . EndsWith ( "Component" ) )
@@ -449,15 +457,13 @@ public static bool CheckDependencies(bool alertDepends = true)
449457
450458 if ( requiredDepends . Any ( depend => depend == component . ID ) && ! node . Checked )
451459 {
452- node . Checked = true ;
453-
454460 if ( ComponentTracker . Downloaded . Exists ( depend => depend . ID == component . ID ) )
455461 {
456462 persistDepends . Add ( component . Title ) ;
457463 }
458464 else
459465 {
460- missingDepends . Add ( component . Title ) ;
466+ missingDepends . Add ( node ) ;
461467 }
462468 }
463469 }
@@ -477,11 +483,23 @@ public static bool CheckDependencies(bool alertDepends = true)
477483
478484 if ( missingDepends . Count > 0 )
479485 {
480- MessageBox . Show (
486+ long missingSize = missingDepends . Select ( n => ( n . Tag as Component ) . Size ) . Sum ( ) ;
487+
488+ var result = MessageBox . Show (
481489 "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
484493 ) ;
494+
495+ if ( result == DialogResult . Yes )
496+ {
497+ missingDepends . ForEach ( d => d . Checked = true ) ;
498+ }
499+ else
500+ {
501+ return false ;
502+ }
485503 }
486504 }
487505
0 commit comments