--- AE/Installer/trunk/source/main_window.cpp 2009/07/08 17:20:07 410 +++ AE/Installer/trunk/source/main_window.cpp 2010/03/14 23:31:14 500 @@ -1,826 +1,23 @@ +/***************************************************************************\ +| Project: AE Installer | +| By: Gumby & Iritscen | +| File: Main_Window.cpp | +| Function: Handles the GUI. | +| Created: 07/05/2009 20:38:25 | +\***************************************************************************/ + #ifndef NTDDI_VERSION #define NTDDI_VERSION NTDDI_WIN7 #endif #ifdef WIN32 - #include +#include #include HWND Handle; - ITaskbarList *pTaskbarList; ITaskbarList3 *pTaskbarList3; #endif -/* - AE/Mod Installer - by Gumby and Iritscen -*/ - -// To-do: - Load credits from text resource file -// - Institute lots of checks into file-handling -// - Clear mod info fields when mod is de-selected - -#define DEBUG -#include -//#include -//#include -#include -#include -#include -#include -#include -#include -#include - -#include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations -#include "boost/lexical_cast.hpp" //int -> string -#include "installer.h" - -#ifdef WIN32 -#include -#else // assume we're on Mac -#include -#include -#endif - -//const string strInstallerVersion = "1.0"; -const bool SPLIT = 1; -const bool NOT_SPLIT = 0; -bool splitInstances = SPLIT; -bool busy = 0; -#ifdef WIN32 -const string strOniSplit = "Onisplit.exe"; -string strImportOption = "-import:nosep"; -const char* strClsCmd = "cls"; -const char* strPauseCmd = "PAUSE"; -#else // set up Mac equivalents since we're in Mac OS -const string strOniSplit = "mono Onisplit.exe"; -string strImportOption = "-import:sep"; -const char* strClsCmd = "clear"; -const char* strPauseCmd = "read -n 1 -p \"Press any key to continue\""; -void Sleep(int ms) { sleep( ms / 1000 ); } -#endif - -using namespace boost::filesystem; -using namespace std; - - - - -#include "boost/date_time/gregorian/gregorian.hpp" -#include "boost/date_time/date_parsing.hpp" -#include "boost/date_time/posix_time/posix_time.hpp" - -string escapePath(string input) { - - string output; - string escape_me = "& ;()|<>\"'\\#*?$"; - for(int i = 0; i < input.size(); i++) { - for(int j = 0; j < escape_me.size(); j++) if (input[i] == escape_me[j]) output += '\\'; - output += input[i]; - } - return output; -} - -int globalizeData(void) -{ - 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; - ptime start_time(second_clock::local_time()); - - setStatusArea("Globalizing!"); - int err = 0; - int parts_done = 0; - char Step_x_x[300]; - //char levels[i][5]; - remove("Globalize.log"); - ofstream logfile("Globalize.log"); - 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 ck(cv, &cv[CvSize]); - vector levels; - for (int f = 0; f < 15; f++) { - levels.push_back(levels_cstr[f]); - } - char choice = 0; - - //SetCurrentDirectory("C:/Program Files/Oni/edition/install"); - ///char levels[i][3]; - path Characters = "../GameDataFolder/level0_Characters"; - path Particles = "../GameDataFolder/level0_Particles"; - path Archive = "../GameDataFolder/Archive"; - path Textures = "../GameDataFolder/level0_Textures"; - path Sounds = "../GameDataFolder/level0_Sounds"; - path Animations = "../GameDataFolder/level0_Animations"; - path TRAC = Animations / "level0_TRAC"; - path TRAM = Animations / "level0_TRAM"; - - vector GDFPaths; - //GDFPaths.push_back(Characters); - GDFPaths.push_back(Particles); - GDFPaths.push_back(Textures); - GDFPaths.push_back(Sounds); - GDFPaths.push_back(TRAC); - GDFPaths.push_back(TRAM); - - - path VanillaCharacters = "VanillaDats/level0_Final/level0_Characters/level0_Characters.oni"; - path VanillaParticles = "VanillaDats/level0_Final/level0_Particles/level0_Particles.oni"; - path VanillaTextures = "VanillaDats/level0_Final/level0_Textures/level0_Textures.oni"; - path VanillaSounds = "VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni"; - path VanillaAnimations = "VanillaDats/level0_Final/level0_Animations/level0_Animations.oni"; - path VanillaTRAC = "VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni"; - path VanillaTRAM = "VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni"; - - vector VanillaPaths; - - //VanillaPaths.push_back(VanillaCharacters); - VanillaPaths.push_back(VanillaParticles); - VanillaPaths.push_back(VanillaTextures); - VanillaPaths.push_back(VanillaSounds); - VanillaPaths.push_back(VanillaTRAC); - VanillaPaths.push_back(VanillaTRAM); - - /* - if (exists("../GameDataFolder/")) - { - //cout << "\nIt looks like you've already globalized Oni's data.\nDo you want to re-globalize?\n(This will erase existing mods installed to the AE's game data.)" - // << "\n1. Re-globalize" - // << "\n2. Return to main menu\n"; - //choice = cin.get(); - cin.ignore(128, '\n'); - if (choice == '1') - remove_all("../GameDataFolder"); // remove AE GDF - if (choice == '2') - return 0; - } - */ - setStatusArea("Removing old GameDataFolder...\n"); - logfile << "Removing old GameDataFolder...\n"; - remove_all( "../GameDataFolder/" ); - setStatusArea("Creating needed directories..."); - logfile << "Creating needed directories...\n"; - create_directory( "../GameDataFolder/" ); - - create_directory( "packages" ); - - if (exists("VanillaDats")) remove_all("VanillaDats"); - create_directory( "VanillaDats" ); - create_directory( "VanillaDats/level0_Final/" ); - //blah blah finish this. - //logfile << "VanillaDats/level0_Final/ created"; - create_directory( Characters ); - create_directory( Particles ); - create_directory( Archive ); - create_directory( Textures ); - create_directory( Sounds ); - create_directory( Animations ); - create_directory( TRAC ); - create_directory( TRAM ); - int num_levels = 0; - for(int i = 1; i < 15; i++) - { - if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) { - num_levels++; - - } - } - logfile << "Exporting and moving...\n\n"; - int total_steps = 8 + 2 * num_levels; - 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"; - logfile << "\tExporting level" << levels[i] << "_Final.dat\n"; - //printf(Step_x_x,"Step %d/%d: exporting level%d_final.dat", parts_done + 1,, levels[i]); setStatusArea((string)Step_x_x); - setStatusArea("Step " + lexical_cast(parts_done + 1) + "/" + lexical_cast(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"); - system((strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat").c_str()); - create_directory( "VanillaDats/level" + levels[i] + "_Final" ); - create_directory( "VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" ); - - directory_iterator end_iter; - for ( directory_iterator dir_itr( "../GameDataFolder/level" + levels[i] + "_Final" ); dir_itr != end_iter; ++dir_itr ) - { - //cout << dir_itr->path().filename(); - if ( is_regular_file( dir_itr->status() ) ) - { - if ( dir_itr->path().filename().substr(0,8) == "TXMPfail" || - dir_itr->path().filename().substr(0,9) == "TXMPlevel" || - ( dir_itr->path().filename().substr(0,4) == "TXMP" && dir_itr->path().filename().find("intro")!=string::npos) || - dir_itr->path().filename().substr(0,4) == "TXMB" || - dir_itr->path().filename() == "M3GMpowerup_lsi.oni" || - dir_itr->path().filename() == "TXMPlsi_icon.oni" || - ( dir_itr->path().filename().substr(0,4) == "TXMB" && dir_itr->path().filename().find("splash_screen.oni")!=string::npos) ) - { - cout <path().filename() << "\n"; - create_directory( dir_itr->path().parent_path() / "NoGlobal"); - if(!exists( dir_itr->path().parent_path() / "NoGlobal" / dir_itr->filename())) rename(dir_itr->path(), dir_itr->path().parent_path() / "NoGlobal" / - dir_itr->filename()); - else remove(dir_itr->path()); - } - else if (dir_itr->path().filename().substr(0,4) == "TRAC" - ) { - cout <path().filename() << "\n"; - if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename()); - else remove(dir_itr->path()); - } - else if (dir_itr->path().filename().substr(0,4) == "TRAM") { - cout <path().filename() << "\n"; - if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename()); - else remove(dir_itr->path()); - } - else if (dir_itr->path().filename().substr(0,4) == "ONSK" || - dir_itr->path().filename().substr(0,4) == "TXMP") { - cout <path().filename() << "\n";\ - create_directory( dir_itr->path().parent_path() / "TexFix"); - if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename()); - //rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename()); - } - else if (dir_itr->path().filename().substr(0,4) == "ONCC" - || dir_itr->path().filename().substr(0,4) == "TRBS" - || dir_itr->path().filename().substr(0,4) == "ONCV" - || dir_itr->path().filename().substr(0,4) == "ONVL" - || dir_itr->path().filename().substr(0,4) == "TRMA" - || dir_itr->path().filename().substr(0,4) == "TRSC" - || dir_itr->path().filename().substr(0,4) == "TRAS") { - cout <path().filename() << "\n"; - if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename()); - else remove(dir_itr->path()); - } - else if (dir_itr->path().filename().substr(0,4) == "OSBD" - || dir_itr->path().filename().substr(0,4) == "SNDD") { - cout << dir_itr->path().filename() << "\n"; - if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename()); - else remove(dir_itr->path()); - } - else if (dir_itr->path().filename().substr(0,5) == "BINA3" - || dir_itr->path().filename().substr(0,10) == "M3GMdebris" - || dir_itr->path().filename() == "M3GMtoxic_bubble.oni" - || dir_itr->path().filename().substr(0,8) == "M3GMelec" - || dir_itr->path().filename().substr(0,7) == "M3GMrat" - || dir_itr->path().filename().substr(0,7) == "M3GMjet" - || dir_itr->path().filename().substr(0,9) == "M3GMbomb_" - || dir_itr->path().filename() == "M3GMbarab_swave.oni" - || dir_itr->path().filename() == "M3GMbloodyfoot.oni" - ){ - cout <path().filename() << "\n"; - if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename()); - else remove(dir_itr->path()); - } - else if (dir_itr->path().filename().substr(0,4) == "AGDB" - || dir_itr->path().filename().substr(0,4) == "TRCM") { - cout <path().filename() << "\n"; - - if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename()); - else remove(dir_itr->path()); - } - else if (dir_itr->path().filename().substr(0,4) == "ONWC") { //fix for buggy ONWC overriding - cout <path().filename() << "\n"; - - if(!exists( "VanillaDats/level0_Final/level0_Final/" + dir_itr->filename())) rename(dir_itr->path(), "VanillaDats/level0_Final/level0_Final/" + dir_itr->filename()); - else remove(dir_itr->path()); - } - - if (exists(dir_itr->path())) { - - } - else { - logfile << "\tMoved file: " << dir_itr->path().filename() << "\n"; - } - } - - - - } - logfile << "\tCleaning up TXMPs...\n"; - system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + levels[i] + "_Final/TXMP*.oni").c_str()); - parts_done++; - - setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); - - } - } - logfile << "Reimporting levels\n"; - for (int i = 0; i < 15; i++) - { - logfile << "\tReimporting level" << levels[i] << "_Final.oni\n"; - //printf(levels[i],"%d",levels[i]); - //printf(Step_x_x,"Step %d/%d: reimporting level", parts_done + 1, 7 + 2 * num_levels); setStatusArea((string)Step_x_x + levels[i] + (string)"_Final.dat"); - setStatusArea("Step " + lexical_cast(parts_done + 1) + "/" + lexical_cast(total_steps) + " reimporting level" + levels[i]+"_Final.oni"); - logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" - + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n'; - string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" - + levels[i] + "_Final/level" + levels[i] + "_Final.oni"); - system(sys_str.c_str() ); - setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); - parts_done++; - } - //create_directory( VanillaCharacters.parent_path() ); - create_directory( VanillaParticles.parent_path() ); - create_directory( VanillaTextures.parent_path() ); - 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"; - setStatusArea("Step " + lexical_cast(parts_done + 1) + "/" + lexical_cast(total_steps) + ": reimporting " + GDFPaths[j].filename() ); - system((strOniSplit + " " + strImportOption + " " + GDFPaths[j].string() + " " + VanillaPaths[j].string()).c_str()); - parts_done++; - setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); - } - logfile << "\nMoving level0_Characters\n"; - setStatusArea("Step " + lexical_cast(parts_done + 1) + "/" + lexical_cast(total_steps) + ": moving level0_Characters" ); - copy((path)"../GameDataFolder/level0_Characters", (path)("VanillaDats/level0_Final")); - /* - 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()); - parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Particles", 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 + " " + Particles.string() + " " + VanillaParticles.string()).c_str()); - parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Textures", 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 + " " + Textures.string() + " " + VanillaTextures.string()).c_str()); - //system((strOniSplit + " " + strImportOption + (string)" " + Animations.string() + (string)" " + VanillaAnimations.string()).c_str()); - parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAC", 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 + " " + TRAC.string() + " " + VanillaTRAC.string()).c_str()); - parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Sounds", 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 + " " + Sounds.string() + " " + VanillaSounds.string()).c_str()); - parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAM", 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 + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str()); - //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/IGMD", (path)"../GameDataFolder"); - setProgressBar( 1000 ); - - if(!exists("../persist.dat")) - copy("../../persist.dat",".."); - if(!exists("../key_config.txt")) - copy("../../key_config.txt",".."); - -#ifndef WIN32 - /* On Mac only, set the current GDF to the AE GDF by writing to Oni's global preferences file (thankfully a standard OS X ".plist" XML file). - Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never - run Oni before :-p */ - string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for edition/ - char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; - strcat(prefsCommand, fullAEpath.c_str()); // get path of edition/ folder (Oni wants the folder that *contains* the GDF) - strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters - system(prefsCommand); - -#endif - - - setStatusArea((string)"Done! Now select your mod packages and click install."); - // 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(); - logfile.close(); - busy = 0; - return err; -} - - -vector getPackages(void) -{ - vector packages; - packages.reserve(65536); // come on, we shouldn't need this much space...right?! - fstream file; - string filename = "\0"; - string MODINFO_CFG = "Mod_Info.cfg"; - - try - { - directory_iterator end_iter; - for (directory_iterator dir_itr("./packages"); dir_itr != end_iter; ++dir_itr) - { - file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str()); - //cout << filename << "\n"; - - if(!file.fail()) - { - //cout << dir_itr->path().string() + MODINFO_CFG; - //would prefer to push a pointer to a package, but this will do for now - packages.push_back(fileToModPackage(file)); - } - file.close(); - file.clear(); - } - sort(packages.begin(), packages.end()); - } - catch (const std::exception & ex) - { - cout << "Warning, something odd happened!\n"; - } - - return packages; -} - -ModPackage fileToModPackage(fstream &file) -{ - /* - This converts a file to a ModPackage struct. - - A few notes... - "iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok. - I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much - slower than reading a variable. - */ - ModPackage package; - string line; - static string NameOfMod = "NameOfMod"; //used for comparing to the current token... - //I could have done it in reverse (*iter).compare("ModString") or - static string ARROW = "->"; //did something like "ModString".compare(*iter), and it would have been - static string ModString = "ModString"; //functionably the same. - static string HasOnis = "HasOnis"; - static string HasDeltas = "HasDeltas"; - static string HasBSL = "HasBSL"; - static string HasDats = "HasDats"; - static string IsEngine = "IsEngine"; - static string Readme = "Readme"; - static string GlobalNeeded = "GlobalNeeded"; - static string Category = "Category"; - static string Creator = "Creator"; - while (! file.eof() ) - { - getline (file,line); - vector tokens; - vector::iterator iter; - tokenize(line, tokens); //string to vector of "words" - if (tokens.capacity() >= 2) { //make sure they are using enough stuff - iter = tokens.begin(); //what word we are on, starts at first word - /* - if (!AEInstallVersion.compare(*iter)) - If mod is too old, skip this mod. - */ - /*else*/if (!NameOfMod.compare(*iter)) { //if it contains the name - for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment - if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) { //ignores "->" and "NameOfMod" - //cout << *iter; - //cout << " "; - package.name += *iter + " "; - } - } - - } - else if (!ModString.compare(*iter)) { - iter++; iter++; - package.modStringName = *iter; - iter++; - package.modStringVersion = atoi((*iter).c_str()); - } - else if (!HasOnis.compare(*iter)) { - iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasOnis = 1; //Gotta love c++'s lack of a standard case-insensitive - else if (!HasBSL.compare(*iter)) { // string comparer...I know my implementation here sucks. I need to change it to check each character one by one. At the moment, - iter++; iter++;} // using "YFR" would probably set it off. :< - - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasBSL = 1; - } - else if (!HasDeltas.compare(*iter)) { - iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1; - } - else if (!HasDats.compare(*iter)) { - iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1; - } - else if (!IsEngine.compare(*iter)) { - iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1; - } - else if (!GlobalNeeded.compare(*iter)) { - iter++; iter++; - if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1; - else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; //Really the only place where checking for "No" is important atm. - } - else if (!Category.compare(*iter)) { - for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment - if (ARROW.compare(*iter) && Category.compare(*iter)) { //ignores "->" and "Category" - //cout << *iter; - //cout << " "; - package.category += *iter + " "; - } - } - } - else if (!Creator.compare(*iter)) { //if it contains the name - for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment - if (ARROW.compare(*iter) && Creator.compare(*iter)) { //ignores "->" and "Category" - //cout << *iter; - //cout << " "; - package.creator += *iter + " "; - } - } - } - else if (!Readme.compare(*iter)) { //if it contains the name - for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment - if (ARROW.compare(*iter) && Readme.compare(*iter)) { //ignores "->" and "Category" - if(!(*iter).compare("\\n")) package.readme += '\n'; - else package.readme += *iter + " "; - } - } - } - } - - } - package.doOutput(); - return package; -} - -void recompileAll(vector installedMods) -{ - busy = 1; - using namespace boost::gregorian; - using namespace boost::posix_time; - using boost::lexical_cast; - using boost::bad_lexical_cast; - - setStatusArea("Importing levels..."); - //setStatusArea("Recompiling Data..."); - path vanilla_dir = "./VanillaDats/"; - string importCommand = ""; - char statusString[128]; - int numberOfDats = 0; - int j = 1; - string datString; - std::stringstream out; - - ptime start_time(second_clock::local_time()); - clearOldDats(); - remove("Install.log"); - ofstream logfile("Install.log"); - logfile << "Mod Installation started " << to_simple_string(start_time) << endl; - logfile.close(); - if(splitInstances == SPLIT){ - recursive_directory_iterator end_iter; - - for ( recursive_directory_iterator dir_itr( vanilla_dir ); - dir_itr != end_iter; - ++dir_itr ) - { - try{ - if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1) - { - numberOfDats++; - } - } - catch(exception ex) { - - } - } - try { - //recursive_directory_iterator end_iter; - - - out << numberOfDats; - datString = out.str(); - for ( recursive_directory_iterator dir_itr( vanilla_dir ); - dir_itr != end_iter; - ++dir_itr ) - { - try - { - if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1) - { - importCommand = strOniSplit + " " + strImportOption + " " + dir_itr->path().parent_path().string() + '/' + dir_itr->path().filename(); - for (int i = 0; i < installedMods.size(); ++i) { - if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename() )) - importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename(); - - //else cout << " VanillaDats/" + installedMods[i] + "/oni/"; - } - importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; - - - setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats - setStatusArea("Step " + lexical_cast(j) + '/' + lexical_cast(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); - - system(importCommand.c_str()); - //Sleep(1000); - //cout << importCommand << "\n"; - j++; - - } - } - 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(); - } - } - - } - 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(); - } - - } - else if(splitInstances == NOT_SPLIT){ - directory_iterator end_iter; - - for ( directory_iterator dir_itr( vanilla_dir ); - dir_itr != end_iter; - ++dir_itr ) - { - - if ( is_directory( dir_itr->status() ) ) - { - numberOfDats++; - } - - - } - - out << numberOfDats; - datString = out.str(); - - for ( directory_iterator dir_itr( vanilla_dir ); - dir_itr != end_iter; - ++dir_itr ) - { - try - { - if ( is_directory( dir_itr->status() ) ) - { - importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; - for (int i = 0; i < installedMods.size(); ++i) { - if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() )) - importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename(); - } - importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; - - - setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats - setStatusArea("Step " + lexical_cast(j) + '/' + lexical_cast(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); - - system(importCommand.c_str()); - - j++; - } - } - 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(); - }} - } - logfile << "Writing config file"; - writeInstalledMods(installedMods); - 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(); - - Sleep(1000); - setProgressBar(0); - busy = 0; -} - -void writeInstalledMods(vector installedMods) -{ - - if ( exists( strInstallCfg ) ) - { - remove( strInstallCfg ); - } - - ofstream file(strInstallCfg.c_str()); - - vectorlist = installedMods; - vector::iterator begin_iter = list.begin(); - vector::iterator end_iter = list.end(); - - sort( list.begin(), list.end() ); - - for( ; begin_iter != end_iter; ++begin_iter) { - file << *begin_iter << " "; - } - - file.close(); - file.clear(); - -} - -vector getInstallString(string Cfg) -{ - //system(strPauseCmd); - vector returnval; - - string line; - fstream file; - - if (exists( Cfg )) - { - file.open(Cfg.c_str()); - getline(file, line); - tokenize(line, returnval); - file.close(); - file.clear(); - sort(returnval.begin(), returnval.end()); - } - else cout << "fail"; - - return returnval; -} - -//stolen token function... -void tokenize(const string& str, vector& tokens, const string& delimiters) -{ - // Skip delimiters at beginning. - string::size_type lastPos = str.find_first_not_of(delimiters, 0); - // Find first "non-delimiter". - string::size_type pos = str.find_first_of(delimiters, lastPos); - - while (string::npos != pos || string::npos != lastPos) - { - // Found a token, add it to the vector. - tokens.push_back(str.substr(lastPos, pos - lastPos)); - // Skip delimiters. Note the "not_of" - lastPos = str.find_first_not_of(delimiters, pos); - // Find next "non-delimiter" - pos = str.find_first_of(delimiters, lastPos); - } -} - -void clearOldDats(void) { - directory_iterator end_iter_gdf; - for ( directory_iterator dir_itr_gdf( "../GameDataFolder" ); - dir_itr_gdf != end_iter_gdf; - ++dir_itr_gdf ) - { - //cout << dir_itr_gdf->path().extension() << "\n"; - if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) { - remove( dir_itr_gdf->path() ); - } - - } - -} - -vector globalInstalledMods; -vector globalPackages; -#include "boost/thread.hpp" #include - -///////////////////////////////////////////////////////////////////////////// -// Name: main_window.cpp -// Purpose: -// Author: -// Modified by: -// Created: 07/05/2009 20:38:25 -// RCS-ID: -// Copyright: -// Licence: -///////////////////////////////////////////////////////////////////////////// - // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -834,9 +31,9 @@ vector globalPackages; ////@begin includes #include "about.h" -////@end includes - #include "main_window.h" +#include "installer.h" +////@end includes ////@begin XPM images #include "aelogosmall.xpm" @@ -846,8 +43,21 @@ vector globalPackages; #include "quit.xpm" ////@end XPM images -//#define wxDebug 1; -//#define wxUSE_UNICODE 1; +bool busy = false; +int updateStatus; +bool installerJustUpdated = false; +vector globalInstalledMods; +vector globalPackages; +// Variable declarations +#ifdef WIN32 +bool splitInstances = true; +string strImportOption = "-import:nosep"; +string strOniSplit = "Onisplit.exe"; +#else +bool splitInstances = false; +string strImportOption = "-import:sep"; +string strOniSplit = "mono Onisplit.exe"; +#endif /* * MainWindow type definition @@ -931,7 +141,6 @@ bool MainWindow::Create( wxWindow* paren return true; } - /* * MainWindow destructor */ @@ -942,7 +151,6 @@ MainWindow::~MainWindow() ////@end MainWindow destruction } - /* * Member initialisation */ @@ -967,10 +175,8 @@ void MainWindow::Init() CompleteRadio = NULL; ReglobalizeButton = NULL; ////@end MainWindow member initialisation - } - /* * Control creation for MainWindow */ @@ -1007,13 +213,12 @@ void MainWindow::CreateControls() wxMenu* itemMenu42 = new wxMenu; itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK); menuBar->Append(itemMenu42, _("Options")); - wxMenu* itemMenu44 = new wxMenu; -#ifdef WIN32 - itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL); - menuBar->Append(itemMenu44, _("Help")); -#else +//#ifdef WIN32 +// itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL); +// menuBar->Append(itemMenu44, _("Help")); +//#else itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL); -#endif +//#endif itemFrame1->SetMenuBar(menuBar); @@ -1080,7 +285,8 @@ void MainWindow::CreateControls() StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 ); StatusArea->SetName(_T("StatusArea")); StatusArea->SetFieldsCount(1); - StatusArea->SetStatusText(_("AE Installer v1.0"), 0); + string versionText = "AE Installer v" + (string)INSTALLER_VERSION; + StatusArea->SetStatusText(versionText.c_str(), 0); itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0); wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL); @@ -1151,38 +357,14 @@ void MainWindow::CreateControls() ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList); #endif - - /*if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) { - strImportOption = "-import:sep"; - splitInstances = NOT_SPLIT; - } - else { - strImportOption = "-import:nosep"; - splitInstances = SPLIT; - }*/ - - -#ifndef WIN32 - strImportOption = "-import:sep"; - splitInstances = NOT_SPLIT; -#else - strImportOption = "-import:nosep"; - splitInstances = SPLIT; -#endif - -#ifndef WIN32 - strImportOption = "-import:sep"; - splitInstances = NOT_SPLIT; -#else - strImportOption = "-import:nosep"; - splitInstances = SPLIT; -#endif + updateStatus = GetUpdateStatus(¤tAE, &updateAE, &installerJustUpdated); globalPackages = getPackages(); globalInstalledMods = getInstallString(); - for (int i = 0; i < globalPackages.size(); i++) { + for (unsigned int i = 0; i < globalPackages.size(); i++) + { Mods_CheckboxList->Append(globalPackages[i].name.c_str()); - if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i); + if (binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName)) Mods_CheckboxList->Check(i); } TheStatusBar = &StatusArea; @@ -1190,27 +372,18 @@ void MainWindow::CreateControls() TheProgressBar = ProgressBar; OptionsPanel->Hide(); -//#ifndef WIN32 -// itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL); - -//#endif - - if(splitInstances == SPLIT) SeperatedRadio->SetValue(true); + if(splitInstances) SeperatedRadio->SetValue(true); else CompleteRadio->SetValue(true); if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true); else SepRadio->SetValue(true); - #ifdef WIN32 RedirectIOToConsole(); HWND hWnd = GetConsoleWindow(); ShowWindow( hWnd, SW_HIDE ); #endif - - //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() ); } - /* * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox */ @@ -1219,23 +392,17 @@ void MainWindow::OnSelectAllCheckboxClic { switch(SelectAll->Get3StateValue()) { case wxCHK_UNCHECKED: - for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); - //SelectAll->Set3StateValue(wxCHK_CHECKED); + for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); break; case wxCHK_CHECKED: - for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true); - //SelectAll->Set3StateValue(wxCHK_UNCHECKED); + for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true); break; case wxCHK_UNDETERMINED: - for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); - //SelectAll->Set3StateValue(wxCHK_CHECKED); + for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); break; - } - } - /* * wxEVT_CREATE event handler for Mods_CheckboxList */ @@ -1243,7 +410,6 @@ void MainWindow::OnSelectAllCheckboxClic void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event ) { - } @@ -1295,7 +461,6 @@ wxBitmap MainWindow::GetBitmapResource( wxIcon MainWindow::GetIconResource( const wxString& name ) { - // Icon retrieval ////@begin MainWindow icon retrieval wxUnusedVar(name); @@ -1308,22 +473,17 @@ wxIcon MainWindow::GetIconResource( cons ////@end MainWindow icon retrieval } - /* * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1 */ void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event ) { - //event.GetSelection titleText->SetValue(globalPackages[event.GetSelection()].name.c_str()); creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str()); descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str()); - - //creatorText->Refresh(); } - /* * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1 */ @@ -1357,8 +517,7 @@ void MainWindow::OnOptionsClick( wxComma this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());} else { -// Uncomment this when we release, it gets annoying if you are testing globalization a lot ;) - wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: These options are for advanced users only, use with caution.", + wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: These options are for advanced users only, use with caution.", "AE Installer Alert", wxOK | wxICON_EXCLAMATION , wxDefaultPosition); YesNoDialog->ShowModal(); OptionsPanel->Show(); @@ -1367,7 +526,6 @@ void MainWindow::OnOptionsClick( wxComma } } - /* * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT */ @@ -1377,12 +535,10 @@ void MainWindow::OnExitClick( wxCommandE exit(0); } - /* * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button */ - struct recompile { recompile(vector localPackages) : thePackages(localPackages) { } @@ -1391,22 +547,25 @@ struct recompile TheInstallButton->Disable(); recompileAll(thePackages); TheInstallButton->Enable(); + } - vector thePackages; }; +void globalize2(void) { + TheInstallButton->Disable(); + globalizeData(); + TheInstallButton->Enable(); +} + void MainWindow::OnInstallButtonClick( wxCommandEvent& event ) { - vector localPackages; - localPackages.push_back("Globalize"); - for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName ); + localPackages.push_back("00000Globalize"); + for(unsigned 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(); + sort(localPackages.begin(), localPackages.end()); + localPackages[0] = "Globalize"; this->InstallButton->Disable(); this->ReglobalizeButton->Disable(); #ifdef WIN32 @@ -1415,49 +574,26 @@ void MainWindow::OnInstallButtonClick( w #else recompileAll(localPackages); #endif - this->InstallButton->Enable(); this->ReglobalizeButton->Enable(); } - - } -/*void setStatusArea( string s ) { -//TheStatusBar = MainWindow::StatusArea; -(**TheStatusBar).SetStatusText(_(s.c_str()), 0); - -//MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1); - -//MainWindow::StatusBar->SetLabel("Importing Files..."); -//StatusBar->SetLabel(s); -//->SetLabel(s); - -}*/ - -void setProgressBar( int i ) { - //TheProgressBar->SetValue( +void setProgressBar( int i ) +{ #ifdef WIN32 - - - if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3))) { - pTaskbarList3->SetProgressValue(Handle,i, 1000); - if ( i == 0 ) { - - pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS); + if ( i == 0 ) + { + pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS); } } - - #endif TheProgressBar->SetValue(i); - } - /* * wxEVT_UPDATE_UI event handler for ID_STATUSBAR */ @@ -1470,7 +606,6 @@ void MainWindow::OnStatusbarUpdate( wxUp ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow. } - /* * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT */ @@ -1479,13 +614,12 @@ void MainWindow::OnAboutClick( wxCommand { ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow. // Before editing this code, remove the block markers. + // TODO: Make About window work again! About* window = new About(this); - int returnValue = window->ShowModal(); window->Destroy(); ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow. } - /* * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton */ @@ -1495,7 +629,6 @@ void MainWindow::OnNoSepRadioButtonSelec static_cast("-import:nosep"); } - /* * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton */ @@ -1505,7 +638,6 @@ void MainWindow::OnSepRadioButtonSelecte static_cast("-import:sep"); } - /* * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton */ @@ -1516,11 +648,9 @@ void MainWindow::OnSepRadioButtonSelecte void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event ) { - splitInstances = NOT_SPLIT; - + splitInstances = false; } - /* * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON */ @@ -1530,23 +660,18 @@ void MainWindow::OnRefreshButtonClick( w refreshMods(globalInstalledMods); } - /* * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD */ - - - -void MainWindow::refreshMods (vector s) { - +// TODO: Make refreshMods actually refresh the list in the window of available mods so we can see any new package info and deleted mods are removed from the list +void MainWindow::refreshMods (vector s) +{ Mods_CheckboxList->Clear(); - //globalInstalledMods = getPackages(); - for (int i = 0; i < globalPackages.size(); i++) { + for (unsigned int i = 0; i < globalPackages.size(); i++) { Mods_CheckboxList->Append(globalPackages[i].name.c_str()); - if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i); - //else Mods_CheckboxList->Check(i,0); - + if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) + Mods_CheckboxList->Check(i); } } @@ -1566,11 +691,8 @@ void MainWindow::OnLoadClick( wxCommandE { refreshMods(getInstallString( string(openFileDialog->GetPath()) )); } - - } - /* * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE */ @@ -1589,14 +711,6 @@ void MainWindow::OnSaveClick( wxCommandE if ( openFileDialog->ShowModal() == wxID_OK ) { - - - //Mods_CheckboxList-> - - - - // - if ( exists( openFileDialog->GetPath().c_str() ) ) { remove( openFileDialog->GetPath().c_str() ); @@ -1605,7 +719,7 @@ void MainWindow::OnSaveClick( wxCommandE ofstream file(openFileDialog->GetPath().c_str()); vectorlist; - for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName ); + for(unsigned int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName ); vector::iterator begin_iter = list.begin(); vector::iterator end_iter = list.end(); @@ -1617,34 +731,28 @@ void MainWindow::OnSaveClick( wxCommandE file.close(); file.clear(); - - //SetCurrentFilename(openFileDialog->GetFilename()); - //theText->LoadFile(openFileDialog->GetFilename()); - //SetStatusText(GetCurrentFilename(), 0); - //SetStatusText(openFileDialog->GetDirectory(),1); } } - - /* * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button */ void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event ) { - wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: This will DELETE the Edition's GameDataFolder and recreate it from the vanilla Oni game data. \n Are you SURE you want to do this? ", "AE Installer Alert", wxYES_NO | wxICON_EXCLAMATION , wxDefaultPosition); - - if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no... + string YesNoMsg = "WARNING: This will DELETE the Edition's GameDataFolder and recreate it from the vanilla Oni game data.\n"; + YesNoMsg = YesNoMsg + "Are you SURE you want to do this?"; + wxMessageDialog* YesNoDialog = new wxMessageDialog(this, YesNoMsg.c_str(), "AE Installer Alert", wxYES_NO | wxICON_EXCLAMATION , wxDefaultPosition); + if (YesNoDialog->ShowModal() == wxID_NO) + { + //if the user said no... } - else { - + else + { this->InstallButton->Disable(); this->ReglobalizeButton->Disable(); - #ifdef WIN32 - boost::thread thrd2(globalizeData); //globalizeData(); //boost::thread::create_thread(&globalizeData); @@ -1653,31 +761,19 @@ void MainWindow::OnReGlobalizeButtonClic #else globalizeData(); #endif - this->InstallButton->Enable(); this->ReglobalizeButton->Enable(); } - } /* * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton */ -/*void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event ) -{ -////@begin wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow. -// Before editing this code, remove the block markers. -event.Skip(); -////@end wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow. -}*/ - - /* * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Seperated_RadioButton */ void MainWindow::OnSeperatedRadioButtonSelected( wxCommandEvent& event ) { -splitInstances = SPLIT; + splitInstances = true; } -