ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/AE/Installer/trunk/source/main_window.cpp
(Generate patch)

Comparing AE/Installer/trunk/source/main_window.cpp (file contents):
Revision 327 by iritscen, Mon Jun 1 01:51:40 2009 UTC vs.
Revision 328 by gumby, Mon Jun 1 02:04:33 2009 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)