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 331 by iritscen, Thu Jun 4 12:05:26 2009 UTC vs.
Revision 400 by gumby, Mon Jul 6 23:53:24 2009 UTC

# Line 1 | Line 1
1 + #ifndef NTDDI_VERSION          
2 + #define NTDDI_VERSION NTDDI_WIN7
3 + #endif
4 + #ifdef WIN32
5 + #include <windows.h>
6 + #include <shobjidl.h>
7 + HWND Handle;
8 +
9 + ITaskbarList *pTaskbarList;
10 + ITaskbarList3 *pTaskbarList3;
11 + #endif
12 +
13   /*
14   AE/Mod Installer
3 v1.0
15   by Gumby and Iritscen
16 < */
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>
# Line 17 | Line 32
32   #include <sstream>
33  
34   #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations
35 <
35 > #include "boost/lexical_cast.hpp" //int -> string
36   #include "installer.h"
37  
38   #ifdef WIN32
# Line 27 | Line 42
42   #include <dirent.h>
43   #endif
44  
45 < const string strInstallerVersion = "1.0";
45 > //const string strInstallerVersion = "1.0";
46   const bool SPLIT = 1;
47   const bool NOT_SPLIT = 0;
48   bool splitInstances = SPLIT;
49 <
49 > bool busy = 0;
50   #ifdef WIN32
51   const string strOniSplit = "Onisplit.exe";
52   string strImportOption = "-import:nosep";
# Line 42 | Line 57 | const string strOniSplit = "mono Onispli
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  
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;
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 <        
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 <                int levels[15] = {0, 1, 2, 3, 4, 6, 8, 9, 10, 11, 12, 13, 14, 18, 19}; // the levels Oni has
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 <                
111 >
112                  //SetCurrentDirectory("C:/Program Files/Oni/edition/install");
113 <                char levelnum[3];
113 >                ///char levels[i][3];
114                  path Characters = "../GameDataFolder/level0_Characters";
115                  path Particles = "../GameDataFolder/level0_Particles";
116                  path Archive = "../GameDataFolder/Archive";
# Line 156 | Line 119 | int globalizeData(void)
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 <                 */
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 <                if (exists("packages/VanillaDats")) remove_all("packages/VanillaDats");
172 <                create_directory( "packages/VanillaDats" );
173 <                
174 <                create_directory( "packages/VanillaDats/level0_Final/" );
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 );
# Line 184 | Line 182 | int globalizeData(void)
182                  create_directory( Animations );
183                  create_directory( TRAC );
184                  create_directory( TRAM );
185 <                
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 <                        sprintf(levelnum,"%d",levels[i]); // int to char array
198 <                        exists("../../GameDataFolder/level" + (string)levelnum + "_Final");
199 <                        system((strOniSplit + " -export ../GameDataFolder/level" + (string)levelnum + "_Final ../../GameDataFolder/level" + (string)levelnum + "_Final.dat").c_str());
200 <                        
201 <                        create_directory( "packages/VanillaDats/level" + (string)levelnum + "_Final" ); //remember to cast your arrays as strings :)
202 <                        create_directory( "packages/VanillaDats/level" + (string)levelnum + "_Final/level" + (string)levelnum + "_Final" );
203 <                        
204 <                        directory_iterator end_iter;
205 <                        for ( directory_iterator dir_itr( "../GameDataFolder/level" + (string)levelnum + "_Final" ); dir_itr != end_iter; ++dir_itr )
206 <                        {
207 <                                //cout << dir_itr->path().filename();
208 <                                if ( is_regular_file( dir_itr->status() ) )
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 <                                        
215 <                                        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)       )
214 >                                        //cout << dir_itr->path().filename();
215 >                                        if ( is_regular_file( dir_itr->status() ) )
216                                          {
217 <                                                cout <<dir_itr->path().filename() << "\n";
218 <                                                create_directory( dir_itr->path().parent_path() / "NoGlobal");  
219 <                                                if(!exists( dir_itr->path().parent_path() / "NoGlobal" / dir_itr->filename())) rename(dir_itr->path(), dir_itr->path().parent_path() / "NoGlobal" /
220 <                                                                                                                                                                                                                          dir_itr->filename());
221 <                                                else remove(dir_itr->path());
222 <                                        }
223 <                                        else if (dir_itr->path().filename().substr(0,4) == "TRAC") {
224 <                                                cout <<dir_itr->path().filename() << "\n";
225 <                                                if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename());
226 <                                                else remove(dir_itr->path());
227 <                                        }
228 <                                        else if (dir_itr->path().filename().substr(0,4) == "TRAM") {
229 <                                                cout <<dir_itr->path().filename() << "\n";
230 <                                                if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename());
231 <                                                else remove(dir_itr->path());
232 <                                        }
233 <                                        else if (dir_itr->path().filename().substr(0,4) == "ONSK" ||
234 <                                                         dir_itr->path().filename().substr(0,4) == "TXMP") {
235 <                                                cout <<dir_itr->path().filename() << "\n";\
236 <                                                create_directory( dir_itr->path().parent_path() / "TexFix");    
237 <                                                if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename());
238 <                                                //rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename());
239 <                                        }
240 <                                        else if (dir_itr->path().filename().substr(0,4) == "ONCC"
241 <                                                         || dir_itr->path().filename().substr(0,4) == "TRBS"
242 <                                                         || dir_itr->path().filename().substr(0,4) == "TRMA"
243 <                                                         || dir_itr->path().filename().substr(0,4) == "TRSC"
244 <                                                         || dir_itr->path().filename().substr(0,4) == "TRAS") {
245 <                                                cout <<dir_itr->path().filename() << "\n";
246 <                                                if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename());
247 <                                                else remove(dir_itr->path());
248 <                                        }
249 <                                        else if (dir_itr->path().filename().substr(0,4) == "OSBD"
250 <                                                         || dir_itr->path().filename().substr(0,4) == "SNDD") {
251 <                                                cout << dir_itr->path().filename() << "\n";
252 <                                                if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename());
253 <                                                else remove(dir_itr->path());
254 <                                        }
255 <                                        else if (dir_itr->path().filename().substr(0,5) == "BINA3"
256 <                                                         || dir_itr->path().filename().substr(0,10) == "M3GMdebris"
257 <                                                         || dir_itr->path().filename() == "M3GMtoxic_bubble.oni"
258 <                                                         || dir_itr->path().filename().substr(0,8) == "M3GMelec"
259 <                                                         || dir_itr->path().filename().substr(0,7) == "M3GMrat"
260 <                                                         || dir_itr->path().filename().substr(0,7) == "M3GMjet"
261 <                                                         || dir_itr->path().filename().substr(0,9) == "M3GMbomb_"
262 <                                                         || dir_itr->path().filename() == "M3GMbarab_swave.oni"
263 <                                                         || dir_itr->path().filename() == "M3GMbloodyfoot.oni"
264 <                                                         ){
265 <                                                cout <<dir_itr->path().filename() << "\n";
266 <                                                if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename());
267 <                                                else remove(dir_itr->path());
268 <                                        }
269 <                                        else if (dir_itr->path().filename().substr(0,4) == "AGDB"
270 <                                                         || dir_itr->path().filename().substr(0,4) == "TRCM") {
271 <                                                cout <<dir_itr->path().filename() << "\n";
272 <                                                
273 <                                                if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename());
274 <                                                else remove(dir_itr->path());
217 >                                                if ( dir_itr->path().filename().substr(0,8) == "TXMPfail" ||
218 >                                                        dir_itr->path().filename().substr(0,9) == "TXMPlevel" ||
219 >                                                        ( dir_itr->path().filename().substr(0,4) == "TXMP" && dir_itr->path().filename().find("intro")!=string::npos) ||
220 >                                                        dir_itr->path().filename().substr(0,4) == "TXMB" ||
221 >                                                        dir_itr->path().filename() == "M3GMpowerup_lsi.oni" ||
222 >                                                        dir_itr->path().filename() == "TXMPlsi_icon.oni" ||
223 >                                                        ( dir_itr->path().filename().substr(0,4) == "TXMB" && dir_itr->path().filename().find("splash_screen.oni")!=string::npos)       )
224 >                                                {
225 >                                                        cout <<dir_itr->path().filename() << "\n";
226 >                                                        create_directory( dir_itr->path().parent_path() / "NoGlobal");  
227 >                                                        if(!exists( dir_itr->path().parent_path() / "NoGlobal" / dir_itr->filename())) rename(dir_itr->path(), dir_itr->path().parent_path() / "NoGlobal" /
228 >                                                                dir_itr->filename());
229 >                                                        else remove(dir_itr->path());
230 >                                                }
231 >                                                else if (dir_itr->path().filename().substr(0,4) == "TRAC"
232 >                                                        || dir_itr->path().filename().substr(0,4) == "ONVL") {
233 >                                                                cout <<dir_itr->path().filename() << "\n";
234 >                                                                if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename());
235 >                                                                else remove(dir_itr->path());
236 >                                                }
237 >                                                else if (dir_itr->path().filename().substr(0,4) == "TRAM") {
238 >                                                        cout <<dir_itr->path().filename() << "\n";
239 >                                                        if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename());
240 >                                                        else remove(dir_itr->path());
241 >                                                }
242 >                                                else if (dir_itr->path().filename().substr(0,4) == "ONSK" ||
243 >                                                        dir_itr->path().filename().substr(0,4) == "TXMP") {
244 >                                                                cout <<dir_itr->path().filename() << "\n";\
245 >                                                                        create_directory( dir_itr->path().parent_path() / "TexFix");    
246 >                                                                if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename());
247 >                                                                //rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename());
248 >                                                }
249 >                                                else if (dir_itr->path().filename().substr(0,4) == "ONCC"
250 >                                                        || dir_itr->path().filename().substr(0,4) == "TRBS"
251 >                                                        || dir_itr->path().filename().substr(0,4) == "ONCV"
252 >                                                        || dir_itr->path().filename().substr(0,4) == "TRMA"
253 >                                                        || dir_itr->path().filename().substr(0,4) == "TRSC"
254 >                                                        || dir_itr->path().filename().substr(0,4) == "TRAS") {
255 >                                                                cout <<dir_itr->path().filename() << "\n";
256 >                                                                if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename());
257 >                                                                else remove(dir_itr->path());
258 >                                                }
259 >                                                else if (dir_itr->path().filename().substr(0,4) == "OSBD"
260 >                                                        || dir_itr->path().filename().substr(0,4) == "SNDD") {
261 >                                                                cout << dir_itr->path().filename() << "\n";
262 >                                                                if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename());
263 >                                                                else remove(dir_itr->path());
264 >                                                }
265 >                                                else if (dir_itr->path().filename().substr(0,5) == "BINA3"
266 >                                                        || dir_itr->path().filename().substr(0,10) == "M3GMdebris"
267 >                                                        || dir_itr->path().filename() == "M3GMtoxic_bubble.oni"
268 >                                                        || dir_itr->path().filename().substr(0,8) == "M3GMelec"
269 >                                                        || dir_itr->path().filename().substr(0,7) == "M3GMrat"
270 >                                                        || dir_itr->path().filename().substr(0,7) == "M3GMjet"
271 >                                                        || dir_itr->path().filename().substr(0,9) == "M3GMbomb_"
272 >                                                        || dir_itr->path().filename() == "M3GMbarab_swave.oni"
273 >                                                        || dir_itr->path().filename() == "M3GMbloodyfoot.oni"
274 >                                                        ){
275 >                                                                cout <<dir_itr->path().filename() << "\n";
276 >                                                                if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename());
277 >                                                                else remove(dir_itr->path());
278 >                                                }
279 >                                                else if (dir_itr->path().filename().substr(0,4) == "AGDB"
280 >                                                        || dir_itr->path().filename().substr(0,4) == "TRCM") {
281 >                                                                cout <<dir_itr->path().filename() << "\n";
282 >
283 >                                                                if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename());
284 >                                                                else remove(dir_itr->path());
285 >                                                }
286 >                                                else if (dir_itr->path().filename().substr(0,4) == "ONWC") { //fix for buggy ONWC overriding
287 >                                                                cout <<dir_itr->path().filename() << "\n";
288 >
289 >                                                                if(!exists( "VanillaDats/level0_Final/level0_Final/" +  dir_itr->filename())) rename(dir_itr->path(), "VanillaDats/level0_Final/level0_Final/" +  dir_itr->filename());
290 >                                                                else remove(dir_itr->path());
291 >                                                }
292 >                                                if (exists(dir_itr->path())) {
293 >
294 >                                                }
295 >                                                else {
296 >                                                        logfile << "\tMoved file: " << dir_itr->path().filename() << "\n";
297 >                                                }
298                                          }
299 +
300 +
301 +
302                                  }
303 <                                
304 <                                
303 >                                logfile << "\tCleaning up TXMPs...\n";
304 >                                system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + levels[i] + "_Final/TXMP*.oni").c_str());
305 >                                parts_done++;
306 >
307 >                                setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
308 >
309                          }
275                        system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + (string)levelnum + "_Final/TXMP*.oni").c_str());
276                        
310                  }
311 <                
311 >                logfile << "Reimporting levels\n";
312                  for (int i = 0; i < 15; i++)
313                  {
314 <                        sprintf(levelnum,"%d",levels[i]);
315 <                        system( (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levelnum + "_Final packages/VanillaDats/level" + levelnum + "_Final/level"
316 <                                         + levelnum + "_Final/level" + levelnum + "_Final.oni").c_str());
314 >                        logfile << "\tReimporting level" << levels[i] << "_Final.oni\n";
315 >                        //printf(levels[i],"%d",levels[i]);
316 >                        //printf(Step_x_x,"Step %d/%d: reimporting level", parts_done + 1, 7 + 2 * num_levels); setStatusArea((string)Step_x_x + levels[i] + (string)"_Final.dat");
317 >                        setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni");
318 >                        logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level"
319 >                                + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n';
320 >                        string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level"
321 >                                + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log");
322 >                                system(sys_str.c_str() );
323 >                        setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
324 >                        parts_done++;
325                  }
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";
326                  create_directory( VanillaCharacters.parent_path() );
327                  create_directory( VanillaParticles.parent_path() );
328                  create_directory( VanillaTextures.parent_path() );
329                  create_directory( VanillaSounds.parent_path() );
330                  create_directory( VanillaAnimations.remove_filename() );
331 +
332 +                for(int j = 0; j < GDFPaths.size(); j++) {
333 +                        logfile << "\tReimporting " << GDFPaths[j].filename() << ".oni\n";
334 +                        setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": reimporting " + GDFPaths[j].filename() );
335 +                        system((strOniSplit + " " + strImportOption + " " + GDFPaths[j].string() + " " + VanillaPaths[j].string()).c_str());
336 +                        parts_done++;
337 +                        setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
338 +                }
339 +                /*
340 +                printf(Step_x_x,"Step %d/%d: reimporting level0_Characters", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
341                  system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str());
342 +                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Particles", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
343                  system((strOniSplit + " " + strImportOption + " " + Particles.string() + " " + VanillaParticles.string()).c_str());
344 +                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Textures", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
345                  system((strOniSplit + " " + strImportOption + " " + Textures.string() + " " + VanillaTextures.string()).c_str());
346                  //system((strOniSplit   + " " + strImportOption + (string)" " + Animations.string() + (string)" " + VanillaAnimations.string()).c_str());
347 +                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAC", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
348                  system((strOniSplit + " " + strImportOption + " " + TRAC.string() + " " + VanillaTRAC.string()).c_str());
349 +                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Sounds", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
350                  system((strOniSplit + " " + strImportOption + " " + Sounds.string() + " " + VanillaSounds.string()).c_str());
351 <                system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str());
352 <                
353 <                create_directory("../GameDataFolder/IGMD");
351 >                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAM", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
352 >                system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str());
353 >                //parts_done++; setStatusArea((string)"Copying level scripts...");setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
354 >                if (exists("../GameDataFolder/IGMD")) remove_all("../GameDataFolder/IGMD");
355 >                */
356 >                create_directory((path)"../GameDataFolder/IGMD");
357                  copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder");
358 <        }
308 <        catch (exception ex) {
309 <                cout << ex.what();
310 <        }
311 <        return err;
312 < }
358 >                setProgressBar( 1000 );
359  
360 < int installPackages(void)
361 < {
362 <        bool installed_something = 0;
363 <        int err = 0;
364 <        ModPackage package;
365 <        vector<string> installed_packages;
366 <        vector<ModPackage> packages;
367 <        vector<ModPackage>::iterator iter;
368 <        vector<string> installString;
369 <        
370 <        iter = packages.begin();
371 <        packages = getPackages();
372 <        vector<string> installedMods = getInstallString();
373 <        
374 <        if (packages.empty())
375 <        {
376 <                cout << "Error: You have no packages!\n";
377 <                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 < }
360 >                copy("../../persist.dat","..");
361 >                copy("../../key_config.txt","..");
362 >                
363 > #ifndef WIN32
364 >                /* On Mac only, set the current GDF to the AE GDF by writing to Oni's global preferences file (thankfully a standard OS X ".plist" XML file).
365 >                   Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never
366 >                   run Oni before :-p */
367 >                string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for edition/
368 >                char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '";
369 >                strcat(prefsCommand, fullAEpath.c_str()); // get path of edition/ folder (Oni wants the folder that *contains* the GDF)
370 >                strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters
371 >                system(prefsCommand);
372 >                
373 > #endif
374 >                
375 >                
376 >                setStatusArea((string)"Done! Now select your mod packages and click install.");
377 >                //      while(1) Sleep(-1);
378  
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;
379          }
380 <        
381 <        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 <                }
380 >        catch (exception & ex) {
381 >                setStatusArea("Warning, handled exception: " + (string)ex.what());
382          }
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 }
383  
384 < int listInstalledPackages(void)
385 < {
386 <        cout << "\nThis feature not yet implemented.\n\n";
387 <        
388 <        return 0;
384 >        ptime end_time(second_clock::local_time());
385 >        time_period total_time (start_time, end_time);
386 >        logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
387 >        //total_time.length().hours();
388 >        logfile.close();
389 >        busy = 0;
390 >        return err;
391   }
392  
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 }
393  
394   vector<ModPackage> getPackages(void)
395   {
# Line 501 | Line 398 | vector<ModPackage> getPackages(void)
398          fstream file;
399          string filename = "\0";
400          string MODINFO_CFG = "Mod_Info.cfg";
401 <        
401 >
402          try
403          {
404                  directory_iterator end_iter;
# Line 509 | Line 406 | vector<ModPackage> getPackages(void)
406                  {
407                          file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str());
408                          //cout << filename << "\n";
409 <                        
409 >
410                          if(!file.fail())
411                          {
412                                  //cout << dir_itr->path().string() + MODINFO_CFG;
# Line 519 | Line 416 | vector<ModPackage> getPackages(void)
416                          file.close();
417                          file.clear();
418                  }
419 +                sort(packages.begin(), packages.end());
420          }
421          catch (const std::exception & ex)
422          {
423                  cout << "Warning, something odd happened!\n";
424          }
425 <        
425 >
426          return packages;
427   }
428  
429   ModPackage fileToModPackage(fstream &file)
430   {
431          /*
432 <         This converts a file to a ModPackage struct.
433 <        
434 <         A few notes...
435 <         "iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok.
436 <         I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much
437 <         slower than reading a variable.
438 <         */
432 >        This converts a file to a ModPackage struct.
433 >
434 >        A few notes...
435 >        "iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok.
436 >        I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much
437 >        slower than reading a variable.
438 >        */
439          ModPackage package;
440          string line;
441          static string NameOfMod = "NameOfMod";  //used for comparing to the current token...
# Line 562 | Line 460 | ModPackage fileToModPackage(fstream &fil
460                  if (tokens.capacity() >= 2) {                   //make sure they are using enough stuff
461                          iter = tokens.begin();                          //what word we are on, starts at first word
462                          /*
463 <                         if (!AEInstallVersion.compare(*iter))
464 <                         If mod is too old, skip this mod.
465 <                         */
463 >                        if (!AEInstallVersion.compare(*iter))
464 >                        If mod is too old, skip this mod.
465 >                        */
466                          /*else*/if (!NameOfMod.compare(*iter))  {       //if it contains the name
467                                  for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
468                                          if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) {                 //ignores "->" and "NameOfMod"
# Line 573 | Line 471 | ModPackage fileToModPackage(fstream &fil
471                                                  package.name += *iter + " ";
472                                          }
473                                  }
474 <                                
474 >
475                          }
476                          else if (!ModString.compare(*iter)) {
477                                  iter++; iter++;
# Line 585 | Line 483 | ModPackage fileToModPackage(fstream &fil
483                                  iter++; iter++;  
484                                  if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasOnis = 1; //Gotta love c++'s lack of a standard case-insensitive
485                                  else if (!HasBSL.compare(*iter)) { // string comparer...I know my implementation here sucks. I need to change it to check each character one by one. At the moment,
486 <                                iter++; iter++;}  // using "YFR" would probably set it off. :<
487 <                                
486 >                                        iter++; iter++;}  // using "YFR" would probably set it off. :<
487 >
488                                  if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasBSL = 1;
489                          }
490                          else if (!HasDeltas.compare(*iter)) {
# Line 633 | Line 531 | ModPackage fileToModPackage(fstream &fil
531                                  }
532                          }
533                  }
534 <                
534 >
535          }
536          package.doOutput();
537          return package;
# Line 641 | Line 539 | ModPackage fileToModPackage(fstream &fil
539  
540   void recompileAll(vector<string> installedMods)
541   {
542 < #ifdef WIN32
543 <        RedirectIOToConsole();
544 <        HWND hWnd = GetConsoleWindow();
545 <        ShowWindow( hWnd, SW_HIDE );
546 < #endif
542 >        busy = 1;
543 >        using namespace boost::gregorian;
544 >        using namespace boost::posix_time;
545 >        using boost::lexical_cast;
546 >        using boost::bad_lexical_cast;
547 >        
548          setStatusArea("Importing levels...");
549          //setStatusArea("Recompiling Data...");
550 <        path vanilla_dir = "./packages/VanillaDats/";
550 >        path vanilla_dir = "./VanillaDats/";
551          string importCommand = "";
552          char statusString[128];
553          int numberOfDats = 0;
554          int j = 1;
555          string datString;
556          std::stringstream out;
557 <        
558 <        
557 >
558 >        ptime start_time(second_clock::local_time());
559          clearOldDats();
560 <        remove("Onisplit.log");
560 >        remove("Install.log");
561 >        ofstream logfile("Install.log");
562 >        logfile << "Mod Installation started " << to_simple_string(start_time) << endl;
563 >        logfile.close();
564          if(splitInstances == SPLIT){
565                  recursive_directory_iterator end_iter;
566 <                
566 >
567                  for ( recursive_directory_iterator dir_itr( vanilla_dir );
568 <                         dir_itr != end_iter;
569 <                         ++dir_itr )
568 >                        dir_itr != end_iter;
569 >                        ++dir_itr )
570                  {
571                          try{
572                                  if ( is_directory( dir_itr->status() ) &&  dir_itr.level() == 1)
# Line 673 | Line 575 | void recompileAll(vector<string> install
575                                  }
576                          }
577                          catch(exception ex) {
578 <                                
578 >
579                          }
580                  }
581 <                
581 >                try {
582                  //recursive_directory_iterator end_iter;
583 <                
584 <                
583 >
584 >
585                  out << numberOfDats;
586                  datString = out.str();
685                try {
587                          for ( recursive_directory_iterator dir_itr( vanilla_dir );
588 <                                 dir_itr != end_iter;
589 <                                 ++dir_itr )
588 >                                dir_itr != end_iter;
589 >                                ++dir_itr )
590                          {
591                                  try
592                                  {
# Line 695 | Line 596 | void recompileAll(vector<string> install
596                                                  for (int i = 0; i < installedMods.size(); ++i) {
597                                                          if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename()  ))
598                                                                  importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename();
599 <                                                        
600 <                                                        //else cout << " packages/VanillaDats/" + installedMods[i] + "/oni/";
599 >
600 >                                                        //else cout << " VanillaDats/" + installedMods[i] + "/oni/";
601                                                  }
602 <                                                importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Onisplit.log";
602 >                                                importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
603 >
604                                                  
703                                                sprintf(statusString,"%d/%i\0",j,numberOfDats);
605                                                  setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
606 <                                                setStatusArea("Importing " +  dir_itr->path().filename() + " " + statusString);
607 <                                                
606 >                                                setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " +  dir_itr->path().filename() + " ");
607 >
608                                                  system(importCommand.c_str());
609                                                  //Sleep(1000);
610                                                  //cout << importCommand << "\n";
611                                                  j++;
612 <                                                
612 >
613                                          }
614                                  }
615                                  catch ( const std::exception & ex )
616                                  {
617 <                                        cout << "Warning, exception " << ex.what() << "!";
617 >
618 >                                        remove("Install.log");
619 >                                        ofstream logfile("Install.log");
620 >
621 >
622 >                                        logfile << "Warning, exception " << ex.what() << "!";
623 >                                        setStatusArea("Warning, exception " + (string)ex.what() + "!");
624 >                                        logfile.close();        
625                                  }
626                          }
627 <                        
627 >
628                  }
629                  catch( const std::exception & ex ) {
630 <                        cout << "Warning, exception " << ex.what() << "!\n"
631 <                        << "You probably need to re-globalize.";
632 <                        //create_directory( "./packages/VanillaDats" );
630 >
631 >                        remove("Install.log");
632 >                        ofstream logfile("Install.log");
633 >
634 >
635 >                        logfile << "Warning, exception " << ex.what() << "!";
636 >                        setStatusArea("Warning, exception " + (string)ex.what() + "!");
637 >                        logfile.close();
638                  }
639 <                
639 >
640          }
641          else if(splitInstances == NOT_SPLIT){
642                  directory_iterator end_iter;
643 <                
643 >
644                  for ( directory_iterator dir_itr( vanilla_dir );
645 <                         dir_itr != end_iter;
646 <                         ++dir_itr )
645 >                        dir_itr != end_iter;
646 >                        ++dir_itr )
647                  {
648 <                        
648 >
649                          if ( is_directory( dir_itr->status() ) )
650                          {
651                                  numberOfDats++;
652                          }
653 <                        
654 <                        
653 >
654 >
655                  }
656 <                
656 >
657                  out << numberOfDats;
658                  datString = out.str();
659 <                
659 >
660                  for ( directory_iterator dir_itr( vanilla_dir );
661 <                         dir_itr != end_iter;
662 <                         ++dir_itr )
661 >                        dir_itr != end_iter;
662 >                        ++dir_itr )
663                  {
664                          try
665                          {
666                                  if ( is_directory( dir_itr->status() ) )
667                                  {
668 <                                        importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " " + "../GameDataFolder/" + dir_itr->path().filename()
756 <                                        + ".dat";
668 >                                        importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " ";
669                                          for (int i = 0; i < installedMods.size(); ++i) {
670                                                  if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename()  ))
671                                                          importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename();
672                                          }
673 <                                        importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat";
674 <                                        
675 <                                        sprintf(statusString,"%d/%i\0",j,numberOfDats);
673 >                                        importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
674 >
675 >
676                                          setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
677 <                                        setStatusArea("Importing " +  dir_itr->path().filename() + " " + statusString);
678 <                                        
677 >                                        setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " +  dir_itr->path().filename() + " ");
678 >
679                                          system(importCommand.c_str());
680 <                                        
680 >
681                                          j++;
682                                  }
683                          }
684                          catch ( const std::exception & ex )
685                          {
686 <                                cout << "Warning, something odd happened!\n";
687 <                        }
688 <                }
686 >
687 >                                remove("Install.log");
688 >                                ofstream logfile("Install.log");
689 >
690 >
691 >                                logfile << "Warning, exception " << ex.what() << "!";
692 >                                setStatusArea("Warning, exception " + (string)ex.what() + "!");
693 >                                logfile.close();
694 >                        }}
695          }
696 +        logfile << "Writing config file";
697          writeInstalledMods(installedMods);
698          setProgressBar(1000);
699 <        setStatusArea("Done!");
700 <        sleep(1000);
699 >        setStatusArea("Done! You can now play Oni.");
700 >
701 >        ptime end_time(second_clock::local_time());
702 >        time_period total_time (start_time, end_time);
703 >
704 >
705 >        ofstream logfile2("Install.log", ios::app | ios::ate);
706 >        string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length();
707 >
708 >        logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
709 >
710 >        //logfile2.write(outstring.c_str(), outstring.length());
711 >        logfile2.close();
712 >
713 >        //total_time.length().hours();
714 >
715 >        Sleep(1000);
716          setProgressBar(0);
717 <        
717 >        busy = 0;
718   }
719  
720   void writeInstalledMods(vector<string> installedMods)
721   {
722 <        
722 >
723          if ( exists( strInstallCfg ) )
724          {
725                  remove( strInstallCfg );
726          }
727 <        
727 >
728          ofstream file(strInstallCfg.c_str());
729 <        
729 >
730          vector<string>list = installedMods;
731          vector<string>::iterator begin_iter = list.begin();
732          vector<string>::iterator end_iter = list.end();
733 <        
733 >
734          sort( list.begin(), list.end() );
735 <        
735 >
736          for( ; begin_iter != end_iter; ++begin_iter) {
737                  file << *begin_iter << " ";
738          }
739 <        
739 >
740          file.close();
741          file.clear();
742 <        
742 >
743   }
744  
745   vector<string> getInstallString(string Cfg)
746   {
747          //system(strPauseCmd);
748          vector<string> returnval;
749 <        
749 >
750          string line;
751          fstream file;
752 <        
752 >
753          if (exists( Cfg ))
754          {
755                  file.open(Cfg.c_str());
# Line 826 | Line 760 | vector<string> getInstallString(string C
760                  sort(returnval.begin(), returnval.end());
761          }
762          else cout << "fail";
763 <        
763 >
764          return returnval;
765   }
766  
# Line 837 | Line 771 | void tokenize(const string& str, vector<
771          string::size_type lastPos = str.find_first_not_of(delimiters, 0);
772          // Find first "non-delimiter".
773          string::size_type pos     = str.find_first_of(delimiters, lastPos);
774 <        
774 >
775          while (string::npos != pos || string::npos != lastPos)
776          {
777                  // Found a token, add it to the vector.
# Line 852 | Line 786 | void tokenize(const string& str, vector<
786   void clearOldDats(void) {
787          directory_iterator end_iter_gdf;
788          for ( directory_iterator dir_itr_gdf( "../GameDataFolder" );
789 <                 dir_itr_gdf != end_iter_gdf;
790 <                 ++dir_itr_gdf )
789 >                dir_itr_gdf != end_iter_gdf;
790 >                ++dir_itr_gdf )
791          {
792                  //cout << dir_itr_gdf->path().extension() << "\n";
793                  if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) {
794                          remove( dir_itr_gdf->path() );
795                  }
796 <                
796 >
797          }
798 <        
798 >
799   }
800  
801   vector<string> globalInstalledMods;
# Line 892 | Line 826 | vector<ModPackage> globalPackages;
826   #endif
827  
828   ////@begin includes
829 < #include "about_window.h"
829 > #include "about.h"
830   ////@end includes
831  
832   #include "main_window.h"
833  
834   ////@begin XPM images
835 < #include "redo.xpm"
835 > #include "aelogosmall.xpm"
836 > #include "undo.xpm"
837   #include "fileopen.xpm"
838   #include "filesaveas.xpm"
839   #include "quit.xpm"
# Line 908 | Line 843 | vector<ModPackage> globalPackages;
843   //#define wxUSE_UNICODE 1;
844  
845   /*
846 < * MainWindow type definition
847 < */
846 > * MainWindow type definition
847 > */
848  
849   IMPLEMENT_CLASS( MainWindow, wxFrame )
850  
851  
852   /*
853 < * MainWindow event table definition
854 < */
853 > * MainWindow event table definition
854 > */
855  
856   BEGIN_EVENT_TABLE( MainWindow, wxFrame )
857  
# Line 936 | Line 871 | BEGIN_EVENT_TABLE( MainWindow, wxFrame )
871  
872      EVT_RADIOBUTTON( NoSep_RadioButton, MainWindow::OnNoSepRadioButtonSelected )
873  
874 <    EVT_RADIOBUTTON( Separated_RadioButton, MainWindow::OnSeparatedRadioButtonSelected )
874 >    EVT_RADIOBUTTON( Seperated_RadioButton, MainWindow::OnSeperatedRadioButtonSelected )
875  
876      EVT_RADIOBUTTON( Complete_RadioButton, MainWindow::OnCompleteRadioButtonSelected )
877  
# Line 958 | Line 893 | END_EVENT_TABLE()
893  
894  
895   /*
896 < * MainWindow constructors
897 < */
896 > * MainWindow constructors
897 > */
898  
899   MainWindow::MainWindow()
900   {
901 <    Init();
901 >        Init();
902   }
903  
904   MainWindow::MainWindow( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
905   {
906 <    Init();
907 <    Create( parent, id, caption, pos, size, style );
906 >        Init();
907 >        Create( parent, id, caption, pos, size, style );
908   }
909  
910  
911   /*
912 < * MainWindow creator
913 < */
912 > * MainWindow creator
913 > */
914  
915   bool MainWindow::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
916   {
917 < ////@begin MainWindow creation
917 >        ////@begin MainWindow creation
918      wxFrame::Create( parent, id, caption, pos, size, style );
919  
920      CreateControls();
921 <    SetIcon(GetIconResource(wxT("oni_special.ico")));
921 >    SetIcon(GetIconResource(wxT("aelogosmall.png")));
922      Centre();
923 < ////@end MainWindow creation
924 <    return true;
923 >        ////@end MainWindow creation
924 >        return true;
925   }
926  
927  
928   /*
929 < * MainWindow destructor
930 < */
929 > * MainWindow destructor
930 > */
931  
932   MainWindow::~MainWindow()
933   {
934 < ////@begin MainWindow destruction
935 < ////@end MainWindow destruction
934 >        ////@begin MainWindow destruction
935 >        ////@end MainWindow destruction
936   }
937  
938  
939   /*
940 < * Member initialisation
941 < */
940 > * Member initialisation
941 > */
942  
943   void MainWindow::Init()
944   {
945 < ////@begin MainWindow member initialisation
945 >        ////@begin MainWindow member initialisation
946      MainSplitter = NULL;
947      SelectAll = NULL;
948      RefreshButton = NULL;
# Line 1021 | Line 956 | void MainWindow::Init()
956      OptionsPanel = NULL;
957      SepRadio = NULL;
958      NoSepRadio = NULL;
959 <    SeparatedRadio = NULL;
959 >    SeperatedRadio = NULL;
960      CompleteRadio = NULL;
961      ReglobalizeButton = NULL;
962 < ////@end MainWindow member initialisation
962 >        ////@end MainWindow member initialisation
963  
964   }
965  
966  
967   /*
968 < * Control creation for MainWindow
969 < */
970 < wxStatusBar* TheStatusBar;
968 > * Control creation for MainWindow
969 > */
970 > wxStatusBar **TheStatusBar;
971   wxButton* TheInstallButton;
972   wxGauge* TheProgressBar;
973   void MainWindow::CreateControls()
974   {    
975 < ////@begin MainWindow content construction
1041 <    // Generated by DialogBlocks, 31/05/2009 19:03:55 (unregistered)
1042 <
975 >        ////@begin MainWindow content construction
976      MainWindow* itemFrame1 = this;
977  
978      wxMenuBar* menuBar = new wxMenuBar;
# Line 1068 | Line 1001 | void MainWindow::CreateControls()
1001      itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
1002      menuBar->Append(itemMenu42, _("Options"));
1003      wxMenu* itemMenu44 = new wxMenu;
1004 <    itemMenu44->Append(wxID_HELP, _("Help"), wxEmptyString, wxITEM_NORMAL);
1005 <    itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1006 <    menuBar->Append(itemMenu44, _("Help"));
1004 > #ifdef WIN32
1005 >        itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1006 >        menuBar->Append(itemMenu44, _("Help"));
1007 > #else
1008 >        itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1009 > #endif  
1010 >
1011      itemFrame1->SetMenuBar(menuBar);
1012  
1013      wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
1014      itemFrame1->SetSizer(itemBoxSizer2);
1015  
1016      MainSplitter = new wxSplitterWindow( itemFrame1, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 100), wxSP_LIVE_UPDATE|wxNO_BORDER );
1017 <    MainSplitter->SetMinimumPaneSize(150);
1017 >    MainSplitter->SetMinimumPaneSize(1);
1018      MainSplitter->SetName(_T("MainSplitter"));
1019  
1020      wxPanel* itemPanel4 = new wxPanel( MainSplitter, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
# Line 1091 | Line 1028 | void MainWindow::CreateControls()
1028      SelectAll->SetName(_T("SelectAll_Checkbox"));
1029      itemBoxSizer6->Add(SelectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1030  
1031 <    RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("redo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
1031 >    RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("undo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
1032      RefreshButton->SetName(_T("RefreshButton"));
1033      itemBoxSizer6->Add(RefreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
1034  
# Line 1125 | Line 1062 | void MainWindow::CreateControls()
1062      itemStaticLine17->Show(false);
1063      itemBoxSizer11->Add(itemStaticLine17, 0, wxGROW|wxALL, 5);
1064  
1065 <    descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_AUTO_URL );
1065 >    descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_RICH2 );
1066      descriptionText->SetName(_T("DescriptionName"));
1067      descriptionText->SetBackgroundColour(wxColour(240, 240, 240));
1068      itemBoxSizer11->Add(descriptionText, 1, wxGROW|wxLEFT|wxRIGHT, 5);
1069  
1070 <    MainSplitter->SplitVertically(itemPanel4, itemPanel10, 150);
1070 >    MainSplitter->SplitVertically(itemPanel4, itemPanel10, 200);
1071      itemBoxSizer2->Add(MainSplitter, 1, wxGROW|wxALL, 0);
1072  
1073      StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 );
1074      StatusArea->SetName(_T("StatusArea"));
1075      StatusArea->SetFieldsCount(1);
1076 <    StatusArea->SetStatusText(_("Status Area"), 0);
1076 >    StatusArea->SetStatusText(_("AE Installer v1.0"), 0);
1077      itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0);
1078  
1079      wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
1080      itemBoxSizer2->Add(itemBoxSizer20, 0, wxGROW|wxALL, 0);
1081  
1082 <    ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxSize(-1, 30), wxGA_SMOOTH );
1082 >    ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxDefaultSize, wxGA_SMOOTH );
1083      ProgressBar->SetValue(0);
1084      itemBoxSizer20->Add(ProgressBar, 1, wxGROW|wxALL, 0);
1085  
1086 <    InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxSize(-1, 30), 0 );
1086 >    InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxDefaultSize, 0 );
1087      itemBoxSizer20->Add(InstallButton, 0, wxGROW|wxALL, 0);
1088  
1089      wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
# Line 1179 | Line 1116 | void MainWindow::CreateControls()
1116      wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxVERTICAL);
1117      itemBoxSizer25->Add(itemBoxSizer30, 0, wxGROW|wxALL, 5);
1118  
1119 <    SeparatedRadio = new wxRadioButton( OptionsPanel, Separated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
1120 <    SeparatedRadio->SetValue(false);
1121 <    SeparatedRadio->SetName(_T("Separated_RadioButton"));
1122 <    itemBoxSizer30->Add(SeparatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
1119 >    SeperatedRadio = new wxRadioButton( OptionsPanel, Seperated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
1120 >    SeperatedRadio->SetValue(false);
1121 >    SeperatedRadio->SetName(_T("Seperated_RadioButton"));
1122 >    itemBoxSizer30->Add(SeperatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
1123  
1124      CompleteRadio = new wxRadioButton( OptionsPanel, Complete_RadioButton, _("Complete Level0"), wxDefaultPosition, wxDefaultSize, 0 );
1125      CompleteRadio->SetValue(false);
# Line 1201 | Line 1138 | void MainWindow::CreateControls()
1138  
1139      // Connect events and objects
1140      Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this);
1141 < ////@end MainWindow content construction
1142 <        
1141 >        ////@end MainWindow content construction
1142 >
1143 >        Handle = (HWND)GetHWND();
1144 >        ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList);
1145 >
1146 >
1147          if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
1148 <                static_cast<string>("-import:sep");
1148 >                strImportOption = "-import:sep";
1149                  splitInstances = NOT_SPLIT;
1150          }
1151          else {
1152 <                static_cast<string>("-import:nosep");
1152 >                strImportOption = "-import:nosep";
1153                  splitInstances = SPLIT;
1154          }
1155 <
1155 >        
1156          globalPackages = getPackages();
1157          globalInstalledMods = getInstallString();
1158 <                for (int i = 0; i < globalPackages.size(); i++) {
1159 <                        Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1160 <                        if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1161 <        }
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);
1158 >        for (int i = 0; i < globalPackages.size(); i++) {
1159 >                Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1160 >                if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1161 >        }
1162  
1163 <                        //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
1163 >        TheStatusBar = &StatusArea;
1164 >        TheInstallButton = InstallButton;
1165 >        TheProgressBar = ProgressBar;
1166 >        OptionsPanel->Hide();
1167 >        
1168 > //#ifndef WIN32
1169 > //      itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1170 >        
1171 > //#endif
1172 >        
1173 >        if(splitInstances == SPLIT) SeperatedRadio->SetValue(true);
1174 >        else CompleteRadio->SetValue(true);
1175 >        if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
1176 >        else SepRadio->SetValue(true);
1177 >
1178 >
1179 > #ifdef WIN32
1180 >        RedirectIOToConsole();
1181 >        HWND hWnd = GetConsoleWindow();
1182 >        ShowWindow( hWnd, SW_HIDE );
1183 > #endif
1184 >
1185 >        //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
1186   }
1187  
1188 <                
1188 >
1189   /*
1190 < * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
1191 < */
1190 > * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
1191 > */
1192  
1193   void MainWindow::OnSelectAllCheckboxClick( wxCommandEvent& event )
1194   {
1195 <                switch(SelectAll->Get3StateValue()) {
1195 >        switch(SelectAll->Get3StateValue()) {
1196          case wxCHK_UNCHECKED:
1197                  for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
1198                  //SelectAll->Set3StateValue(wxCHK_CHECKED);
# Line 1255 | Line 1207 | void MainWindow::OnSelectAllCheckboxClic
1207                  break;
1208  
1209          }
1210 <        
1210 >
1211   }
1212  
1213  
1214   /*
1215 < * wxEVT_CREATE event handler for Mods_CheckboxList
1216 < */
1215 > * wxEVT_CREATE event handler for Mods_CheckboxList
1216 > */
1217  
1218   void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event )
1219   {
# Line 1271 | Line 1223 | void MainWindow::ModList_OnCreate( wxWin
1223  
1224  
1225   /*
1226 < * Should we show tooltips?
1227 < */
1226 > * Should we show tooltips?
1227 > */
1228  
1229   bool MainWindow::ShowToolTips()
1230   {
1231 <    return true;
1231 >        return true;
1232   }
1233  
1234   /*
1235 < * Get bitmap resources
1236 < */
1235 > * Get bitmap resources
1236 > */
1237  
1238   wxBitmap MainWindow::GetBitmapResource( const wxString& name )
1239   {
1240 <    // Bitmap retrieval
1241 < ////@begin MainWindow bitmap retrieval
1240 >        // Bitmap retrieval
1241 >        ////@begin MainWindow bitmap retrieval
1242      wxUnusedVar(name);
1243 <    if (name == _T("redo.xpm"))
1243 >    if (name == _T("undo.xpm"))
1244      {
1245 <        wxBitmap bitmap(redo_xpm);
1245 >        wxBitmap bitmap( undo_xpm);
1246          return bitmap;
1247      }
1248      else if (name == _T("fileopen.xpm"))
# Line 1309 | Line 1261 | wxBitmap MainWindow::GetBitmapResource(
1261          return bitmap;
1262      }
1263      return wxNullBitmap;
1264 < ////@end MainWindow bitmap retrieval
1264 >        ////@end MainWindow bitmap retrieval
1265   }
1266  
1267   /*
1268 < * Get icon resources
1269 < */
1268 > * Get icon resources
1269 > */
1270  
1271   wxIcon MainWindow::GetIconResource( const wxString& name )
1272   {
1273 <    // Icon retrieval
1274 < ////@begin MainWindow icon retrieval
1273 >
1274 >        // Icon retrieval
1275 >        ////@begin MainWindow icon retrieval
1276      wxUnusedVar(name);
1277 <    if (name == _T("oni_special.ico"))
1277 >    if (name == _T("aelogosmall.png"))
1278      {
1279 <        wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO);
1279 >        wxIcon icon(aelogosmall_xpm);
1280          return icon;
1281      }
1282      return wxNullIcon;
1283 < ////@end MainWindow icon retrieval
1283 >        ////@end MainWindow icon retrieval
1284   }
1285  
1286  
1287   /*
1288 < * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
1289 < */
1288 > * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
1289 > */
1290  
1291   void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event )
1292   {
# Line 1342 | Line 1295 | void MainWindow::OnModsCheckboxList1Sele
1295          creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str());
1296          descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str());
1297  
1298 <        creatorText->Refresh();
1298 >        //creatorText->Refresh();
1299   }
1300  
1301  
1302   /*
1303 < * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
1304 < */
1303 > * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
1304 > */
1305  
1306   void MainWindow::OnModsCheckboxList1Toggled( wxCommandEvent& event )
1307   {
1308          SelectAll->Set3StateValue(wxCHK_UNDETERMINED);
1309          if(event.GetInt()) {
1310 <        /*
1310 >                /*
1311                  switch(SelectAll->Get3StateValue()) {
1312 <        case wxCHK_UNCHECKED:
1312 >                case wxCHK_UNCHECKED:
1313                  break;
1314 <        case wxCHK_CHECKED:
1314 >                case wxCHK_CHECKED:
1315                  break;
1316 <        case wxCHK_UNDETERMINED :
1316 >                case wxCHK_UNDETERMINED :
1317                  break;
1318 <        }
1319 <        */
1318 >                }
1319 >                */
1320          }
1321   }
1322  
1323  
1324   /*
1325 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
1326 < */
1325 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
1326 > */
1327  
1328   void MainWindow::OnOptionsClick( wxCommandEvent& event )
1329   {
1377        
1330          if (!event.GetInt() ) {
1331                  OptionsPanel->Hide();
1332 <                MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
1332 >                
1333 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
1334          else {
1335 + //              Uncomment this when we release, it gets annoying if you are testing globalization a lot ;)
1336 +                wxMessageDialog* YesNoDialog = new wxMessageDialog(this,                        "WARNING: These options are for advanced users only, use with caution.",
1337 +                                                                                                                   "AE Installer Alert",  wxOK | wxICON_EXCLAMATION     , wxDefaultPosition);
1338 +                YesNoDialog->ShowModal();
1339                  OptionsPanel->Show();
1340 <                MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight());
1340 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight()+1);
1341 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-1);
1342          }
1343   }
1344  
1345  
1346   /*
1347 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
1348 < */
1347 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
1348 > */
1349  
1350   void MainWindow::OnExitClick( wxCommandEvent& event )
1351   {
1352 < exit(0);
1352 >        exit(0);
1353   }
1354  
1355  
1356   /*
1357 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
1358 < */
1357 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
1358 > */
1359  
1360  
1361   struct recompile
1362   {
1363 <    recompile(vector<string> localPackages) : thePackages(localPackages) { }
1364 <    void operator()()
1365 <    {
1363 >        recompile(vector<string> localPackages) : thePackages(localPackages) { }
1364 >        void operator()()
1365 >        {
1366                  TheInstallButton->Disable();
1367 <       recompileAll(thePackages);
1368 <           TheInstallButton->Enable();
1369 <    }
1367 >                recompileAll(thePackages);
1368 >                TheInstallButton->Enable();
1369 >        }
1370  
1371 <    vector<string> thePackages;
1371 >        vector<string> thePackages;
1372   };
1373  
1374   void MainWindow::OnInstallButtonClick( wxCommandEvent& event )
1375   {
1376 <        
1376 >
1377          vector<string> localPackages;
1378          localPackages.push_back("Globalize");
1379          for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
1380          if ( !localPackages.empty() )   {
1381 <                
1381 >        
1382                  //MainWindow::MainWindow().Hide();      
1383 <        //      boost::thread thrd2(recompileAll(localPackages) );
1383 >                //      boost::thread thrd2(recompileAll(localPackages) );
1384                  //MainWindow::MainWindow().Show();
1385 <    recompile packages(localPackages);
1386 <    boost::thread thrd(packages);
1385 >                this->InstallButton->Disable();
1386 >                this->ReglobalizeButton->Disable();
1387 > #ifdef WIN32
1388 >                recompile packages(localPackages);
1389 >                boost::thread thrd(packages);
1390 > #else
1391 >                recompileAll(localPackages);
1392 > #endif
1393  
1394 +                this->InstallButton->Enable();
1395 +                this->ReglobalizeButton->Enable();
1396          }
1397 <        
1398 <        
1397 >
1398 >
1399   }
1400  
1401 < void setStatusArea( string s ) {
1402 <        TheStatusBar->SetStatusText(_(s.c_str()));
1403 <        
1404 <                //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
1405 <                                                
1406 <        //MainWindow::StatusBar->SetLabel("Importing Files...");
1407 <        //StatusBar->SetLabel(s);
1401 > /*void setStatusArea( string s ) {
1402 > //TheStatusBar = MainWindow::StatusArea;
1403 > (**TheStatusBar).SetStatusText(_(s.c_str()), 0);
1404 >
1405 > //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
1406 >
1407 > //MainWindow::StatusBar->SetLabel("Importing Files...");
1408 > //StatusBar->SetLabel(s);
1409   //->SetLabel(s);
1410 +
1411 + }*/
1412 +
1413 + void setProgressBar( int i ) {
1414 +        //TheProgressBar->SetValue(
1415 + #ifdef WIN32
1416 +        
1417 +
1418 +
1419 + if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3)))
1420 + {
1421          
1422 +        pTaskbarList3->SetProgressValue(Handle,i, 1000);
1423 +        if ( i == 0 ) {
1424 +
1425 +        pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS);
1426 +        }
1427   }
1428  
1446 void setProgressBar( int i ) {
1447 //TheProgressBar->SetValue(
1429  
1430 + #endif
1431          TheProgressBar->SetValue(i);
1432  
1433   }
1434  
1435  
1436   /*
1437 < * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
1438 < */
1437 > * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
1438 > */
1439  
1440   void MainWindow::OnStatusbarUpdate( wxUpdateUIEvent& event )
1441   {
1442 < ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1442 >        ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1443      // Before editing this code, remove the block markers.
1444      event.Skip();
1445 < ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1445 >        ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1446   }
1447  
1448  
1449   /*
1450 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
1451 < */
1450 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
1451 > */
1452  
1453   void MainWindow::OnAboutClick( wxCommandEvent& event )
1454   {
1455 < ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1455 >        ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1456      // Before editing this code, remove the block markers.
1457      About* window = new About(this);
1458      int returnValue = window->ShowModal();
1459      window->Destroy();
1460 < ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1460 >        ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1461   }
1462  
1463  
1464   /*
1465 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
1466 < */
1465 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
1466 > */
1467  
1468   void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event )
1469   {
# Line 1490 | Line 1472 | void MainWindow::OnNoSepRadioButtonSelec
1472  
1473  
1474   /*
1475 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
1476 < */
1475 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
1476 > */
1477  
1478   void MainWindow::OnSepRadioButtonSelected( wxCommandEvent& event )
1479   {
# Line 1500 | Line 1482 | void MainWindow::OnSepRadioButtonSelecte
1482  
1483  
1484   /*
1485 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1486 < */
1505 <
1506 < void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
1507 < {
1508 < splitInstances = SPLIT;
1509 <
1510 < }
1511 <
1485 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1486 > */
1487  
1488   /*
1489 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
1490 < */
1489 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
1490 > */
1491  
1492   void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event )
1493   {
1494 < splitInstances = NOT_SPLIT;
1494 >        splitInstances = NOT_SPLIT;
1495  
1496   }
1497  
1498  
1499   /*
1500 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
1501 < */
1500 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
1501 > */
1502  
1503   void MainWindow::OnRefreshButtonClick( wxCommandEvent& event )
1504   {
# Line 1532 | Line 1507 | void MainWindow::OnRefreshButtonClick( w
1507  
1508  
1509   /*
1510 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
1511 < */
1510 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
1511 > */
1512  
1513  
1514  
1515  
1516   void MainWindow::refreshMods (vector<string> s) {
1517 <        
1517 >
1518          Mods_CheckboxList->Clear();
1519 <                                           //globalInstalledMods = getPackages();
1520 <                for (int i = 0; i < globalPackages.size(); i++) {
1521 <                        Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1522 <                        if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1523 <                        //else Mods_CheckboxList->Check(i,0);
1524 <                
1525 <                }
1519 >        //globalInstalledMods = getPackages();
1520 >        for (int i = 0; i < globalPackages.size(); i++) {
1521 >                Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1522 >                if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1523 >                //else Mods_CheckboxList->Check(i,0);
1524 >
1525 >        }
1526   }
1527  
1528   void MainWindow::OnLoadClick( wxCommandEvent& event )
1529   {
1530 +        if (busy == 1) return;
1531          static const wxChar *FILETYPES = _T(
1532                  "Mod Loadouts (*.cfg)|*.cfg|"
1533                  "All files (*.*)|*.*"
1534 <        );
1535 <        
1534 >                );
1535 >
1536          wxFileDialog* openFileDialog =
1537                  new wxFileDialog( this, _("Open Mod Loadout"), "", "", FILETYPES,
1538 <                                  wxOPEN, wxDefaultPosition);
1539 <
1538 >                wxOPEN, wxDefaultPosition);
1539 >
1540          if ( openFileDialog->ShowModal() == wxID_OK )
1541          {
1542                  refreshMods(getInstallString( string(openFileDialog->GetPath()) ));
# Line 1571 | Line 1547 | void MainWindow::OnLoadClick( wxCommandE
1547  
1548  
1549   /*
1550 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
1551 < */
1550 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
1551 > */
1552  
1553   void MainWindow::OnSaveClick( wxCommandEvent& event )
1554   {
1555 +        if (busy == 1) return;
1556          static const wxChar *FILETYPES = _T(
1557                  "Mod Loadouts (*.cfg)|*.cfg|"
1558                  "All files (*.*)|*.*"
1559 <        );
1559 >                );
1560  
1561 <                wxFileDialog* openFileDialog =
1561 >        wxFileDialog* openFileDialog =
1562                  new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
1563                  wxSAVE, wxDefaultPosition);
1564  
1565          if ( openFileDialog->ShowModal() == wxID_OK )
1566          {
1567  
1568 <                
1569 <                        //Mods_CheckboxList->
1568 >
1569 >                //Mods_CheckboxList->
1570  
1571  
1572  
1573                  //
1574 <                
1574 >
1575                  if ( exists( openFileDialog->GetPath().c_str() ) )
1576 <        {
1577 <                remove( openFileDialog->GetPath().c_str() );
1578 <        }
1576 >                {
1577 >                        remove( openFileDialog->GetPath().c_str() );
1578 >                }
1579  
1580 <        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();
1580 >                ofstream file(openFileDialog->GetPath().c_str());
1581  
1582 <        sort( list.begin(), list.end() );
1582 >                vector<string>list;
1583 >                for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
1584 >                vector<string>::iterator begin_iter = list.begin();
1585 >                vector<string>::iterator end_iter = list.end();
1586  
1587 <        for( ; begin_iter != end_iter; ++begin_iter) {
1588 <                file << *begin_iter << " ";
1589 <        }
1590 <        
1591 <        file.close();
1592 <        file.clear();
1587 >                sort( list.begin(), list.end() );
1588 >
1589 >                for( ; begin_iter != end_iter; ++begin_iter) {
1590 >                        file << *begin_iter << " ";
1591 >                }
1592 >
1593 >                file.close();
1594 >                file.clear();
1595  
1596                  //SetCurrentFilename(openFileDialog->GetFilename());
1597                  //theText->LoadFile(openFileDialog->GetFilename());
# Line 1624 | Line 1601 | void MainWindow::OnSaveClick( wxCommandE
1601   }
1602  
1603  
1604 +
1605   /*
1606 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
1607 < */
1606 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
1607 > */
1608  
1609   void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event )
1610   {
1611 < globalizeData();
1612 <                setProgressBar(1000);
1613 <                setStatusArea("Done!");
1636 < }
1611 >        wxMessageDialog* YesNoDialog = new wxMessageDialog(this,                        "WARNING: This will DELETE the Edition's GameDataFolder and recreate it from the vanilla Oni game data. \n Are you SURE you want to do this? ", "AE Installer Alert",  wxYES_NO | wxICON_EXCLAMATION    , wxDefaultPosition);
1612 >
1613 >        if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no...
1614  
1615 +        }
1616 +        else {
1617 +        
1618 +                this->InstallButton->Disable();
1619 +                this->ReglobalizeButton->Disable();
1620 +
1621 + #ifdef WIN32
1622 +
1623 +                boost::thread thrd2(globalizeData);
1624 +                //globalizeData();
1625 +                //boost::thread::create_thread(&globalizeData);
1626 +                //       boost::thread_group Tg;
1627 +                // Tg.create_thread( &globalizeData(), this );
1628 + #else
1629 +                globalizeData();
1630 + #endif
1631 +                
1632 +                this->InstallButton->Enable();
1633 +                this->ReglobalizeButton->Enable();
1634 +        }
1635  
1636 + }
1637   /*
1638 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1639 < */
1638 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1639 > */
1640  
1641   /*void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
1642   {
1643   ////@begin wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
1644 <    // Before editing this code, remove the block markers.
1645 <    event.Skip();
1644 > // Before editing this code, remove the block markers.
1645 > event.Skip();
1646   ////@end wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
1647   }*/
1648  
1649 +
1650 + /*
1651 + * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Seperated_RadioButton
1652 + */
1653 +
1654 + void MainWindow::OnSeperatedRadioButtonSelected( wxCommandEvent& event )
1655 + {
1656 + splitInstances = SPLIT;
1657 + }
1658 +

Diff Legend

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