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 410 by gumby, Wed Jul 8 17:20:07 2009 UTC vs.
Revision 487 by iritscen, Wed Dec 30 01:51:38 2009 UTC

# Line 1 | Line 1
1 + /***************************************************************************\
2 + | Project: AE Installer                                                                                                         |
3 + | By: Gumby & Iritscen                                                                                                          |
4 + | File: Main_Window.cpp                                                                                                         |
5 + | Function: Handles the GUI.                                                                                            |
6 + | Created: 07/05/2009 20:38:25                                                                                          |
7 + \***************************************************************************/
8 +
9   #ifndef NTDDI_VERSION          
10   #define NTDDI_VERSION NTDDI_WIN7
11   #endif
12   #ifdef WIN32
13 < #include <windows.h>
13 > #include <windows.h>
14   #include <shobjidl.h>
15   HWND Handle;
8
16   ITaskbarList *pTaskbarList;
17   ITaskbarList3 *pTaskbarList3;
18   #endif
19  
13 /*
14 AE/Mod Installer
15 by Gumby and Iritscen
16 */
17
18 // To-do: - Load credits from text resource file
19 //                - Institute lots of checks into file-handling
20 //                - Clear mod info fields when mod is de-selected
21
22 #define DEBUG
23 #include <stdio.h>
24 //#include <conio.h>
25 //#include <process.h>
26 #include <string>
27 #include <iostream>
28 #include <cctype>
29 #include <vector>
30 #include <fstream>
31 #include <errno.h>
32 #include <sstream>
33
34 #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations
35 #include "boost/lexical_cast.hpp" //int -> string
36 #include "installer.h"
37
38 #ifdef WIN32
39 #include <windows.h>
40 #else // assume we're on Mac
41 #include <stdlib.h>
42 #include <dirent.h>
43 #endif
44
45 //const string strInstallerVersion = "1.0";
46 const bool SPLIT = 1;
47 const bool NOT_SPLIT = 0;
48 bool splitInstances = SPLIT;
49 bool busy = 0;
50 #ifdef WIN32
51 const string strOniSplit = "Onisplit.exe";
52 string strImportOption = "-import:nosep";
53 const char* strClsCmd = "cls";
54 const char* strPauseCmd = "PAUSE";
55 #else // set up Mac equivalents since we're in Mac OS
56 const string strOniSplit = "mono Onisplit.exe";
57 string strImportOption = "-import:sep";
58 const char* strClsCmd = "clear";
59 const char* strPauseCmd = "read -n 1 -p \"Press any key to continue\"";
60 void Sleep(int ms) { sleep( ms / 1000 ); }
61 #endif
62
63 using namespace boost::filesystem;
64 using namespace std;
65
66
67
68
69 #include "boost/date_time/gregorian/gregorian.hpp"
70 #include "boost/date_time/date_parsing.hpp"
71 #include "boost/date_time/posix_time/posix_time.hpp"
72
73 string escapePath(string input) {
74        
75        string output;
76        string escape_me = "& ;()|<>\"'\\#*?$";
77        for(int i = 0; i < input.size(); i++)  {
78                for(int j = 0; j < escape_me.size(); j++) if (input[i] == escape_me[j]) output += '\\';
79                output += input[i];
80        }
81        return output;
82 }
83
84 int globalizeData(void)
85 {
86        busy = 1;
87        using boost::lexical_cast;
88        using boost::bad_lexical_cast;
89        // using namespace boost::posix_time;
90        using namespace boost::gregorian;
91        using namespace boost::posix_time;
92        ptime start_time(second_clock::local_time());
93
94        setStatusArea("Globalizing!");
95        int err = 0;
96        int parts_done = 0;
97        char Step_x_x[300];
98        //char levels[i][5];
99        remove("Globalize.log");
100        ofstream logfile("Globalize.log");
101        logfile << "Globalization started " << to_simple_string(start_time) << endl;
102        try {
103
104                char levels_cstr[15][3] = {"0", "1", "2", "3", "4", "6", "8", "9", "10", "11", "12", "13", "14", "18", "19"}; // the levels Oni has...probably should have made a string array. Oops.
105                //const vector<double> ck(cv, &cv[CvSize]);
106                vector<string> levels;
107                for (int f = 0; f < 15; f++) {
108                        levels.push_back(levels_cstr[f]);
109                }
110                char choice = 0;
111
112                //SetCurrentDirectory("C:/Program Files/Oni/edition/install");
113                ///char levels[i][3];
114                path Characters = "../GameDataFolder/level0_Characters";
115                path Particles = "../GameDataFolder/level0_Particles";
116                path Archive = "../GameDataFolder/Archive";
117                path Textures  = "../GameDataFolder/level0_Textures";
118                path Sounds = "../GameDataFolder/level0_Sounds";
119                path Animations = "../GameDataFolder/level0_Animations";
120                path TRAC = Animations / "level0_TRAC";
121                path TRAM = Animations / "level0_TRAM";
122
123                vector<path> GDFPaths;
124                //GDFPaths.push_back(Characters);
125                GDFPaths.push_back(Particles);
126                GDFPaths.push_back(Textures);
127                GDFPaths.push_back(Sounds);
128                GDFPaths.push_back(TRAC);
129                GDFPaths.push_back(TRAM);
130
131
132                path VanillaCharacters = "VanillaDats/level0_Final/level0_Characters/level0_Characters.oni";
133                path VanillaParticles = "VanillaDats/level0_Final/level0_Particles/level0_Particles.oni";
134                path VanillaTextures  = "VanillaDats/level0_Final/level0_Textures/level0_Textures.oni";
135                path VanillaSounds = "VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni";
136                path VanillaAnimations = "VanillaDats/level0_Final/level0_Animations/level0_Animations.oni";
137                path VanillaTRAC = "VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni";
138                path VanillaTRAM = "VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni";
139
140                vector<path> VanillaPaths;
141
142                //VanillaPaths.push_back(VanillaCharacters);
143                VanillaPaths.push_back(VanillaParticles);
144                VanillaPaths.push_back(VanillaTextures);
145                VanillaPaths.push_back(VanillaSounds);
146                VanillaPaths.push_back(VanillaTRAC);
147                VanillaPaths.push_back(VanillaTRAM);
148
149                /*
150                if (exists("../GameDataFolder/"))
151                {
152                //cout << "\nIt looks like you've already globalized Oni's data.\nDo you want to re-globalize?\n(This will erase existing mods installed to the AE's game data.)"
153                //       << "\n1. Re-globalize"
154                //       << "\n2. Return to main menu\n";
155                //choice = cin.get();
156                cin.ignore(128, '\n');
157                if (choice == '1')
158                remove_all("../GameDataFolder"); // remove AE GDF
159                if (choice == '2')
160                return 0;
161                }
162                */
163                setStatusArea("Removing old GameDataFolder...\n");
164                logfile <<  "Removing old GameDataFolder...\n";
165                remove_all( "../GameDataFolder/" );
166                setStatusArea("Creating needed directories...");
167                logfile <<  "Creating needed directories...\n";
168                create_directory( "../GameDataFolder/" );
169
170                create_directory( "packages" );
171
172                if (exists("VanillaDats")) remove_all("VanillaDats");
173                create_directory( "VanillaDats" );
174                create_directory( "VanillaDats/level0_Final/" );
175                //blah blah finish this.
176                //logfile <<  "VanillaDats/level0_Final/ created";
177                create_directory( Characters );
178                create_directory( Particles );
179                create_directory( Archive );
180                create_directory( Textures );
181                create_directory( Sounds );
182                create_directory( Animations );
183                create_directory( TRAC );
184                create_directory( TRAM );
185                int num_levels = 0;
186                for(int i = 1; i < 15; i++)
187                {
188                        if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) {
189                                num_levels++;
190
191                        }
192                }
193                logfile << "Exporting and moving...\n\n";
194                int total_steps =  8 + 2 * num_levels;
195                for(int i = 0; i < 15; i++)
196                {
197
198                        //printf(levels[i],"%d",levels[i]); // int to char array
199
200                        if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) {
201                                logfile << "level" << levels[i] << "_Final\n";
202                                logfile << "\tExporting level" << levels[i] << "_Final.dat\n";
203                                //printf(Step_x_x,"Step %d/%d: exporting level%d_final.dat", parts_done + 1,, levels[i]); setStatusArea((string)Step_x_x);
204                                setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " exporting level" + levels[i]+"_Final.dat");
205                                create_directory( "../GameDataFolder/level" + levels[i] + "_Final" );
206                                //                              setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat");
207                                system((strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat").c_str());
208                                create_directory( "VanillaDats/level" + levels[i] + "_Final" );
209                                create_directory( "VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" );
210
211                                directory_iterator end_iter;
212                                for ( directory_iterator dir_itr( "../GameDataFolder/level" + levels[i] + "_Final" ); dir_itr != end_iter; ++dir_itr )
213                                {
214                                        //cout << dir_itr->path().filename();
215                                        if ( is_regular_file( dir_itr->status() ) )
216                                        {
217                                                if ( dir_itr->path().filename().substr(0,8) == "TXMPfail" ||
218                                                        dir_itr->path().filename().substr(0,9) == "TXMPlevel" ||
219                                                        ( dir_itr->path().filename().substr(0,4) == "TXMP" && dir_itr->path().filename().find("intro")!=string::npos) ||
220                                                        dir_itr->path().filename().substr(0,4) == "TXMB" ||
221                                                        dir_itr->path().filename() == "M3GMpowerup_lsi.oni" ||
222                                                        dir_itr->path().filename() == "TXMPlsi_icon.oni" ||
223                                                        ( dir_itr->path().filename().substr(0,4) == "TXMB" && dir_itr->path().filename().find("splash_screen.oni")!=string::npos)       )
224                                                {
225                                                        cout <<dir_itr->path().filename() << "\n";
226                                                        create_directory( dir_itr->path().parent_path() / "NoGlobal");  
227                                                        if(!exists( dir_itr->path().parent_path() / "NoGlobal" / dir_itr->filename())) rename(dir_itr->path(), dir_itr->path().parent_path() / "NoGlobal" /
228                                                                dir_itr->filename());
229                                                        else remove(dir_itr->path());
230                                                }
231                                                else if (dir_itr->path().filename().substr(0,4) == "TRAC"
232                                                        ) {
233                                                                cout <<dir_itr->path().filename() << "\n";
234                                                                if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename());
235                                                                else remove(dir_itr->path());
236                                                }
237                                                else if (dir_itr->path().filename().substr(0,4) == "TRAM") {
238                                                        cout <<dir_itr->path().filename() << "\n";
239                                                        if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename());
240                                                        else remove(dir_itr->path());
241                                                }
242                                                else if (dir_itr->path().filename().substr(0,4) == "ONSK" ||
243                                                        dir_itr->path().filename().substr(0,4) == "TXMP") {
244                                                                cout <<dir_itr->path().filename() << "\n";\
245                                                                        create_directory( dir_itr->path().parent_path() / "TexFix");    
246                                                                if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename());
247                                                                //rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename());
248                                                }
249                                                else if (dir_itr->path().filename().substr(0,4) == "ONCC"
250                                                        || dir_itr->path().filename().substr(0,4) == "TRBS"
251                                                        || dir_itr->path().filename().substr(0,4) == "ONCV"
252                                                        || dir_itr->path().filename().substr(0,4) == "ONVL"
253                                                        || dir_itr->path().filename().substr(0,4) == "TRMA"
254                                                        || dir_itr->path().filename().substr(0,4) == "TRSC"
255                                                        || dir_itr->path().filename().substr(0,4) == "TRAS") {
256                                                                cout <<dir_itr->path().filename() << "\n";
257                                                                if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename());
258                                                                else remove(dir_itr->path());
259                                                }
260                                                else if (dir_itr->path().filename().substr(0,4) == "OSBD"
261                                                        || dir_itr->path().filename().substr(0,4) == "SNDD") {
262                                                                cout << dir_itr->path().filename() << "\n";
263                                                                if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename());
264                                                                else remove(dir_itr->path());
265                                                }
266                                                else if (dir_itr->path().filename().substr(0,5) == "BINA3"
267                                                        || dir_itr->path().filename().substr(0,10) == "M3GMdebris"
268                                                        || dir_itr->path().filename() == "M3GMtoxic_bubble.oni"
269                                                        || dir_itr->path().filename().substr(0,8) == "M3GMelec"
270                                                        || dir_itr->path().filename().substr(0,7) == "M3GMrat"
271                                                        || dir_itr->path().filename().substr(0,7) == "M3GMjet"
272                                                        || dir_itr->path().filename().substr(0,9) == "M3GMbomb_"
273                                                        || dir_itr->path().filename() == "M3GMbarab_swave.oni"
274                                                        || dir_itr->path().filename() == "M3GMbloodyfoot.oni"
275                                                        ){
276                                                                cout <<dir_itr->path().filename() << "\n";
277                                                                if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename());
278                                                                else remove(dir_itr->path());
279                                                }
280                                                else if (dir_itr->path().filename().substr(0,4) == "AGDB"
281                                                        || dir_itr->path().filename().substr(0,4) == "TRCM") {
282                                                                cout <<dir_itr->path().filename() << "\n";
283
284                                                                if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename());
285                                                                else remove(dir_itr->path());
286                                                }
287                                                else if (dir_itr->path().filename().substr(0,4) == "ONWC") { //fix for buggy ONWC overriding
288                                                                cout <<dir_itr->path().filename() << "\n";
289
290                                                                if(!exists( "VanillaDats/level0_Final/level0_Final/" +  dir_itr->filename())) rename(dir_itr->path(), "VanillaDats/level0_Final/level0_Final/" +  dir_itr->filename());
291                                                                else remove(dir_itr->path());
292                                                }
293
294                                                if (exists(dir_itr->path())) {
295
296                                                }
297                                                else {
298                                                        logfile << "\tMoved file: " << dir_itr->path().filename() << "\n";
299                                                }
300                                        }
301
302
303
304                                }
305                                logfile << "\tCleaning up TXMPs...\n";
306                                system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + levels[i] + "_Final/TXMP*.oni").c_str());
307                                parts_done++;
308
309                                setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
310
311                        }
312                }
313                logfile << "Reimporting levels\n";
314                for (int i = 0; i < 15; i++)
315                {
316                        logfile << "\tReimporting level" << levels[i] << "_Final.oni\n";
317                        //printf(levels[i],"%d",levels[i]);
318                        //printf(Step_x_x,"Step %d/%d: reimporting level", parts_done + 1, 7 + 2 * num_levels); setStatusArea((string)Step_x_x + levels[i] + (string)"_Final.dat");
319                        setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni");
320                        logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level"
321                                + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n';
322                        string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level"
323                                + levels[i] + "_Final/level" + levels[i] + "_Final.oni");
324                                system(sys_str.c_str() );
325                        setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
326                        parts_done++;
327                }
328                //create_directory( VanillaCharacters.parent_path() );
329                create_directory( VanillaParticles.parent_path() );
330                create_directory( VanillaTextures.parent_path() );
331                create_directory( VanillaSounds.parent_path() );
332                create_directory( VanillaAnimations.remove_filename() );
333
334                for(int j = 0; j < GDFPaths.size(); j++) {
335                        logfile << "\tReimporting " << GDFPaths[j].filename() << ".oni\n";
336                        setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": reimporting " + GDFPaths[j].filename() );
337                        system((strOniSplit + " " + strImportOption + " " + GDFPaths[j].string() + " " + VanillaPaths[j].string()).c_str());
338                        parts_done++;
339                        setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
340                }
341                logfile << "\nMoving level0_Characters\n";
342                setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": moving level0_Characters" );      
343                copy((path)"../GameDataFolder/level0_Characters", (path)("VanillaDats/level0_Final"));
344                /*
345                printf(Step_x_x,"Step %d/%d: reimporting level0_Characters", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
346                system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str());
347                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Particles", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
348                system((strOniSplit + " " + strImportOption + " " + Particles.string() + " " + VanillaParticles.string()).c_str());
349                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Textures", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
350                system((strOniSplit + " " + strImportOption + " " + Textures.string() + " " + VanillaTextures.string()).c_str());
351                //system((strOniSplit   + " " + strImportOption + (string)" " + Animations.string() + (string)" " + VanillaAnimations.string()).c_str());
352                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAC", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
353                system((strOniSplit + " " + strImportOption + " " + TRAC.string() + " " + VanillaTRAC.string()).c_str());
354                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Sounds", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
355                system((strOniSplit + " " + strImportOption + " " + Sounds.string() + " " + VanillaSounds.string()).c_str());
356                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAM", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
357                system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str());
358                //parts_done++; setStatusArea((string)"Copying level scripts...");setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
359                if (exists("../GameDataFolder/IGMD")) remove_all("../GameDataFolder/IGMD");
360                */
361                create_directory((path)"../GameDataFolder/IGMD");
362                copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder");
363                setProgressBar( 1000 );
364
365                if(!exists("../persist.dat"))
366                        copy("../../persist.dat","..");
367                if(!exists("../key_config.txt"))
368                        copy("../../key_config.txt","..");
369                
370 #ifndef WIN32
371                /* On Mac only, set the current GDF to the AE GDF by writing to Oni's global preferences file (thankfully a standard OS X ".plist" XML file).
372                   Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never
373                   run Oni before :-p */
374                string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for edition/
375                char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '";
376                strcat(prefsCommand, fullAEpath.c_str()); // get path of edition/ folder (Oni wants the folder that *contains* the GDF)
377                strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters
378                system(prefsCommand);
379                
380 #endif
381                
382                
383                setStatusArea((string)"Done! Now select your mod packages and click install.");
384                //      while(1) Sleep(-1);
385
386        }
387        catch (exception & ex) {
388                setStatusArea("Warning, handled exception: " + (string)ex.what());
389        }
390
391        ptime end_time(second_clock::local_time());
392        time_period total_time (start_time, end_time);
393        logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
394        //total_time.length().hours();
395        logfile.close();
396        busy = 0;
397        return err;
398 }
399
400
401 vector<ModPackage> getPackages(void)
402 {
403        vector<ModPackage> packages;
404        packages.reserve(65536); // come on, we shouldn't need this much space...right?!
405        fstream file;
406        string filename = "\0";
407        string MODINFO_CFG = "Mod_Info.cfg";
408
409        try
410        {
411                directory_iterator end_iter;
412                for (directory_iterator dir_itr("./packages"); dir_itr != end_iter; ++dir_itr)
413                {
414                        file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str());
415                        //cout << filename << "\n";
416
417                        if(!file.fail())
418                        {
419                                //cout << dir_itr->path().string() + MODINFO_CFG;
420                                //would prefer to push a pointer to a package, but this will do for now
421                                packages.push_back(fileToModPackage(file));
422                        }      
423                        file.close();
424                        file.clear();
425                }
426                sort(packages.begin(), packages.end());
427        }
428        catch (const std::exception & ex)
429        {
430                cout << "Warning, something odd happened!\n";
431        }
432
433        return packages;
434 }
435
436 ModPackage fileToModPackage(fstream &file)
437 {
438        /*
439        This converts a file to a ModPackage struct.
440
441        A few notes...
442        "iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok.
443        I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much
444        slower than reading a variable.
445        */
446        ModPackage package;
447        string line;
448        static string NameOfMod = "NameOfMod";  //used for comparing to the current token...
449        //I could have done it in reverse (*iter).compare("ModString") or  
450        static string ARROW = "->";                             //did something like "ModString".compare(*iter), and it would have been
451        static string ModString = "ModString";  //functionably the same.
452        static string HasOnis = "HasOnis";
453        static string HasDeltas = "HasDeltas";
454        static string HasBSL = "HasBSL";
455        static string HasDats = "HasDats";
456        static string IsEngine = "IsEngine";
457        static string Readme = "Readme";
458        static string GlobalNeeded = "GlobalNeeded";
459        static string Category = "Category";
460        static string Creator = "Creator";
461        while (! file.eof() )
462        {
463                getline (file,line);
464                vector<string> tokens;
465                vector<string>::iterator iter;
466                tokenize(line, tokens);                                 //string to vector of "words"
467                if (tokens.capacity() >= 2) {                   //make sure they are using enough stuff
468                        iter = tokens.begin();                          //what word we are on, starts at first word
469                        /*
470                        if (!AEInstallVersion.compare(*iter))
471                        If mod is too old, skip this mod.
472                        */
473                        /*else*/if (!NameOfMod.compare(*iter))  {       //if it contains the name
474                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
475                                        if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) {                 //ignores "->" and "NameOfMod"
476                                                //cout << *iter;
477                                                //cout << " ";
478                                                package.name += *iter + " ";
479                                        }
480                                }
481
482                        }
483                        else if (!ModString.compare(*iter)) {
484                                iter++; iter++;
485                                package.modStringName = *iter;
486                                iter++;
487                                package.modStringVersion = atoi((*iter).c_str());
488                        }
489                        else if (!HasOnis.compare(*iter)) {
490                                iter++; iter++;  
491                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasOnis = 1; //Gotta love c++'s lack of a standard case-insensitive
492                                else if (!HasBSL.compare(*iter)) { // string comparer...I know my implementation here sucks. I need to change it to check each character one by one. At the moment,
493                                        iter++; iter++;}  // using "YFR" would probably set it off. :<
494
495                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasBSL = 1;
496                        }
497                        else if (!HasDeltas.compare(*iter)) {
498                                iter++; iter++;  
499                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1;
500                        }
501                        else if (!HasDats.compare(*iter)) {
502                                iter++; iter++;  
503                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1;
504                        }
505                        else if (!IsEngine.compare(*iter)) {
506                                iter++; iter++;  
507                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1;
508                        }
509                        else if (!GlobalNeeded.compare(*iter)) {
510                                iter++; iter++;  
511                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1;
512                                else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; //Really the only place where checking for "No" is important atm.
513                        }
514                        else if (!Category.compare(*iter))  {  
515                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
516                                        if (ARROW.compare(*iter) && Category.compare(*iter)) {                  //ignores "->" and "Category"
517                                                //cout << *iter;
518                                                //cout << " ";
519                                                package.category += *iter + " ";
520                                        }
521                                }
522                        }
523                        else if (!Creator.compare(*iter))  {    //if it contains the name
524                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
525                                        if (ARROW.compare(*iter) && Creator.compare(*iter)) {                   //ignores "->" and "Category"
526                                                //cout << *iter;
527                                                //cout << " ";
528                                                package.creator += *iter + " ";
529                                        }
530                                }
531                        }
532                        else if (!Readme.compare(*iter))  {     //if it contains the name
533                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
534                                        if (ARROW.compare(*iter) && Readme.compare(*iter)) {                    //ignores "->" and "Category"
535                                                if(!(*iter).compare("\\n")) package.readme += '\n';
536                                                else package.readme += *iter + " ";
537                                        }
538                                }
539                        }
540                }
541
542        }
543        package.doOutput();
544        return package;
545 }
546
547 void recompileAll(vector<string> installedMods)
548 {
549        busy = 1;
550        using namespace boost::gregorian;
551        using namespace boost::posix_time;
552        using boost::lexical_cast;
553        using boost::bad_lexical_cast;
554        
555        setStatusArea("Importing levels...");
556        //setStatusArea("Recompiling Data...");
557        path vanilla_dir = "./VanillaDats/";
558        string importCommand = "";
559        char statusString[128];
560        int numberOfDats = 0;
561        int j = 1;
562        string datString;
563        std::stringstream out;
564
565        ptime start_time(second_clock::local_time());
566        clearOldDats();
567        remove("Install.log");
568        ofstream logfile("Install.log");
569        logfile << "Mod Installation started " << to_simple_string(start_time) << endl;
570        logfile.close();
571        if(splitInstances == SPLIT){
572                recursive_directory_iterator end_iter;
573
574                for ( recursive_directory_iterator dir_itr( vanilla_dir );
575                        dir_itr != end_iter;
576                        ++dir_itr )
577                {
578                        try{
579                                if ( is_directory( dir_itr->status() ) &&  dir_itr.level() == 1)
580                                {
581                                        numberOfDats++;
582                                }
583                        }
584                        catch(exception ex) {
585
586                        }
587                }
588                try {
589                //recursive_directory_iterator end_iter;
590
591
592                out << numberOfDats;
593                datString = out.str();
594                        for ( recursive_directory_iterator dir_itr( vanilla_dir );
595                                dir_itr != end_iter;
596                                ++dir_itr )
597                        {
598                                try
599                                {
600                                        if ( is_directory( dir_itr->status() ) &&  dir_itr.level() == 1)
601                                        {
602                                                importCommand = strOniSplit + " " + strImportOption + " " + dir_itr->path().parent_path().string() + '/' + dir_itr->path().filename();
603                                                for (int i = 0; i < installedMods.size(); ++i) {
604                                                        if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename()  ))
605                                                                importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename();
606
607                                                        //else cout << " VanillaDats/" + installedMods[i] + "/oni/";
608                                                }
609                                                importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
610
611                                                
612                                                setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
613                                                setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " +  dir_itr->path().filename() + " ");
614
615                                                system(importCommand.c_str());
616                                                //Sleep(1000);
617                                                //cout << importCommand << "\n";
618                                                j++;
619
620                                        }
621                                }
622                                catch ( const std::exception & ex )
623                                {
624
625                                        remove("Install.log");
626                                        ofstream logfile("Install.log");
627
628
629                                        logfile << "Warning, exception " << ex.what() << "!";
630                                        setStatusArea("Warning, exception " + (string)ex.what() + "!");
631                                        logfile.close();        
632                                }
633                        }
634
635                }
636                catch( const std::exception & ex ) {
637
638                        remove("Install.log");
639                        ofstream logfile("Install.log");
640
641
642                        logfile << "Warning, exception " << ex.what() << "!";
643                        setStatusArea("Warning, exception " + (string)ex.what() + "!");
644                        logfile.close();
645                }
646
647        }
648        else if(splitInstances == NOT_SPLIT){
649                directory_iterator end_iter;
650
651                for ( directory_iterator dir_itr( vanilla_dir );
652                        dir_itr != end_iter;
653                        ++dir_itr )
654                {
655
656                        if ( is_directory( dir_itr->status() ) )
657                        {
658                                numberOfDats++;
659                        }
660
661
662                }
663
664                out << numberOfDats;
665                datString = out.str();
666
667                for ( directory_iterator dir_itr( vanilla_dir );
668                        dir_itr != end_iter;
669                        ++dir_itr )
670                {
671                        try
672                        {
673                                if ( is_directory( dir_itr->status() ) )
674                                {
675                                        importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " ";
676                                        for (int i = 0; i < installedMods.size(); ++i) {
677                                                if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename()  ))
678                                                        importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename();
679                                        }
680                                        importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
681
682
683                                        setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
684                                        setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " +  dir_itr->path().filename() + " ");
685
686                                        system(importCommand.c_str());
687
688                                        j++;
689                                }
690                        }
691                        catch ( const std::exception & ex )
692                        {
693
694                                remove("Install.log");
695                                ofstream logfile("Install.log");
696
697
698                                logfile << "Warning, exception " << ex.what() << "!";
699                                setStatusArea("Warning, exception " + (string)ex.what() + "!");
700                                logfile.close();
701                        }}
702        }
703        logfile << "Writing config file";
704        writeInstalledMods(installedMods);
705        setProgressBar(1000);
706        setStatusArea("Done! You can now play Oni.");
707
708        ptime end_time(second_clock::local_time());
709        time_period total_time (start_time, end_time);
710
711
712        ofstream logfile2("Install.log", ios::app | ios::ate);
713        string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length();
714
715        logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
716
717        //logfile2.write(outstring.c_str(), outstring.length());
718        logfile2.close();
719
720        //total_time.length().hours();
721
722        Sleep(1000);
723        setProgressBar(0);
724        busy = 0;
725 }
726
727 void writeInstalledMods(vector<string> installedMods)
728 {
729
730        if ( exists( strInstallCfg ) )
731        {
732                remove( strInstallCfg );
733        }
734
735        ofstream file(strInstallCfg.c_str());
736
737        vector<string>list = installedMods;
738        vector<string>::iterator begin_iter = list.begin();
739        vector<string>::iterator end_iter = list.end();
740
741        sort( list.begin(), list.end() );
742
743        for( ; begin_iter != end_iter; ++begin_iter) {
744                file << *begin_iter << " ";
745        }
746
747        file.close();
748        file.clear();
749
750 }
751
752 vector<string> getInstallString(string Cfg)
753 {
754        //system(strPauseCmd);
755        vector<string> returnval;
756
757        string line;
758        fstream file;
759
760        if (exists( Cfg ))
761        {
762                file.open(Cfg.c_str());
763                getline(file, line);
764                tokenize(line, returnval);
765                file.close();
766                file.clear();
767                sort(returnval.begin(), returnval.end());
768        }
769        else cout << "fail";
770
771        return returnval;
772 }
773
774 //stolen token function...
775 void tokenize(const string& str, vector<string>& tokens, const string& delimiters)
776 {
777        // Skip delimiters at beginning.
778        string::size_type lastPos = str.find_first_not_of(delimiters, 0);
779        // Find first "non-delimiter".
780        string::size_type pos     = str.find_first_of(delimiters, lastPos);
781
782        while (string::npos != pos || string::npos != lastPos)
783        {
784                // Found a token, add it to the vector.
785                tokens.push_back(str.substr(lastPos, pos - lastPos));
786                // Skip delimiters.  Note the "not_of"
787                lastPos = str.find_first_not_of(delimiters, pos);
788                // Find next "non-delimiter"
789                pos = str.find_first_of(delimiters, lastPos);
790        }
791 }
792
793 void clearOldDats(void) {
794        directory_iterator end_iter_gdf;
795        for ( directory_iterator dir_itr_gdf( "../GameDataFolder" );
796                dir_itr_gdf != end_iter_gdf;
797                ++dir_itr_gdf )
798        {
799                //cout << dir_itr_gdf->path().extension() << "\n";
800                if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) {
801                        remove( dir_itr_gdf->path() );
802                }
803
804        }
805
806 }
807
808 vector<string> globalInstalledMods;
809 vector<ModPackage> globalPackages;
810 #include "boost/thread.hpp"
20   #include <boost/thread/mutex.hpp>
812
813 /////////////////////////////////////////////////////////////////////////////
814 // Name:        main_window.cpp
815 // Purpose:    
816 // Author:      
817 // Modified by:
818 // Created:     07/05/2009 20:38:25
819 // RCS-ID:      
820 // Copyright:  
821 // Licence:    
822 /////////////////////////////////////////////////////////////////////////////
823
21   // For compilers that support precompilation, includes "wx/wx.h".
22   #include "wx/wxprec.h"
23  
# Line 834 | Line 31 | vector<ModPackage> globalPackages;
31  
32   ////@begin includes
33   #include "about.h"
837 ////@end includes
838
34   #include "main_window.h"
35 + #include "installer.h"
36 + ////@end includes
37  
38   ////@begin XPM images
39   #include "aelogosmall.xpm"
# Line 846 | Line 43 | vector<ModPackage> globalPackages;
43   #include "quit.xpm"
44   ////@end XPM images
45  
46 < //#define wxDebug 1;
47 < //#define wxUSE_UNICODE 1;
46 > bool busy = false;
47 > vector<string> globalInstalledMods;
48 > vector<ModPackage> globalPackages;
49 > // Variable declarations
50 > #ifdef WIN32
51 > bool splitInstances = true;
52 > string strImportOption = "-import:nosep";
53 > string strOniSplit = "Onisplit.exe";
54 > #else
55 > bool splitInstances = false;
56 > string strImportOption = "-import:sep";
57 > string strOniSplit = "mono Onisplit.exe";
58 > #endif
59  
60   /*
61   * MainWindow type definition
# Line 931 | Line 139 | bool MainWindow::Create( wxWindow* paren
139          return true;
140   }
141  
934
142   /*
143   * MainWindow destructor
144   */
# Line 942 | Line 149 | MainWindow::~MainWindow()
149          ////@end MainWindow destruction
150   }
151  
945
152   /*
153   * Member initialisation
154   */
# Line 967 | Line 173 | void MainWindow::Init()
173      CompleteRadio = NULL;
174      ReglobalizeButton = NULL;
175          ////@end MainWindow member initialisation
970
176   }
177  
973
178   /*
179   * Control creation for MainWindow
180   */
# Line 1007 | Line 211 | void MainWindow::CreateControls()
211      wxMenu* itemMenu42 = new wxMenu;
212      itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
213      menuBar->Append(itemMenu42, _("Options"));
1010    wxMenu* itemMenu44 = new wxMenu;
214   #ifdef WIN32
215          itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
216          menuBar->Append(itemMenu44, _("Help"));
# Line 1080 | Line 283 | void MainWindow::CreateControls()
283      StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 );
284      StatusArea->SetName(_T("StatusArea"));
285      StatusArea->SetFieldsCount(1);
286 <    StatusArea->SetStatusText(_("AE Installer v1.0"), 0);
286 >        string versionText = "AE Installer v" + (string)INSTALLER_VERSION;
287 >    StatusArea->SetStatusText(versionText.c_str(), 0);
288      itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0);
289  
290      wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
# Line 1150 | Line 354 | void MainWindow::CreateControls()
354          Handle = (HWND)GetHWND();
355          ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList);
356   #endif
1153
1154
1155        /*if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
1156                strImportOption = "-import:sep";
1157                splitInstances = NOT_SPLIT;
1158        }
1159        else {
1160                strImportOption = "-import:nosep";
1161                splitInstances = SPLIT;
1162        }*/
1163        
1164
1165 #ifndef WIN32
1166                strImportOption = "-import:sep";
1167                splitInstances = NOT_SPLIT;
1168 #else
1169                strImportOption = "-import:nosep";
1170                splitInstances = SPLIT;
1171 #endif
1172
1173 #ifndef WIN32
1174        strImportOption = "-import:sep";
1175        splitInstances = NOT_SPLIT;
1176 #else
1177        strImportOption = "-import:nosep";
1178        splitInstances = SPLIT;
1179 #endif
357          
358          globalPackages = getPackages();
359          globalInstalledMods = getInstallString();
360 <        for (int i = 0; i < globalPackages.size(); i++) {
360 >        for (unsigned int i = 0; i < globalPackages.size(); i++) {
361                  Mods_CheckboxList->Append(globalPackages[i].name.c_str());
362                  if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
363          }
# Line 1190 | Line 367 | void MainWindow::CreateControls()
367          TheProgressBar = ProgressBar;
368          OptionsPanel->Hide();
369          
370 < //#ifndef WIN32
1194 < //      itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1195 <        
1196 < //#endif
1197 <        
1198 <        if(splitInstances == SPLIT) SeperatedRadio->SetValue(true);
370 >        if(splitInstances) SeperatedRadio->SetValue(true);
371          else CompleteRadio->SetValue(true);
372          if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
373          else SepRadio->SetValue(true);
374  
1203
375   #ifdef WIN32
376          RedirectIOToConsole();
377          HWND hWnd = GetConsoleWindow();
378          ShowWindow( hWnd, SW_HIDE );
379   #endif
1209
1210        //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
380   }
381  
1213
382   /*
383   * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
384   */
# Line 1219 | Line 387 | void MainWindow::OnSelectAllCheckboxClic
387   {
388          switch(SelectAll->Get3StateValue()) {
389          case wxCHK_UNCHECKED:
390 <                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
1223 <                //SelectAll->Set3StateValue(wxCHK_CHECKED);
390 >                for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
391                  break;
392          case wxCHK_CHECKED:
393 <                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true);
1227 <                //SelectAll->Set3StateValue(wxCHK_UNCHECKED);
393 >                for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true);
394                  break;
395          case wxCHK_UNDETERMINED:
396 <                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
1231 <                //SelectAll->Set3StateValue(wxCHK_CHECKED);
396 >                for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
397                  break;
1233
398          }
1235
399   }
400  
1238
401   /*
402   * wxEVT_CREATE event handler for Mods_CheckboxList
403   */
# Line 1243 | Line 405 | void MainWindow::OnSelectAllCheckboxClic
405   void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event )
406   {
407  
1246
408   }
409  
410  
# Line 1295 | Line 456 | wxBitmap MainWindow::GetBitmapResource(
456  
457   wxIcon MainWindow::GetIconResource( const wxString& name )
458   {
1298
459          // Icon retrieval
460          ////@begin MainWindow icon retrieval
461      wxUnusedVar(name);
# Line 1308 | Line 468 | wxIcon MainWindow::GetIconResource( cons
468          ////@end MainWindow icon retrieval
469   }
470  
1311
471   /*
472   * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
473   */
474  
475   void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event )
476   {
1318        //event.GetSelection
477          titleText->SetValue(globalPackages[event.GetSelection()].name.c_str());
478          creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str());
479          descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str());
1322
1323        //creatorText->Refresh();
480   }
481  
1326
482   /*
483   * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
484   */
# Line 1357 | Line 512 | void MainWindow::OnOptionsClick( wxComma
512                  
513                  this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
514          else {
515 < //              Uncomment this when we release, it gets annoying if you are testing globalization a lot ;)
1361 <                wxMessageDialog* YesNoDialog = new wxMessageDialog(this,                        "WARNING: These options are for advanced users only, use with caution.",
515 >                wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: These options are for advanced users only, use with caution.",
516                                                                                                                     "AE Installer Alert",  wxOK | wxICON_EXCLAMATION     , wxDefaultPosition);
517                  YesNoDialog->ShowModal();
518                  OptionsPanel->Show();
# Line 1367 | Line 521 | void MainWindow::OnOptionsClick( wxComma
521          }
522   }
523  
1370
524   /*
525   * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
526   */
# Line 1377 | Line 530 | void MainWindow::OnExitClick( wxCommandE
530          exit(0);
531   }
532  
1380
533   /*
534   * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
535   */
536  
1385
537   struct recompile
538   {
539          recompile(vector<string> localPackages) : thePackages(localPackages) { }
# Line 1391 | Line 542 | struct recompile
542                  TheInstallButton->Disable();
543                  recompileAll(thePackages);
544                  TheInstallButton->Enable();
545 +                
546          }
1395
547          vector<string> thePackages;
548   };
549  
550 + void globalize2(void) {
551 +                TheInstallButton->Disable();
552 +                globalizeData();
553 +                TheInstallButton->Enable();
554 + }
555 +
556   void MainWindow::OnInstallButtonClick( wxCommandEvent& event )
557   {
1401
558          vector<string> localPackages;
559 <        localPackages.push_back("Globalize");
560 <        for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
559 >        localPackages.push_back("00000Globalize");
560 >        for(unsigned int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
561          if ( !localPackages.empty() )   {
562 <        
563 <                //MainWindow::MainWindow().Hide();      
1408 <                //      boost::thread thrd2(recompileAll(localPackages) );
1409 <                //MainWindow::MainWindow().Show();
562 >                sort(localPackages.begin(), localPackages.end());
563 >                localPackages[0] = "Globalize";
564                  this->InstallButton->Disable();
565                  this->ReglobalizeButton->Disable();
566   #ifdef WIN32
# Line 1415 | Line 569 | void MainWindow::OnInstallButtonClick( w
569   #else
570                  recompileAll(localPackages);
571   #endif
1418
572                  this->InstallButton->Enable();
573                  this->ReglobalizeButton->Enable();
574          }
1422
1423
575   }
576  
577 < /*void setStatusArea( string s ) {
578 < //TheStatusBar = MainWindow::StatusArea;
1428 < (**TheStatusBar).SetStatusText(_(s.c_str()), 0);
1429 <
1430 < //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
1431 <
1432 < //MainWindow::StatusBar->SetLabel("Importing Files...");
1433 < //StatusBar->SetLabel(s);
1434 < //->SetLabel(s);
1435 <
1436 < }*/
1437 <
1438 < void setProgressBar( int i ) {
1439 <        //TheProgressBar->SetValue(
577 > void setProgressBar( int i )
578 > {
579   #ifdef WIN32
1441        
1442
1443
580   if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3)))
581   {
1446        
582          pTaskbarList3->SetProgressValue(Handle,i, 1000);
583 <        if ( i == 0 ) {
584 <
585 <        pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS);
583 >        if ( i == 0 )
584 >        {
585 >                pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS);
586          }
587   }
1453
1454
588   #endif
589          TheProgressBar->SetValue(i);
1457
590   }
591  
1460
592   /*
593   * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
594   */
# Line 1470 | Line 601 | void MainWindow::OnStatusbarUpdate( wxUp
601          ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
602   }
603  
1473
604   /*
605   * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
606   */
# Line 1479 | Line 609 | void MainWindow::OnAboutClick( wxCommand
609   {
610          ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
611      // Before editing this code, remove the block markers.
612 +        // TODO: Make About window work again!
613      About* window = new About(this);
1483    int returnValue = window->ShowModal();
614      window->Destroy();
615          ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
616   }
617  
1488
618   /*
619   * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
620   */
# Line 1495 | Line 624 | void MainWindow::OnNoSepRadioButtonSelec
624          static_cast<string>("-import:nosep");
625   }
626  
1498
627   /*
628   * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
629   */
# Line 1505 | Line 633 | void MainWindow::OnSepRadioButtonSelecte
633          static_cast<string>("-import:sep");
634   }
635  
1508
636   /*
637   * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
638   */
# Line 1516 | Line 643 | void MainWindow::OnSepRadioButtonSelecte
643  
644   void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event )
645   {
646 <        splitInstances = NOT_SPLIT;
1520 <
646 >        splitInstances = false;
647   }
648  
1523
649   /*
650   * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
651   */
# Line 1530 | Line 655 | void MainWindow::OnRefreshButtonClick( w
655          refreshMods(globalInstalledMods);
656   }
657  
1533
658   /*
659   * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
660   */
661  
662 <
663 <
664 <
1541 < void MainWindow::refreshMods (vector<string> s) {
1542 <
662 > // TODO: Make refreshMods actually refresh the list in the window of available mods so we can see any new package info and deleted mods are removed from the list
663 > void MainWindow::refreshMods (vector<string> s)
664 > {
665          Mods_CheckboxList->Clear();
666 <        //globalInstalledMods = getPackages();
1545 <        for (int i = 0; i < globalPackages.size(); i++) {
666 >        for (unsigned int i = 0; i < globalPackages.size(); i++) {
667                  Mods_CheckboxList->Append(globalPackages[i].name.c_str());
668 <                if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
669 <                //else Mods_CheckboxList->Check(i,0);
1549 <
668 >                if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) )
669 >                        Mods_CheckboxList->Check(i);
670          }
671   }
672  
# Line 1566 | Line 686 | void MainWindow::OnLoadClick( wxCommandE
686          {
687                  refreshMods(getInstallString( string(openFileDialog->GetPath()) ));
688          }
1569
1570
689   }
690  
1573
691   /*
692   * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
693   */
# Line 1589 | Line 706 | void MainWindow::OnSaveClick( wxCommandE
706  
707          if ( openFileDialog->ShowModal() == wxID_OK )
708          {
1592
1593
1594                //Mods_CheckboxList->
1595
1596
1597
1598                //
1599
709                  if ( exists( openFileDialog->GetPath().c_str() ) )
710                  {
711                          remove( openFileDialog->GetPath().c_str() );
# Line 1605 | Line 714 | void MainWindow::OnSaveClick( wxCommandE
714                  ofstream file(openFileDialog->GetPath().c_str());
715  
716                  vector<string>list;
717 <                for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
717 >                for(unsigned int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
718                  vector<string>::iterator begin_iter = list.begin();
719                  vector<string>::iterator end_iter = list.end();
720  
# Line 1617 | Line 726 | void MainWindow::OnSaveClick( wxCommandE
726  
727                  file.close();
728                  file.clear();
1620
1621                //SetCurrentFilename(openFileDialog->GetFilename());
1622                //theText->LoadFile(openFileDialog->GetFilename());
1623                //SetStatusText(GetCurrentFilename(), 0);
1624                //SetStatusText(openFileDialog->GetDirectory(),1);
729          }
730   }
731  
1628
1629
732   /*
733   * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
734   */
735  
736   void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event )
737   {
738 <        wxMessageDialog* YesNoDialog = new wxMessageDialog(this,                        "WARNING: This will DELETE the Edition's GameDataFolder and recreate it from the vanilla Oni game data. \n Are you SURE you want to do this? ", "AE Installer Alert",  wxYES_NO | wxICON_EXCLAMATION    , wxDefaultPosition);
739 <
740 <        if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no...
738 >        string YesNoMsg = "WARNING: This will DELETE the Edition's GameDataFolder and recreate it from the vanilla Oni game data.\n";
739 >        YesNoMsg = YesNoMsg + "Are you SURE you want to do this?";
740 >        wxMessageDialog* YesNoDialog = new wxMessageDialog(this, YesNoMsg.c_str(), "AE Installer Alert",  wxYES_NO | wxICON_EXCLAMATION , wxDefaultPosition);
741  
742 +        if (YesNoDialog->ShowModal() == wxID_NO)
743 +        {
744 +                //if the user said no...
745          }
746 <        else {
747 <        
746 >        else
747 >        {
748                  this->InstallButton->Disable();
749                  this->ReglobalizeButton->Disable();
1645
750   #ifdef WIN32
1647
751                  boost::thread thrd2(globalizeData);
752                  //globalizeData();
753                  //boost::thread::create_thread(&globalizeData);
# Line 1653 | Line 756 | void MainWindow::OnReGlobalizeButtonClic
756   #else
757                  globalizeData();
758   #endif
1656                
759                  this->InstallButton->Enable();
760                  this->ReglobalizeButton->Enable();
761          }
1660
762   }
763   /*
764   * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
765   */
766  
1666 /*void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
1667 {
1668 ////@begin wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
1669 // Before editing this code, remove the block markers.
1670 event.Skip();
1671 ////@end wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
1672 }*/
1673
1674
767   /*
768   * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Seperated_RadioButton
769   */
770  
771   void MainWindow::OnSeperatedRadioButtonSelected( wxCommandEvent& event )
772   {
773 < splitInstances = SPLIT;
773 >        splitInstances = true;
774   }
1683

Diff Legend

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