Changeset 357 for AE/Installer/trunk
- Timestamp:
- Jun 19, 2009, 11:32:17 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/Installer/trunk/source/main_window.cpp
r355 r357 35 35 const bool NOT_SPLIT = 0; 36 36 bool splitInstances = SPLIT; 37 37 bool busy = 0; 38 38 #ifdef WIN32 39 39 const string strOniSplit = "Onisplit.exe"; … … 61 61 int globalizeData(void) 62 62 { 63 using boost::lexical_cast; 64 using boost::bad_lexical_cast; 65 // using namespace boost::posix_time; 63 busy = 1; 64 using boost::lexical_cast; 65 using boost::bad_lexical_cast; 66 // using namespace boost::posix_time; 66 67 using namespace boost::gregorian; 67 68 using namespace boost::posix_time; … … 77 78 logfile << "Globalization started " << to_simple_string(start_time) << endl; 78 79 try { 79 80 80 81 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. 81 82 //const vector<double> ck(cv, &cv[CvSize]); … … 96 97 path TRAC = Animations / "level0_TRAC"; 97 98 path TRAM = Animations / "level0_TRAM"; 98 99 99 100 vector<path> GDFPaths; 100 101 GDFPaths.push_back(Characters); … … 104 105 GDFPaths.push_back(TRAC); 105 106 GDFPaths.push_back(TRAM); 106 107 107 108 108 109 path VanillaCharacters = "packages/VanillaDats/level0_Final/level0_Characters/level0_Characters.oni"; 109 110 path VanillaParticles = "packages/VanillaDats/level0_Final/level0_Particles/level0_Particles.oni"; … … 115 116 116 117 vector<path> VanillaPaths; 117 118 118 119 VanillaPaths.push_back(VanillaCharacters); 119 120 VanillaPaths.push_back(VanillaParticles); … … 122 123 VanillaPaths.push_back(VanillaTRAC); 123 124 VanillaPaths.push_back(VanillaTRAM); 124 125 125 126 /* 126 127 if (exists("../GameDataFolder/")) … … 143 144 logfile << "Creating needed directories...\n"; 144 145 create_directory( "../GameDataFolder/" ); 145 146 146 147 create_directory( "packages" ); 147 148 148 149 if (exists("packages/VanillaDats")) remove_all("packages/VanillaDats"); 149 150 create_directory( "packages/VanillaDats" ); 150 151 151 152 create_directory( "packages/VanillaDats/level0_Final/" ); 152 153 //blah blah finish this. … … 163 164 for(int i = 1; i < 15; i++) 164 165 { 165 166 if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) { 166 167 num_levels++; 167 168 … … 172 173 for(int i = 0; i < 15; i++) 173 174 { 174 175 175 176 //printf(levels[i],"%d",levels[i]); // int to char array 176 177 177 178 if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) { 178 179 logfile << "level" << levels[i] << "_Final\n"; … … 181 182 setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " exporting level" + levels[i]+"_Final.dat"); 182 183 create_directory( "../GameDataFolder/level" + levels[i] + "_Final" ); 183 // setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat");184 // setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat"); 184 185 system((strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat").c_str()); 185 186 create_directory( "packages/VanillaDats/level" + levels[i] + "_Final" ); … … 257 258 || dir_itr->path().filename().substr(0,4) == "TRCM") { 258 259 cout <<dir_itr->path().filename() << "\n"; 259 260 260 261 if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename()); 261 262 else remove(dir_itr->path()); … … 270 271 271 272 272 273 273 274 } 274 275 logfile << "\tCleaning up TXMPs...\n"; … … 277 278 278 279 setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); 279 280 280 281 } 281 282 } … … 290 291 + levels[i] + "_Final/level" + levels[i] + "_Final.oni > Globalize.oni").c_str()); 291 292 setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); 292 293 parts_done++; 293 294 } 294 295 create_directory( VanillaCharacters.parent_path() ); … … 297 298 create_directory( VanillaSounds.parent_path() ); 298 299 create_directory( VanillaAnimations.remove_filename() ); 299 300 300 301 for(int j = 0; j < GDFPaths.size(); j++) { 301 302 logfile << "\tReimporting " << GDFPaths[j].filename() << ".oni\n"; … … 305 306 setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); 306 307 } 307 /*308 /* 308 309 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) )); 309 310 system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str()); … … 321 322 //parts_done++; setStatusArea((string)"Copying level scripts...");setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); 322 323 if (exists("../GameDataFolder/IGMD")) remove_all("../GameDataFolder/IGMD"); 323 */324 */ 324 325 create_directory((path)"../GameDataFolder/IGMD"); 325 326 copy((path)"packages/VanillaBSL/", (path)"../GameDataFolder"); 326 327 setProgressBar( 1000 ); 327 328 setStatusArea((string)"Done! Now select your mod packages and click install."); 328 // while(1) Sleep(-1);329 329 // while(1) Sleep(-1); 330 330 331 } 331 332 catch (exception ex) { 332 333 setStatusArea("Warning, handled exception: " + (string)ex.what()); 333 334 } 334 335 336 337 338 335 336 ptime end_time(second_clock::local_time()); 337 time_period total_time (start_time, end_time); 338 logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length(); 339 //total_time.length().hours(); 339 340 logfile.close(); 340 341 busy = 0; 341 342 return err; 342 343 } … … 491 492 void recompileAll(vector<string> installedMods) 492 493 { 494 busy = 1; 493 495 using namespace boost::gregorian; 494 496 using namespace boost::posix_time; 497 using boost::lexical_cast; 498 using boost::bad_lexical_cast; 495 499 496 500 setStatusArea("Importing levels..."); … … 551 555 importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; 552 556 553 printf(statusString,"%d/%i\0",j,numberOfDats);557 554 558 setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats 555 setStatusArea(" Importing " + dir_itr->path().filename() + " " + statusString);559 setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); 556 560 557 561 system(importCommand.c_str()); … … 564 568 catch ( const std::exception & ex ) 565 569 { 566 567 remove("Install.log");568 ofstream logfile("Install.log");569 570 570 571 remove("Install.log"); 572 ofstream logfile("Install.log"); 573 574 571 575 logfile << "Warning, exception " << ex.what() << "!"; 572 576 setStatusArea("Warning, exception " + (string)ex.what() + "!"); 573 logfile.close();577 logfile.close(); 574 578 } 575 579 } … … 577 581 } 578 582 catch( const std::exception & ex ) { 579 580 remove("Install.log");581 ofstream logfile("Install.log");582 583 584 585 586 logfile.close();583 584 remove("Install.log"); 585 ofstream logfile("Install.log"); 586 587 588 logfile << "Warning, exception " << ex.what() << "!"; 589 setStatusArea("Warning, exception " + (string)ex.what() + "!"); 590 logfile.close(); 587 591 } 588 592 … … 623 627 importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; 624 628 625 printf(statusString,"%d/%i\0",j,numberOfDats); 629 626 630 setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats 627 setStatusArea(" Importing " + dir_itr->path().filename() + " " + statusString);631 setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); 628 632 629 633 system(importCommand.c_str()); … … 634 638 catch ( const std::exception & ex ) 635 639 { 636 637 remove("Install.log");638 ofstream logfile("Install.log");639 640 641 642 643 logfile.close();640 641 remove("Install.log"); 642 ofstream logfile("Install.log"); 643 644 645 logfile << "Warning, exception " << ex.what() << "!"; 646 setStatusArea("Warning, exception " + (string)ex.what() + "!"); 647 logfile.close(); 644 648 }} 645 649 } … … 648 652 setProgressBar(1000); 649 653 setStatusArea("Done! You can now play Oni."); 650 651 652 653 654 655 656 657 658 659 660 661 logfile2.close();662 663 664 654 655 ptime end_time(second_clock::local_time()); 656 time_period total_time (start_time, end_time); 657 658 659 ofstream logfile2("Install.log", ios::app | ios::ate); 660 string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length(); 661 662 logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length(); 663 664 //logfile2.write(outstring.c_str(), outstring.length()); 665 logfile2.close(); 666 667 //total_time.length().hours(); 668 665 669 Sleep(1000); 666 670 setProgressBar(0); 671 busy = 0; 667 672 } 668 673 … … 869 874 SetIcon(GetIconResource(wxT("oni_special.ico"))); 870 875 Centre(); 871 872 876 877 873 878 ////@end MainWindow creation 874 879 return true; … … 958 963 menuBar->Append(itemMenu44, _("Help")); 959 964 itemFrame1->SetMenuBar(menuBar); 960 965 961 966 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); 962 967 itemFrame1->SetSizer(itemBoxSizer2); … … 1116 1121 if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true); 1117 1122 else SepRadio->SetValue(true); 1118 1119 1123 1124 1120 1125 #ifdef WIN32 1121 1126 RedirectIOToConsole(); … … 1123 1128 ShowWindow( hWnd, SW_HIDE ); 1124 1129 #endif 1125 1126 1130 1131 //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() ); 1127 1132 } 1128 1133 … … 1218 1223 if (name == _T("oni_special.ico")) 1219 1224 { 1220 // wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO);1221 // return icon;1225 // wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO); 1226 // return icon; 1222 1227 } 1223 1228 return wxNullIcon; … … 1271 1276 1272 1277 1273 1278 1274 1279 1275 1280 if (!event.GetInt() ) { … … 1321 1326 for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName ); 1322 1327 if ( !localPackages.empty() ) { 1323 1328 1324 1329 //MainWindow::MainWindow().Hide(); 1325 1330 // boost::thread thrd2(recompileAll(localPackages) ); 1326 1331 //MainWindow::MainWindow().Show(); 1332 this->InstallButton->Disable(); 1333 this->ReglobalizeButton->Disable(); 1327 1334 #ifdef WIN32 1328 1335 recompile packages(localPackages); 1329 1336 boost::thread thrd(packages); 1330 1337 #else 1331 this->Disable();1332 1338 recompileAll(localPackages); 1333 this->Enable();1334 1339 #endif 1335 1340 1341 this->InstallButton->Enable(); 1342 this->ReglobalizeButton->Enable(); 1336 1343 } 1337 1344 … … 1460 1467 void MainWindow::OnLoadClick( wxCommandEvent& event ) 1461 1468 { 1469 if (busy == 1) return; 1462 1470 static const wxChar *FILETYPES = _T( 1463 1471 "Mod Loadouts (*.cfg)|*.cfg|" … … 1484 1492 void MainWindow::OnSaveClick( wxCommandEvent& event ) 1485 1493 { 1494 if (busy == 1) return; 1486 1495 static const wxChar *FILETYPES = _T( 1487 1496 "Mod Loadouts (*.cfg)|*.cfg|" … … 1542 1551 1543 1552 if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no... 1553 1554 } 1555 else { 1556 1557 this->InstallButton->Disable(); 1558 this->ReglobalizeButton->Disable(); 1559 1560 #ifdef WIN32 1561 1562 boost::thread thrd2(globalizeData); 1563 //globalizeData(); 1564 //boost::thread::create_thread(&globalizeData); 1565 // boost::thread_group Tg; 1566 // Tg.create_thread( &globalizeData(), this ); 1567 #else 1568 globalizeData(); 1569 setProgressBar(1000); 1570 setStatusArea("Done!"); 1571 #endif 1544 1572 1545 } 1546 else { 1547 1548 1549 1550 #ifdef WIN32 1551 1552 boost::thread thrd2(globalizeData); 1553 //globalizeData(); 1554 //boost::thread::create_thread(&globalizeData); 1555 // boost::thread_group Tg; 1556 // Tg.create_thread( &globalizeData(), this ); 1557 #else 1558 globalizeData(); 1559 setProgressBar(1000); 1560 setStatusArea("Done!"); 1561 #endif 1562 } 1573 this->InstallButton->Enable(); 1574 this->ReglobalizeButton->Enable(); 1575 } 1563 1576 1564 1577 }
Note:
See TracChangeset
for help on using the changeset viewer.