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