Index: AE/Installer/trunk/source/main_window.cpp
===================================================================
--- AE/Installer/trunk/source/main_window.cpp	(revision 356)
+++ AE/Installer/trunk/source/main_window.cpp	(revision 357)
@@ -35,5 +35,5 @@
 const bool NOT_SPLIT = 0;
 bool splitInstances = SPLIT;
-
+bool busy = 0;
 #ifdef WIN32
 const string strOniSplit = "Onisplit.exe";
@@ -61,7 +61,8 @@
 int globalizeData(void)
 {
-	    using boost::lexical_cast;
-    using boost::bad_lexical_cast;
-// using namespace boost::posix_time;
+	busy = 1;
+	using boost::lexical_cast;
+	using boost::bad_lexical_cast;
+	// using namespace boost::posix_time;
 	using namespace boost::gregorian;
 	using namespace boost::posix_time;
@@ -77,5 +78,5 @@
 	logfile << "Globalization started " << to_simple_string(start_time) << endl;
 	try {
-		
+
 		char levels_cstr[15][3] = {"0", "1", "2", "3", "4", "6", "8", "9", "10", "11", "12", "13", "14", "18", "19"}; // the levels Oni has...probably should have made a string array. Oops.
 		//const vector<double> ck(cv, &cv[CvSize]);
@@ -96,5 +97,5 @@
 		path TRAC = Animations / "level0_TRAC";
 		path TRAM = Animations / "level0_TRAM";
-		
+
 		vector<path> GDFPaths;
 		GDFPaths.push_back(Characters);
@@ -104,6 +105,6 @@
 		GDFPaths.push_back(TRAC);
 		GDFPaths.push_back(TRAM);
-		
-			
+
+
 		path VanillaCharacters = "packages/VanillaDats/level0_Final/level0_Characters/level0_Characters.oni";
 		path VanillaParticles = "packages/VanillaDats/level0_Final/level0_Particles/level0_Particles.oni";
@@ -115,5 +116,5 @@
 
 		vector<path> VanillaPaths;
-		
+
 		VanillaPaths.push_back(VanillaCharacters);
 		VanillaPaths.push_back(VanillaParticles);
@@ -122,5 +123,5 @@
 		VanillaPaths.push_back(VanillaTRAC);
 		VanillaPaths.push_back(VanillaTRAM);
-		
+
 		/*
 		if (exists("../GameDataFolder/"))
@@ -143,10 +144,10 @@
 		logfile <<  "Creating needed directories...\n";
 		create_directory( "../GameDataFolder/" );
-		
+
 		create_directory( "packages" );
-		
+
 		if (exists("packages/VanillaDats")) remove_all("packages/VanillaDats"); 
 		create_directory( "packages/VanillaDats" );
-		
+
 		create_directory( "packages/VanillaDats/level0_Final/" );
 		//blah blah finish this.
@@ -163,5 +164,5 @@
 		for(int i = 1; i < 15; i++)
 		{
-				if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) {
+			if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) {
 				num_levels++;
 
@@ -172,7 +173,7 @@
 		for(int i = 0; i < 15; i++)
 		{
-			
+
 			//printf(levels[i],"%d",levels[i]); // int to char array
-			
+
 			if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) {
 				logfile << "level" << levels[i] << "_Final\n";
@@ -181,5 +182,5 @@
 				setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " exporting level" + levels[i]+"_Final.dat");
 				create_directory( "../GameDataFolder/level" + levels[i] + "_Final" ); 
-//				setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat");
+				//				setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat");
 				system((strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat").c_str());
 				create_directory( "packages/VanillaDats/level" + levels[i] + "_Final" ); 
@@ -257,5 +258,5 @@
 							|| dir_itr->path().filename().substr(0,4) == "TRCM") {
 								cout <<dir_itr->path().filename() << "\n";
-					
+
 								if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename());
 								else remove(dir_itr->path());
@@ -270,5 +271,5 @@
 
 
-						
+
 				}
 				logfile << "\tCleaning up TXMPs...\n";
@@ -277,5 +278,5 @@
 
 				setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); 
-				
+
 			}
 		}
@@ -290,5 +291,5 @@
 				+ levels[i] + "_Final/level" + levels[i] + "_Final.oni > Globalize.oni").c_str());
 			setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
-				parts_done++;
+			parts_done++;
 		}
 		create_directory( VanillaCharacters.parent_path() );
@@ -297,5 +298,5 @@
 		create_directory( VanillaSounds.parent_path() );
 		create_directory( VanillaAnimations.remove_filename() );
-		
+
 		for(int j = 0; j < GDFPaths.size(); j++) {
 			logfile << "\tReimporting " << GDFPaths[j].filename() << ".oni\n";
@@ -305,5 +306,5 @@
 			setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); 
 		}
-/*
+		/*
 		printf(Step_x_x,"Step %d/%d: reimporting level0_Characters", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); 
 		system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str());
@@ -321,22 +322,22 @@
 		//parts_done++; setStatusArea((string)"Copying level scripts...");setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); 
 		if (exists("../GameDataFolder/IGMD")) remove_all("../GameDataFolder/IGMD");
-*/
+		*/
 		create_directory((path)"../GameDataFolder/IGMD");
 		copy((path)"packages/VanillaBSL/", (path)"../GameDataFolder");
 		setProgressBar( 1000 ); 
 		setStatusArea((string)"Done! Now select your mod packages and click install.");
-	//	while(1) Sleep(-1);
-		
+		//	while(1) Sleep(-1);
+
 	}
 	catch (exception ex) {
 		setStatusArea("Warning, handled exception: " + (string)ex.what());
 	}
-	
-		ptime end_time(second_clock::local_time());
-		time_period total_time (start_time, end_time);
-		logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
-		//total_time.length().hours();
+
+	ptime end_time(second_clock::local_time());
+	time_period total_time (start_time, end_time);
+	logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
+	//total_time.length().hours();
 	logfile.close();
-
+	busy = 0;
 	return err;
 }
@@ -491,6 +492,9 @@
 void recompileAll(vector<string> installedMods)
 {
+	busy = 1;
 	using namespace boost::gregorian;
 	using namespace boost::posix_time;
+	using boost::lexical_cast;
+	using boost::bad_lexical_cast;
 	
 	setStatusArea("Importing levels...");
@@ -551,7 +555,7 @@
 						importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
 
-						printf(statusString,"%d/%i\0",j,numberOfDats);	
+						
 						setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
-						setStatusArea("Importing " +  dir_itr->path().filename() + " " + statusString);
+						setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " +  dir_itr->path().filename() + " ");
 
 						system(importCommand.c_str());
@@ -564,12 +568,12 @@
 				catch ( const std::exception & ex )
 				{
-					
-	remove("Install.log");
-	ofstream logfile("Install.log");
-	
-	
+
+					remove("Install.log");
+					ofstream logfile("Install.log");
+
+
 					logfile << "Warning, exception " << ex.what() << "!";
 					setStatusArea("Warning, exception " + (string)ex.what() + "!");
-logfile.close();	
+					logfile.close();	
 				}
 			}
@@ -577,12 +581,12 @@
 		}
 		catch( const std::exception & ex ) {
-	
-	remove("Install.log");
-	ofstream logfile("Install.log");
-	
-	
-					logfile << "Warning, exception " << ex.what() << "!";
-					setStatusArea("Warning, exception " + (string)ex.what() + "!");
-logfile.close();
+
+			remove("Install.log");
+			ofstream logfile("Install.log");
+
+
+			logfile << "Warning, exception " << ex.what() << "!";
+			setStatusArea("Warning, exception " + (string)ex.what() + "!");
+			logfile.close();
 		}
 
@@ -623,7 +627,7 @@
 					importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
 
-					printf(statusString,"%d/%i\0",j,numberOfDats);	
+
 					setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
-					setStatusArea("Importing " +  dir_itr->path().filename() + " " + statusString);
+					setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " +  dir_itr->path().filename() + " ");
 
 					system(importCommand.c_str());
@@ -634,12 +638,12 @@
 			catch ( const std::exception & ex )
 			{
-	
-	remove("Install.log");
-	ofstream logfile("Install.log");
-	
-	
-					logfile << "Warning, exception " << ex.what() << "!";
-					setStatusArea("Warning, exception " + (string)ex.what() + "!");
-logfile.close();
+
+				remove("Install.log");
+				ofstream logfile("Install.log");
+
+
+				logfile << "Warning, exception " << ex.what() << "!";
+				setStatusArea("Warning, exception " + (string)ex.what() + "!");
+				logfile.close();
 			}}
 	}
@@ -648,21 +652,22 @@
 	setProgressBar(1000);
 	setStatusArea("Done! You can now play Oni.");
-	
-		ptime end_time(second_clock::local_time());
-		time_period total_time (start_time, end_time);
-			
-	
-		ofstream logfile2("Install.log", ios::app | ios::ate);
-		string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length();
-		
-		logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
-		
-		//logfile2.write(outstring.c_str(), outstring.length());
-logfile2.close();
-
-		//total_time.length().hours();
-	
+
+	ptime end_time(second_clock::local_time());
+	time_period total_time (start_time, end_time);
+
+
+	ofstream logfile2("Install.log", ios::app | ios::ate);
+	string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length();
+
+	logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
+
+	//logfile2.write(outstring.c_str(), outstring.length());
+	logfile2.close();
+
+	//total_time.length().hours();
+
 	Sleep(1000);
 	setProgressBar(0);
+	busy = 0;
 }
 
@@ -869,6 +874,6 @@
 	SetIcon(GetIconResource(wxT("oni_special.ico")));
 	Centre();
-	
-	
+
+
 	////@end MainWindow creation
 	return true;
@@ -958,5 +963,5 @@
 	menuBar->Append(itemMenu44, _("Help"));
 	itemFrame1->SetMenuBar(menuBar);
-
+	
 	wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
 	itemFrame1->SetSizer(itemBoxSizer2);
@@ -1116,6 +1121,6 @@
 	if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
 	else SepRadio->SetValue(true);
-	
-	
+
+
 #ifdef WIN32
 	RedirectIOToConsole(); 
@@ -1123,6 +1128,6 @@
 	ShowWindow( hWnd, SW_HIDE ); 
 #endif
-	
-		//MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
+
+	//MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
 }
 
@@ -1218,6 +1223,6 @@
 	if (name == _T("oni_special.ico"))
 	{
-	//	wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO);
-	//	return icon;
+		//	wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO);
+		//	return icon;
 	}
 	return wxNullIcon;
@@ -1271,5 +1276,5 @@
 
 
-	
+
 
 	if (!event.GetInt() ) {
@@ -1321,17 +1326,19 @@
 	for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
 	if ( !localPackages.empty() )	{
-
+	
 		//MainWindow::MainWindow().Hide();	
 		//	boost::thread thrd2(recompileAll(localPackages) );
 		//MainWindow::MainWindow().Show();
+		this->InstallButton->Disable();
+		this->ReglobalizeButton->Disable();
 #ifdef WIN32
 		recompile packages(localPackages);
 		boost::thread thrd(packages);
 #else
-		this->Disable();
 		recompileAll(localPackages);
-		this->Enable();
 #endif
 
+		this->InstallButton->Enable();
+		this->ReglobalizeButton->Enable();
 	}
 
@@ -1460,4 +1467,5 @@
 void MainWindow::OnLoadClick( wxCommandEvent& event )
 {
+	if (busy == 1) return;
 	static const wxChar *FILETYPES = _T(
 		"Mod Loadouts (*.cfg)|*.cfg|"
@@ -1484,4 +1492,5 @@
 void MainWindow::OnSaveClick( wxCommandEvent& event )
 {
+	if (busy == 1) return;
 	static const wxChar *FILETYPES = _T(
 		"Mod Loadouts (*.cfg)|*.cfg|"
@@ -1542,23 +1551,27 @@
 
 	if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no...
+
+	}
+	else {
+	
+		this->InstallButton->Disable();
+		this->ReglobalizeButton->Disable();
+
+#ifdef WIN32
+
+		boost::thread thrd2(globalizeData);
+		//globalizeData();
+		//boost::thread::create_thread(&globalizeData);
+		//	 boost::thread_group Tg;
+		// Tg.create_thread( &globalizeData(), this );
+#else
+		globalizeData();
+		setProgressBar(1000);
+		setStatusArea("Done!");
+#endif
 		
-	}
-	else {
-		
-	
-
-#ifdef WIN32
-
-	boost::thread thrd2(globalizeData);
-	//globalizeData();
-	//boost::thread::create_thread(&globalizeData);
-	//	 boost::thread_group Tg;
-	// Tg.create_thread( &globalizeData(), this );
-#else
-	globalizeData();
-	setProgressBar(1000);
-	setStatusArea("Done!");
-#endif
-}
+		this->InstallButton->Enable();
+		this->ReglobalizeButton->Enable();
+	}
 
 }
