[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 |
|
---|
[423] | 365 | if(exists("../../persist.dat")) if(!exists("../persist.dat"))
|
---|
[403] | 366 | copy("../../persist.dat","..");
|
---|
[423] | 367 | if(exists("../../key_config.txt"))if(!exists("../key_config.txt"))
|
---|
[403] | 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)
|
---|
[423] | 548 | {try {
|
---|
[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;
|
---|
[423] | 554 | path vanilla_dir = "./VanillaDats/";
|
---|
[328] | 555 | string importCommand = "";
|
---|
| 556 | char statusString[128];
|
---|
| 557 | int numberOfDats = 0;
|
---|
| 558 | int j = 1;
|
---|
| 559 | string datString;
|
---|
[423] | 560 |
|
---|
| 561 |
|
---|
| 562 | setStatusArea("Importing levels...");
|
---|
| 563 | //setStatusArea("Recompiling Data...");
|
---|
| 564 |
|
---|
[328] | 565 | std::stringstream out;
|
---|
[355] | 566 |
|
---|
| 567 | ptime start_time(second_clock::local_time());
|
---|
[328] | 568 | clearOldDats();
|
---|
[423] | 569 |
|
---|
| 570 | if(exists("Install.log")) remove("Install.log");
|
---|
[355] | 571 | ofstream logfile("Install.log");
|
---|
| 572 | logfile << "Mod Installation started " << to_simple_string(start_time) << endl;
|
---|
| 573 | logfile.close();
|
---|
[423] | 574 |
|
---|
| 575 |
|
---|
[328] | 576 | if(splitInstances == SPLIT){
|
---|
| 577 | recursive_directory_iterator end_iter;
|
---|
[355] | 578 |
|
---|
[328] | 579 | for ( recursive_directory_iterator dir_itr( vanilla_dir );
|
---|
[355] | 580 | dir_itr != end_iter;
|
---|
| 581 | ++dir_itr )
|
---|
[328] | 582 | {
|
---|
| 583 | try{
|
---|
| 584 | if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1)
|
---|
| 585 | {
|
---|
| 586 | numberOfDats++;
|
---|
| 587 | }
|
---|
| 588 | }
|
---|
[423] | 589 | catch(exception & ex) {
|
---|
| 590 | remove("Install.log");
|
---|
| 591 | ofstream logfile("Install.log");
|
---|
[355] | 592 |
|
---|
[423] | 593 |
|
---|
| 594 | logfile << "Warning, exception " << ex.what() << "!";
|
---|
| 595 | setStatusArea("Warning, exception " + (string)ex.what() + "!");
|
---|
| 596 | logfile.close();
|
---|
[328] | 597 | }
|
---|
| 598 | }
|
---|
[400] | 599 | try {
|
---|
[328] | 600 | //recursive_directory_iterator end_iter;
|
---|
[423] | 601 |
|
---|
[355] | 602 |
|
---|
[328] | 603 | out << numberOfDats;
|
---|
| 604 | datString = out.str();
|
---|
| 605 | for ( recursive_directory_iterator dir_itr( vanilla_dir );
|
---|
[355] | 606 | dir_itr != end_iter;
|
---|
| 607 | ++dir_itr )
|
---|
[328] | 608 | {
|
---|
| 609 | try
|
---|
| 610 | {
|
---|
| 611 | if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1)
|
---|
| 612 | {
|
---|
| 613 | importCommand = strOniSplit + " " + strImportOption + " " + dir_itr->path().parent_path().string() + '/' + dir_itr->path().filename();
|
---|
| 614 | for (int i = 0; i < installedMods.size(); ++i) {
|
---|
| 615 | if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename() ))
|
---|
| 616 | importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename();
|
---|
[355] | 617 |
|
---|
[400] | 618 | //else cout << " VanillaDats/" + installedMods[i] + "/oni/";
|
---|
[328] | 619 | }
|
---|
[355] | 620 | importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
|
---|
| 621 |
|
---|
[357] | 622 |
|
---|
[328] | 623 | setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
|
---|
[357] | 624 | setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " ");
|
---|
[355] | 625 |
|
---|
[328] | 626 | system(importCommand.c_str());
|
---|
| 627 | //Sleep(1000);
|
---|
| 628 | //cout << importCommand << "\n";
|
---|
| 629 | j++;
|
---|
[355] | 630 |
|
---|
[328] | 631 | }
|
---|
| 632 | }
|
---|
| 633 | catch ( const std::exception & ex )
|
---|
| 634 | {
|
---|
[357] | 635 |
|
---|
| 636 | remove("Install.log");
|
---|
| 637 | ofstream logfile("Install.log");
|
---|
| 638 |
|
---|
| 639 |
|
---|
[355] | 640 | logfile << "Warning, exception " << ex.what() << "!";
|
---|
| 641 | setStatusArea("Warning, exception " + (string)ex.what() + "!");
|
---|
[357] | 642 | logfile.close();
|
---|
[328] | 643 | }
|
---|
| 644 | }
|
---|
[355] | 645 |
|
---|
[328] | 646 | }
|
---|
| 647 | catch( const std::exception & ex ) {
|
---|
[357] | 648 |
|
---|
| 649 | remove("Install.log");
|
---|
| 650 | ofstream logfile("Install.log");
|
---|
| 651 |
|
---|
| 652 |
|
---|
| 653 | logfile << "Warning, exception " << ex.what() << "!";
|
---|
| 654 | setStatusArea("Warning, exception " + (string)ex.what() + "!");
|
---|
| 655 | logfile.close();
|
---|
[328] | 656 | }
|
---|
[355] | 657 |
|
---|
[328] | 658 | }
|
---|
| 659 | else if(splitInstances == NOT_SPLIT){
|
---|
| 660 | directory_iterator end_iter;
|
---|
[355] | 661 |
|
---|
[328] | 662 | for ( directory_iterator dir_itr( vanilla_dir );
|
---|
[355] | 663 | dir_itr != end_iter;
|
---|
| 664 | ++dir_itr )
|
---|
[328] | 665 | {
|
---|
[355] | 666 |
|
---|
[328] | 667 | if ( is_directory( dir_itr->status() ) )
|
---|
| 668 | {
|
---|
| 669 | numberOfDats++;
|
---|
| 670 | }
|
---|
[355] | 671 |
|
---|
| 672 |
|
---|
[328] | 673 | }
|
---|
[355] | 674 |
|
---|
[328] | 675 | out << numberOfDats;
|
---|
| 676 | datString = out.str();
|
---|
[355] | 677 |
|
---|
[328] | 678 | for ( directory_iterator dir_itr( vanilla_dir );
|
---|
[355] | 679 | dir_itr != end_iter;
|
---|
| 680 | ++dir_itr )
|
---|
[328] | 681 | {
|
---|
| 682 | try
|
---|
| 683 | {
|
---|
| 684 | if ( is_directory( dir_itr->status() ) )
|
---|
| 685 | {
|
---|
[385] | 686 | importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " ";
|
---|
[328] | 687 | for (int i = 0; i < installedMods.size(); ++i) {
|
---|
| 688 | if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() ))
|
---|
| 689 | importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename();
|
---|
| 690 | }
|
---|
[355] | 691 | importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
|
---|
| 692 |
|
---|
[357] | 693 |
|
---|
[328] | 694 | setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
|
---|
[357] | 695 | setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " ");
|
---|
[355] | 696 |
|
---|
[328] | 697 | system(importCommand.c_str());
|
---|
[355] | 698 |
|
---|
[328] | 699 | j++;
|
---|
| 700 | }
|
---|
| 701 | }
|
---|
| 702 | catch ( const std::exception & ex )
|
---|
| 703 | {
|
---|
[357] | 704 |
|
---|
| 705 | remove("Install.log");
|
---|
| 706 | ofstream logfile("Install.log");
|
---|
| 707 |
|
---|
| 708 |
|
---|
| 709 | logfile << "Warning, exception " << ex.what() << "!";
|
---|
| 710 | setStatusArea("Warning, exception " + (string)ex.what() + "!");
|
---|
| 711 | logfile.close();
|
---|
[355] | 712 | }}
|
---|
[328] | 713 | }
|
---|
[355] | 714 | logfile << "Writing config file";
|
---|
[328] | 715 | writeInstalledMods(installedMods);
|
---|
| 716 | setProgressBar(1000);
|
---|
[355] | 717 | setStatusArea("Done! You can now play Oni.");
|
---|
| 718 |
|
---|
[357] | 719 | ptime end_time(second_clock::local_time());
|
---|
| 720 | time_period total_time (start_time, end_time);
|
---|
| 721 |
|
---|
| 722 |
|
---|
| 723 | ofstream logfile2("Install.log", ios::app | ios::ate);
|
---|
| 724 | string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length();
|
---|
| 725 |
|
---|
| 726 | logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
|
---|
| 727 |
|
---|
| 728 | //logfile2.write(outstring.c_str(), outstring.length());
|
---|
| 729 | logfile2.close();
|
---|
| 730 |
|
---|
| 731 | //total_time.length().hours();
|
---|
| 732 |
|
---|
[353] | 733 | Sleep(1000);
|
---|
[328] | 734 | setProgressBar(0);
|
---|
[423] | 735 |
|
---|
[328] | 736 | }
|
---|
[423] | 737 | catch(exception & ex) {
|
---|
| 738 | remove("Install.log");
|
---|
| 739 | ofstream logfile("Install.log");
|
---|
[328] | 740 |
|
---|
[423] | 741 |
|
---|
| 742 | logfile << "Warning, exception " << ex.what() << "!";
|
---|
| 743 | setStatusArea("Warning, exception " + (string)ex.what() + "!");
|
---|
| 744 | logfile.close();
|
---|
| 745 | }
|
---|
| 746 | busy = 0;
|
---|
| 747 | }
|
---|
| 748 |
|
---|
| 749 |
|
---|
[328] | 750 | void writeInstalledMods(vector<string> installedMods)
|
---|
| 751 | {
|
---|
[355] | 752 |
|
---|
[328] | 753 | if ( exists( strInstallCfg ) )
|
---|
| 754 | {
|
---|
| 755 | remove( strInstallCfg );
|
---|
| 756 | }
|
---|
[355] | 757 |
|
---|
[328] | 758 | ofstream file(strInstallCfg.c_str());
|
---|
[355] | 759 |
|
---|
[328] | 760 | vector<string>list = installedMods;
|
---|
| 761 | vector<string>::iterator begin_iter = list.begin();
|
---|
| 762 | vector<string>::iterator end_iter = list.end();
|
---|
[355] | 763 |
|
---|
[328] | 764 | sort( list.begin(), list.end() );
|
---|
[355] | 765 |
|
---|
[328] | 766 | for( ; begin_iter != end_iter; ++begin_iter) {
|
---|
| 767 | file << *begin_iter << " ";
|
---|
| 768 | }
|
---|
[355] | 769 |
|
---|
[328] | 770 | file.close();
|
---|
| 771 | file.clear();
|
---|
[355] | 772 |
|
---|
[328] | 773 | }
|
---|
| 774 |
|
---|
| 775 | vector<string> getInstallString(string Cfg)
|
---|
| 776 | {
|
---|
| 777 | //system(strPauseCmd);
|
---|
| 778 | vector<string> returnval;
|
---|
[355] | 779 |
|
---|
[328] | 780 | string line;
|
---|
| 781 | fstream file;
|
---|
[355] | 782 |
|
---|
[328] | 783 | if (exists( Cfg ))
|
---|
| 784 | {
|
---|
| 785 | file.open(Cfg.c_str());
|
---|
| 786 | getline(file, line);
|
---|
| 787 | tokenize(line, returnval);
|
---|
| 788 | file.close();
|
---|
| 789 | file.clear();
|
---|
| 790 | sort(returnval.begin(), returnval.end());
|
---|
| 791 | }
|
---|
| 792 | else cout << "fail";
|
---|
[355] | 793 |
|
---|
[328] | 794 | return returnval;
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | //stolen token function...
|
---|
| 798 | void tokenize(const string& str, vector<string>& tokens, const string& delimiters)
|
---|
| 799 | {
|
---|
| 800 | // Skip delimiters at beginning.
|
---|
| 801 | string::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
---|
| 802 | // Find first "non-delimiter".
|
---|
| 803 | string::size_type pos = str.find_first_of(delimiters, lastPos);
|
---|
[355] | 804 |
|
---|
[328] | 805 | while (string::npos != pos || string::npos != lastPos)
|
---|
| 806 | {
|
---|
| 807 | // Found a token, add it to the vector.
|
---|
| 808 | tokens.push_back(str.substr(lastPos, pos - lastPos));
|
---|
| 809 | // Skip delimiters. Note the "not_of"
|
---|
| 810 | lastPos = str.find_first_not_of(delimiters, pos);
|
---|
| 811 | // Find next "non-delimiter"
|
---|
| 812 | pos = str.find_first_of(delimiters, lastPos);
|
---|
| 813 | }
|
---|
| 814 | }
|
---|
| 815 |
|
---|
| 816 | void clearOldDats(void) {
|
---|
| 817 | directory_iterator end_iter_gdf;
|
---|
| 818 | for ( directory_iterator dir_itr_gdf( "../GameDataFolder" );
|
---|
[355] | 819 | dir_itr_gdf != end_iter_gdf;
|
---|
| 820 | ++dir_itr_gdf )
|
---|
[328] | 821 | {
|
---|
| 822 | //cout << dir_itr_gdf->path().extension() << "\n";
|
---|
| 823 | if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) {
|
---|
| 824 | remove( dir_itr_gdf->path() );
|
---|
| 825 | }
|
---|
[355] | 826 |
|
---|
[328] | 827 | }
|
---|
[355] | 828 |
|
---|
[328] | 829 | }
|
---|
| 830 |
|
---|
| 831 | vector<string> globalInstalledMods;
|
---|
| 832 | vector<ModPackage> globalPackages;
|
---|
| 833 | #include "boost/thread.hpp"
|
---|
| 834 | #include <boost/thread/mutex.hpp>
|
---|
| 835 |
|
---|
| 836 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 837 | // Name: main_window.cpp
|
---|
| 838 | // Purpose:
|
---|
| 839 | // Author:
|
---|
| 840 | // Modified by:
|
---|
| 841 | // Created: 07/05/2009 20:38:25
|
---|
| 842 | // RCS-ID:
|
---|
| 843 | // Copyright:
|
---|
| 844 | // Licence:
|
---|
| 845 | /////////////////////////////////////////////////////////////////////////////
|
---|
| 846 |
|
---|
| 847 | // For compilers that support precompilation, includes "wx/wx.h".
|
---|
| 848 | #include "wx/wxprec.h"
|
---|
| 849 |
|
---|
| 850 | #ifdef __BORLANDC__
|
---|
| 851 | #pragma hdrstop
|
---|
| 852 | #endif
|
---|
| 853 |
|
---|
| 854 | #ifndef WX_PRECOMP
|
---|
| 855 | #include "wx/wx.h"
|
---|
| 856 | #endif
|
---|
| 857 |
|
---|
| 858 | ////@begin includes
|
---|
[385] | 859 | #include "about.h"
|
---|
[328] | 860 | ////@end includes
|
---|
| 861 |
|
---|
| 862 | #include "main_window.h"
|
---|
| 863 |
|
---|
| 864 | ////@begin XPM images
|
---|
[385] | 865 | #include "aelogosmall.xpm"
|
---|
| 866 | #include "undo.xpm"
|
---|
[328] | 867 | #include "fileopen.xpm"
|
---|
| 868 | #include "filesaveas.xpm"
|
---|
| 869 | #include "quit.xpm"
|
---|
| 870 | ////@end XPM images
|
---|
| 871 |
|
---|
| 872 | //#define wxDebug 1;
|
---|
| 873 | //#define wxUSE_UNICODE 1;
|
---|
| 874 |
|
---|
| 875 | /*
|
---|
[355] | 876 | * MainWindow type definition
|
---|
| 877 | */
|
---|
[328] | 878 |
|
---|
| 879 | IMPLEMENT_CLASS( MainWindow, wxFrame )
|
---|
| 880 |
|
---|
| 881 |
|
---|
| 882 | /*
|
---|
[355] | 883 | * MainWindow event table definition
|
---|
| 884 | */
|
---|
[328] | 885 |
|
---|
| 886 | BEGIN_EVENT_TABLE( MainWindow, wxFrame )
|
---|
| 887 |
|
---|
| 888 | ////@begin MainWindow event table entries
|
---|
[385] | 889 | EVT_CHECKBOX( SelectAll_Checkbox, MainWindow::OnSelectAllCheckboxClick )
|
---|
[328] | 890 |
|
---|
[385] | 891 | EVT_BUTTON( Refresh_Button, MainWindow::OnRefreshButtonClick )
|
---|
[328] | 892 |
|
---|
[385] | 893 | EVT_LISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Selected )
|
---|
| 894 | EVT_CHECKLISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Toggled )
|
---|
[328] | 895 |
|
---|
[385] | 896 | EVT_UPDATE_UI( ID_STATUSBAR, MainWindow::OnStatusbarUpdate )
|
---|
[328] | 897 |
|
---|
[385] | 898 | EVT_BUTTON( Install_Button, MainWindow::OnInstallButtonClick )
|
---|
[328] | 899 |
|
---|
[385] | 900 | EVT_RADIOBUTTON( Sep_RadioButton, MainWindow::OnSepRadioButtonSelected )
|
---|
[328] | 901 |
|
---|
[385] | 902 | EVT_RADIOBUTTON( NoSep_RadioButton, MainWindow::OnNoSepRadioButtonSelected )
|
---|
[328] | 903 |
|
---|
[385] | 904 | EVT_RADIOBUTTON( Seperated_RadioButton, MainWindow::OnSeperatedRadioButtonSelected )
|
---|
[328] | 905 |
|
---|
[385] | 906 | EVT_RADIOBUTTON( Complete_RadioButton, MainWindow::OnCompleteRadioButtonSelected )
|
---|
[328] | 907 |
|
---|
[385] | 908 | EVT_BUTTON( ReGlobalize_Button, MainWindow::OnReGlobalizeButtonClick )
|
---|
[328] | 909 |
|
---|
[385] | 910 | EVT_MENU( wxID_LOAD, MainWindow::OnLoadClick )
|
---|
[328] | 911 |
|
---|
[385] | 912 | EVT_MENU( wxID_SAVE, MainWindow::OnSaveClick )
|
---|
[328] | 913 |
|
---|
[385] | 914 | EVT_MENU( wxID_EXIT, MainWindow::OnExitClick )
|
---|
[328] | 915 |
|
---|
[385] | 916 | EVT_MENU( wxID_OPTIONS, MainWindow::OnOptionsClick )
|
---|
[328] | 917 |
|
---|
[385] | 918 | EVT_MENU( wxID_ABOUT, MainWindow::OnAboutClick )
|
---|
[328] | 919 |
|
---|
| 920 | ////@end MainWindow event table entries
|
---|
| 921 |
|
---|
| 922 | END_EVENT_TABLE()
|
---|
| 923 |
|
---|
| 924 |
|
---|
| 925 | /*
|
---|
[355] | 926 | * MainWindow constructors
|
---|
| 927 | */
|
---|
[328] | 928 |
|
---|
| 929 | MainWindow::MainWindow()
|
---|
| 930 | {
|
---|
[355] | 931 | Init();
|
---|
[328] | 932 | }
|
---|
| 933 |
|
---|
| 934 | MainWindow::MainWindow( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
---|
| 935 | {
|
---|
[355] | 936 | Init();
|
---|
| 937 | Create( parent, id, caption, pos, size, style );
|
---|
[328] | 938 | }
|
---|
| 939 |
|
---|
| 940 |
|
---|
| 941 | /*
|
---|
[355] | 942 | * MainWindow creator
|
---|
| 943 | */
|
---|
[328] | 944 |
|
---|
| 945 | bool MainWindow::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
|
---|
| 946 | {
|
---|
[355] | 947 | ////@begin MainWindow creation
|
---|
[385] | 948 | wxFrame::Create( parent, id, caption, pos, size, style );
|
---|
[328] | 949 |
|
---|
[385] | 950 | CreateControls();
|
---|
| 951 | SetIcon(GetIconResource(wxT("aelogosmall.png")));
|
---|
| 952 | Centre();
|
---|
[355] | 953 | ////@end MainWindow creation
|
---|
| 954 | return true;
|
---|
[328] | 955 | }
|
---|
| 956 |
|
---|
| 957 |
|
---|
| 958 | /*
|
---|
[355] | 959 | * MainWindow destructor
|
---|
| 960 | */
|
---|
[328] | 961 |
|
---|
| 962 | MainWindow::~MainWindow()
|
---|
| 963 | {
|
---|
[355] | 964 | ////@begin MainWindow destruction
|
---|
| 965 | ////@end MainWindow destruction
|
---|
[328] | 966 | }
|
---|
| 967 |
|
---|
| 968 |
|
---|
| 969 | /*
|
---|
[355] | 970 | * Member initialisation
|
---|
| 971 | */
|
---|
[328] | 972 |
|
---|
| 973 | void MainWindow::Init()
|
---|
| 974 | {
|
---|
[355] | 975 | ////@begin MainWindow member initialisation
|
---|
[385] | 976 | MainSplitter = NULL;
|
---|
| 977 | SelectAll = NULL;
|
---|
| 978 | RefreshButton = NULL;
|
---|
| 979 | Mods_CheckboxList = NULL;
|
---|
| 980 | titleText = NULL;
|
---|
| 981 | creatorText = NULL;
|
---|
| 982 | descriptionText = NULL;
|
---|
| 983 | StatusArea = NULL;
|
---|
| 984 | ProgressBar = NULL;
|
---|
| 985 | InstallButton = NULL;
|
---|
| 986 | OptionsPanel = NULL;
|
---|
| 987 | SepRadio = NULL;
|
---|
| 988 | NoSepRadio = NULL;
|
---|
| 989 | SeperatedRadio = NULL;
|
---|
| 990 | CompleteRadio = NULL;
|
---|
| 991 | ReglobalizeButton = NULL;
|
---|
[355] | 992 | ////@end MainWindow member initialisation
|
---|
[328] | 993 |
|
---|
| 994 | }
|
---|
| 995 |
|
---|
| 996 |
|
---|
| 997 | /*
|
---|
[355] | 998 | * Control creation for MainWindow
|
---|
| 999 | */
|
---|
[353] | 1000 | wxStatusBar **TheStatusBar;
|
---|
[328] | 1001 | wxButton* TheInstallButton;
|
---|
| 1002 | wxGauge* TheProgressBar;
|
---|
| 1003 | void MainWindow::CreateControls()
|
---|
| 1004 | {
|
---|
[355] | 1005 | ////@begin MainWindow content construction
|
---|
[385] | 1006 | MainWindow* itemFrame1 = this;
|
---|
[328] | 1007 |
|
---|
[385] | 1008 | wxMenuBar* menuBar = new wxMenuBar;
|
---|
| 1009 | wxMenu* itemMenu37 = new wxMenu;
|
---|
| 1010 | {
|
---|
| 1011 | wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_LOAD, _("&Load Configuration..."), wxEmptyString, wxITEM_NORMAL);
|
---|
| 1012 | wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("fileopen.xpm")));
|
---|
| 1013 | menuItem->SetBitmap(bitmap);
|
---|
| 1014 | itemMenu37->Append(menuItem);
|
---|
| 1015 | }
|
---|
| 1016 | {
|
---|
| 1017 | wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_SAVE, _("&Save Configuration..."), wxEmptyString, wxITEM_NORMAL);
|
---|
| 1018 | wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("filesaveas.xpm")));
|
---|
| 1019 | menuItem->SetBitmap(bitmap);
|
---|
| 1020 | itemMenu37->Append(menuItem);
|
---|
| 1021 | }
|
---|
| 1022 | itemMenu37->AppendSeparator();
|
---|
| 1023 | {
|
---|
| 1024 | wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_EXIT, _("Exit"), wxEmptyString, wxITEM_NORMAL);
|
---|
| 1025 | wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("quit.xpm")));
|
---|
| 1026 | menuItem->SetBitmap(bitmap);
|
---|
| 1027 | itemMenu37->Append(menuItem);
|
---|
| 1028 | }
|
---|
| 1029 | menuBar->Append(itemMenu37, _("&File"));
|
---|
| 1030 | wxMenu* itemMenu42 = new wxMenu;
|
---|
| 1031 | itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
|
---|
| 1032 | menuBar->Append(itemMenu42, _("Options"));
|
---|
| 1033 | wxMenu* itemMenu44 = new wxMenu;
|
---|
[390] | 1034 | #ifdef WIN32
|
---|
| 1035 | itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
|
---|
| 1036 | menuBar->Append(itemMenu44, _("Help"));
|
---|
| 1037 | #else
|
---|
| 1038 | itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
|
---|
| 1039 | #endif
|
---|
| 1040 |
|
---|
[385] | 1041 | itemFrame1->SetMenuBar(menuBar);
|
---|
[328] | 1042 |
|
---|
[385] | 1043 | wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1044 | itemFrame1->SetSizer(itemBoxSizer2);
|
---|
[328] | 1045 |
|
---|
[385] | 1046 | MainSplitter = new wxSplitterWindow( itemFrame1, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 100), wxSP_LIVE_UPDATE|wxNO_BORDER );
|
---|
| 1047 | MainSplitter->SetMinimumPaneSize(1);
|
---|
| 1048 | MainSplitter->SetName(_T("MainSplitter"));
|
---|
[328] | 1049 |
|
---|
[385] | 1050 | wxPanel* itemPanel4 = new wxPanel( MainSplitter, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
|
---|
| 1051 | wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1052 | itemPanel4->SetSizer(itemBoxSizer5);
|
---|
[328] | 1053 |
|
---|
[385] | 1054 | wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
|
---|
| 1055 | itemBoxSizer5->Add(itemBoxSizer6, 0, wxGROW|wxALL, 0);
|
---|
| 1056 | SelectAll = new wxCheckBox( itemPanel4, SelectAll_Checkbox, _("Select All/None"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE );
|
---|
| 1057 | SelectAll->SetValue(false);
|
---|
| 1058 | SelectAll->SetName(_T("SelectAll_Checkbox"));
|
---|
| 1059 | itemBoxSizer6->Add(SelectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
---|
[328] | 1060 |
|
---|
[385] | 1061 | RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("undo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
|
---|
| 1062 | RefreshButton->SetName(_T("RefreshButton"));
|
---|
| 1063 | itemBoxSizer6->Add(RefreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
|
---|
[328] | 1064 |
|
---|
[385] | 1065 | wxArrayString Mods_CheckboxListStrings;
|
---|
| 1066 | Mods_CheckboxList = new wxCheckListBox( itemPanel4, Mods_CheckboxList1, wxDefaultPosition, wxDefaultSize, Mods_CheckboxListStrings, wxLB_HSCROLL );
|
---|
| 1067 | Mods_CheckboxList->SetName(_T("Mods_CheckboxList"));
|
---|
| 1068 | itemBoxSizer5->Add(Mods_CheckboxList, 1, wxGROW|wxALL, 0);
|
---|
[328] | 1069 |
|
---|
[385] | 1070 | wxPanel* itemPanel10 = new wxPanel( MainSplitter, DescriptionHolder_Panel, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
|
---|
| 1071 | itemPanel10->SetName(_T("DescriptionHolder_Panel"));
|
---|
| 1072 | wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1073 | itemPanel10->SetSizer(itemBoxSizer11);
|
---|
[328] | 1074 |
|
---|
[385] | 1075 | wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
|
---|
| 1076 | itemBoxSizer11->Add(itemBoxSizer12, 0, wxGROW|wxALL, 0);
|
---|
| 1077 | wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1078 | itemBoxSizer12->Add(itemBoxSizer13, 1, wxALIGN_CENTER_VERTICAL|wxALL, 0);
|
---|
| 1079 | titleText = new wxTextCtrl( itemPanel10, Title_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
---|
| 1080 | titleText->SetName(_T("Title_Text"));
|
---|
| 1081 | titleText->SetBackgroundColour(wxColour(240, 240, 240));
|
---|
| 1082 | itemBoxSizer13->Add(titleText, 1, wxGROW|wxLEFT, 5);
|
---|
[328] | 1083 |
|
---|
[385] | 1084 | wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1085 | itemBoxSizer12->Add(itemBoxSizer15, 1, wxGROW|wxALL, 0);
|
---|
| 1086 | creatorText = new wxTextCtrl( itemPanel10, Author_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_RIGHT );
|
---|
| 1087 | creatorText->SetName(_T("Author_Text"));
|
---|
| 1088 | creatorText->SetBackgroundColour(wxColour(240, 240, 240));
|
---|
| 1089 | itemBoxSizer15->Add(creatorText, 1, wxGROW|wxRIGHT, 5);
|
---|
[328] | 1090 |
|
---|
[385] | 1091 | wxStaticLine* itemStaticLine17 = new wxStaticLine( itemPanel10, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
---|
| 1092 | itemStaticLine17->Show(false);
|
---|
| 1093 | itemBoxSizer11->Add(itemStaticLine17, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1094 |
|
---|
[385] | 1095 | descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_RICH2 );
|
---|
| 1096 | descriptionText->SetName(_T("DescriptionName"));
|
---|
| 1097 | descriptionText->SetBackgroundColour(wxColour(240, 240, 240));
|
---|
| 1098 | itemBoxSizer11->Add(descriptionText, 1, wxGROW|wxLEFT|wxRIGHT, 5);
|
---|
[328] | 1099 |
|
---|
[385] | 1100 | MainSplitter->SplitVertically(itemPanel4, itemPanel10, 200);
|
---|
| 1101 | itemBoxSizer2->Add(MainSplitter, 1, wxGROW|wxALL, 0);
|
---|
[328] | 1102 |
|
---|
[385] | 1103 | StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 );
|
---|
| 1104 | StatusArea->SetName(_T("StatusArea"));
|
---|
| 1105 | StatusArea->SetFieldsCount(1);
|
---|
| 1106 | StatusArea->SetStatusText(_("AE Installer v1.0"), 0);
|
---|
| 1107 | itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0);
|
---|
[328] | 1108 |
|
---|
[385] | 1109 | wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
|
---|
| 1110 | itemBoxSizer2->Add(itemBoxSizer20, 0, wxGROW|wxALL, 0);
|
---|
[328] | 1111 |
|
---|
[385] | 1112 | ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxDefaultSize, wxGA_SMOOTH );
|
---|
| 1113 | ProgressBar->SetValue(0);
|
---|
| 1114 | itemBoxSizer20->Add(ProgressBar, 1, wxGROW|wxALL, 0);
|
---|
[328] | 1115 |
|
---|
[385] | 1116 | InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxDefaultSize, 0 );
|
---|
| 1117 | itemBoxSizer20->Add(InstallButton, 0, wxGROW|wxALL, 0);
|
---|
[328] | 1118 |
|
---|
[385] | 1119 | wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1120 | itemBoxSizer2->Add(itemBoxSizer23, 0, wxGROW|wxALL, 0);
|
---|
[328] | 1121 |
|
---|
[385] | 1122 | OptionsPanel = new wxPanel( itemFrame1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
|
---|
| 1123 | itemBoxSizer2->Add(OptionsPanel, 0, wxGROW, 0);
|
---|
[328] | 1124 |
|
---|
[385] | 1125 | wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL);
|
---|
| 1126 | OptionsPanel->SetSizer(itemBoxSizer25);
|
---|
[328] | 1127 |
|
---|
[385] | 1128 | wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1129 | itemBoxSizer25->Add(itemBoxSizer26, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1130 |
|
---|
[385] | 1131 | SepRadio = new wxRadioButton( OptionsPanel, Sep_RadioButton, _("Sep"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
---|
| 1132 | SepRadio->SetValue(false);
|
---|
| 1133 | if (MainWindow::ShowToolTips())
|
---|
| 1134 | SepRadio->SetToolTip(_("For PC Demo and Mac"));
|
---|
| 1135 | itemBoxSizer26->Add(SepRadio, 0, wxALIGN_LEFT|wxALL, 5);
|
---|
[328] | 1136 |
|
---|
[385] | 1137 | NoSepRadio = new wxRadioButton( OptionsPanel, NoSep_RadioButton, _("NoSep"), wxDefaultPosition, wxDefaultSize, 0 );
|
---|
| 1138 | NoSepRadio->SetValue(false);
|
---|
| 1139 | if (MainWindow::ShowToolTips())
|
---|
| 1140 | NoSepRadio->SetToolTip(_("For PC Retail"));
|
---|
| 1141 | itemBoxSizer26->Add(NoSepRadio, 0, wxALIGN_LEFT|wxALL, 5);
|
---|
[328] | 1142 |
|
---|
[385] | 1143 | wxStaticLine* itemStaticLine29 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
|
---|
| 1144 | itemBoxSizer25->Add(itemStaticLine29, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1145 |
|
---|
[385] | 1146 | wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1147 | itemBoxSizer25->Add(itemBoxSizer30, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1148 |
|
---|
[385] | 1149 | SeperatedRadio = new wxRadioButton( OptionsPanel, Seperated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
|
---|
| 1150 | SeperatedRadio->SetValue(false);
|
---|
| 1151 | SeperatedRadio->SetName(_T("Seperated_RadioButton"));
|
---|
| 1152 | itemBoxSizer30->Add(SeperatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
|
---|
[328] | 1153 |
|
---|
[385] | 1154 | CompleteRadio = new wxRadioButton( OptionsPanel, Complete_RadioButton, _("Complete Level0"), wxDefaultPosition, wxDefaultSize, 0 );
|
---|
| 1155 | CompleteRadio->SetValue(false);
|
---|
| 1156 | CompleteRadio->SetName(_T("Complete_RadioButton"));
|
---|
| 1157 | itemBoxSizer30->Add(CompleteRadio, 0, wxALIGN_LEFT|wxALL, 5);
|
---|
[328] | 1158 |
|
---|
[385] | 1159 | wxStaticLine* itemStaticLine33 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
|
---|
| 1160 | itemBoxSizer25->Add(itemStaticLine33, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1161 |
|
---|
[385] | 1162 | wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL);
|
---|
| 1163 | itemBoxSizer25->Add(itemBoxSizer34, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
|
---|
[328] | 1164 |
|
---|
[385] | 1165 | ReglobalizeButton = new wxButton( OptionsPanel, ReGlobalize_Button, _("Reglobalize"), wxDefaultPosition, wxDefaultSize, 0 );
|
---|
| 1166 | ReglobalizeButton->SetName(_T("Reglobalize_Button"));
|
---|
| 1167 | itemBoxSizer34->Add(ReglobalizeButton, 0, wxGROW|wxALL, 5);
|
---|
[328] | 1168 |
|
---|
[385] | 1169 | // Connect events and objects
|
---|
| 1170 | Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this);
|
---|
[355] | 1171 | ////@end MainWindow content construction
|
---|
[403] | 1172 | #ifdef WIN32
|
---|
[394] | 1173 | Handle = (HWND)GetHWND();
|
---|
| 1174 | ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList);
|
---|
[403] | 1175 | #endif
|
---|
[394] | 1176 |
|
---|
[410] | 1177 |
|
---|
[409] | 1178 | /*if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
|
---|
[385] | 1179 | strImportOption = "-import:sep";
|
---|
[328] | 1180 | splitInstances = NOT_SPLIT;
|
---|
| 1181 | }
|
---|
| 1182 | else {
|
---|
[385] | 1183 | strImportOption = "-import:nosep";
|
---|
[328] | 1184 | splitInstances = SPLIT;
|
---|
[409] | 1185 | }*/
|
---|
[390] | 1186 |
|
---|
[410] | 1187 |
|
---|
[409] | 1188 | #ifndef WIN32
|
---|
[410] | 1189 | strImportOption = "-import:sep";
|
---|
| 1190 | splitInstances = NOT_SPLIT;
|
---|
| 1191 | #else
|
---|
| 1192 | strImportOption = "-import:nosep";
|
---|
| 1193 | splitInstances = SPLIT;
|
---|
| 1194 | #endif
|
---|
| 1195 |
|
---|
| 1196 | #ifndef WIN32
|
---|
[409] | 1197 | strImportOption = "-import:sep";
|
---|
| 1198 | splitInstances = NOT_SPLIT;
|
---|
| 1199 | #else
|
---|
| 1200 | strImportOption = "-import:nosep";
|
---|
| 1201 | splitInstances = SPLIT;
|
---|
| 1202 | #endif
|
---|
| 1203 |
|
---|
[328] | 1204 | globalPackages = getPackages();
|
---|
| 1205 | globalInstalledMods = getInstallString();
|
---|
[355] | 1206 | for (int i = 0; i < globalPackages.size(); i++) {
|
---|
| 1207 | Mods_CheckboxList->Append(globalPackages[i].name.c_str());
|
---|
| 1208 | if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
|
---|
[328] | 1209 | }
|
---|
| 1210 |
|
---|
[355] | 1211 | TheStatusBar = &StatusArea;
|
---|
| 1212 | TheInstallButton = InstallButton;
|
---|
| 1213 | TheProgressBar = ProgressBar;
|
---|
| 1214 | OptionsPanel->Hide();
|
---|
[390] | 1215 |
|
---|
| 1216 | //#ifndef WIN32
|
---|
| 1217 | // itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
|
---|
| 1218 |
|
---|
| 1219 | //#endif
|
---|
| 1220 |
|
---|
[385] | 1221 | if(splitInstances == SPLIT) SeperatedRadio->SetValue(true);
|
---|
[355] | 1222 | else CompleteRadio->SetValue(true);
|
---|
| 1223 | if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
|
---|
| 1224 | else SepRadio->SetValue(true);
|
---|
[357] | 1225 |
|
---|
| 1226 |
|
---|
[355] | 1227 | #ifdef WIN32
|
---|
| 1228 | RedirectIOToConsole();
|
---|
| 1229 | HWND hWnd = GetConsoleWindow();
|
---|
| 1230 | ShowWindow( hWnd, SW_HIDE );
|
---|
| 1231 | #endif
|
---|
[357] | 1232 |
|
---|
| 1233 | //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
|
---|
[328] | 1234 | }
|
---|
| 1235 |
|
---|
[355] | 1236 |
|
---|
[328] | 1237 | /*
|
---|
[355] | 1238 | * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
|
---|
| 1239 | */
|
---|
[328] | 1240 |
|
---|
| 1241 | void MainWindow::OnSelectAllCheckboxClick( wxCommandEvent& event )
|
---|
| 1242 | {
|
---|
[355] | 1243 | switch(SelectAll->Get3StateValue()) {
|
---|
[328] | 1244 | case wxCHK_UNCHECKED:
|
---|
| 1245 | for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
|
---|
| 1246 | //SelectAll->Set3StateValue(wxCHK_CHECKED);
|
---|
| 1247 | break;
|
---|
| 1248 | case wxCHK_CHECKED:
|
---|
| 1249 | for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true);
|
---|
| 1250 | //SelectAll->Set3StateValue(wxCHK_UNCHECKED);
|
---|
| 1251 | break;
|
---|
| 1252 | case wxCHK_UNDETERMINED:
|
---|
| 1253 | for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
|
---|
| 1254 | //SelectAll->Set3StateValue(wxCHK_CHECKED);
|
---|
| 1255 | break;
|
---|
| 1256 |
|
---|
| 1257 | }
|
---|
[355] | 1258 |
|
---|
[328] | 1259 | }
|
---|
| 1260 |
|
---|
| 1261 |
|
---|
| 1262 | /*
|
---|
[355] | 1263 | * wxEVT_CREATE event handler for Mods_CheckboxList
|
---|
| 1264 | */
|
---|
[328] | 1265 |
|
---|
| 1266 | void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event )
|
---|
| 1267 | {
|
---|
| 1268 |
|
---|
| 1269 |
|
---|
| 1270 | }
|
---|
| 1271 |
|
---|
| 1272 |
|
---|
| 1273 | /*
|
---|
[355] | 1274 | * Should we show tooltips?
|
---|
| 1275 | */
|
---|
[328] | 1276 |
|
---|
| 1277 | bool MainWindow::ShowToolTips()
|
---|
| 1278 | {
|
---|
[355] | 1279 | return true;
|
---|
[328] | 1280 | }
|
---|
| 1281 |
|
---|
| 1282 | /*
|
---|
[355] | 1283 | * Get bitmap resources
|
---|
| 1284 | */
|
---|
[328] | 1285 |
|
---|
| 1286 | wxBitmap MainWindow::GetBitmapResource( const wxString& name )
|
---|
| 1287 | {
|
---|
[355] | 1288 | // Bitmap retrieval
|
---|
| 1289 | ////@begin MainWindow bitmap retrieval
|
---|
[385] | 1290 | wxUnusedVar(name);
|
---|
| 1291 | if (name == _T("undo.xpm"))
|
---|
| 1292 | {
|
---|
| 1293 | wxBitmap bitmap( undo_xpm);
|
---|
| 1294 | return bitmap;
|
---|
| 1295 | }
|
---|
| 1296 | else if (name == _T("fileopen.xpm"))
|
---|
| 1297 | {
|
---|
| 1298 | wxBitmap bitmap( fileopen_xpm);
|
---|
| 1299 | return bitmap;
|
---|
| 1300 | }
|
---|
| 1301 | else if (name == _T("filesaveas.xpm"))
|
---|
| 1302 | {
|
---|
| 1303 | wxBitmap bitmap( filesaveas_xpm);
|
---|
| 1304 | return bitmap;
|
---|
| 1305 | }
|
---|
| 1306 | else if (name == _T("quit.xpm"))
|
---|
| 1307 | {
|
---|
| 1308 | wxBitmap bitmap( quit_xpm);
|
---|
| 1309 | return bitmap;
|
---|
| 1310 | }
|
---|
| 1311 | return wxNullBitmap;
|
---|
[355] | 1312 | ////@end MainWindow bitmap retrieval
|
---|
[328] | 1313 | }
|
---|
| 1314 |
|
---|
| 1315 | /*
|
---|
[355] | 1316 | * Get icon resources
|
---|
| 1317 | */
|
---|
[328] | 1318 |
|
---|
| 1319 | wxIcon MainWindow::GetIconResource( const wxString& name )
|
---|
| 1320 | {
|
---|
[355] | 1321 |
|
---|
| 1322 | // Icon retrieval
|
---|
| 1323 | ////@begin MainWindow icon retrieval
|
---|
[385] | 1324 | wxUnusedVar(name);
|
---|
| 1325 | if (name == _T("aelogosmall.png"))
|
---|
| 1326 | {
|
---|
| 1327 | wxIcon icon(aelogosmall_xpm);
|
---|
| 1328 | return icon;
|
---|
| 1329 | }
|
---|
| 1330 | return wxNullIcon;
|
---|
[355] | 1331 | ////@end MainWindow icon retrieval
|
---|
[328] | 1332 | }
|
---|
| 1333 |
|
---|
| 1334 |
|
---|
| 1335 | /*
|
---|
[355] | 1336 | * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
|
---|
| 1337 | */
|
---|
[328] | 1338 |
|
---|
| 1339 | void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event )
|
---|
| 1340 | {
|
---|
| 1341 | //event.GetSelection
|
---|
| 1342 | titleText->SetValue(globalPackages[event.GetSelection()].name.c_str());
|
---|
| 1343 | creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str());
|
---|
| 1344 | descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str());
|
---|
| 1345 |
|
---|
[353] | 1346 | //creatorText->Refresh();
|
---|
[328] | 1347 | }
|
---|
| 1348 |
|
---|
| 1349 |
|
---|
| 1350 | /*
|
---|
[355] | 1351 | * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
|
---|
| 1352 | */
|
---|
[328] | 1353 |
|
---|
| 1354 | void MainWindow::OnModsCheckboxList1Toggled( wxCommandEvent& event )
|
---|
| 1355 | {
|
---|
| 1356 | SelectAll->Set3StateValue(wxCHK_UNDETERMINED);
|
---|
| 1357 | if(event.GetInt()) {
|
---|
[355] | 1358 | /*
|
---|
[328] | 1359 | switch(SelectAll->Get3StateValue()) {
|
---|
[355] | 1360 | case wxCHK_UNCHECKED:
|
---|
[328] | 1361 | break;
|
---|
[355] | 1362 | case wxCHK_CHECKED:
|
---|
[328] | 1363 | break;
|
---|
[355] | 1364 | case wxCHK_UNDETERMINED :
|
---|
[328] | 1365 | break;
|
---|
[355] | 1366 | }
|
---|
| 1367 | */
|
---|
[328] | 1368 | }
|
---|
| 1369 | }
|
---|
| 1370 |
|
---|
| 1371 |
|
---|
| 1372 | /*
|
---|
[355] | 1373 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
|
---|
| 1374 | */
|
---|
[328] | 1375 |
|
---|
| 1376 | void MainWindow::OnOptionsClick( wxCommandEvent& event )
|
---|
| 1377 | {
|
---|
| 1378 | if (!event.GetInt() ) {
|
---|
| 1379 | OptionsPanel->Hide();
|
---|
[385] | 1380 |
|
---|
[358] | 1381 | this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
|
---|
[328] | 1382 | else {
|
---|
[358] | 1383 | // Uncomment this when we release, it gets annoying if you are testing globalization a lot ;)
|
---|
[373] | 1384 | wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: These options are for advanced users only, use with caution.",
|
---|
| 1385 | "AE Installer Alert", wxOK | wxICON_EXCLAMATION , wxDefaultPosition);
|
---|
[358] | 1386 | YesNoDialog->ShowModal();
|
---|
[328] | 1387 | OptionsPanel->Show();
|
---|
[379] | 1388 | this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight()+1);
|
---|
| 1389 | this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-1);
|
---|
[328] | 1390 | }
|
---|
| 1391 | }
|
---|
| 1392 |
|
---|
| 1393 |
|
---|
| 1394 | /*
|
---|
[355] | 1395 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
|
---|
| 1396 | */
|
---|
[328] | 1397 |
|
---|
| 1398 | void MainWindow::OnExitClick( wxCommandEvent& event )
|
---|
| 1399 | {
|
---|
[355] | 1400 | exit(0);
|
---|
[328] | 1401 | }
|
---|
| 1402 |
|
---|
| 1403 |
|
---|
| 1404 | /*
|
---|
[355] | 1405 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
|
---|
| 1406 | */
|
---|
[328] | 1407 |
|
---|
| 1408 |
|
---|
| 1409 | struct recompile
|
---|
| 1410 | {
|
---|
[355] | 1411 | recompile(vector<string> localPackages) : thePackages(localPackages) { }
|
---|
| 1412 | void operator()()
|
---|
| 1413 | {
|
---|
[328] | 1414 | TheInstallButton->Disable();
|
---|
[355] | 1415 | recompileAll(thePackages);
|
---|
| 1416 | TheInstallButton->Enable();
|
---|
[423] | 1417 |
|
---|
[355] | 1418 | }
|
---|
[328] | 1419 |
|
---|
[355] | 1420 | vector<string> thePackages;
|
---|
[328] | 1421 | };
|
---|
| 1422 |
|
---|
[423] | 1423 | void globalize2(void) {
|
---|
| 1424 | TheInstallButton->Disable();
|
---|
| 1425 | globalizeData();
|
---|
| 1426 | TheInstallButton->Enable();
|
---|
| 1427 | }
|
---|
| 1428 |
|
---|
| 1429 |
|
---|
| 1430 |
|
---|
[328] | 1431 | void MainWindow::OnInstallButtonClick( wxCommandEvent& event )
|
---|
| 1432 | {
|
---|
[355] | 1433 |
|
---|
[328] | 1434 | vector<string> localPackages;
|
---|
[423] | 1435 | localPackages.push_back("00000Globalize");
|
---|
[328] | 1436 | for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
|
---|
| 1437 | if ( !localPackages.empty() ) {
|
---|
[423] | 1438 | sort(localPackages.begin(), localPackages.end());
|
---|
| 1439 | localPackages[0] = "Globalize";
|
---|
[328] | 1440 | //MainWindow::MainWindow().Hide();
|
---|
[355] | 1441 | // boost::thread thrd2(recompileAll(localPackages) );
|
---|
[328] | 1442 | //MainWindow::MainWindow().Show();
|
---|
[357] | 1443 | this->InstallButton->Disable();
|
---|
| 1444 | this->ReglobalizeButton->Disable();
|
---|
[353] | 1445 | #ifdef WIN32
|
---|
| 1446 | recompile packages(localPackages);
|
---|
| 1447 | boost::thread thrd(packages);
|
---|
| 1448 | #else
|
---|
| 1449 | recompileAll(localPackages);
|
---|
| 1450 | #endif
|
---|
[328] | 1451 |
|
---|
[357] | 1452 | this->InstallButton->Enable();
|
---|
| 1453 | this->ReglobalizeButton->Enable();
|
---|
[328] | 1454 | }
|
---|
[355] | 1455 |
|
---|
| 1456 |
|
---|
[328] | 1457 | }
|
---|
| 1458 |
|
---|
[353] | 1459 | /*void setStatusArea( string s ) {
|
---|
[355] | 1460 | //TheStatusBar = MainWindow::StatusArea;
|
---|
| 1461 | (**TheStatusBar).SetStatusText(_(s.c_str()), 0);
|
---|
| 1462 |
|
---|
| 1463 | //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
|
---|
| 1464 |
|
---|
| 1465 | //MainWindow::StatusBar->SetLabel("Importing Files...");
|
---|
| 1466 | //StatusBar->SetLabel(s);
|
---|
[328] | 1467 | //->SetLabel(s);
|
---|
[355] | 1468 |
|
---|
[353] | 1469 | }*/
|
---|
[328] | 1470 |
|
---|
| 1471 | void setProgressBar( int i ) {
|
---|
[355] | 1472 | //TheProgressBar->SetValue(
|
---|
[394] | 1473 | #ifdef WIN32
|
---|
| 1474 |
|
---|
[328] | 1475 |
|
---|
[394] | 1476 |
|
---|
| 1477 | if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3)))
|
---|
| 1478 | {
|
---|
| 1479 |
|
---|
| 1480 | pTaskbarList3->SetProgressValue(Handle,i, 1000);
|
---|
| 1481 | if ( i == 0 ) {
|
---|
| 1482 |
|
---|
| 1483 | pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS);
|
---|
| 1484 | }
|
---|
| 1485 | }
|
---|
| 1486 |
|
---|
| 1487 |
|
---|
| 1488 | #endif
|
---|
[328] | 1489 | TheProgressBar->SetValue(i);
|
---|
| 1490 |
|
---|
| 1491 | }
|
---|
| 1492 |
|
---|
| 1493 |
|
---|
| 1494 | /*
|
---|
[355] | 1495 | * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
|
---|
| 1496 | */
|
---|
[328] | 1497 |
|
---|
| 1498 | void MainWindow::OnStatusbarUpdate( wxUpdateUIEvent& event )
|
---|
| 1499 | {
|
---|
[355] | 1500 | ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
|
---|
[385] | 1501 | // Before editing this code, remove the block markers.
|
---|
| 1502 | event.Skip();
|
---|
[355] | 1503 | ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
|
---|
[328] | 1504 | }
|
---|
| 1505 |
|
---|
| 1506 |
|
---|
| 1507 | /*
|
---|
[355] | 1508 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
|
---|
| 1509 | */
|
---|
[328] | 1510 |
|
---|
| 1511 | void MainWindow::OnAboutClick( wxCommandEvent& event )
|
---|
| 1512 | {
|
---|
[355] | 1513 | ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
|
---|
[385] | 1514 | // Before editing this code, remove the block markers.
|
---|
| 1515 | About* window = new About(this);
|
---|
| 1516 | int returnValue = window->ShowModal();
|
---|
| 1517 | window->Destroy();
|
---|
[355] | 1518 | ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
|
---|
[328] | 1519 | }
|
---|
| 1520 |
|
---|
| 1521 |
|
---|
| 1522 | /*
|
---|
[355] | 1523 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
|
---|
| 1524 | */
|
---|
[328] | 1525 |
|
---|
| 1526 | void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event )
|
---|
| 1527 | {
|
---|
| 1528 | static_cast<string>("-import:nosep");
|
---|
| 1529 | }
|
---|
| 1530 |
|
---|
| 1531 |
|
---|
| 1532 | /*
|
---|
[355] | 1533 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
|
---|
| 1534 | */
|
---|
[328] | 1535 |
|
---|
| 1536 | void MainWindow::OnSepRadioButtonSelected( wxCommandEvent& event )
|
---|
| 1537 | {
|
---|
| 1538 | static_cast<string>("-import:sep");
|
---|
| 1539 | }
|
---|
| 1540 |
|
---|
| 1541 |
|
---|
| 1542 | /*
|
---|
[355] | 1543 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
|
---|
| 1544 | */
|
---|
[328] | 1545 |
|
---|
| 1546 | /*
|
---|
[355] | 1547 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
|
---|
| 1548 | */
|
---|
[328] | 1549 |
|
---|
| 1550 | void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event )
|
---|
| 1551 | {
|
---|
[355] | 1552 | splitInstances = NOT_SPLIT;
|
---|
[328] | 1553 |
|
---|
| 1554 | }
|
---|
| 1555 |
|
---|
| 1556 |
|
---|
| 1557 | /*
|
---|
[355] | 1558 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
|
---|
| 1559 | */
|
---|
[328] | 1560 |
|
---|
| 1561 | void MainWindow::OnRefreshButtonClick( wxCommandEvent& event )
|
---|
| 1562 | {
|
---|
| 1563 | refreshMods(globalInstalledMods);
|
---|
| 1564 | }
|
---|
| 1565 |
|
---|
| 1566 |
|
---|
| 1567 | /*
|
---|
[355] | 1568 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
|
---|
| 1569 | */
|
---|
[328] | 1570 |
|
---|
| 1571 |
|
---|
| 1572 |
|
---|
| 1573 |
|
---|
| 1574 | void MainWindow::refreshMods (vector<string> s) {
|
---|
[355] | 1575 |
|
---|
[328] | 1576 | Mods_CheckboxList->Clear();
|
---|
[355] | 1577 | //globalInstalledMods = getPackages();
|
---|
| 1578 | for (int i = 0; i < globalPackages.size(); i++) {
|
---|
| 1579 | Mods_CheckboxList->Append(globalPackages[i].name.c_str());
|
---|
| 1580 | if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
|
---|
| 1581 | //else Mods_CheckboxList->Check(i,0);
|
---|
| 1582 |
|
---|
| 1583 | }
|
---|
[328] | 1584 | }
|
---|
| 1585 |
|
---|
| 1586 | void MainWindow::OnLoadClick( wxCommandEvent& event )
|
---|
| 1587 | {
|
---|
[357] | 1588 | if (busy == 1) return;
|
---|
[328] | 1589 | static const wxChar *FILETYPES = _T(
|
---|
| 1590 | "Mod Loadouts (*.cfg)|*.cfg|"
|
---|
| 1591 | "All files (*.*)|*.*"
|
---|
[355] | 1592 | );
|
---|
| 1593 |
|
---|
[328] | 1594 | wxFileDialog* openFileDialog =
|
---|
| 1595 | new wxFileDialog( this, _("Open Mod Loadout"), "", "", FILETYPES,
|
---|
[355] | 1596 | wxOPEN, wxDefaultPosition);
|
---|
| 1597 |
|
---|
[328] | 1598 | if ( openFileDialog->ShowModal() == wxID_OK )
|
---|
| 1599 | {
|
---|
| 1600 | refreshMods(getInstallString( string(openFileDialog->GetPath()) ));
|
---|
| 1601 | }
|
---|
| 1602 |
|
---|
| 1603 |
|
---|
| 1604 | }
|
---|
| 1605 |
|
---|
| 1606 |
|
---|
| 1607 | /*
|
---|
[355] | 1608 | * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
|
---|
| 1609 | */
|
---|
[328] | 1610 |
|
---|
| 1611 | void MainWindow::OnSaveClick( wxCommandEvent& event )
|
---|
| 1612 | {
|
---|
[357] | 1613 | if (busy == 1) return;
|
---|
[328] | 1614 | static const wxChar *FILETYPES = _T(
|
---|
| 1615 | "Mod Loadouts (*.cfg)|*.cfg|"
|
---|
| 1616 | "All files (*.*)|*.*"
|
---|
[355] | 1617 | );
|
---|
[328] | 1618 |
|
---|
[355] | 1619 | wxFileDialog* openFileDialog =
|
---|
[328] | 1620 | new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
|
---|
| 1621 | wxSAVE, wxDefaultPosition);
|
---|
| 1622 |
|
---|
| 1623 | if ( openFileDialog->ShowModal() == wxID_OK )
|
---|
| 1624 | {
|
---|
| 1625 |
|
---|
| 1626 |
|
---|
[355] | 1627 | //Mods_CheckboxList->
|
---|
[328] | 1628 |
|
---|
| 1629 |
|
---|
[355] | 1630 |
|
---|
[328] | 1631 | //
|
---|
[355] | 1632 |
|
---|
[328] | 1633 | if ( exists( openFileDialog->GetPath().c_str() ) )
|
---|
[355] | 1634 | {
|
---|
| 1635 | remove( openFileDialog->GetPath().c_str() );
|
---|
| 1636 | }
|
---|
[328] | 1637 |
|
---|
[355] | 1638 | ofstream file(openFileDialog->GetPath().c_str());
|
---|
[328] | 1639 |
|
---|
[355] | 1640 | vector<string>list;
|
---|
| 1641 | for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
|
---|
| 1642 | vector<string>::iterator begin_iter = list.begin();
|
---|
| 1643 | vector<string>::iterator end_iter = list.end();
|
---|
[328] | 1644 |
|
---|
[355] | 1645 | sort( list.begin(), list.end() );
|
---|
[328] | 1646 |
|
---|
[355] | 1647 | for( ; begin_iter != end_iter; ++begin_iter) {
|
---|
| 1648 | file << *begin_iter << " ";
|
---|
| 1649 | }
|
---|
| 1650 |
|
---|
| 1651 | file.close();
|
---|
| 1652 | file.clear();
|
---|
| 1653 |
|
---|
[328] | 1654 | //SetCurrentFilename(openFileDialog->GetFilename());
|
---|
| 1655 | //theText->LoadFile(openFileDialog->GetFilename());
|
---|
| 1656 | //SetStatusText(GetCurrentFilename(), 0);
|
---|
| 1657 | //SetStatusText(openFileDialog->GetDirectory(),1);
|
---|
| 1658 | }
|
---|
| 1659 | }
|
---|
| 1660 |
|
---|
| 1661 |
|
---|
[355] | 1662 |
|
---|
[328] | 1663 | /*
|
---|
[355] | 1664 | * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
|
---|
| 1665 | */
|
---|
[328] | 1666 |
|
---|
| 1667 | void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event )
|
---|
| 1668 | {
|
---|
[379] | 1669 | 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] | 1670 |
|
---|
| 1671 | if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no...
|
---|
[357] | 1672 |
|
---|
[355] | 1673 | }
|
---|
| 1674 | else {
|
---|
| 1675 |
|
---|
[357] | 1676 | this->InstallButton->Disable();
|
---|
| 1677 | this->ReglobalizeButton->Disable();
|
---|
[355] | 1678 |
|
---|
| 1679 | #ifdef WIN32
|
---|
| 1680 |
|
---|
[357] | 1681 | boost::thread thrd2(globalizeData);
|
---|
| 1682 | //globalizeData();
|
---|
| 1683 | //boost::thread::create_thread(&globalizeData);
|
---|
| 1684 | // boost::thread_group Tg;
|
---|
| 1685 | // Tg.create_thread( &globalizeData(), this );
|
---|
[355] | 1686 | #else
|
---|
[357] | 1687 | globalizeData();
|
---|
[355] | 1688 | #endif
|
---|
[357] | 1689 |
|
---|
| 1690 | this->InstallButton->Enable();
|
---|
| 1691 | this->ReglobalizeButton->Enable();
|
---|
| 1692 | }
|
---|
[328] | 1693 |
|
---|
[355] | 1694 | }
|
---|
[328] | 1695 | /*
|
---|
[355] | 1696 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
|
---|
| 1697 | */
|
---|
[328] | 1698 |
|
---|
[331] | 1699 | /*void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
|
---|
[328] | 1700 | {
|
---|
[331] | 1701 | ////@begin wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
|
---|
[355] | 1702 | // Before editing this code, remove the block markers.
|
---|
| 1703 | event.Skip();
|
---|
[331] | 1704 | ////@end wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
|
---|
| 1705 | }*/
|
---|
[328] | 1706 |
|
---|
[385] | 1707 |
|
---|
| 1708 | /*
|
---|
| 1709 | * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Seperated_RadioButton
|
---|
| 1710 | */
|
---|
| 1711 |
|
---|
| 1712 | void MainWindow::OnSeperatedRadioButtonSelected( wxCommandEvent& event )
|
---|
| 1713 | {
|
---|
| 1714 | splitInstances = SPLIT;
|
---|
| 1715 | }
|
---|
| 1716 |
|
---|