2020
2121namespace Spore_ModAPI_Easy_Installer
2222{
23- static class EasyInstaller
23+ public static class EasyInstaller
2424 {
2525 enum FileChooserType
2626 {
@@ -38,15 +38,16 @@ enum FileType
3838 Spore_Package // a .package that goes to the Spore data folder instead of the EP1 one
3939 }
4040
41- enum ResultType
41+ public enum ResultType
4242 {
4343 Success ,
4444 InstallerExecuted , // we have found a custom installer, close Easy installer and execute that one
4545 UnsupportedFile ,
4646 GalacticAdventuresNotFound ,
4747 UnauthorizedAccess ,
4848 InvalidPath ,
49- ModNotInstalled
49+ ModNotInstalled ,
50+ NoInstallerFound
5051 }
5152 //// Show a file chooser and returns the path selected. It can ask for files or directories.
5253 //static string ShowFileChooser(FileChooserType type, string title, string filter);
@@ -140,7 +141,6 @@ static void Main()
140141 catch ( Exception ex )
141142 {
142143 errorStrings [ i ] = ex . Message ; results . Add ( ResultType . UnsupportedFile ) ;
143- MessageBox . Show ( ex . ToString ( ) + "\n " + ex . StackTrace , "AAA" ) ;
144144 }
145145 }
146146 for ( int i = 0 ; i < results . Count ; i ++ ) //foreach (ResultType type in results)
@@ -149,7 +149,9 @@ static void Main()
149149 ResultType type = results [ i ] ;
150150 outcome += GetResultText ( type , Path . GetFileNameWithoutExtension ( inputPaths [ i ] ) , errorStrings [ i ] ) + "\n " ;
151151 }
152- WaitForExit ( ) ;
152+
153+ ModList . Save ( ) ;
154+ ShowExitMessageBox ( ) ;
153155 }
154156 }
155157 }
@@ -467,9 +469,6 @@ private static ResultType ExtractSporemodZip(string inputFile, ModConfiguration
467469 return ResultType . Success ;
468470 }
469471
470- [ DllImport ( "user32.dll" , ExactSpelling = true ) ]
471- static extern bool IsWindow ( IntPtr hWnd ) ;
472-
473472 private static bool CheckModCoreDllsVersion ( ZipArchiveEntry xmlEntry )
474473 {
475474 try
@@ -524,9 +523,9 @@ static ResultType TryExecuteInstaller(string inputFile, string modName)
524523 win . SignalRevealInstaller ( ) ;
525524
526525 installerThread . Join ( ) ;
527-
526+
528527 if ( ! XmlInstallerCancellation . Cancellation [ modName . Trim ( '"' ) ] )
529- return ResultType . InstallerExecuted ;
528+ return win . GetResult ( ) ;
530529 else
531530 return ResultType . ModNotInstalled ;
532531 }
@@ -536,7 +535,7 @@ static ResultType TryExecuteInstaller(string inputFile, string modName)
536535 }
537536 else
538537 {
539- return ResultType . Success ;
538+ return ResultType . NoInstallerFound ;
540539 }
541540 }
542541 }
@@ -580,12 +579,7 @@ static ResultType InstallSporemod(string inputFile, string modName)
580579 {
581580 var result = TryExecuteInstaller ( inputFile , modName ) ;
582581
583- if ( ( result == ResultType . InstallerExecuted ) || ( result == ResultType . ModNotInstalled ) )
584- {
585- // the custom installer executed, we don't need to do anything else
586- return ResultType . InstallerExecuted ;
587- }
588- else if ( result == ResultType . Success )
582+ if ( result == ResultType . NoInstallerFound )
589583 {
590584 // the custom installer just didn't exist, extract as ZIP file
591585
@@ -728,8 +722,6 @@ static string GetResultText(ResultType result, string modName, string errorStrin
728722 // show message to the user
729723 return Strings . ModInstalled1 + modName + Strings . ModInstalled2 ;
730724 }
731- else if ( result == ResultType . InstallerExecuted )
732- return string . Empty ;
733725 else if ( result == ResultType . ModNotInstalled )
734726 {
735727 return Strings . ModInstalled1 + modName + Strings . InstallationCancelled ;
@@ -746,25 +738,6 @@ static string GetResultText(ResultType result, string modName, string errorStrin
746738 }
747739 }
748740
749- static void WaitForExit ( )
750- {
751- int counter = 0 ;
752- System . Timers . Timer timer = new System . Timers . Timer ( 10 ) ;
753- timer . Elapsed += ( sneder , args ) =>
754- {
755- if ( ( counter > 5 ) && ( XmlInstallerWindow . installerWindows . Count == 0 ) )
756- {
757- timer . Stop ( ) ;
758- ModList . Save ( ) ;
759- ShowExitMessageBox ( ) ;
760- }
761- else
762- counter ++ ;
763- } ;
764- timer . Start ( ) ;
765- Application . Run ( ) ;
766- }
767-
768741 static void ShowExitMessageBox ( )
769742 {
770743 Thread thread = new Thread ( ( ) =>
0 commit comments