[328] | 1 | /*
|
---|
[355] | 2 | AE/Mod Installer
|
---|
| 3 | by Gumby and Iritscen
|
---|
| 4 | */
|
---|
[328] | 5 |
|
---|
[371] | 6 | // To-do: - Load credits from text resource file
|
---|
| 7 | // - Version number in credits should be universalized
|
---|
[353] | 8 | // - Institute lots of checks into file-handling
|
---|
[371] | 9 | // - Clear mod info fields when mod is de-selected
|
---|
[353] | 10 |
|
---|
[328] | 11 | #define DEBUG
|
---|
| 12 | #include <stdio.h>
|
---|
| 13 | //#include <conio.h>
|
---|
| 14 | //#include <process.h>
|
---|
| 15 | #include <string>
|
---|
| 16 | #include <iostream>
|
---|
| 17 | #include <cctype>
|
---|
| 18 | #include <vector>
|
---|
| 19 | #include <fstream>
|
---|
| 20 | #include <errno.h>
|
---|
| 21 | #include <sstream>
|
---|
| 22 |
|
---|
| 23 | #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations
|
---|
[355] | 24 | #include "boost/lexical_cast.hpp" //int -> string
|
---|
[328] | 25 | #include "installer.h"
|
---|
| 26 |
|
---|
| 27 | #ifdef WIN32
|
---|
| 28 | #include <windows.h>
|
---|
| 29 | #else // assume we're on Mac
|
---|
| 30 | #include <stdlib.h>
|
---|
| 31 | #include <dirent.h>
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
| 34 | const string strInstallerVersion = "1.0";
|
---|
| 35 | const bool SPLIT = 1;
|
---|
| 36 | const bool NOT_SPLIT = 0;
|
---|
| 37 | bool splitInstances = SPLIT;
|
---|
[357] | 38 | bool busy = 0;
|
---|
[328] | 39 | #ifdef WIN32
|
---|
| 40 | const string strOniSplit = "Onisplit.exe";
|
---|
| 41 | string strImportOption = "-import:nosep";
|
---|
| 42 | const char* strClsCmd = "cls";
|
---|
| 43 | const char* strPauseCmd = "PAUSE";
|
---|
| 44 | #else // set up Mac equivalents since we're in Mac OS
|
---|
| 45 | const string strOniSplit = "mono Onisplit.exe";
|
---|
| 46 | string strImportOption = "-import:sep";
|
---|
| 47 | const char* strClsCmd = "clear";
|
---|
| 48 | const char* strPauseCmd = "read -n 1 -p \"Press any key to continue\"";
|
---|
[353] | 49 | void Sleep(int ms) { sleep( ms / 1000 ); }
|
---|
[328] | 50 | #endif
|
---|
| 51 |
|
---|
| 52 | using namespace boost::filesystem;
|
---|
| 53 | using namespace std;
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 |
|
---|
[355] | 58 | #include "boost/date_time/gregorian/gregorian.hpp"
|
---|
| 59 | #include "boost/date_time/date_parsing.hpp"
|
---|
| 60 | #include "boost/date_time/posix_time/posix_time.hpp"
|
---|
[328] | 61 |
|
---|
[355] | 62 | int globalizeData(void)
|
---|
[328] | 63 | {
|
---|
[357] | 64 | busy = 1;
|
---|
| 65 | using boost::lexical_cast;
|
---|
| 66 | using boost::bad_lexical_cast;
|
---|
| 67 | // using namespace boost::posix_time;
|
---|
[355] | 68 | using namespace boost::gregorian;
|
---|
| 69 | using namespace boost::posix_time;
|
---|
| 70 | ptime start_time(second_clock::local_time());
|
---|
[328] | 71 |
|
---|
[355] | 72 | setStatusArea("Globalizing!");
|
---|
[328] | 73 | int err = 0;
|
---|
[355] | 74 | int parts_done = 0;
|
---|
| 75 | char Step_x_x[300];
|
---|
| 76 | //char levels[i][5];
|
---|
| 77 | remove("Globalize.log");
|
---|
| 78 | ofstream logfile("Globalize.log");
|
---|
| 79 | logfile << "Globalization started " << to_simple_string(start_time) << endl;
|
---|
[328] | 80 | try {
|
---|
[357] | 81 |
|
---|
[355] | 82 | 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.
|
---|
| 83 | //const vector<double> ck(cv, &cv[CvSize]);
|
---|
| 84 | vector<string> levels;
|
---|
| 85 | for (int f = 0; f < 15; f++) {
|
---|
| 86 | levels.push_back(levels_cstr[f]);
|
---|
| 87 | }
|
---|
[328] | 88 | char choice = 0;
|
---|
[355] | 89 |
|
---|
[328] | 90 | //SetCurrentDirectory("C:/Program Files/Oni/edition/install");
|
---|
[355] | 91 | ///char levels[i][3];
|
---|
[328] | 92 | path Characters = "../GameDataFolder/level0_Characters";
|
---|
| 93 | path Particles = "../GameDataFolder/level0_Particles";
|
---|
| 94 | path Archive = "../GameDataFolder/Archive";
|
---|
| 95 | path Textures = "../GameDataFolder/level0_Textures";
|
---|
| 96 | path Sounds = "../GameDataFolder/level0_Sounds";
|
---|
| 97 | path Animations = "../GameDataFolder/level0_Animations";
|
---|
| 98 | path TRAC = Animations / "level0_TRAC";
|
---|
| 99 | path TRAM = Animations / "level0_TRAM";
|
---|
[357] | 100 |
|
---|
[355] | 101 | vector<path> GDFPaths;
|
---|
| 102 | GDFPaths.push_back(Characters);
|
---|
| 103 | GDFPaths.push_back(Particles);
|
---|
| 104 | GDFPaths.push_back(Textures);
|
---|
| 105 | GDFPaths.push_back(Sounds);
|
---|
| 106 | GDFPaths.push_back(TRAC);
|
---|
| 107 | GDFPaths.push_back(TRAM);
|
---|
[357] | 108 |
|
---|
| 109 |
|
---|
[355] | 110 | path VanillaCharacters = "packages/VanillaDats/level0_Final/level0_Characters/level0_Characters.oni";
|
---|
| 111 | path VanillaParticles = "packages/VanillaDats/level0_Final/level0_Particles/level0_Particles.oni";
|
---|
| 112 | path VanillaTextures = "packages/VanillaDats/level0_Final/level0_Textures/level0_Textures.oni";
|
---|
| 113 | path VanillaSounds = "packages/VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni";
|
---|
| 114 | path VanillaAnimations = "packages/VanillaDats/level0_Final/level0_Animations/level0_Animations.oni";
|
---|
| 115 | path VanillaTRAC = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni";
|
---|
| 116 | path VanillaTRAM = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni";
|
---|
| 117 |
|
---|
| 118 | vector<path> VanillaPaths;
|
---|
[357] | 119 |
|
---|
[355] | 120 | VanillaPaths.push_back(VanillaCharacters);
|
---|
| 121 | VanillaPaths.push_back(VanillaParticles);
|
---|
| 122 | VanillaPaths.push_back(VanillaTextures);
|
---|
| 123 | VanillaPaths.push_back(VanillaSounds);
|
---|
| 124 | VanillaPaths.push_back(VanillaTRAC);
|
---|
| 125 | VanillaPaths.push_back(VanillaTRAM);
|
---|
[357] | 126 |
|
---|
[328] | 127 | /*
|
---|
[355] | 128 | if (exists("../GameDataFolder/"))
|
---|
| 129 | {
|
---|
| 130 | //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.)"
|
---|
| 131 | // << "\n1. Re-globalize"
|
---|
| 132 | // << "\n2. Return to main menu\n";
|
---|
| 133 | //choice = cin.get();
|
---|
| 134 | cin.ignore(128, '\n');
|
---|
| 135 | if (choice == '1')
|
---|
| 136 | remove_all("../GameDataFolder"); // remove AE GDF
|
---|
| 137 | if (choice == '2')
|
---|
| 138 | return 0;
|
---|
| 139 | }
|
---|
| 140 | */
|
---|
| 141 | setStatusArea("Removing old GameDataFolder...\n");
|
---|
| 142 | logfile << "Removing old GameDataFolder...\n";
|
---|
| 143 | remove_all( "../GameDataFolder/" );
|
---|
| 144 | setStatusArea("Creating needed directories...");
|
---|
| 145 | logfile << "Creating needed directories...\n";
|
---|
[328] | 146 | create_directory( "../GameDataFolder/" );
|
---|
[357] | 147 |
|
---|
[328] | 148 | create_directory( "packages" );
|
---|
[357] | 149 |
|
---|
[355] | 150 | if (exists("packages/VanillaDats")) remove_all("packages/VanillaDats");
|
---|
[328] | 151 | create_directory( "packages/VanillaDats" );
|
---|
[357] | 152 |
|
---|
[328] | 153 | create_directory( "packages/VanillaDats/level0_Final/" );
|
---|
[355] | 154 | //blah blah finish this.
|
---|
| 155 | //logfile << "packages/VanillaDats/level0_Final/ created";
|
---|
[328] | 156 | create_directory( Characters );
|
---|
| 157 | create_directory( Particles );
|
---|
| 158 | create_directory( Archive );
|
---|
| 159 | create_directory( Textures );
|
---|
| 160 | create_directory( Sounds );
|
---|
| 161 | create_directory( Animations );
|
---|
| 162 | create_directory( TRAC );
|
---|
| 163 | create_directory( TRAM );
|
---|
[355] | 164 | int num_levels = 0;
|
---|
| 165 | for(int i = 1; i < 15; i++)
|
---|
| 166 | {
|
---|
[357] | 167 | if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) {
|
---|
[355] | 168 | num_levels++;
|
---|
| 169 |
|
---|
| 170 | }
|
---|
| 171 | }
|
---|
| 172 | logfile << "Exporting and moving...\n\n";
|
---|
| 173 | int total_steps = 8 + 2 * num_levels;
|
---|
[328] | 174 | for(int i = 0; i < 15; i++)
|
---|
| 175 | {
|
---|
[357] | 176 |
|
---|
[355] | 177 | //printf(levels[i],"%d",levels[i]); // int to char array
|
---|
[357] | 178 |
|
---|
[355] | 179 | if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) {
|
---|
| 180 | logfile << "level" << levels[i] << "_Final\n";
|
---|
| 181 | logfile << "\tExporting level" << levels[i] << "_Final.dat\n";
|
---|
| 182 | //printf(Step_x_x,"Step %d/%d: exporting level%d_final.dat", parts_done + 1,, levels[i]); setStatusArea((string)Step_x_x);
|
---|
| 183 | setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " exporting level" + levels[i]+"_Final.dat");
|
---|
| 184 | create_directory( "../GameDataFolder/level" + levels[i] + "_Final" );
|
---|
[357] | 185 | // setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat");
|
---|
[355] | 186 | system((strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat").c_str());
|
---|
| 187 | create_directory( "packages/VanillaDats/level" + levels[i] + "_Final" );
|
---|
| 188 | create_directory( "packages/VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" );
|
---|
| 189 |
|
---|
| 190 | directory_iterator end_iter;
|
---|
| 191 | for ( directory_iterator dir_itr( "../GameDataFolder/level" + levels[i] + "_Final" ); dir_itr != end_iter; ++dir_itr )
|
---|
[328] | 192 | {
|
---|
[355] | 193 | //cout << dir_itr->path().filename();
|
---|
| 194 | if ( is_regular_file( dir_itr->status() ) )
|
---|
| 195 | {
|
---|
| 196 | if ( dir_itr->path().filename().substr(0,8) == "TXMPfail" ||
|
---|
| 197 | dir_itr->path().filename().substr(0,9) == "TXMPlevel" ||
|
---|
| 198 | ( dir_itr->path().filename().substr(0,4) == "TXMP" && dir_itr->path().filename().find("intro")!=string::npos) ||
|
---|
| 199 | dir_itr->path().filename().substr(0,4) == "TXMB" ||
|
---|
| 200 | dir_itr->path().filename() == "M3GMpowerup_lsi.oni" ||
|
---|
| 201 | dir_itr->path().filename() == "TXMPlsi_icon.oni" ||
|
---|
| 202 | ( dir_itr->path().filename().substr(0,4) == "TXMB" && dir_itr->path().filename().find("splash_screen.oni")!=string::npos) )
|
---|
| 203 | {
|
---|
| 204 | cout <<dir_itr->path().filename() << "\n";
|
---|
| 205 | create_directory( dir_itr->path().parent_path() / "NoGlobal");
|
---|
| 206 | if(!exists( dir_itr->path().parent_path() / "NoGlobal" / dir_itr->filename())) rename(dir_itr->path(), dir_itr->path().parent_path() / "NoGlobal" /
|
---|
| 207 | dir_itr->filename());
|
---|
| 208 | else remove(dir_itr->path());
|
---|
| 209 | }
|
---|
| 210 | else if (dir_itr->path().filename().substr(0,4) == "TRAC"
|
---|
| 211 | || dir_itr->path().filename().substr(0,4) == "ONVL") {
|
---|
| 212 | cout <<dir_itr->path().filename() << "\n";
|
---|
| 213 | if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename());
|
---|
| 214 | else remove(dir_itr->path());
|
---|
| 215 | }
|
---|
| 216 | else if (dir_itr->path().filename().substr(0,4) == "TRAM") {
|
---|
| 217 | cout <<dir_itr->path().filename() << "\n";
|
---|
| 218 | if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename());
|
---|
| 219 | else remove(dir_itr->path());
|
---|
| 220 | }
|
---|
| 221 | else if (dir_itr->path().filename().substr(0,4) == "ONSK" ||
|
---|
| 222 | dir_itr->path().filename().substr(0,4) == "TXMP") {
|
---|
| 223 | cout <<dir_itr->path().filename() << "\n";\
|
---|
| 224 | create_directory( dir_itr->path().parent_path() / "TexFix");
|
---|
| 225 | if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename());
|
---|
| 226 | //rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename());
|
---|
| 227 | }
|
---|
| 228 | else if (dir_itr->path().filename().substr(0,4) == "ONCC"
|
---|
| 229 | || dir_itr->path().filename().substr(0,4) == "TRBS"
|
---|
| 230 | || dir_itr->path().filename().substr(0,4) == "ONCV"
|
---|
| 231 | || dir_itr->path().filename().substr(0,4) == "TRMA"
|
---|
| 232 | || dir_itr->path().filename().substr(0,4) == "TRSC"
|
---|
| 233 | || dir_itr->path().filename().substr(0,4) == "TRAS") {
|
---|
| 234 | cout <<dir_itr->path().filename() << "\n";
|
---|
| 235 | if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename());
|
---|
| 236 | else remove(dir_itr->path());
|
---|
| 237 | }
|
---|
| 238 | else if (dir_itr->path().filename().substr(0,4) == "OSBD"
|
---|
| 239 | || dir_itr->path().filename().substr(0,4) == "SNDD") {
|
---|
| 240 | cout << dir_itr->path().filename() << "\n";
|
---|
| 241 | if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename());
|
---|
| 242 | else remove(dir_itr->path());
|
---|
| 243 | }
|
---|
| 244 | else if (dir_itr->path().filename().substr(0,5) == "BINA3"
|
---|
| 245 | || dir_itr->path().filename().substr(0,10) == "M3GMdebris"
|
---|
| 246 | || dir_itr->path().filename() == "M3GMtoxic_bubble.oni"
|
---|
| 247 | || dir_itr->path().filename().substr(0,8) == "M3GMelec"
|
---|
| 248 | || dir_itr->path().filename().substr(0,7) == "M3GMrat"
|
---|
| 249 | || dir_itr->path().filename().substr(0,7) == "M3GMjet"
|
---|
| 250 | || dir_itr->path().filename().substr(0,9) == "M3GMbomb_"
|
---|
| 251 | || dir_itr->path().filename() == "M3GMbarab_swave.oni"
|
---|
| 252 | || dir_itr->path().filename() == "M3GMbloodyfoot.oni"
|
---|
| 253 | ){
|
---|
| 254 | cout <<dir_itr->path().filename() << "\n";
|
---|
| 255 | if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename());
|
---|
| 256 | else remove(dir_itr->path());
|
---|
| 257 | }
|
---|
| 258 | else if (dir_itr->path().filename().substr(0,4) == "AGDB"
|
---|
| 259 | || dir_itr->path().filename().substr(0,4) == "TRCM") {
|
---|
| 260 | cout <<dir_itr->path().filename() << "\n";
|
---|
[357] | 261 |
|
---|
[355] | 262 | if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename());
|
---|
| 263 | else remove(dir_itr->path());
|
---|
| 264 | }
|
---|
| 265 | if (exists(dir_itr->path())) {
|
---|
| 266 |
|
---|
| 267 | }
|
---|
| 268 | else {
|
---|
[372] | 269 | //logfile << "\tMoved file: " << dir_itr->path().filename() << "\n";
|
---|
[355] | 270 | }
|
---|
[328] | 271 | }
|
---|
[355] | 272 |
|
---|
| 273 |
|
---|
[357] | 274 |
|
---|
[328] | 275 | }
|
---|
[355] | 276 | logfile << "\tCleaning up TXMPs...\n";
|
---|
| 277 | system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + levels[i] + "_Final/TXMP*.oni").c_str());
|
---|
| 278 | parts_done++;
|
---|
| 279 |
|
---|
| 280 | setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
|
---|
[357] | 281 |
|
---|
[328] | 282 | }
|
---|
| 283 | }
|
---|
[355] | 284 | logfile << "Reimporting levels\n";
|
---|
[328] | 285 | for (int i = 0; i < 15; i++)
|
---|
| 286 | {
|
---|
[355] | 287 | logfile << "\tReimporting level" << levels[i] << "_Final.oni\n";
|
---|
| 288 | //printf(levels[i],"%d",levels[i]);
|
---|
| 289 | //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");
|
---|
| 290 | setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni");
|
---|
| 291 | system( (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final packages/VanillaDats/level" + levels[i] + "_Final/level"
|
---|
[372] | 292 | + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str());
|
---|
[355] | 293 | setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
|
---|
[357] | 294 | parts_done++;
|
---|
[328] | 295 | }
|
---|
| 296 | create_directory( VanillaCharacters.parent_path() );
|
---|
| 297 | create_directory( VanillaParticles.parent_path() );
|
---|
| 298 | create_directory( VanillaTextures.parent_path() );
|
---|
| 299 | create_directory( VanillaSounds.parent_path() );
|
---|
| 300 | create_directory( VanillaAnimations.remove_filename() );
|
---|
[357] | 301 |
|
---|
[355] | 302 | for(int j = 0; j < GDFPaths.size(); j++) {
|
---|
| 303 | logfile << "\tReimporting " << GDFPaths[j].filename() << ".oni\n";
|
---|
[358] | 304 | setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": reimporting " + GDFPaths[j].filename() );
|
---|
[355] | 305 | system((strOniSplit + " " + strImportOption + " " + GDFPaths[j].string() + " " + VanillaPaths[j].string()).c_str());
|
---|
| 306 | parts_done++;
|
---|
| 307 | setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
|
---|
| 308 | }
|
---|
[357] | 309 | /*
|
---|
[355] | 310 | 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) ));
|
---|
[328] | 311 | system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str());
|
---|
[355] | 312 | 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) ));
|
---|
[328] | 313 | system((strOniSplit + " " + strImportOption + " " + Particles.string() + " " + VanillaParticles.string()).c_str());
|
---|
[355] | 314 | 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) ));
|
---|
[328] | 315 | system((strOniSplit + " " + strImportOption + " " + Textures.string() + " " + VanillaTextures.string()).c_str());
|
---|
| 316 | //system((strOniSplit + " " + strImportOption + (string)" " + Animations.string() + (string)" " + VanillaAnimations.string()).c_str());
|
---|
[355] | 317 | 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) ));
|
---|
[328] | 318 | system((strOniSplit + " " + strImportOption + " " + TRAC.string() + " " + VanillaTRAC.string()).c_str());
|
---|
[355] | 319 | 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) ));
|
---|
[328] | 320 | system((strOniSplit + " " + strImportOption + " " + Sounds.string() + " " + VanillaSounds.string()).c_str());
|
---|
[355] | 321 | 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) ));
|
---|
| 322 | system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str());
|
---|
| 323 | //parts_done++; setStatusArea((string)"Copying level scripts...");setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
|
---|
| 324 | if (exists("../GameDataFolder/IGMD")) remove_all("../GameDataFolder/IGMD");
|
---|
[357] | 325 | */
|
---|
[355] | 326 | create_directory((path)"../GameDataFolder/IGMD");
|
---|
[359] | 327 | copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder");
|
---|
[355] | 328 | setProgressBar( 1000 );
|
---|
| 329 | setStatusArea((string)"Done! Now select your mod packages and click install.");
|
---|
[357] | 330 | // while(1) Sleep(-1);
|
---|
| 331 |
|
---|
[328] | 332 | }
|
---|
| 333 | catch (exception ex) {
|
---|
[355] | 334 | setStatusArea("Warning, handled exception: " + (string)ex.what());
|
---|
[328] | 335 | }
|
---|
[357] | 336 |
|
---|
| 337 | ptime end_time(second_clock::local_time());
|
---|
| 338 | time_period total_time (start_time, end_time);
|
---|
| 339 | logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
|
---|
| 340 | //total_time.length().hours();
|
---|
[355] | 341 | logfile.close();
|
---|
[357] | 342 | busy = 0;
|
---|
[328] | 343 | return err;
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 |
|
---|
| 347 | vector<ModPackage> getPackages(void)
|
---|
| 348 | {
|
---|
| 349 | vector<ModPackage> packages;
|
---|
| 350 | packages.reserve(65536); // come on, we shouldn't need this much space...right?!
|
---|
| 351 | fstream file;
|
---|
| 352 | string filename = "\0";
|
---|
| 353 | string MODINFO_CFG = "Mod_Info.cfg";
|
---|
[355] | 354 |
|
---|
[328] | 355 | try
|
---|
| 356 | {
|
---|
| 357 | directory_iterator end_iter;
|
---|
| 358 | for (directory_iterator dir_itr("./packages"); dir_itr != end_iter; ++dir_itr)
|
---|
| 359 | {
|
---|
| 360 | file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str());
|
---|
| 361 | //cout << filename << "\n";
|
---|
[355] | 362 |
|
---|
[328] | 363 | if(!file.fail())
|
---|
| 364 | {
|
---|
| 365 | //cout << dir_itr->path().string() + MODINFO_CFG;
|
---|
| 366 | //would prefer to push a pointer to a package, but this will do for now
|
---|
| 367 | packages.push_back(fileToModPackage(file));
|
---|
| 368 | }
|
---|
| 369 | file.close();
|
---|
| 370 | file.clear();
|
---|
| 371 | }
|
---|
[355] | 372 | sort(packages.begin(), packages.end());
|
---|
[328] | 373 | }
|
---|
| 374 | catch (const std::exception & ex)
|
---|
| 375 | {
|
---|
| 376 | cout << "Warning, something odd happened!\n";
|
---|
| 377 | }
|
---|
[355] | 378 |
|
---|
[328] | 379 | return packages;
|
---|
| 380 | }
|
---|
| 381 |
|
---|
| 382 | ModPackage fileToModPackage(fstream &file)
|
---|
| 383 | {
|
---|
| 384 | /*
|
---|
[355] | 385 | This converts a file to a ModPackage struct.
|
---|
| 386 |
|
---|
| 387 | A few notes...
|
---|
| 388 | "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.
|
---|
| 389 | 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
|
---|
| 390 | slower than reading a variable.
|
---|
| 391 | */
|
---|
[328] | 392 | ModPackage package;
|
---|
| 393 | string line;
|
---|
| 394 | static string NameOfMod = "NameOfMod"; //used for comparing to the current token...
|
---|
| 395 | //I could have done it in reverse (*iter).compare("ModString") or
|
---|
| 396 | static string ARROW = "->"; //did something like "ModString".compare(*iter), and it would have been
|
---|
| 397 | static string ModString = "ModString"; //functionably the same.
|
---|
| 398 | static string HasOnis = "HasOnis";
|
---|
| 399 | static string HasDeltas = "HasDeltas";
|
---|
| 400 | static string HasBSL = "HasBSL";
|
---|
| 401 | static string HasDats = "HasDats";
|
---|
| 402 | static string IsEngine = "IsEngine";
|
---|
| 403 | static string Readme = "Readme";
|
---|
| 404 | static string GlobalNeeded = "GlobalNeeded";
|
---|
| 405 | static string Category = "Category";
|
---|
| 406 | static string Creator = "Creator";
|
---|
| 407 | while (! file.eof() )
|
---|
| 408 | {
|
---|
| 409 | getline (file,line);
|
---|
| 410 | vector<string> tokens;
|
---|
| 411 | vector<string>::iterator iter;
|
---|
| 412 | tokenize(line, tokens); //string to vector of "words"
|
---|
| 413 | if (tokens.capacity() >= 2) { //make sure they are using enough stuff
|
---|
| 414 | iter = tokens.begin(); //what word we are on, starts at first word
|
---|
| 415 | /*
|
---|
[355] | 416 | if (!AEInstallVersion.compare(*iter))
|
---|
| 417 | If mod is too old, skip this mod.
|
---|
| 418 | */
|
---|
[328] | 419 | /*else*/if (!NameOfMod.compare(*iter)) { //if it contains the name
|
---|
| 420 | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment
|
---|
| 421 | if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) { //ignores "->" and "NameOfMod"
|
---|
| 422 | //cout << *iter;
|
---|
| 423 | //cout << " ";
|
---|
| 424 | package.name += *iter + " ";
|
---|
| 425 | }
|
---|
| 426 | }
|
---|
[355] | 427 |
|
---|
[328] | 428 | }
|
---|
| 429 | else if (!ModString.compare(*iter)) {
|
---|
| 430 | iter++; iter++;
|
---|
| 431 | package.modStringName = *iter;
|
---|
| 432 | iter++;
|
---|
| 433 | package.modStringVersion = atoi((*iter).c_str());
|
---|
| 434 | }
|
---|
| 435 | else if (!HasOnis.compare(*iter)) {
|
---|
| 436 | iter++; iter++;
|
---|
| 437 | 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
|
---|
| 438 | 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,
|
---|
[355] | 439 | iter++; iter++;} // using "YFR" would probably set it off. :<
|
---|
| 440 |
|
---|
[328] | 441 | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasBSL = 1;
|
---|
| 442 | }
|
---|
| 443 | else if (!HasDeltas.compare(*iter)) {
|
---|
| 444 | iter++; iter++;
|
---|
| 445 | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1;
|
---|
| 446 | }
|
---|
| 447 | else if (!HasDats.compare(*iter)) {
|
---|
| 448 | iter++; iter++;
|
---|
| 449 | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1;
|
---|
| 450 | }
|
---|
| 451 | else if (!IsEngine.compare(*iter)) {
|
---|
| 452 | iter++; iter++;
|
---|
| 453 | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1;
|
---|
| 454 | }
|
---|
| 455 | else if (!GlobalNeeded.compare(*iter)) {
|
---|
| 456 | iter++; iter++;
|
---|
| 457 | if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1;
|
---|
| 458 | else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; //Really the only place where checking for "No" is important atm.
|
---|
| 459 | }
|
---|
| 460 | else if (!Category.compare(*iter)) {
|
---|
| 461 | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment
|
---|
| 462 | if (ARROW.compare(*iter) && Category.compare(*iter)) { //ignores "->" and "Category"
|
---|
| 463 | //cout << *iter;
|
---|
| 464 | //cout << " ";
|
---|
| 465 | package.category += *iter + " ";
|
---|
| 466 | }
|
---|
| 467 | }
|
---|
| 468 | }
|
---|
| 469 | else if (!Creator.compare(*iter)) { //if it contains the name
|
---|
| 470 | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment
|
---|
| 471 | if (ARROW.compare(*iter) && Creator.compare(*iter)) { //ignores "->" and "Category"
|
---|
| 472 | //cout << *iter;
|
---|
| 473 | //cout << " ";
|
---|
| 474 | package.creator += *iter + " ";
|
---|
| 475 | }
|
---|
| 476 | }
|
---|
| 477 | }
|
---|
| 478 | else if (!Readme.compare(*iter)) { //if it contains the name
|
---|
| 479 | for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment
|
---|
| 480 | if (ARROW.compare(*iter) && Readme.compare(*iter)) { //ignores "->" and "Category"
|
---|
| 481 | if(!(*iter).compare("\\n")) package.readme += '\n';
|
---|
| 482 | else package.readme += *iter + " ";
|
---|
| 483 | }
|
---|
| 484 | }
|
---|
| 485 | }
|
---|
| 486 | }
|
---|
[355] | 487 |
|
---|
[328] | 488 | }
|
---|
| 489 | package.doOutput();
|
---|
| 490 | return package;
|
---|
| 491 | }
|
---|
| 492 |
|
---|
| 493 | void recompileAll(vector<string> installedMods)
|
---|
| 494 | {
|
---|
[357] | 495 | busy = 1;
|
---|
[355] | 496 | using namespace boost::gregorian;
|
---|
| 497 | using namespace boost::posix_time;
|
---|
[357] | 498 | using boost::lexical_cast;
|
---|
| 499 | using boost::bad_lexical_cast;
|
---|
[355] | 500 |
|
---|
[328] | 501 | setStatusArea("Importing levels...");
|
---|
| 502 | //setStatusArea("Recompiling Data...");
|
---|
| 503 | path vanilla_dir = "./packages/VanillaDats/";
|
---|
| 504 | string importCommand = "";
|
---|
| 505 | char statusString[128];
|
---|
| 506 | int numberOfDats = 0;
|
---|
| 507 | int j = 1;
|
---|
| 508 | string datString;
|
---|
| 509 | std::stringstream out;
|
---|
[355] | 510 |
|
---|
| 511 | ptime start_time(second_clock::local_time());
|
---|
[328] | 512 | clearOldDats();
|
---|
[355] | 513 | remove("Install.log");
|
---|
| 514 | ofstream logfile("Install.log");
|
---|
| 515 | logfile << "Mod Installation started " << to_simple_string(start_time) << endl;
|
---|
| 516 | logfile.close();
|
---|
[328] | 517 | if(splitInstances == SPLIT){
|
---|
| 518 | recursive_directory_iterator end_iter;
|
---|
[355] | 519 |
|
---|
[328] | 520 | for ( recursive_directory_iterator dir_itr( vanilla_dir );
|
---|
[355] | 521 | dir_itr != end_iter;
|
---|
| 522 | ++dir_itr )
|
---|
[328] | 523 | {
|
---|
| 524 | try{
|
---|
| 525 | if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1)
|
---|
| 526 | {
|
---|
| 527 | numberOfDats++;
|
---|
| 528 | }
|
---|
| 529 | }
|
---|
| 530 | catch(exception ex) {
|
---|
[355] | 531 |
|
---|
[328] | 532 | }
|
---|
| 533 | }
|
---|
[355] | 534 |
|
---|
[328] | 535 | //recursive_directory_iterator end_iter;
|
---|
[355] | 536 |
|
---|
| 537 |
|
---|
[328] | 538 | out << numberOfDats;
|
---|
| 539 | datString = out.str();
|
---|
| 540 | try {
|
---|
| 541 | for ( recursive_directory_iterator dir_itr( vanilla_dir );
|
---|
[355] | 542 | dir_itr != end_iter;
|
---|
| 543 | ++dir_itr )
|
---|
[328] | 544 | {
|
---|
| 545 | try
|
---|
| 546 | {
|
---|
| 547 | if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1)
|
---|
| 548 | {
|
---|
| 549 | importCommand = strOniSplit + " " + strImportOption + " " + dir_itr->path().parent_path().string() + '/' + dir_itr->path().filename();
|
---|
| 550 | for (int i = 0; i < installedMods.size(); ++i) {
|
---|
| 551 | if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename() ))
|
---|
| 552 | importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename();
|
---|
[355] | 553 |
|
---|
[328] | 554 | //else cout << " packages/VanillaDats/" + installedMods[i] + "/oni/";
|
---|
| 555 | }
|
---|
[355] | 556 | importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
|
---|
| 557 |
|
---|
[357] | 558 |
|
---|
[328] | 559 | setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
|
---|
[357] | 560 | setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " ");
|
---|
[355] | 561 |
|
---|
[328] | 562 | system(importCommand.c_str());
|
---|
| 563 | //Sleep(1000);
|
---|
| 564 | //cout << importCommand << "\n";
|
---|
| 565 | j++;
|
---|
[355] | 566 |
|
---|
[328] | 567 | }
|
---|
| 568 | }
|
---|
| 569 | catch ( const std::exception & ex )
|
---|
| 570 | {
|
---|
[357] | 571 |
|
---|
| 572 | remove("Install.log");
|
---|
| 573 | ofstream logfile("Install.log");
|
---|
| 574 |
|
---|
| 575 |
|
---|
[355] | 576 | logfile << "Warning, exception " << ex.what() << "!";
|
---|
| 577 | setStatusArea("Warning, exception " + (string)ex.what() + "!");
|
---|
[357] | 578 | logfile.close();
|
---|
[328] | 579 | }
|
---|
| 580 | }
|
---|
[355] | 581 |
|
---|
[328] | 582 | }
|
---|
| 583 | catch( const std::exception & ex ) {
|
---|
[357] | 584 |
|
---|
| 585 | remove("Install.log");
|
---|
| 586 | ofstream logfile("Install.log");
|
---|
| 587 |
|
---|
| 588 |
|
---|
| 589 | logfile << "Warning, exception " << ex.what() << "!";
|
---|
| 590 | setStatusArea("Warning, exception " + (string)ex.what() + "!");
|
---|
| 591 | logfile.close();
|
---|
[328] | 592 | }
|
---|
[355] | 593 |
|
---|
[328] | 594 | }
|
---|
| 595 | else if(splitInstances == NOT_SPLIT){
|
---|
| 596 | directory_iterator end_iter;
|
---|
[355] | 597 |
|
---|
[328] | 598 | for ( directory_iterator dir_itr( vanilla_dir );
|
---|
[355] | 599 | dir_itr != end_iter;
|
---|
| 600 | ++dir_itr )
|
---|
[328] | 601 | {
|
---|
[355] | 602 |
|
---|
[328] | 603 | if ( is_directory( dir_itr->status() ) )
|
---|
| 604 | {
|
---|
| 605 | numberOfDats++;
|
---|
| 606 | }
|
---|
[355] | 607 |
|
---|
| 608 |
|
---|
[328] | 609 | }
|
---|
[355] | 610 |
|
---|
[328] | 611 | out << numberOfDats;
|
---|
| 612 | datString = out.str();
|
---|
[355] | 613 |
|
---|
[328] | 614 | for ( directory_iterator dir_itr( vanilla_dir );
|
---|
[355] | 615 | dir_itr != end_iter;
|
---|
| 616 | ++dir_itr )
|
---|
[328] | 617 | {
|
---|
| 618 | try
|
---|
| 619 | {
|
---|
| 620 | if ( is_directory( dir_itr->status() ) )
|
---|
| 621 | {
|
---|
| 622 | importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " " + "../GameDataFolder/" + dir_itr->path().filename()
|
---|
[355] | 623 | + ".dat";
|
---|
[328] | 624 | for (int i = 0; i < installedMods.size(); ++i) {
|
---|
| 625 | if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() ))
|
---|
| 626 | importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename();
|
---|
| 627 | }
|
---|
[355] | 628 | importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
|
---|
| 629 |
|
---|
[357] | 630 |
|
---|
[328] | 631 | setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
|
---|
[357] | 632 | setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " ");
|
---|
[355] | 633 |
|
---|
[328] | 634 | system(importCommand.c_str());
|
---|
[355] | 635 |
|
---|
[328] | 636 | j++;
|
---|
| 637 | }
|
---|
| 638 | }
|
---|
| 639 | catch ( const std::exception & ex )
|
---|
| 640 | {
|
---|
[357] | 641 |
|
---|
| 642 | remove("Install.log");
|
---|
| 643 | ofstream logfile("Install.log");
|
---|
| 644 |
|
---|
| 645 |
|
---|
| 646 | logfile << "Warning, exception " << ex.what() << "!";
|
---|
| 647 | setStatusArea("Warning, exception " + (string)ex.what() + "!");
|
---|
| 648 | logfile.close();
|
---|
[355] | 649 | }}
|
---|
[328] | 650 | }
|
---|
[355] | 651 | logfile << "Writing config file";
|
---|
[328] | 652 | writeInstalledMods(installedMods);
|
---|
| 653 | setProgressBar(1000);
|
---|
[355] | 654 | setStatusArea("Done! You can now play Oni.");
|
---|
| 655 |
|
---|
[357] | 656 | ptime end_time(second_clock::local_time());
|
---|
| 657 | time_period total_time (start_time, end_time);
|
---|
| 658 |
|
---|
| 659 |
|
---|
| 660 | ofstream logfile2("Install.log", ios::app | ios::ate);
|
---|
| 661 | string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length();
|
---|
| 662 |
|
---|
| 663 | logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
|
---|
| 664 |
|
---|
| 665 | //logfile2.write(outstring.c_str(), outstring.length());
|
---|
| 666 | logfile2.close();
|
---|
| 667 |
|
---|
| 668 | //total_time.length().hours();
|
---|
| 669 |
|
---|
[353] | 670 | Sleep(1000);
|
---|
[328] | 671 | setProgressBar(0);
|
---|
[357] | 672 | busy = 0;
|
---|
[328] | 673 | }
|
---|
| 674 |
|
---|
| 675 | void writeInstalledMods(vector<string> installedMods)
|
---|
| 676 | {
|
---|
[355] | 677 |
|
---|
[328] | 678 | if ( exists( strInstallCfg ) )
|
---|
| 679 | {
|
---|
| 680 | remove( strInstallCfg );
|
---|
| 681 | }
|
---|
[355] | 682 |
|
---|
[328] | 683 | ofstream file(strInstallCfg.c_str());
|
---|
[355] | 684 |
|
---|
[328] | 685 | vector<string>list = installedMods;
|
---|
| 686 | vector<string>::iterator begin_iter = list.begin();
|
---|
| 687 | vector<string>::iterator end_iter = list.end();
|
---|
[355] | 688 |
|
---|
[328] | 689 | sort( list.begin(), list.end() );
|
---|
[355] | 690 |
|
---|
[328] | 691 | for( ; begin_iter != end_iter; ++begin_iter) {
|
---|
| 692 | file << *begin_iter << " ";
|
---|
| 693 | }
|
---|
[355] | 694 |
|
---|
[328] | 695 | file.close();
|
---|
| 696 | file.clear();
|
---|
[355] | 697 |
|
---|
[328] | 698 | }
|
---|
| 699 |
|
---|
| 700 | vector<string> getInstallString(string Cfg)
|
---|
| 701 | {
|
---|
| 702 | //system(strPauseCmd);
|
---|
| 703 | vector<string> returnval;
|
---|
[355] | 704 |
|
---|
[328] | 705 | string line;
|
---|
| 706 | fstream file;
|
---|
[355] | 707 |
|
---|
[328] | 708 | if (exists( Cfg ))
|
---|
| 709 | {
|
---|
| 710 | file.open(Cfg.c_str());
|
---|
| 711 | getline(file, line);
|
---|
| 712 | tokenize(line, returnval);
|
---|
| 713 | file.close();
|
---|
| 714 | file.clear();
|
---|
| 715 | sort(returnval.begin(), returnval.end());
|
---|
| 716 | }
|
---|
| 717 | else cout << "fail";
|
---|
[355] | 718 |
|
---|
[328] | 719 | return returnval;
|
---|
| 720 | }
|
---|
| 721 |
|
---|
| 722 | //stolen token function...
|
---|
| 723 | void tokenize(const string& str, vector<string>& tokens, const string& delimiters)
|
---|
| 724 | {
|
---|
| 725 | // Skip delimiters at beginning.
|
---|
| 726 | string::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
---|
| 727 | // Find first "non-delimiter".
|
---|
| 728 | string::size_type pos = str.find_first_of(delimiters, lastPos);
|
---|
[355] | 729 |
|
---|
[328] | 730 | while (string::npos != pos || string::npos != lastPos)
|
---|
| 731 | {
|
---|
| 732 | // Found a token, add it to the vector.
|
---|
| 733 | tokens.push_back(str.substr(lastPos, pos - lastPos));
|
---|
| 734 | // Skip delimiters. Note the "not_of"
|
---|
| 735 | lastPos = str.find_first_not_of(delimiters, pos);
|
---|
| 736 | // Find next "non-delimiter"
|
---|
| 737 | pos = str.find_first_of(delimiters, lastPos);
|
---|
| 738 | }
|
---|
| 739 | }
|
---|
| 740 |
|
---|
| 741 | void clearOldDats(void) {
|
---|
| 742 | directory_iterator end_iter_gdf;
|
---|
| 743 | for ( directory_iterator dir_itr_gdf( "../GameDataFolder" );
|
---|
[355] | 744 | dir_itr_gdf != end_iter_gdf;
|
---|
| 745 | ++dir_itr_gdf )
|
---|
[328] | 746 | {
|
---|
| 747 | //cout << dir_itr_gdf->path().extension() << "\n";
|
---|
| 748 | if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) {
|
---|
| 749 | remove( dir_itr_gdf->path() );
|
---|
| 750 | }
|
---|
[355] | 751 |
|
---|
[328] | 752 | }
|
---|
[355] | 753 |
|
---|
[328] | 754 | }
|
---|
| 755 |
|
---|
| 756 | vector<string> globalInstalledMods;
|
---|
| 757 | vector<ModPackage> globalPackages;
|
---|
| 758 | #include "boost/thread.hpp"
|
---|
| 759 | #include <boost/thread/mutex.hpp>
|
---|
| 760 |
|
---|
| 761 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 762 | // Name: main_window.cpp
|
---|
| 763 | // Purpose:
|
---|
| 764 | // Author:
|
---|
| 765 | // Modified by:
|
---|
| 766 | // Created: 07/05/2009 20:38:25
|
---|
| 767 | // RCS-ID:
|
---|
| 768 | // Copyright:
|
---|
| 769 | // Licence:
|
---|
| 770 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 771 |
|
---|
| 772 | // For compilers that support precompilation, includes "wx/wx.h".
|
---|
| 773 | #include "wx/wxprec.h"
|
---|
| 774 |
|
---|
| 775 | #ifdef __BORLANDC__
|
---|
| 776 | #pragma hdrstop
|
---|
| 777 | #endif
|
---|
| 778 |
|
---|
| 779 | #ifndef WX_PRECOMP
|
---|
| 780 | #include "wx/wx.h"
|
---|
| 781 | #endif
|
---|
| 782 |
|
---|
| 783 | ////@begin includes
|
---|
| 784 | #include "about_window.h"
|
---|
| 785 | ////@end includes
|
---|
| 786 |
|
---|
| 787 | #include "main_window.h"
|
---|
| 788 |
|
---|
| 789 | ////@begin XPM images
|
---|
| 790 | #include "redo.xpm"
|
---|
| 791 | #include "fileopen.xpm"
|
---|
| 792 | #include "filesaveas.xpm"
|
---|
| 793 | #include "quit.xpm"
|
---|
| 794 | ////@end XPM images
|
---|
| 795 |
|
---|
| 796 | //#define wxDebug 1;
|
---|
| 797 | //#define wxUSE_UNICODE 1;
|
---|
| 798 |
|
---|
| 799 | /*
|
---|
[355] | 800 | * MainWindow type definition
|
---|
| 801 | */
|
---|
[328] | 802 |
|
---|
| 803 | IMPLEMENT_CLASS( MainWindow, wxFrame )
|
---|
| 804 |
|
---|
| 805 |
|
---|
| 806 | /*
|
---|
[355] | 807 | * MainWindow event table definition
|
---|
| 808 | */
|
---|
[328] | 809 |
|
---|
| 810 | BEGIN_EVENT_TABLE( MainWindow, wxFrame )
|
---|
| 811 |
|
---|
| 812 | ////@begin MainWindow event table entries
|
---|
[355] | 813 | EVT_CHECKBOX( SelectAll_Checkbox, MainWindow::OnSelectAllCheckboxClick )
|
---|
[328] | 814 |
|
---|
[355] | 815 | EVT_BUTTON( Refresh_Button, MainWindow::OnRefreshButtonClick )
|
---|
[328] | 816 |
|
---|
[355] | 817 | EVT_LISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Selected )
|
---|
| 818 | EVT_CHECKLISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Toggled )
|
---|
[328] | 819 |
|
---|
[355] | 820 | EVT_UPDATE_UI( ID_STATUSBAR, MainWindow::OnStatusbarUpdate )
|
---|
[328] | 821 |
|
---|
[355] | 822 | EVT_BUTTON( Install_Button, MainWindow::OnInstallButtonClick )
|
---|
[328] | 823 |
|
---|
[355] | 824 | EVT_RADIOBUTTON( Sep_RadioButton, MainWindow::OnSepRadioButtonSelected )
|
---|
[328] | 825 |
|
---|
[355] | 826 | EVT_RADIOBUTTON( NoSep_RadioButton, MainWindow::OnNoSepRadioButtonSelected )
|
---|
[328] | 827 |
|
---|
[355] | 828 | EVT_RADIOBUTTON( Separated_RadioButton, MainWindow::OnSeparatedRadioButtonSelected )
|
---|
[328] | 829 |
|
---|
[355] | 830 | EVT_RADIOBUTTON( Complete_RadioButton, MainWindow::OnCompleteRadioButtonSelected )
|
---|
[328] | 831 |
|
---|
[355] | 832 | EVT_BUTTON( ReGlobalize_Button, MainWindow::OnReGlobalizeButtonClick )
|
---|
[328] | 833 |
|
---|
[355] | 834 | EVT_MENU( wxID_LOAD, MainWindow::OnLoadClick )
|
---|
[328] | 835 |
|
---|
[355] | 836 | EVT_MENU( wxID_SAVE, MainWindow::OnSaveClick )
|
---|
[328] | 837 |
|
---|
[355] | 838 | EVT_MENU( wxID_EXIT, MainWindow::OnExitClick )
|
---|
[328] | 839 |
|
---|
[355] | 840 | EVT_MENU( wxID_OPTIONS, MainWindow::OnOptionsClick )
|
---|
[328] | 841 |
|
---|
[355] | 842 | EVT_MENU( wxID_ABOUT, MainWindow::OnAboutClick )
|
---|
[328] | 843 |
|
---|
| 844 | ////@end MainWindow event table entries
|
---|
| 845 |
|
---|
| 846 | END_EVENT_TABLE()
|
---|
| 847 |
|
---|
| 848 |
|
---|
| 849 | /*
|
---|
[355] | 850 | * MainWindow constructors
|
---|
| 851 | */
|
---|
[328] | 852 |
|
---|
| 853 | MainWindow::MainWindow()
|
---|
| 854 | {
|
---|
[355] | 855 | Init();
|
---|
[328] | 856 | }
|
---|
| 857 |
|
---|
| 858 | MainWindow::MainWindow( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
---|
| 859 | {
|
---|
[355] | 860 | Init();
|
---|
| 861 | Create( parent, id, caption, pos, size, style );
|
---|
[328] | 862 | }
|
---|
| 863 |
|
---|
| 864 |
|
---|
| 865 | /*
|
---|
[355] | 866 | * MainWindow creator
|
---|
| 867 | */
|
---|
[328] | 868 |
|
---|
| 869 | bool MainWindow::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
---|
| 870 | {
|
---|
[355] | 871 | ////@begin MainWindow creation
|
---|
| 872 | wxFrame::Create( parent, id, caption, pos, size, style );
|
---|
[328] | 873 |
|
---|
[355] | 874 | CreateControls();
|
---|
| 875 | SetIcon(GetIconResource(wxT("oni_special.ico")));
|
---|
| 876 | Centre();
|
---|
[357] | 877 |
|
---|
| 878 |
|
---|
[355] | 879 | ////@end MainWindow creation
|
---|
| 880 | return true;
|
---|
[328] | 881 | }
|
---|
| 882 |
|
---|
| 883 |
|
---|
| 884 | /*
|
---|
[355] | 885 | * MainWindow destructor
|
---|
| 886 | */
|
---|
[328] | 887 |
|
---|
| 888 | MainWindow::~MainWindow()
|
---|
| 889 | {
|
---|
[355] | 890 | ////@begin MainWindow destruction
|
---|
| 891 | ////@end MainWindow destruction
|
---|
[328] | 892 | }
|
---|
| 893 |
|
---|
| 894 |
|
---|
| 895 | /*
|
---|
[355] | 896 | * Member initialisation
|
---|
| 897 | */
|
---|
[328] | 898 |
|
---|
| 899 | void MainWindow::Init()
|
---|
| 900 | {
|
---|
[355] | 901 | ////@begin MainWindow member initialisation
|
---|
| 902 | MainSplitter = NULL;
|
---|
| 903 | SelectAll = NULL;
|
---|
| 904 | RefreshButton = NULL;
|
---|
| 905 | Mods_CheckboxList = NULL;
|
---|
| 906 | titleText = NULL;
|
---|
| 907 | creatorText = NULL;
|
---|
| 908 | descriptionText = NULL;
|
---|
| 909 | StatusArea = NULL;
|
---|
| 910 | ProgressBar = NULL;
|
---|
| 911 | InstallButton = NULL;
|
---|
| 912 | OptionsPanel = NULL;
|
---|
| 913 | SepRadio = NULL;
|
---|
| 914 | NoSepRadio = NULL;
|
---|
| 915 | SeparatedRadio = NULL;
|
---|
| 916 | CompleteRadio = NULL;
|
---|
| 917 | ReglobalizeButton = NULL;
|
---|
| 918 | ////@end MainWindow member initialisation
|
---|
[328] | 919 |
|
---|
| 920 | }
|
---|
| 921 |
|
---|
| 922 |
|
---|
| 923 | /*
|
---|
[355] | 924 | * Control creation for MainWindow
|
---|
| 925 | */
|
---|
[353] | 926 | wxStatusBar **TheStatusBar;
|
---|
[328] | 927 | wxButton* TheInstallButton;
|
---|
| 928 | wxGauge* TheProgressBar;
|
---|
| 929 | void MainWindow::CreateControls()
|
---|
| 930 | {
|
---|
[355] | 931 | ////@begin MainWindow content construction
|
---|
| 932 | // Generated by DialogBlocks, 31/05/2009 19:03:55 (unregistered)
|
---|
[328] | 933 |
|
---|
[355] | 934 | MainWindow* itemFrame1 = this;
|
---|
[328] | 935 |
|
---|
[355] | 936 | wxMenuBar* menuBar = new wxMenuBar;
|
---|
| 937 | wxMenu* itemMenu37 = new wxMenu;
|
---|
| 938 | {
|
---|
| 939 | wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_LOAD, _("&Load Configuration..."), wxEmptyString, wxITEM_NORMAL);
|
---|
| 940 | wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("fileopen.xpm")));
|
---|
| 941 | menuItem->SetBitmap(bitmap);
|
---|
| 942 | itemMenu37->Append(menuItem);
|
---|
| 943 | }
|
---|
| 944 | {
|
---|
| 945 | wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_SAVE, _("&Save Configuration..."), wxEmptyString, wxITEM_NORMAL);
|
---|
| 946 | wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("filesaveas.xpm")));
|
---|
| 947 | menuItem->SetBitmap(bitmap);
|
---|
| 948 | itemMenu37->Append(menuItem);
|
---|
| 949 | }
|
---|
| 950 | itemMenu37->AppendSeparator();
|
---|
| 951 | {
|
---|
| 952 | wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_EXIT, _("Exit"), wxEmptyString, wxITEM_NORMAL);
|
---|
| 953 | wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("quit.xpm")));
|
---|
| 954 | menuItem->SetBitmap(bitmap);
|
---|
| 955 | itemMenu37->Append(menuItem);
|
---|
| 956 | }
|
---|
| 957 | menuBar->Append(itemMenu37, _("&File"));
|
---|
| 958 | wxMenu* itemMenu42 = new wxMenu;
|
---|
| 959 | itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
|
---|
| 960 | menuBar->Append(itemMenu42, _("Options"));
|
---|
| 961 | wxMenu* itemMenu44 = new wxMenu;
|
---|
| 962 | itemMenu44->Append(wxID_HELP, _("Help"), wxEmptyString, wxITEM_NORMAL);
|
---|
| 963 | itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
|
---|
| 964 | menuBar->Append(itemMenu44, _("Help"));
|
---|
| 965 | itemFrame1->SetMenuBar(menuBar);
|
---|
[357] | 966 |
|
---|
[355] | 967 | wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
|
---|
| 968 | itemFrame1->SetSizer(itemBoxSizer2);
|
---|
[328] | 969 |
|
---|
[355] | 970 | MainSplitter = new wxSplitterWindow( itemFrame1, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 100), wxSP_LIVE_UPDATE|wxNO_BORDER );
|
---|
| 971 | MainSplitter->SetMinimumPaneSize(150);
|
---|
| 972 | MainSplitter->SetName(_T("MainSplitter"));
|
---|
[328] | 973 |
|
---|
[355] | 974 | wxPanel* itemPanel4 = new wxPanel( MainSplitter, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
|
---|
| 975 | wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
|
---|
| 976 | itemPanel4->SetSizer(itemBoxSizer5);
|
---|
[328] | 977 |
|
---|
[355] | 978 | wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
|
---|
| 979 | itemBoxSizer5->Add(itemBoxSizer6, 0, wxGROW|wxALL, 0);
|
---|
| 980 | SelectAll = new wxCheckBox( itemPanel4, SelectAll_Checkbox, _("Select All/None"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE );
|
---|
| 981 | SelectAll->SetValue(false);
|
---|
| 982 | SelectAll->SetName(_T("SelectAll_Checkbox"));
|
---|
| 983 | itemBoxSizer6->Add(SelectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
---|
[328] | 984 |
|
---|
[355] | 985 | RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("redo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
|
---|
| 986 | RefreshButton->SetName(_T("RefreshButton"));
|
---|
| 987 | itemBoxSizer6->Add(RefreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
|
---|
[328] | 988 |
|
---|
[355] | 989 | wxArrayString Mods_CheckboxListStrings;
|
---|
| 990 | Mods_CheckboxList = new wxCheckListBox( itemPanel4, Mods_CheckboxList1, wxDefaultPosition, wxDefaultSize, Mods_CheckboxListStrings, wxLB_HSCROLL );
|
---|
| 991 | Mods_CheckboxList->SetName(_T("Mods_CheckboxList"));
|
---|
| 992 | itemBoxSizer5->Add(Mods_CheckboxList, 1, wxGROW|wxALL, 0);
|
---|
[328] | 993 |
|
---|
[355] | 994 | wxPanel* itemPanel10 = new wxPanel( MainSplitter, DescriptionHolder_Panel, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
|
---|
| 995 | itemPanel10->SetName(_T("DescriptionHolder_Panel"));
|
---|
| 996 | wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL);
|
---|
| 997 | itemPanel10->SetSizer(itemBoxSizer11);
|
---|
[328] | 998 |
|
---|
[355] | 999 | wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
|
---|
| 1000 | itemBoxSizer11->Add(itemBoxSizer12, 0, wxGROW|wxALL, 0);
|
---|
| 1001 | wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1002 | itemBoxSizer12->Add(itemBoxSizer13, 1, wxALIGN_CENTER_VERTICAL|wxALL, 0);
|
---|
| 1003 | titleText = new wxTextCtrl( itemPanel10, Title_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
---|
| 1004 | titleText->SetName(_T("Title_Text"));
|
---|
| 1005 | titleText->SetBackgroundColour(wxColour(240, 240, 240));
|
---|
| 1006 | itemBoxSizer13->Add(titleText, 1, wxGROW|wxLEFT, 5);
|
---|
[328] | 1007 |
|
---|
[355] | 1008 | wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1009 | itemBoxSizer12->Add(itemBoxSizer15, 1, wxGROW|wxALL, 0);
|
---|
| 1010 | creatorText = new wxTextCtrl( itemPanel10, Author_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_RIGHT );
|
---|
| 1011 | creatorText->SetName(_T("Author_Text"));
|
---|
| 1012 | creatorText->SetBackgroundColour(wxColour(240, 240, 240));
|
---|
| 1013 | itemBoxSizer15->Add(creatorText, 1, wxGROW|wxRIGHT, 5);
|
---|
[328] | 1014 |
|
---|
[355] | 1015 | wxStaticLine* itemStaticLine17 = new wxStaticLine( itemPanel10, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
---|
| 1016 | itemStaticLine17->Show(false);
|
---|
| 1017 | itemBoxSizer11->Add(itemStaticLine17, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1018 |
|
---|
[355] | 1019 | descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_AUTO_URL );
|
---|
| 1020 | descriptionText->SetName(_T("DescriptionName"));
|
---|
| 1021 | descriptionText->SetBackgroundColour(wxColour(240, 240, 240));
|
---|
| 1022 | itemBoxSizer11->Add(descriptionText, 1, wxGROW|wxLEFT|wxRIGHT, 5);
|
---|
[328] | 1023 |
|
---|
[355] | 1024 | MainSplitter->SplitVertically(itemPanel4, itemPanel10, 150);
|
---|
| 1025 | itemBoxSizer2->Add(MainSplitter, 1, wxGROW|wxALL, 0);
|
---|
[328] | 1026 |
|
---|
[355] | 1027 | StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 );
|
---|
| 1028 | StatusArea->SetName(_T("StatusArea"));
|
---|
| 1029 | StatusArea->SetFieldsCount(1);
|
---|
| 1030 | StatusArea->SetStatusText(_("Status Area"), 0);
|
---|
| 1031 | itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0);
|
---|
[328] | 1032 |
|
---|
[355] | 1033 | wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
|
---|
| 1034 | itemBoxSizer2->Add(itemBoxSizer20, 0, wxGROW|wxALL, 0);
|
---|
[328] | 1035 |
|
---|
[355] | 1036 | ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxSize(-1, 30), wxGA_SMOOTH );
|
---|
| 1037 | ProgressBar->SetValue(0);
|
---|
| 1038 | itemBoxSizer20->Add(ProgressBar, 1, wxGROW|wxALL, 0);
|
---|
[328] | 1039 |
|
---|
[355] | 1040 | InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxSize(-1, 30), 0 );
|
---|
| 1041 | itemBoxSizer20->Add(InstallButton, 0, wxGROW|wxALL, 0);
|
---|
[328] | 1042 |
|
---|
[355] | 1043 | wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1044 | itemBoxSizer2->Add(itemBoxSizer23, 0, wxGROW|wxALL, 0);
|
---|
[328] | 1045 |
|
---|
[355] | 1046 | OptionsPanel = new wxPanel( itemFrame1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
|
---|
| 1047 | itemBoxSizer2->Add(OptionsPanel, 0, wxGROW, 0);
|
---|
[328] | 1048 |
|
---|
[355] | 1049 | wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL);
|
---|
| 1050 | OptionsPanel->SetSizer(itemBoxSizer25);
|
---|
[328] | 1051 |
|
---|
[355] | 1052 | wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1053 | itemBoxSizer25->Add(itemBoxSizer26, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1054 |
|
---|
[355] | 1055 | SepRadio = new wxRadioButton( OptionsPanel, Sep_RadioButton, _("Sep"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
---|
| 1056 | SepRadio->SetValue(false);
|
---|
| 1057 | if (MainWindow::ShowToolTips())
|
---|
| 1058 | SepRadio->SetToolTip(_("For PC Demo and Mac"));
|
---|
| 1059 | itemBoxSizer26->Add(SepRadio, 0, wxALIGN_LEFT|wxALL, 5);
|
---|
[328] | 1060 |
|
---|
[355] | 1061 | NoSepRadio = new wxRadioButton( OptionsPanel, NoSep_RadioButton, _("NoSep"), wxDefaultPosition, wxDefaultSize, 0 );
|
---|
| 1062 | NoSepRadio->SetValue(false);
|
---|
| 1063 | if (MainWindow::ShowToolTips())
|
---|
| 1064 | NoSepRadio->SetToolTip(_("For PC Retail"));
|
---|
| 1065 | itemBoxSizer26->Add(NoSepRadio, 0, wxALIGN_LEFT|wxALL, 5);
|
---|
[328] | 1066 |
|
---|
[355] | 1067 | wxStaticLine* itemStaticLine29 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
|
---|
| 1068 | itemBoxSizer25->Add(itemStaticLine29, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1069 |
|
---|
[355] | 1070 | wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1071 | itemBoxSizer25->Add(itemBoxSizer30, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1072 |
|
---|
[355] | 1073 | SeparatedRadio = new wxRadioButton( OptionsPanel, Separated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
---|
| 1074 | SeparatedRadio->SetValue(false);
|
---|
| 1075 | SeparatedRadio->SetName(_T("Separated_RadioButton"));
|
---|
| 1076 | itemBoxSizer30->Add(SeparatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
|
---|
[328] | 1077 |
|
---|
[355] | 1078 | CompleteRadio = new wxRadioButton( OptionsPanel, Complete_RadioButton, _("Complete Level0"), wxDefaultPosition, wxDefaultSize, 0 );
|
---|
| 1079 | CompleteRadio->SetValue(false);
|
---|
| 1080 | CompleteRadio->SetName(_T("Complete_RadioButton"));
|
---|
| 1081 | itemBoxSizer30->Add(CompleteRadio, 0, wxALIGN_LEFT|wxALL, 5);
|
---|
[328] | 1082 |
|
---|
[355] | 1083 | wxStaticLine* itemStaticLine33 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
|
---|
| 1084 | itemBoxSizer25->Add(itemStaticLine33, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1085 |
|
---|
[355] | 1086 | wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1087 | itemBoxSizer25->Add(itemBoxSizer34, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
---|
[328] | 1088 |
|
---|
[355] | 1089 | ReglobalizeButton = new wxButton( OptionsPanel, ReGlobalize_Button, _("Reglobalize"), wxDefaultPosition, wxDefaultSize, 0 );
|
---|
| 1090 | ReglobalizeButton->SetName(_T("Reglobalize_Button"));
|
---|
| 1091 | itemBoxSizer34->Add(ReglobalizeButton, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1092 |
|
---|
[355] | 1093 | // Connect events and objects
|
---|
| 1094 | Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this);
|
---|
| 1095 | ////@end MainWindow content construction
|
---|
| 1096 |
|
---|
[328] | 1097 | if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
|
---|
| 1098 | static_cast<string>("-import:sep");
|
---|
| 1099 | splitInstances = NOT_SPLIT;
|
---|
| 1100 | }
|
---|
| 1101 | else {
|
---|
| 1102 | static_cast<string>("-import:nosep");
|
---|
| 1103 | splitInstances = SPLIT;
|
---|
| 1104 | }
|
---|
| 1105 |
|
---|
| 1106 | globalPackages = getPackages();
|
---|
| 1107 | globalInstalledMods = getInstallString();
|
---|
[355] | 1108 | for (int i = 0; i < globalPackages.size(); i++) {
|
---|
| 1109 | Mods_CheckboxList->Append(globalPackages[i].name.c_str());
|
---|
| 1110 | if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
|
---|
[328] | 1111 | }
|
---|
| 1112 |
|
---|
[355] | 1113 | TheStatusBar = &StatusArea;
|
---|
| 1114 | TheInstallButton = InstallButton;
|
---|
| 1115 | TheProgressBar = ProgressBar;
|
---|
| 1116 | OptionsPanel->Hide();
|
---|
| 1117 | if(splitInstances == SPLIT) SeparatedRadio->SetValue(true);
|
---|
| 1118 | else CompleteRadio->SetValue(true);
|
---|
| 1119 |
|
---|
| 1120 |
|
---|
| 1121 |
|
---|
| 1122 | if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
|
---|
| 1123 | else SepRadio->SetValue(true);
|
---|
[357] | 1124 |
|
---|
| 1125 |
|
---|
[355] | 1126 | #ifdef WIN32
|
---|
| 1127 | RedirectIOToConsole();
|
---|
| 1128 | HWND hWnd = GetConsoleWindow();
|
---|
| 1129 | ShowWindow( hWnd, SW_HIDE );
|
---|
| 1130 | #endif
|
---|
[357] | 1131 |
|
---|
| 1132 | //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
|
---|
[328] | 1133 | }
|
---|
| 1134 |
|
---|
[355] | 1135 |
|
---|
[328] | 1136 | /*
|
---|
[355] | 1137 | * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
|
---|
| 1138 | */
|
---|
[328] | 1139 |
|
---|
| 1140 | void MainWindow::OnSelectAllCheckboxClick( wxCommandEvent& event )
|
---|
| 1141 | {
|
---|
[355] | 1142 | switch(SelectAll->Get3StateValue()) {
|
---|
[328] | 1143 | case wxCHK_UNCHECKED:
|
---|
| 1144 | for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
|
---|
| 1145 | //SelectAll->Set3StateValue(wxCHK_CHECKED);
|
---|
| 1146 | break;
|
---|
| 1147 | case wxCHK_CHECKED:
|
---|
| 1148 | for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true);
|
---|
| 1149 | //SelectAll->Set3StateValue(wxCHK_UNCHECKED);
|
---|
| 1150 | break;
|
---|
| 1151 | case wxCHK_UNDETERMINED:
|
---|
| 1152 | for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
|
---|
| 1153 | //SelectAll->Set3StateValue(wxCHK_CHECKED);
|
---|
| 1154 | break;
|
---|
| 1155 |
|
---|
| 1156 | }
|
---|
[355] | 1157 |
|
---|
[328] | 1158 | }
|
---|
| 1159 |
|
---|
| 1160 |
|
---|
| 1161 | /*
|
---|
[355] | 1162 | * wxEVT_CREATE event handler for Mods_CheckboxList
|
---|
| 1163 | */
|
---|
[328] | 1164 |
|
---|
| 1165 | void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event )
|
---|
| 1166 | {
|
---|
| 1167 |
|
---|
| 1168 |
|
---|
| 1169 | }
|
---|
| 1170 |
|
---|
| 1171 |
|
---|
| 1172 | /*
|
---|
[355] | 1173 | * Should we show tooltips?
|
---|
| 1174 | */
|
---|
[328] | 1175 |
|
---|
| 1176 | bool MainWindow::ShowToolTips()
|
---|
| 1177 | {
|
---|
[355] | 1178 | return true;
|
---|
[328] | 1179 | }
|
---|
| 1180 |
|
---|
| 1181 | /*
|
---|
[355] | 1182 | * Get bitmap resources
|
---|
| 1183 | */
|
---|
[328] | 1184 |
|
---|
| 1185 | wxBitmap MainWindow::GetBitmapResource( const wxString& name )
|
---|
| 1186 | {
|
---|
[355] | 1187 | // Bitmap retrieval
|
---|
| 1188 | ////@begin MainWindow bitmap retrieval
|
---|
| 1189 | wxUnusedVar(name);
|
---|
| 1190 | if (name == _T("redo.xpm"))
|
---|
| 1191 | {
|
---|
| 1192 | wxBitmap bitmap(redo_xpm);
|
---|
| 1193 | return bitmap;
|
---|
| 1194 | }
|
---|
| 1195 | else if (name == _T("fileopen.xpm"))
|
---|
| 1196 | {
|
---|
| 1197 | wxBitmap bitmap( fileopen_xpm);
|
---|
| 1198 | return bitmap;
|
---|
| 1199 | }
|
---|
| 1200 | else if (name == _T("filesaveas.xpm"))
|
---|
| 1201 | {
|
---|
| 1202 | wxBitmap bitmap( filesaveas_xpm);
|
---|
| 1203 | return bitmap;
|
---|
| 1204 | }
|
---|
| 1205 | else if (name == _T("quit.xpm"))
|
---|
| 1206 | {
|
---|
| 1207 | wxBitmap bitmap( quit_xpm);
|
---|
| 1208 | return bitmap;
|
---|
| 1209 | }
|
---|
| 1210 | return wxNullBitmap;
|
---|
| 1211 | ////@end MainWindow bitmap retrieval
|
---|
[328] | 1212 | }
|
---|
| 1213 |
|
---|
| 1214 | /*
|
---|
[355] | 1215 | * Get icon resources
|
---|
| 1216 | */
|
---|
[328] | 1217 |
|
---|
| 1218 | wxIcon MainWindow::GetIconResource( const wxString& name )
|
---|
| 1219 | {
|
---|
[355] | 1220 |
|
---|
| 1221 | // Icon retrieval
|
---|
| 1222 | ////@begin MainWindow icon retrieval
|
---|
| 1223 | wxUnusedVar(name);
|
---|
| 1224 | if (name == _T("oni_special.ico"))
|
---|
| 1225 | {
|
---|
[357] | 1226 | // wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO);
|
---|
| 1227 | // return icon;
|
---|
[355] | 1228 | }
|
---|
| 1229 | return wxNullIcon;
|
---|
| 1230 | ////@end MainWindow icon retrieval
|
---|
[328] | 1231 | }
|
---|
| 1232 |
|
---|
| 1233 |
|
---|
| 1234 | /*
|
---|
[355] | 1235 | * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
|
---|
| 1236 | */
|
---|
[328] | 1237 |
|
---|
| 1238 | void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event )
|
---|
| 1239 | {
|
---|
| 1240 | //event.GetSelection
|
---|
| 1241 | titleText->SetValue(globalPackages[event.GetSelection()].name.c_str());
|
---|
| 1242 | creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str());
|
---|
| 1243 | descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str());
|
---|
| 1244 |
|
---|
[353] | 1245 | //creatorText->Refresh();
|
---|
[328] | 1246 | }
|
---|
| 1247 |
|
---|
| 1248 |
|
---|
| 1249 | /*
|
---|
[355] | 1250 | * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
|
---|
| 1251 | */
|
---|
[328] | 1252 |
|
---|
| 1253 | void MainWindow::OnModsCheckboxList1Toggled( wxCommandEvent& event )
|
---|
| 1254 | {
|
---|
| 1255 | SelectAll->Set3StateValue(wxCHK_UNDETERMINED);
|
---|
| 1256 | if(event.GetInt()) {
|
---|
[355] | 1257 | /*
|
---|
[328] | 1258 | switch(SelectAll->Get3StateValue()) {
|
---|
[355] | 1259 | case wxCHK_UNCHECKED:
|
---|
[328] | 1260 | break;
|
---|
[355] | 1261 | case wxCHK_CHECKED:
|
---|
[328] | 1262 | break;
|
---|
[355] | 1263 | case wxCHK_UNDETERMINED :
|
---|
[328] | 1264 | break;
|
---|
[355] | 1265 | }
|
---|
| 1266 | */
|
---|
[328] | 1267 | }
|
---|
| 1268 | }
|
---|
| 1269 |
|
---|
| 1270 |
|
---|
| 1271 | /*
|
---|
[355] | 1272 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
|
---|
| 1273 | */
|
---|
[328] | 1274 |
|
---|
| 1275 | void MainWindow::OnOptionsClick( wxCommandEvent& event )
|
---|
| 1276 | {
|
---|
| 1277 | if (!event.GetInt() ) {
|
---|
| 1278 | OptionsPanel->Hide();
|
---|
[358] | 1279 | this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
|
---|
[328] | 1280 | else {
|
---|
[358] | 1281 | // Uncomment this when we release, it gets annoying if you are testing globalization a lot ;)
|
---|
[373] | 1282 | wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: These options are for advanced users only, use with caution.",
|
---|
| 1283 | "AE Installer Alert", wxOK | wxICON_EXCLAMATION , wxDefaultPosition);
|
---|
[358] | 1284 | YesNoDialog->ShowModal();
|
---|
[328] | 1285 | OptionsPanel->Show();
|
---|
[373] | 1286 | this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight()+2);
|
---|
[328] | 1287 | }
|
---|
| 1288 | }
|
---|
| 1289 |
|
---|
| 1290 |
|
---|
| 1291 | /*
|
---|
[355] | 1292 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
|
---|
| 1293 | */
|
---|
[328] | 1294 |
|
---|
| 1295 | void MainWindow::OnExitClick( wxCommandEvent& event )
|
---|
| 1296 | {
|
---|
[355] | 1297 | exit(0);
|
---|
[328] | 1298 | }
|
---|
| 1299 |
|
---|
| 1300 |
|
---|
| 1301 | /*
|
---|
[355] | 1302 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
|
---|
| 1303 | */
|
---|
[328] | 1304 |
|
---|
| 1305 |
|
---|
| 1306 | struct recompile
|
---|
| 1307 | {
|
---|
[355] | 1308 | recompile(vector<string> localPackages) : thePackages(localPackages) { }
|
---|
| 1309 | void operator()()
|
---|
| 1310 | {
|
---|
[328] | 1311 | TheInstallButton->Disable();
|
---|
[355] | 1312 | recompileAll(thePackages);
|
---|
| 1313 | TheInstallButton->Enable();
|
---|
| 1314 | }
|
---|
[328] | 1315 |
|
---|
[355] | 1316 | vector<string> thePackages;
|
---|
[328] | 1317 | };
|
---|
| 1318 |
|
---|
| 1319 | void MainWindow::OnInstallButtonClick( wxCommandEvent& event )
|
---|
| 1320 | {
|
---|
[355] | 1321 |
|
---|
[328] | 1322 | vector<string> localPackages;
|
---|
| 1323 | localPackages.push_back("Globalize");
|
---|
| 1324 | for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
|
---|
| 1325 | if ( !localPackages.empty() ) {
|
---|
[357] | 1326 |
|
---|
[328] | 1327 | //MainWindow::MainWindow().Hide();
|
---|
[355] | 1328 | // boost::thread thrd2(recompileAll(localPackages) );
|
---|
[328] | 1329 | //MainWindow::MainWindow().Show();
|
---|
[357] | 1330 | this->InstallButton->Disable();
|
---|
| 1331 | this->ReglobalizeButton->Disable();
|
---|
[353] | 1332 | #ifdef WIN32
|
---|
| 1333 | recompile packages(localPackages);
|
---|
| 1334 | boost::thread thrd(packages);
|
---|
| 1335 | #else
|
---|
| 1336 | recompileAll(localPackages);
|
---|
| 1337 | #endif
|
---|
[328] | 1338 |
|
---|
[357] | 1339 | this->InstallButton->Enable();
|
---|
| 1340 | this->ReglobalizeButton->Enable();
|
---|
[328] | 1341 | }
|
---|
[355] | 1342 |
|
---|
| 1343 |
|
---|
[328] | 1344 | }
|
---|
| 1345 |
|
---|
[353] | 1346 | /*void setStatusArea( string s ) {
|
---|
[355] | 1347 | //TheStatusBar = MainWindow::StatusArea;
|
---|
| 1348 | (**TheStatusBar).SetStatusText(_(s.c_str()), 0);
|
---|
| 1349 |
|
---|
| 1350 | //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
|
---|
| 1351 |
|
---|
| 1352 | //MainWindow::StatusBar->SetLabel("Importing Files...");
|
---|
| 1353 | //StatusBar->SetLabel(s);
|
---|
[328] | 1354 | //->SetLabel(s);
|
---|
[355] | 1355 |
|
---|
[353] | 1356 | }*/
|
---|
[328] | 1357 |
|
---|
| 1358 | void setProgressBar( int i ) {
|
---|
[355] | 1359 | //TheProgressBar->SetValue(
|
---|
[328] | 1360 |
|
---|
| 1361 | TheProgressBar->SetValue(i);
|
---|
| 1362 |
|
---|
| 1363 | }
|
---|
| 1364 |
|
---|
| 1365 |
|
---|
| 1366 | /*
|
---|
[355] | 1367 | * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
|
---|
| 1368 | */
|
---|
[328] | 1369 |
|
---|
| 1370 | void MainWindow::OnStatusbarUpdate( wxUpdateUIEvent& event )
|
---|
| 1371 | {
|
---|
[355] | 1372 | ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
|
---|
| 1373 | // Before editing this code, remove the block markers.
|
---|
| 1374 | event.Skip();
|
---|
| 1375 | ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
|
---|
[328] | 1376 | }
|
---|
| 1377 |
|
---|
| 1378 |
|
---|
| 1379 | /*
|
---|
[355] | 1380 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
|
---|
| 1381 | */
|
---|
[328] | 1382 |
|
---|
| 1383 | void MainWindow::OnAboutClick( wxCommandEvent& event )
|
---|
| 1384 | {
|
---|
[355] | 1385 | ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
|
---|
| 1386 | // Before editing this code, remove the block markers.
|
---|
| 1387 | About* window = new About(this);
|
---|
| 1388 | int returnValue = window->ShowModal();
|
---|
| 1389 | window->Destroy();
|
---|
| 1390 | ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
|
---|
[328] | 1391 | }
|
---|
| 1392 |
|
---|
| 1393 |
|
---|
| 1394 | /*
|
---|
[355] | 1395 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
|
---|
| 1396 | */
|
---|
[328] | 1397 |
|
---|
| 1398 | void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event )
|
---|
| 1399 | {
|
---|
| 1400 | static_cast<string>("-import:nosep");
|
---|
| 1401 | }
|
---|
| 1402 |
|
---|
| 1403 |
|
---|
| 1404 | /*
|
---|
[355] | 1405 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
|
---|
| 1406 | */
|
---|
[328] | 1407 |
|
---|
| 1408 | void MainWindow::OnSepRadioButtonSelected( wxCommandEvent& event )
|
---|
| 1409 | {
|
---|
| 1410 | static_cast<string>("-import:sep");
|
---|
| 1411 | }
|
---|
| 1412 |
|
---|
| 1413 |
|
---|
| 1414 | /*
|
---|
[355] | 1415 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
|
---|
| 1416 | */
|
---|
[328] | 1417 |
|
---|
| 1418 | void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
|
---|
| 1419 | {
|
---|
[355] | 1420 | splitInstances = SPLIT;
|
---|
[328] | 1421 |
|
---|
| 1422 | }
|
---|
| 1423 |
|
---|
| 1424 |
|
---|
| 1425 | /*
|
---|
[355] | 1426 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
|
---|
| 1427 | */
|
---|
[328] | 1428 |
|
---|
| 1429 | void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event )
|
---|
| 1430 | {
|
---|
[355] | 1431 | splitInstances = NOT_SPLIT;
|
---|
[328] | 1432 |
|
---|
| 1433 | }
|
---|
| 1434 |
|
---|
| 1435 |
|
---|
| 1436 | /*
|
---|
[355] | 1437 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
|
---|
| 1438 | */
|
---|
[328] | 1439 |
|
---|
| 1440 | void MainWindow::OnRefreshButtonClick( wxCommandEvent& event )
|
---|
| 1441 | {
|
---|
| 1442 | refreshMods(globalInstalledMods);
|
---|
| 1443 | }
|
---|
| 1444 |
|
---|
| 1445 |
|
---|
| 1446 | /*
|
---|
[355] | 1447 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
|
---|
| 1448 | */
|
---|
[328] | 1449 |
|
---|
| 1450 |
|
---|
| 1451 |
|
---|
| 1452 |
|
---|
| 1453 | void MainWindow::refreshMods (vector<string> s) {
|
---|
[355] | 1454 |
|
---|
[328] | 1455 | Mods_CheckboxList->Clear();
|
---|
[355] | 1456 | //globalInstalledMods = getPackages();
|
---|
| 1457 | for (int i = 0; i < globalPackages.size(); i++) {
|
---|
| 1458 | Mods_CheckboxList->Append(globalPackages[i].name.c_str());
|
---|
| 1459 | if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
|
---|
| 1460 | //else Mods_CheckboxList->Check(i,0);
|
---|
| 1461 |
|
---|
| 1462 | }
|
---|
[328] | 1463 | }
|
---|
| 1464 |
|
---|
| 1465 | void MainWindow::OnLoadClick( wxCommandEvent& event )
|
---|
| 1466 | {
|
---|
[357] | 1467 | if (busy == 1) return;
|
---|
[328] | 1468 | static const wxChar *FILETYPES = _T(
|
---|
| 1469 | "Mod Loadouts (*.cfg)|*.cfg|"
|
---|
| 1470 | "All files (*.*)|*.*"
|
---|
[355] | 1471 | );
|
---|
| 1472 |
|
---|
[328] | 1473 | wxFileDialog* openFileDialog =
|
---|
| 1474 | new wxFileDialog( this, _("Open Mod Loadout"), "", "", FILETYPES,
|
---|
[355] | 1475 | wxOPEN, wxDefaultPosition);
|
---|
| 1476 |
|
---|
[328] | 1477 | if ( openFileDialog->ShowModal() == wxID_OK )
|
---|
| 1478 | {
|
---|
| 1479 | refreshMods(getInstallString( string(openFileDialog->GetPath()) ));
|
---|
| 1480 | }
|
---|
| 1481 |
|
---|
| 1482 |
|
---|
| 1483 | }
|
---|
| 1484 |
|
---|
| 1485 |
|
---|
| 1486 | /*
|
---|
[355] | 1487 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
|
---|
| 1488 | */
|
---|
[328] | 1489 |
|
---|
| 1490 | void MainWindow::OnSaveClick( wxCommandEvent& event )
|
---|
| 1491 | {
|
---|
[357] | 1492 | if (busy == 1) return;
|
---|
[328] | 1493 | static const wxChar *FILETYPES = _T(
|
---|
| 1494 | "Mod Loadouts (*.cfg)|*.cfg|"
|
---|
| 1495 | "All files (*.*)|*.*"
|
---|
[355] | 1496 | );
|
---|
[328] | 1497 |
|
---|
[355] | 1498 | wxFileDialog* openFileDialog =
|
---|
[328] | 1499 | new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
|
---|
| 1500 | wxSAVE, wxDefaultPosition);
|
---|
| 1501 |
|
---|
| 1502 | if ( openFileDialog->ShowModal() == wxID_OK )
|
---|
| 1503 | {
|
---|
| 1504 |
|
---|
| 1505 |
|
---|
[355] | 1506 | //Mods_CheckboxList->
|
---|
[328] | 1507 |
|
---|
| 1508 |
|
---|
[355] | 1509 |
|
---|
[328] | 1510 | //
|
---|
[355] | 1511 |
|
---|
[328] | 1512 | if ( exists( openFileDialog->GetPath().c_str() ) )
|
---|
[355] | 1513 | {
|
---|
| 1514 | remove( openFileDialog->GetPath().c_str() );
|
---|
| 1515 | }
|
---|
[328] | 1516 |
|
---|
[355] | 1517 | ofstream file(openFileDialog->GetPath().c_str());
|
---|
[328] | 1518 |
|
---|
[355] | 1519 | vector<string>list;
|
---|
| 1520 | for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
|
---|
| 1521 | vector<string>::iterator begin_iter = list.begin();
|
---|
| 1522 | vector<string>::iterator end_iter = list.end();
|
---|
[328] | 1523 |
|
---|
[355] | 1524 | sort( list.begin(), list.end() );
|
---|
[328] | 1525 |
|
---|
[355] | 1526 | for( ; begin_iter != end_iter; ++begin_iter) {
|
---|
| 1527 | file << *begin_iter << " ";
|
---|
| 1528 | }
|
---|
| 1529 |
|
---|
| 1530 | file.close();
|
---|
| 1531 | file.clear();
|
---|
| 1532 |
|
---|
[328] | 1533 | //SetCurrentFilename(openFileDialog->GetFilename());
|
---|
| 1534 | //theText->LoadFile(openFileDialog->GetFilename());
|
---|
| 1535 | //SetStatusText(GetCurrentFilename(), 0);
|
---|
| 1536 | //SetStatusText(openFileDialog->GetDirectory(),1);
|
---|
| 1537 | }
|
---|
| 1538 | }
|
---|
| 1539 |
|
---|
| 1540 |
|
---|
[355] | 1541 |
|
---|
[328] | 1542 | /*
|
---|
[355] | 1543 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
|
---|
| 1544 | */
|
---|
[328] | 1545 |
|
---|
| 1546 | void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event )
|
---|
| 1547 | {
|
---|
[355] | 1548 | wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: This will DELETE the Edition's GameDataFolder and reglobalize all of your data. \n Are you SURE you want to do this? ", "AE Installer Alert", wxYES_NO | wxICON_EXCLAMATION , wxDefaultPosition);
|
---|
| 1549 |
|
---|
| 1550 | if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no...
|
---|
[357] | 1551 |
|
---|
[355] | 1552 | }
|
---|
| 1553 | else {
|
---|
| 1554 |
|
---|
[357] | 1555 | this->InstallButton->Disable();
|
---|
| 1556 | this->ReglobalizeButton->Disable();
|
---|
[355] | 1557 |
|
---|
| 1558 | #ifdef WIN32
|
---|
| 1559 |
|
---|
[357] | 1560 | boost::thread thrd2(globalizeData);
|
---|
| 1561 | //globalizeData();
|
---|
| 1562 | //boost::thread::create_thread(&globalizeData);
|
---|
| 1563 | // boost::thread_group Tg;
|
---|
| 1564 | // Tg.create_thread( &globalizeData(), this );
|
---|
[355] | 1565 | #else
|
---|
[357] | 1566 | globalizeData();
|
---|
[355] | 1567 | #endif
|
---|
[357] | 1568 |
|
---|
| 1569 | this->InstallButton->Enable();
|
---|
| 1570 | this->ReglobalizeButton->Enable();
|
---|
| 1571 | }
|
---|
[328] | 1572 |
|
---|
[355] | 1573 | }
|
---|
[328] | 1574 | /*
|
---|
[355] | 1575 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
|
---|
| 1576 | */
|
---|
[328] | 1577 |
|
---|
[331] | 1578 | /*void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
|
---|
[328] | 1579 | {
|
---|
[331] | 1580 | ////@begin wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
|
---|
[355] | 1581 | // Before editing this code, remove the block markers.
|
---|
| 1582 | event.Skip();
|
---|
[331] | 1583 | ////@end wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
|
---|
| 1584 | }*/
|
---|
[328] | 1585 |
|
---|