--- AE/Installer/trunk/source/main_window.cpp 2009/07/06 14:44:10 392 +++ AE/Installer/trunk/source/main_window.cpp 2009/10/20 22:55:16 469 @@ -1,3 +1,15 @@ +#ifndef NTDDI_VERSION +#define NTDDI_VERSION NTDDI_WIN7 +#endif +#ifdef WIN32 + #include +#include +HWND Handle; + +ITaskbarList *pTaskbarList; +ITaskbarList3 *pTaskbarList3; +#endif + /* AE/Mod Installer by Gumby and Iritscen @@ -21,6 +33,7 @@ #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations #include "boost/lexical_cast.hpp" //int -> string +#include "boost/algorithm/string.hpp" #include "installer.h" #ifdef WIN32 @@ -30,7 +43,7 @@ #include #endif -//const string strInstallerVersion = "1.0"; + const bool SPLIT = 1; const bool NOT_SPLIT = 0; bool splitInstances = SPLIT; @@ -52,6 +65,8 @@ using namespace boost::filesystem; using namespace std; +vector globalInstalledMods; +vector globalPackages; #include "boost/date_time/gregorian/gregorian.hpp" @@ -62,8 +77,8 @@ 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 += '//'; + for(unsigned int i = 0; i < input.size(); i++) { + for(unsigned int j = 0; j < escape_me.size(); j++) if (input[i] == escape_me[j]) output += '\\'; output += input[i]; } return output; @@ -109,7 +124,7 @@ int globalizeData(void) path TRAM = Animations / "level0_TRAM"; vector GDFPaths; - GDFPaths.push_back(Characters); + //GDFPaths.push_back(Characters); GDFPaths.push_back(Particles); GDFPaths.push_back(Textures); GDFPaths.push_back(Sounds); @@ -117,17 +132,17 @@ int globalizeData(void) 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"; - path VanillaTextures = "packages/VanillaDats/level0_Final/level0_Textures/level0_Textures.oni"; - path VanillaSounds = "packages/VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni"; - path VanillaAnimations = "packages/VanillaDats/level0_Final/level0_Animations/level0_Animations.oni"; - path VanillaTRAC = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni"; - path VanillaTRAM = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni"; + 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(VanillaCharacters); VanillaPaths.push_back(VanillaParticles); VanillaPaths.push_back(VanillaTextures); VanillaPaths.push_back(VanillaSounds); @@ -157,11 +172,11 @@ int globalizeData(void) create_directory( "packages" ); - if (exists("packages/VanillaDats")) remove_all("packages/VanillaDats"); - create_directory( "packages/VanillaDats" ); - create_directory( "packages/VanillaDats/level0_Final/" ); + if (exists("VanillaDats")) remove_all("VanillaDats"); + create_directory( "VanillaDats" ); + create_directory( "VanillaDats/level0_Final/" ); //blah blah finish this. - //logfile << "packages/VanillaDats/level0_Final/ created"; + //logfile << "VanillaDats/level0_Final/ created"; create_directory( Characters ); create_directory( Particles ); create_directory( Archive ); @@ -180,6 +195,7 @@ int globalizeData(void) } logfile << "Exporting and moving...\n\n"; int total_steps = 8 + 2 * num_levels; + for(int i = 0; i < 15; i++) { @@ -193,8 +209,15 @@ int globalizeData(void) 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( "packages/VanillaDats/level" + levels[i] + "_Final" ); - create_directory( "packages/VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" ); + create_directory( "VanillaDats/level" + levels[i] + "_Final" ); + create_directory( "VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" ); + + //Moves the AKEV and other files into a safe directory so that level specific textures are not globalized... + if ( strcmp(levels[i].c_str(), "0") ){ + create_directory( "../GameDataFolder/level" + levels[i] + "_Final/AKEV" ); + system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final/AKEV ../GameDataFolder/level" + levels[i] + "_Final/AKEV*.oni").c_str()); + + } directory_iterator end_iter; for ( directory_iterator dir_itr( "../GameDataFolder/level" + levels[i] + "_Final" ); dir_itr != end_iter; ++dir_itr ) @@ -217,7 +240,7 @@ int globalizeData(void) else remove(dir_itr->path()); } else if (dir_itr->path().filename().substr(0,4) == "TRAC" - || dir_itr->path().filename().substr(0,4) == "ONVL") { + ) { cout <path().filename() << "\n"; if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename()); else remove(dir_itr->path()); @@ -237,6 +260,7 @@ int globalizeData(void) 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") { @@ -274,22 +298,31 @@ int globalizeData(void) else if (dir_itr->path().filename().substr(0,4) == "ONWC") { //fix for buggy ONWC overriding cout <path().filename() << "\n"; - if(!exists( "packages/VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final/" + dir_itr->filename())) rename(dir_itr->path(), "packages/VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final/" + dir_itr->filename()); + 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 << "\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()); + + + if ( strcmp(levels[i].c_str(), "0") ){ + system((strOniSplit + " -move:overwrite ../GameDataFolder/level" + levels[i] + "_Final ../GameDataFolder/level" + levels[i] + "_Final/AKEV/AKEV*.oni").c_str()); + remove( "../GameDataFolder/level" + levels[i] + "_Final/AKEV" ); + } + parts_done++; setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); @@ -303,27 +336,47 @@ int globalizeData(void) //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 packages/VanillaDats/level" + levels[i] + "_Final/level" + 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 packages/VanillaDats/level" + levels[i] + "_Final/level" - + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize2.log"); + 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( 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++) { + for(unsigned 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")); + GDFPaths.push_back( Characters ); + for(int i = 0; i < GDFPaths.size(); i++) + { + directory_iterator end_iter; + for ( directory_iterator dir_itr( GDFPaths[i] ); dir_itr != end_iter; ++dir_itr ) + { + try + { + + + rename(dir_itr->path(), "../GameDataFolder/level0_Final/" + dir_itr->path().filename() ); + } + catch(exception &ex) { + + } + } + } /* 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()); @@ -344,19 +397,22 @@ int globalizeData(void) create_directory((path)"../GameDataFolder/IGMD"); copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder"); setProgressBar( 1000 ); + + if(exists("../../persist.dat")) if(!exists("../persist.dat")) - // CIP:last of all, set up the edition folder as a playable Oni installation by placing the latest application (+ Daodan DLL on Windows) in edition/ - // or we could just include it in the zip in the proper place already. + //TODO: Concactate level0 Dirs. - copy("../../persist.dat","../persist.dat"); - copy("../../keyconfig.txt","../keyconfig.txt"); + copy("../../persist.dat",".."); + if(exists("../../key_config.txt"))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). - If there are no Oni prefs (only possible if Oni has not been run even once), then the above line will fail silently, no harm done, - and when the user does run Oni for the first time, using the copy of the app in the AE GDF, Oni will set the prefs to use that GDF at that point */ - path fullAEpath = system_complete("."); // get full path for Installer - char prefsCommand[300] = "defaults write com.godgames.oni RetailInstallationPath -string '"; - strcat(prefsCommand, fullAEpath.parent_path().parent_path().string().c_str()); // get path of edition/ folder (Oni wants the folder that *contains* the GDF) + 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); @@ -367,7 +423,7 @@ int globalizeData(void) // while(1) Sleep(-1); } - catch (exception ex) { + catch (exception & ex) { setStatusArea("Warning, handled exception: " + (string)ex.what()); } @@ -391,8 +447,7 @@ vector getPackages(void) try { - directory_iterator end_iter; - for (directory_iterator dir_itr("./packages"); dir_itr != end_iter; ++dir_itr) + for (directory_iterator dir_itr("./packages"), end_itr; dir_itr != end_itr; ++dir_itr) { file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str()); //cout << filename << "\n"; @@ -471,11 +526,12 @@ ModPackage fileToModPackage(fstream &fil } 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; + if ( boost::iequals(*iter, "Yes")) package.hasOnis = 1; + } + 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 ( boost::iequals(*iter, "Yes")) package.hasBSL = 1; + else if ( boost::iequals(*iter, "Addon")) package.hasAddon = 1; } else if (!HasDeltas.compare(*iter)) { iter++; iter++; @@ -501,56 +557,61 @@ ModPackage fileToModPackage(fstream &fil //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 (!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 + " "; - } + } + 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; + +} +package.doOutput(); +return package; } void recompileAll(vector installedMods) -{ +{try { 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 = "./packages/VanillaDats/"; + path vanilla_dir = "./VanillaDats/"; string importCommand = ""; char statusString[128]; int numberOfDats = 0; int j = 1; string datString; + + + setStatusArea("Importing levels..."); + //setStatusArea("Recompiling Data..."); + std::stringstream out; ptime start_time(second_clock::local_time()); clearOldDats(); - remove("Install.log"); + + if(exists("Install.log")) 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; @@ -564,17 +625,22 @@ void recompileAll(vector install numberOfDats++; } } - catch(exception ex) { + catch(exception & ex) { + remove("Install.log"); + ofstream logfile("Install.log"); + + logfile << "Warning, exception " << ex.what() << "!"; + setStatusArea("Warning, exception " + (string)ex.what() + "!"); + logfile.close(); } } - + try { //recursive_directory_iterator end_iter; - + out << numberOfDats; datString = out.str(); - try { for ( recursive_directory_iterator dir_itr( vanilla_dir ); dir_itr != end_iter; ++dir_itr ) @@ -584,11 +650,11 @@ void recompileAll(vector install 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) { + for (unsigned 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 << " packages/VanillaDats/" + installedMods[i] + "/oni/"; + //else cout << " VanillaDats/" + installedMods[i] + "/oni/"; } importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; @@ -657,7 +723,7 @@ void recompileAll(vector install if ( is_directory( dir_itr->status() ) ) { importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; - for (int i = 0; i < installedMods.size(); ++i) { + for (unsigned 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(); } @@ -684,10 +750,63 @@ void recompileAll(vector install logfile.close(); }} } + + + + + + + + + + + vector BSLfolders; + vector skippedfolders; + + +ofstream BSLlog("BSL.log"); + for ( directory_iterator dir_itr( "../GameDataFolder/IGMD/" ), end_itr; + dir_itr != end_itr; + ++dir_itr ) { + if( exists(dir_itr->path().string() + "/ignore.txt") ){ + BSLfolders.push_back(dir_itr->path().filename()); + skippedfolders.push_back(dir_itr->path().filename()); + } + } + + for (int i = installedMods.size() - 1; i >= 0; i--) { //Iterates through the installed mods (backwards :P) + for (unsigned int j = 0; j < globalPackages.size(); ++j) { //looking in the global packages + if (globalPackages[j].modStringName == installedMods[i]) { //for a mod that has BSL in it + /*BSLlog << "Testing " << globalPackages[j].modStringName << "\n" + << "HasBSL: " << globalPackages[j].hasBSL << "\n" + << "HasAddon: " << globalPackages[j].hasAddon << "\n";*/ + if(!(globalPackages[j].hasAddon || globalPackages[j].hasBSL)) break; //skip non-BSL + if( exists( "packages/" + globalPackages[j].modStringName + "/BSL/" ) ) { + copyBSL("packages/" + globalPackages[j].modStringName + "/BSL", BSLfolders, globalPackages[j] ); + BSLlog << "Copied " << globalPackages[j].modStringName << "!\n"; + } + + } + + } + } + + ModPackage emptyPackage; + emptyPackage.modStringName = "VanillaBSL"; + emptyPackage.hasBSL = 1; + copyBSL("packages/VanillaBSL/IGMD", BSLfolders, emptyPackage); + BSLlog.close(); + + logfile << "Writing config file"; writeInstalledMods(installedMods); setProgressBar(1000); - setStatusArea("Done! You can now play Oni."); + + string finallyDone = "Done! You can now play Oni."; + + + + setStatusArea(finallyDone); ptime end_time(second_clock::local_time()); time_period total_time (start_time, end_time); @@ -696,7 +815,7 @@ void recompileAll(vector install 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 << "\nInstallation ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length(); //logfile2.write(outstring.c_str(), outstring.length()); logfile2.close(); @@ -705,9 +824,69 @@ void recompileAll(vector install Sleep(1000); setProgressBar(0); + + } + catch(exception & ex) { + remove("Install.log"); //why did we do this? :| + ofstream logfile("Install.log"); + + + logfile << "Warning, exception " << ex.what() << "!"; + setStatusArea("Warning, exception " + (string)ex.what() + "!"); + logfile.close(); + } busy = 0; } +void copyBSL(string copypath, vector& BSLfolders, ModPackage pkg) { + + ofstream BSLlog("BSL2.log", ios::app ); + + try { + for ( directory_iterator dir_itr( copypath ), end_itr; + dir_itr != end_itr; + ++dir_itr ) { + + if ( is_directory( dir_itr->path() ) && dir_itr->path().string() != ".svn" ) { + BSLlog << "Testing " << dir_itr->path().string() << " HasBSL: " << pkg.hasBSL << " HasAddon: " << pkg.hasAddon << "\n"; + int skip_folder = 0; + + for(unsigned int k = 0; k < BSLfolders.size(); k++) {//iterate through already found BSL folders + BSLlog << "testing " << dir_itr->path().filename() << " vs " << BSLfolders[k] << "\n"; + if(dir_itr->path().filename() == BSLfolders[k]) { + skip_folder = 1; + BSLlog << "skipping " << BSLfolders[k] << " in " << pkg.modStringName << "\n"; + break; + } + } + if (!skip_folder && !exists("../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/ignore.txt")) { + remove_all( "../GameDataFolder/IGMD/" + dir_itr->path().filename() ); + Sleep(100); + create_directory( "../GameDataFolder/IGMD/" + dir_itr->path().filename()); + BSLlog << "Copied " << dir_itr->path().string() << " in " << pkg.modStringName << "!\n"; + for ( directory_iterator bsl_itr( dir_itr->path() ); + bsl_itr != end_itr; + bsl_itr++ ) { + if ( bsl_itr->path().extension() == ".bsl" ) { + copy_file(bsl_itr->path(), "../GameDataFolder/IGMD/" + dir_itr->path().filename() + "/" + bsl_itr->path().filename()); + } + } + BSLfolders.push_back( dir_itr->path().filename() ); //add back check for addon + BSLlog << "Pushing " << dir_itr->path().filename() << "\n" ; + } + } + } + } + catch ( const std::exception & ex ) + { + setStatusArea("Warning, exception " + (string)ex.what() + "!"); + while(1) Sleep(1000); + } + BSLlog.close(); + +} + + void writeInstalledMods(vector installedMods) { @@ -789,8 +968,6 @@ void clearOldDats(void) { } -vector globalInstalledMods; -vector globalPackages; #include "boost/thread.hpp" #include @@ -1064,7 +1241,7 @@ void MainWindow::CreateControls() StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 ); StatusArea->SetName(_T("StatusArea")); StatusArea->SetFieldsCount(1); - StatusArea->SetStatusText(_("AE Installer v1.0"), 0); + StatusArea->SetStatusText(_("AE Installer v1.0.1"), 0); itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0); wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL); @@ -1130,19 +1307,41 @@ void MainWindow::CreateControls() // Connect events and objects Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this); ////@end MainWindow content construction +#ifdef WIN32 + Handle = (HWND)GetHWND(); + ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList); +#endif - if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) { + + /*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 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); } @@ -1181,15 +1380,15 @@ void MainWindow::OnSelectAllCheckboxClic { switch(SelectAll->Get3StateValue()) { case wxCHK_UNCHECKED: - for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); + for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); //SelectAll->Set3StateValue(wxCHK_CHECKED); break; case wxCHK_CHECKED: - for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true); + for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true); //SelectAll->Set3StateValue(wxCHK_UNCHECKED); break; case wxCHK_UNDETERMINED: - for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); + for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); //SelectAll->Set3StateValue(wxCHK_CHECKED); break; @@ -1353,19 +1552,29 @@ 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() ) { - + sort(localPackages.begin(), localPackages.end()); + localPackages[0] = "Globalize"; //MainWindow::MainWindow().Hide(); // boost::thread thrd2(recompileAll(localPackages) ); //MainWindow::MainWindow().Show(); @@ -1399,7 +1608,22 @@ void MainWindow::OnInstallButtonClick( w void setProgressBar( int i ) { //TheProgressBar->SetValue( +#ifdef WIN32 + + +if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3))) +{ + + pTaskbarList3->SetProgressValue(Handle,i, 1000); + if ( i == 0 ) { + + pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS); + } +} + + +#endif TheProgressBar->SetValue(i); } @@ -1489,7 +1713,7 @@ void MainWindow::refreshMods (vectorClear(); //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); @@ -1552,7 +1776,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();