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