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