@@ -35,13 +35,7 @@ public Component(XmlNode node) : base(node)
3535 }
3636 else
3737 {
38- MessageBox . Show (
39- "An error occurred while parsing the component list XML. Please alert Flashpoint staff ASAP!\n \n " +
40- "Description: Root element does not contain URL attribute" ,
41- "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
42- ) ;
43-
44- Environment . Exit ( 1 ) ;
38+ FPM . ParseError ( "Root element does not contain URL attribute." ) ;
4539 }
4640
4741 // Hash
@@ -54,13 +48,7 @@ public Component(XmlNode node) : base(node)
5448 }
5549 else
5650 {
57- MessageBox . Show (
58- "An error occurred while parsing the component list XML. Please alert Flashpoint staff ASAP!\n \n " +
59- $ "Description: Hash of component \" { Title } \" is invalid",
60- "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
61- ) ;
62-
63- Environment . Exit ( 1 ) ;
51+ FPM . ParseError ( $ "Hash of component \" { Title } \" is invalid.") ;
6452 }
6553
6654 // Size
@@ -70,13 +58,7 @@ public Component(XmlNode node) : base(node)
7058
7159 if ( stringSize != "" && ! long . TryParse ( stringSize , out size ) )
7260 {
73- MessageBox . Show (
74- "An error occurred while parsing the component list XML. Please alert Flashpoint staff ASAP!\n \n " +
75- $ "Description: Size of component \" { Title } \" is not a number",
76- "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
77- ) ;
78-
79- Environment . Exit ( 1 ) ;
61+ FPM . ParseError ( $ "Size of component \" { Title } \" is not a number.") ;
8062 }
8163
8264 Size = size ;
@@ -93,13 +75,7 @@ public Component(XmlNode node) : base(node)
9375 }
9476 else
9577 {
96- MessageBox . Show (
97- "An error occurred while parsing the component list XML. Please alert Flashpoint staff ASAP!\n \n " +
98- $ "Description: Modified date of component \" { Title } \" is invalid",
99- "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
100- ) ;
101-
102- Environment . Exit ( 1 ) ;
78+ FPM . ParseError ( $ "Date modified of component \" { Title } \" is invalid.") ;
10379 }
10480
10581 // Path
@@ -156,13 +132,7 @@ protected static string GetAttribute(XmlNode node, string attribute, bool throwE
156132 }
157133 else if ( throwError )
158134 {
159- MessageBox . Show (
160- "An error occurred while parsing the component list XML. Please alert Flashpoint staff ASAP!\n \n " +
161- $ "Description: Required { node . Name } attribute \" { attribute } \" was not found",
162- "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
163- ) ;
164-
165- Environment . Exit ( 1 ) ;
135+ FPM . ParseError ( $ "Required { node . Name } attribute \" { attribute } \" was not found") ;
166136 }
167137
168138 return "" ;
@@ -193,6 +163,8 @@ public static class RepoXmlTemplates
193163 // 1 = Reinstall outdated components
194164 // 2 = Reinstall broken components
195165 public static int OperateMode { get ; set ; } = 0 ;
166+ // Controls whether to apply accommodations for offline use
167+ public static bool OfflineMode { get ; set ; } = false ;
196168 // Controls whether the update tab is selected at launch
197169 public static bool OpenUpdateTab { get ; set ; } = false ;
198170 // Controls whether the launcher should be opened upon the manager closing
@@ -300,14 +272,16 @@ public static void SyncManager(bool init = false)
300272 ComponentTracker . Downloaded . Add ( component ) ;
301273 if ( ! node . Checked ) node . Checked = true ;
302274 }
303- else if ( node . Checked )
275+ else
304276 {
305- node . Checked = false ;
277+ if ( OfflineMode ) node . ForeColor = Color . FromArgb ( 255 , 96 , 96 , 96 ) ;
278+ if ( node . Checked ) node . Checked = false ;
306279 }
307280 }
308- else if ( init )
281+ else
309282 {
310- node . Checked = node . Checked ;
283+ if ( OfflineMode ) node . ForeColor = Color . FromArgb ( 255 , 96 , 96 , 96 ) ;
284+ if ( init ) node . Checked = node . Checked ;
311285 }
312286 } ) ;
313287
@@ -459,10 +433,9 @@ public static void DeleteFileAndDirectories(string file)
459433 }
460434 catch ( Exception e ) when ( ! ( e is DirectoryNotFoundException ) )
461435 {
462- MessageBox . Show (
436+ GenericError (
463437 "Failed to delete the following file:\n " + file + "\n \n " +
464- "Make sure it is not open or being used by another program." ,
465- "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
438+ "Make sure it is not open or being used by another program."
466439 ) ;
467440
468441 return ;
@@ -509,10 +482,9 @@ public static bool WriteConfig(string path, string source)
509482 }
510483 catch
511484 {
512- MessageBox . Show (
485+ GenericError (
513486 "Could not write to configuration file (fpm.cfg)." +
514- "Make sure it is not being used by another program." ,
515- "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
487+ "Make sure it is not being used by another program."
516488 ) ;
517489
518490 return false ;
@@ -579,9 +551,9 @@ void AddDependencies(string[] depends)
579551 {
580552 if ( alertDepends )
581553 {
582- MessageBox . Show (
554+ GenericError (
583555 "The following components cannot be removed because one or more components depend on them:\n \n " +
584- string . Join ( ", " , persistDepends ) , "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
556+ string . Join ( ", " , persistDepends )
585557 ) ;
586558 }
587559
@@ -630,6 +602,22 @@ public static string GetFormattedBytes(long bytes)
630602
631603 return "0 bytes" ;
632604 }
605+
606+ // Function for errors unrelated to the component list
607+ public static void GenericError ( string message ) => MessageBox . Show (
608+ message , "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
609+ ) ;
610+
611+ // Function for errors related to the component list
612+ public static void ParseError ( string message )
613+ {
614+ MessageBox . Show (
615+ $ "The following error occurred while parsing the component list:\n \n { message } ",
616+ "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error
617+ ) ;
618+
619+ Environment . Exit ( 1 ) ;
620+ }
633621 }
634622 }
635623}
0 commit comments