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