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 353 by iritscen, Sun Jun 14 23:28:58 2009 UTC vs.
Revision 423 by gumby, Wed Jul 15 21:16:14 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
15   by Gumby and Iritscen
16 < */
16 > */
17  
18 < // To-do: - Disable Install button when nothing (new) is selected
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  
# Line 20 | 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 30 | 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 52 | Line 64 | using namespace boost::filesystem;
64   using namespace std;
65  
66  
55 /*
56 int main(void)
57 {
58 if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) splitInstances = NOT_SPLIT;
59 else splitInstances = NOT_SPLIT;
60 //     SetConsoleTitle("AE Installer"); windows junk, convert to SDL
61 #ifdef WIN32  
62 system("color 0A");
63 #endif
64 cout << "\nWelcome to the AE installer!\n";
65 cout << "\nWhat would you like to do?\n";
66
67 return mainMenu();
68 }
69 */
70
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";
86 <                        cout << "6. Quit\n\n";
87 <                        
88 <                        choice = cin.get();
89 <                        cin.ignore(128, '\n');
90 <                        switch(choice)
91 <                        {
92 <                                case '1':
93 <                                        err = installPackages();
94 <                                        break;
95 <                                case '2':
96 <                                        err = uninstallPackages();
97 <                                        break;
98 <                                case '3':
99 <                                        err = listInstalledPackages();
100 <                                        break;
101 <                                case '4':
102 <                                        err = globalizeData();
103 <                                        break;
104 <                                case '5':
105 <                                        err = printInstallerInfo();
106 <                                        break;
107 <                                case '6':
108 <                                        exit = true;
109 <                                        break;
110 <                                default:
111 <                                        cout << "Please choose one of the above numbers, and press Enter.\n\n";
112 <                        }
113 <                        if (err) // if something fatal happened
114 <                                exit = true;
115 <                }
116 <                else {
117 <                        cout << "\n1. Globalize data\n";
118 <                        cout << "2. About AE\n";
119 <                        cout << "3. Quit\n\n";
120 <                        
121 <                        choice = cin.get();
122 <                        cin.ignore(128, '\n');
123 <                        switch(choice)
124 <                        {
125 <                                case '1':
126 <                                        err = globalizeData();
127 <                                        break;
128 <                                case '2':
129 <                                        err = printInstallerInfo();
130 <                                        break;
131 <                                case '3':
132 <                                        exit = true;
133 <                                        break;
134 <                                default:
135 <                                        cout << "Please choose one of the above numbers, and press Enter.\n\n";
136 <                        }
137 <                        if (err) // if something fatal happened
138 <                                exit = true;
139 <                }
140 <        } while(!exit);
141 <        
142 <        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 160 | 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 188 | 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" ||
209 <                                                dir_itr->path().filename().substr(0,9) == "TXMPlevel" ||
210 <                                                ( dir_itr->path().filename().substr(0,4) == "TXMP" && dir_itr->path().filename().find("intro")!=string::npos) ||
211 <                                                dir_itr->path().filename().substr(0,4) == "TXMB" ||
212 <                                                dir_itr->path().filename() == "M3GMpowerup_lsi.oni" ||
213 <                                                dir_itr->path().filename() == "TXMPlsi_icon.oni" ||
214 <                                                ( 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 >                                                        ) {
233 >                                                                cout <<dir_itr->path().filename() << "\n";
234 >                                                                if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename());
235 >                                                                else remove(dir_itr->path());
236 >                                                }
237 >                                                else if (dir_itr->path().filename().substr(0,4) == "TRAM") {
238 >                                                        cout <<dir_itr->path().filename() << "\n";
239 >                                                        if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename());
240 >                                                        else remove(dir_itr->path());
241 >                                                }
242 >                                                else if (dir_itr->path().filename().substr(0,4) == "ONSK" ||
243 >                                                        dir_itr->path().filename().substr(0,4) == "TXMP") {
244 >                                                                cout <<dir_itr->path().filename() << "\n";\
245 >                                                                        create_directory( dir_itr->path().parent_path() / "TexFix");    
246 >                                                                if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename());
247 >                                                                //rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename());
248 >                                                }
249 >                                                else if (dir_itr->path().filename().substr(0,4) == "ONCC"
250 >                                                        || dir_itr->path().filename().substr(0,4) == "TRBS"
251 >                                                        || dir_itr->path().filename().substr(0,4) == "ONCV"
252 >                                                        || dir_itr->path().filename().substr(0,4) == "ONVL"
253 >                                                        || dir_itr->path().filename().substr(0,4) == "TRMA"
254 >                                                        || dir_itr->path().filename().substr(0,4) == "TRSC"
255 >                                                        || dir_itr->path().filename().substr(0,4) == "TRAS") {
256 >                                                                cout <<dir_itr->path().filename() << "\n";
257 >                                                                if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename());
258 >                                                                else remove(dir_itr->path());
259 >                                                }
260 >                                                else if (dir_itr->path().filename().substr(0,4) == "OSBD"
261 >                                                        || dir_itr->path().filename().substr(0,4) == "SNDD") {
262 >                                                                cout << dir_itr->path().filename() << "\n";
263 >                                                                if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename());
264 >                                                                else remove(dir_itr->path());
265 >                                                }
266 >                                                else if (dir_itr->path().filename().substr(0,5) == "BINA3"
267 >                                                        || dir_itr->path().filename().substr(0,10) == "M3GMdebris"
268 >                                                        || dir_itr->path().filename() == "M3GMtoxic_bubble.oni"
269 >                                                        || dir_itr->path().filename().substr(0,8) == "M3GMelec"
270 >                                                        || dir_itr->path().filename().substr(0,7) == "M3GMrat"
271 >                                                        || dir_itr->path().filename().substr(0,7) == "M3GMjet"
272 >                                                        || dir_itr->path().filename().substr(0,9) == "M3GMbomb_"
273 >                                                        || dir_itr->path().filename() == "M3GMbarab_swave.oni"
274 >                                                        || dir_itr->path().filename() == "M3GMbloodyfoot.oni"
275 >                                                        ){
276 >                                                                cout <<dir_itr->path().filename() << "\n";
277 >                                                                if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename());
278 >                                                                else remove(dir_itr->path());
279 >                                                }
280 >                                                else if (dir_itr->path().filename().substr(0,4) == "AGDB"
281 >                                                        || dir_itr->path().filename().substr(0,4) == "TRCM") {
282 >                                                                cout <<dir_itr->path().filename() << "\n";
283 >
284 >                                                                if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename());
285 >                                                                else remove(dir_itr->path());
286 >                                                }
287 >                                                else if (dir_itr->path().filename().substr(0,4) == "ONWC") { //fix for buggy ONWC overriding
288 >                                                                cout <<dir_itr->path().filename() << "\n";
289 >
290 >                                                                if(!exists( "VanillaDats/level0_Final/level0_Final/" +  dir_itr->filename())) rename(dir_itr->path(), "VanillaDats/level0_Final/level0_Final/" +  dir_itr->filename());
291 >                                                                else remove(dir_itr->path());
292 >                                                }
293 >
294 >                                                if (exists(dir_itr->path())) {
295 >
296 >                                                }
297 >                                                else {
298 >                                                        logfile << "\tMoved file: " << dir_itr->path().filename() << "\n";
299 >                                                }
300                                          }
301 +
302 +
303 +
304                                  }
305 <                                
306 <                                
305 >                                logfile << "\tCleaning up TXMPs...\n";
306 >                                system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + levels[i] + "_Final/TXMP*.oni").c_str());
307 >                                parts_done++;
308 >
309 >                                setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
310 >
311                          }
279                        system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + (string)levelnum + "_Final/TXMP*.oni").c_str());
280                        
312                  }
313 <                
313 >                logfile << "Reimporting levels\n";
314                  for (int i = 0; i < 15; i++)
315                  {
316 <                        sprintf(levelnum,"%d",levels[i]);
317 <                        system( (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levelnum + "_Final packages/VanillaDats/level" + levelnum + "_Final/level"
318 <                                         + levelnum + "_Final/level" + levelnum + "_Final.oni").c_str());
316 >                        logfile << "\tReimporting level" << levels[i] << "_Final.oni\n";
317 >                        //printf(levels[i],"%d",levels[i]);
318 >                        //printf(Step_x_x,"Step %d/%d: reimporting level", parts_done + 1, 7 + 2 * num_levels); setStatusArea((string)Step_x_x + levels[i] + (string)"_Final.dat");
319 >                        setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni");
320 >                        logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level"
321 >                                + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n';
322 >                        string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level"
323 >                                + levels[i] + "_Final/level" + levels[i] + "_Final.oni");
324 >                                system(sys_str.c_str() );
325 >                        setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
326 >                        parts_done++;
327                  }
328 <                path VanillaCharacters = "packages/VanillaDats/level0_Final/level0_Characters/level0_Characters.oni";
290 <                path VanillaParticles = "packages/VanillaDats/level0_Final/level0_Particles/level0_Particles.oni";
291 <                path VanillaTextures  = "packages/VanillaDats/level0_Final/level0_Textures/level0_Textures.oni";
292 <                path VanillaSounds = "packages/VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni";
293 <                path VanillaAnimations = "packages/VanillaDats/level0_Final/level0_Animations/level0_Animations.oni";
294 <                path VanillaTRAC = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni";
295 <                path VanillaTRAM = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni";
296 <                create_directory( VanillaCharacters.parent_path() );
328 >                //create_directory( VanillaCharacters.parent_path() );
329                  create_directory( VanillaParticles.parent_path() );
330                  create_directory( VanillaTextures.parent_path() );
331                  create_directory( VanillaSounds.parent_path() );
332                  create_directory( VanillaAnimations.remove_filename() );
333 +
334 +                for(int j = 0; j < GDFPaths.size(); j++) {
335 +                        logfile << "\tReimporting " << GDFPaths[j].filename() << ".oni\n";
336 +                        setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": reimporting " + GDFPaths[j].filename() );
337 +                        system((strOniSplit + " " + strImportOption + " " + GDFPaths[j].string() + " " + VanillaPaths[j].string()).c_str());
338 +                        parts_done++;
339 +                        setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
340 +                }
341 +                logfile << "\nMoving level0_Characters\n";
342 +                setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": moving level0_Characters" );      
343 +                copy((path)"../GameDataFolder/level0_Characters", (path)("VanillaDats/level0_Final"));
344 +                /*
345 +                printf(Step_x_x,"Step %d/%d: reimporting level0_Characters", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
346                  system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str());
347 +                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Particles", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
348                  system((strOniSplit + " " + strImportOption + " " + Particles.string() + " " + VanillaParticles.string()).c_str());
349 +                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Textures", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
350                  system((strOniSplit + " " + strImportOption + " " + Textures.string() + " " + VanillaTextures.string()).c_str());
351                  //system((strOniSplit   + " " + strImportOption + (string)" " + Animations.string() + (string)" " + VanillaAnimations.string()).c_str());
352 +                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAC", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
353                  system((strOniSplit + " " + strImportOption + " " + TRAC.string() + " " + VanillaTRAC.string()).c_str());
354 +                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Sounds", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
355                  system((strOniSplit + " " + strImportOption + " " + Sounds.string() + " " + VanillaSounds.string()).c_str());
356 <                system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str());
357 <                
358 <                create_directory("../GameDataFolder/IGMD");
356 >                parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAM", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
357 >                system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str());
358 >                //parts_done++; setStatusArea((string)"Copying level scripts...");setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) ));
359 >                if (exists("../GameDataFolder/IGMD")) remove_all("../GameDataFolder/IGMD");
360 >                */
361 >                create_directory((path)"../GameDataFolder/IGMD");
362                  copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder");
363 <        }
312 <        catch (exception ex) {
313 <                cout << ex.what();
314 <        }
315 <        return err;
316 < }
363 >                setProgressBar( 1000 );
364  
365 < int installPackages(void)
366 < {
367 <        bool installed_something = 0;
368 <        int err = 0;
369 <        ModPackage package;
370 <        vector<string> installed_packages;
371 <        vector<ModPackage> packages;
372 <        vector<ModPackage>::iterator iter;
373 <        vector<string> installString;
374 <        
375 <        iter = packages.begin();
376 <        packages = getPackages();
377 <        vector<string> installedMods = getInstallString();
378 <        
379 <        if (packages.empty())
380 <        {
381 <                cout << "Error: You have no packages!\n";
382 <                return 0;
383 <        }
384 <        
338 <        cout << "Detecting installed packages...\n";
339 <        
340 <        int index = 1;
341 <        char choice = '0';
342 <        
343 <        for (vector<ModPackage>::iterator package_iter = packages.begin(); package_iter != packages.end(); ++package_iter)
344 <        {
345 <                if (!binary_search(installedMods.begin(), installedMods.end(), package_iter->modStringName))
346 <                { //package_iter->isInstalled :< I forgot about this...
347 <                        //cout << index << " ";
348 <                        system(strClsCmd);
349 <                        cout << (*package_iter).name << "\n";
350 <                        for (int character = 1; character <= (*package_iter).name.length() - 1; character++) cout << '-';
351 <                        cout << "\n"
352 <                        << (*package_iter).readme << "\n\n"
353 <                        << "Please enter a number choice\n"
354 <                        << " 1. Add\n"
355 <                        << " 2. Don't Add\n"
356 <                        << "";
357 <                        index++;
358 <                        choice = 0;
359 <                        
360 <                        do
361 <                        {
362 <                                choice = cin.get();
363 <                                cin.ignore(1280, '\n');
364 <                        } while(choice == 0);
365 <                        
366 <                        if (choice == '1')
367 <                        {
368 <                                cout << "\nInstalling...\n\n";
369 <                                if (package_iter->hasOnis || (package_iter->hasDeltas /*(*package_iter).isUnpacked */ ))
370 <                                {
371 <                                        installed_something = 1;
372 <                                        installedMods.push_back(package_iter->modStringName);
373 <                                        system(strPauseCmd);
374 <                                }
375 <                        }
376 <                }
377 <        }
378 <        if (index == 1)
379 <        {
380 <                cout << "Warning: All packages are already installed\n";
381 <                //would you like to recombine your data?
382 <                return 0;
383 <        }
384 <        if (installed_something == 0)
385 <        {
386 <                cout << "Warning: You didn't add anything!\n";
387 <                //would you like to recombine your data?
388 <                return 0;
389 <        }
390 <        
391 <        sort(installedMods.begin(), installedMods.end());
392 <        //system(Onisplit.c_str());
393 <        recompileAll(installedMods);
394 <        system(strPauseCmd);
395 <        
396 <        return err;
397 < }
365 >                if(exists("../../persist.dat")) if(!exists("../persist.dat"))
366 >                        copy("../../persist.dat","..");
367 >                if(exists("../../key_config.txt"))if(!exists("../key_config.txt"))
368 >                        copy("../../key_config.txt","..");
369 >                
370 > #ifndef WIN32
371 >                /* On Mac only, set the current GDF to the AE GDF by writing to Oni's global preferences file (thankfully a standard OS X ".plist" XML file).
372 >                   Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never
373 >                   run Oni before :-p */
374 >                string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for edition/
375 >                char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '";
376 >                strcat(prefsCommand, fullAEpath.c_str()); // get path of edition/ folder (Oni wants the folder that *contains* the GDF)
377 >                strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters
378 >                system(prefsCommand);
379 >                
380 > #endif
381 >                
382 >                
383 >                setStatusArea((string)"Done! Now select your mod packages and click install.");
384 >                //      while(1) Sleep(-1);
385  
399 int uninstallPackages(void)
400 {
401        int err = 0;
402        ModPackage package;
403        vector<string> installed_packages;
404        vector<ModPackage> packages;
405        vector<ModPackage>::iterator iter;
406        vector<string> installString;
407        
408        iter = packages.begin();
409        packages = getPackages();
410        
411        
412        cout << "Detecting installed packages...\n";
413        
414        vector<string> installedMods = getInstallString();
415        
416        if (packages.empty())
417        {
418                cout << "Error: You have no packages!\n";
419                return 0;
386          }
387 <        
388 <        int index = 0;
423 <        int uninstalled_something = 0;
424 <        char choice = '0';
425 <        
426 <        for (vector<ModPackage>::iterator package_iter = packages.begin(); package_iter != packages.end(); ++package_iter)
427 <        {
428 <                if (binary_search(installedMods.begin(), installedMods.end(), package_iter->modStringName))
429 <                { //package_iter->isInstalled :< I forgot about this...
430 <                        //cout << index << " ";
431 <                        system(strClsCmd);
432 <                        cout << (*package_iter).name << "\n";
433 <                        for (int character = 1; character <= (*package_iter).name.length() - 1; character++) cout << '-';
434 <                        cout << "\n"
435 <                        << (*package_iter).readme << "\n\n"
436 <                        << "Please enter a number choice\n"
437 <                        << " 1. Remove\n"
438 <                        << " 2. Don't Remove\n"
439 <                        << "";
440 <                        
441 <                        choice = 0;
442 <                        
443 <                        do
444 <                        {
445 <                                choice = cin.get();
446 <                                cin.ignore(1280, '\n');
447 <                        } while(choice == 0);
448 <                        
449 <                        if (choice == '1')
450 <                        {
451 <                                cout << "\nUninstalling...\n\n";
452 <                                installedMods.erase( installedMods.begin() + (index) );
453 <                                system(strPauseCmd);
454 <                                uninstalled_something = 1;
455 <                                
456 <                        }
457 <                        else {
458 <                                index++;
459 <                        }
460 <                }
387 >        catch (exception & ex) {
388 >                setStatusArea("Warning, handled exception: " + (string)ex.what());
389          }
462        if ( uninstalled_something == 0 )
463        {
464                if (index == 0) //bad practice, I need to implement a second vector or something. Meh.
465                {
466                        cout << "\nWarning: You have no installed packages!";
467                }
468                else
469                {
470                        cout << "\nWarning: You didn't remove anything!";
471                }
472                //would you like to recombine your data?
473                return 0;
474                
475        }      
476        sort(installedMods.begin(), installedMods.end());
477        //system(Onisplit.c_str());
478        recompileAll(installedMods);
479        system(strPauseCmd);
480        
481        return err;
482 }
390  
391 < int listInstalledPackages(void)
392 < {
393 <        cout << "\nThis feature not yet implemented.\n\n";
394 <        
395 <        return 0;
391 >        ptime end_time(second_clock::local_time());
392 >        time_period total_time (start_time, end_time);
393 >        logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
394 >        //total_time.length().hours();
395 >        logfile.close();
396 >        busy = 0;
397 >        return err;
398   }
399  
491 int printInstallerInfo(void)
492 {
493        cout << "\nAE/Mod Installer\n";
494        cout << "version " << strInstallerVersion << "\n";
495        cout << "by Gumby & Iritscen\n";
496        cout << "see http://oni.bungie.org/community/forums for more info\n\n";
497        
498        return 0;
499 }
400  
401   vector<ModPackage> getPackages(void)
402   {
# Line 505 | Line 405 | vector<ModPackage> getPackages(void)
405          fstream file;
406          string filename = "\0";
407          string MODINFO_CFG = "Mod_Info.cfg";
408 <        
408 >
409          try
410          {
411                  directory_iterator end_iter;
# Line 513 | Line 413 | vector<ModPackage> getPackages(void)
413                  {
414                          file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str());
415                          //cout << filename << "\n";
416 <                        
416 >
417                          if(!file.fail())
418                          {
419                                  //cout << dir_itr->path().string() + MODINFO_CFG;
# Line 523 | Line 423 | vector<ModPackage> getPackages(void)
423                          file.close();
424                          file.clear();
425                  }
426 +                sort(packages.begin(), packages.end());
427          }
428          catch (const std::exception & ex)
429          {
430                  cout << "Warning, something odd happened!\n";
431          }
432 <        
432 >
433          return packages;
434   }
435  
436   ModPackage fileToModPackage(fstream &file)
437   {
438          /*
439 <         This converts a file to a ModPackage struct.
440 <        
441 <         A few notes...
442 <         "iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok.
443 <         I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much
444 <         slower than reading a variable.
445 <         */
439 >        This converts a file to a ModPackage struct.
440 >
441 >        A few notes...
442 >        "iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok.
443 >        I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much
444 >        slower than reading a variable.
445 >        */
446          ModPackage package;
447          string line;
448          static string NameOfMod = "NameOfMod";  //used for comparing to the current token...
# Line 566 | Line 467 | ModPackage fileToModPackage(fstream &fil
467                  if (tokens.capacity() >= 2) {                   //make sure they are using enough stuff
468                          iter = tokens.begin();                          //what word we are on, starts at first word
469                          /*
470 <                         if (!AEInstallVersion.compare(*iter))
471 <                         If mod is too old, skip this mod.
472 <                         */
470 >                        if (!AEInstallVersion.compare(*iter))
471 >                        If mod is too old, skip this mod.
472 >                        */
473                          /*else*/if (!NameOfMod.compare(*iter))  {       //if it contains the name
474                                  for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
475                                          if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) {                 //ignores "->" and "NameOfMod"
# Line 577 | Line 478 | ModPackage fileToModPackage(fstream &fil
478                                                  package.name += *iter + " ";
479                                          }
480                                  }
481 <                                
481 >
482                          }
483                          else if (!ModString.compare(*iter)) {
484                                  iter++; iter++;
# Line 589 | Line 490 | ModPackage fileToModPackage(fstream &fil
490                                  iter++; iter++;  
491                                  if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasOnis = 1; //Gotta love c++'s lack of a standard case-insensitive
492                                  else if (!HasBSL.compare(*iter)) { // string comparer...I know my implementation here sucks. I need to change it to check each character one by one. At the moment,
493 <                                iter++; iter++;}  // using "YFR" would probably set it off. :<
494 <                                
493 >                                        iter++; iter++;}  // using "YFR" would probably set it off. :<
494 >
495                                  if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasBSL = 1;
496                          }
497                          else if (!HasDeltas.compare(*iter)) {
# Line 637 | Line 538 | ModPackage fileToModPackage(fstream &fil
538                                  }
539                          }
540                  }
541 <                
541 >
542          }
543          package.doOutput();
544          return package;
545   }
546  
547   void recompileAll(vector<string> installedMods)
548 < {
549 < #ifdef WIN32
550 <        RedirectIOToConsole();
551 <        HWND hWnd = GetConsoleWindow();
552 <        ShowWindow( hWnd, SW_HIDE );
553 < #endif
554 <        setStatusArea("Importing levels...");
654 <        //setStatusArea("Recompiling Data...");
655 <        path vanilla_dir = "./packages/VanillaDats/";
548 > {try {
549 >        busy = 1;
550 >        using namespace boost::gregorian;
551 >        using namespace boost::posix_time;
552 >        using boost::lexical_cast;
553 >        using boost::bad_lexical_cast;
554 >                path vanilla_dir = "./VanillaDats/";
555          string importCommand = "";
556          char statusString[128];
557          int numberOfDats = 0;
558          int j = 1;
559          string datString;
661        std::stringstream out;
662        
560          
561 +
562 +        setStatusArea("Importing levels...");
563 +        //setStatusArea("Recompiling Data...");
564 +
565 +        std::stringstream out;
566 +
567 +        ptime start_time(second_clock::local_time());
568          clearOldDats();
569 <        remove("Onisplit.log");
569 >        
570 >        if(exists("Install.log")) remove("Install.log");
571 >        ofstream logfile("Install.log");
572 >        logfile << "Mod Installation started " << to_simple_string(start_time) << endl;
573 >        logfile.close();
574 >
575 >
576          if(splitInstances == SPLIT){
577                  recursive_directory_iterator end_iter;
578 <                
578 >
579                  for ( recursive_directory_iterator dir_itr( vanilla_dir );
580 <                         dir_itr != end_iter;
581 <                         ++dir_itr )
580 >                        dir_itr != end_iter;
581 >                        ++dir_itr )
582                  {
583                          try{
584                                  if ( is_directory( dir_itr->status() ) &&  dir_itr.level() == 1)
# Line 676 | Line 586 | void recompileAll(vector<string> install
586                                          numberOfDats++;
587                                  }
588                          }
589 <                        catch(exception ex) {
590 <                                
589 >                        catch(exception & ex) {
590 >                                        remove("Install.log");
591 >                                        ofstream logfile("Install.log");
592 >
593 >
594 >                                        logfile << "Warning, exception " << ex.what() << "!";
595 >                                        setStatusArea("Warning, exception " + (string)ex.what() + "!");
596 >                                        logfile.close();        
597                          }
598                  }
599 <                
599 >                try {
600                  //recursive_directory_iterator end_iter;
601                  
602 <                
602 >
603                  out << numberOfDats;
604                  datString = out.str();
689                try {
605                          for ( recursive_directory_iterator dir_itr( vanilla_dir );
606 <                                 dir_itr != end_iter;
607 <                                 ++dir_itr )
606 >                                dir_itr != end_iter;
607 >                                ++dir_itr )
608                          {
609                                  try
610                                  {
# Line 699 | Line 614 | void recompileAll(vector<string> install
614                                                  for (int i = 0; i < installedMods.size(); ++i) {
615                                                          if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename()  ))
616                                                                  importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename();
617 <                                                        
618 <                                                        //else cout << " packages/VanillaDats/" + installedMods[i] + "/oni/";
617 >
618 >                                                        //else cout << " VanillaDats/" + installedMods[i] + "/oni/";
619                                                  }
620 <                                                importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Onisplit.log";
620 >                                                importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
621 >
622                                                  
707                                                sprintf(statusString,"%d/%i\0",j,numberOfDats);
623                                                  setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
624 <                                                setStatusArea("Importing " +  dir_itr->path().filename() + " " + statusString);
625 <                                                
624 >                                                setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " +  dir_itr->path().filename() + " ");
625 >
626                                                  system(importCommand.c_str());
627                                                  //Sleep(1000);
628                                                  //cout << importCommand << "\n";
629                                                  j++;
630 <                                                
630 >
631                                          }
632                                  }
633                                  catch ( const std::exception & ex )
634                                  {
635 <                                        cout << "Warning, exception " << ex.what() << "!";
635 >
636 >                                        remove("Install.log");
637 >                                        ofstream logfile("Install.log");
638 >
639 >
640 >                                        logfile << "Warning, exception " << ex.what() << "!";
641 >                                        setStatusArea("Warning, exception " + (string)ex.what() + "!");
642 >                                        logfile.close();        
643                                  }
644                          }
645 <                        
645 >
646                  }
647                  catch( const std::exception & ex ) {
648 <                        cout << "Warning, exception " << ex.what() << "!\n"
649 <                        << "You probably need to re-globalize.";
650 <                        //create_directory( "./packages/VanillaDats" );
648 >
649 >                        remove("Install.log");
650 >                        ofstream logfile("Install.log");
651 >
652 >
653 >                        logfile << "Warning, exception " << ex.what() << "!";
654 >                        setStatusArea("Warning, exception " + (string)ex.what() + "!");
655 >                        logfile.close();
656                  }
657 <                
657 >
658          }
659          else if(splitInstances == NOT_SPLIT){
660                  directory_iterator end_iter;
661 <                
661 >
662                  for ( directory_iterator dir_itr( vanilla_dir );
663 <                         dir_itr != end_iter;
664 <                         ++dir_itr )
663 >                        dir_itr != end_iter;
664 >                        ++dir_itr )
665                  {
666 <                        
666 >
667                          if ( is_directory( dir_itr->status() ) )
668                          {
669                                  numberOfDats++;
670                          }
671 <                        
672 <                        
671 >
672 >
673                  }
674 <                
674 >
675                  out << numberOfDats;
676                  datString = out.str();
677 <                
677 >
678                  for ( directory_iterator dir_itr( vanilla_dir );
679 <                         dir_itr != end_iter;
680 <                         ++dir_itr )
679 >                        dir_itr != end_iter;
680 >                        ++dir_itr )
681                  {
682                          try
683                          {
684                                  if ( is_directory( dir_itr->status() ) )
685                                  {
686 <                                        importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " " + "../GameDataFolder/" + dir_itr->path().filename()
760 <                                        + ".dat";
686 >                                        importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " ";
687                                          for (int i = 0; i < installedMods.size(); ++i) {
688                                                  if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename()  ))
689                                                          importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename();
690                                          }
691 <                                        importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat";
692 <                                        
693 <                                        sprintf(statusString,"%d/%i\0",j,numberOfDats);
691 >                                        importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
692 >
693 >
694                                          setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
695 <                                        setStatusArea("Importing " +  dir_itr->path().filename() + " " + statusString);
696 <                                        
695 >                                        setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " +  dir_itr->path().filename() + " ");
696 >
697                                          system(importCommand.c_str());
698 <                                        
698 >
699                                          j++;
700                                  }
701                          }
702                          catch ( const std::exception & ex )
703                          {
704 <                                cout << "Warning, something odd happened!\n";
705 <                        }
706 <                }
704 >
705 >                                remove("Install.log");
706 >                                ofstream logfile("Install.log");
707 >
708 >
709 >                                logfile << "Warning, exception " << ex.what() << "!";
710 >                                setStatusArea("Warning, exception " + (string)ex.what() + "!");
711 >                                logfile.close();
712 >                        }}
713          }
714 +        logfile << "Writing config file";
715          writeInstalledMods(installedMods);
716          setProgressBar(1000);
717 <        setStatusArea("Done!");
717 >        setStatusArea("Done! You can now play Oni.");
718 >
719 >        ptime end_time(second_clock::local_time());
720 >        time_period total_time (start_time, end_time);
721 >
722 >
723 >        ofstream logfile2("Install.log", ios::app | ios::ate);
724 >        string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length();
725 >
726 >        logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length();
727 >
728 >        //logfile2.write(outstring.c_str(), outstring.length());
729 >        logfile2.close();
730 >
731 >        //total_time.length().hours();
732 >
733          Sleep(1000);
734          setProgressBar(0);
735 +        
736 + }
737 +                        catch(exception & ex) {
738 +                                        remove("Install.log");
739 +                                        ofstream logfile("Install.log");
740 +
741 +
742 +                                        logfile << "Warning, exception " << ex.what() << "!";
743 +                                        setStatusArea("Warning, exception " + (string)ex.what() + "!");
744 +                                        logfile.close();        
745 +                        }
746 +                        busy = 0;
747   }
748  
749 +
750   void writeInstalledMods(vector<string> installedMods)
751   {
752 <        
752 >
753          if ( exists( strInstallCfg ) )
754          {
755                  remove( strInstallCfg );
756          }
757 <        
757 >
758          ofstream file(strInstallCfg.c_str());
759 <        
759 >
760          vector<string>list = installedMods;
761          vector<string>::iterator begin_iter = list.begin();
762          vector<string>::iterator end_iter = list.end();
763 <        
763 >
764          sort( list.begin(), list.end() );
765 <        
765 >
766          for( ; begin_iter != end_iter; ++begin_iter) {
767                  file << *begin_iter << " ";
768          }
769 <        
769 >
770          file.close();
771          file.clear();
772 <        
772 >
773   }
774  
775   vector<string> getInstallString(string Cfg)
776   {
777          //system(strPauseCmd);
778          vector<string> returnval;
779 <        
779 >
780          string line;
781          fstream file;
782 <        
782 >
783          if (exists( Cfg ))
784          {
785                  file.open(Cfg.c_str());
# Line 829 | Line 790 | vector<string> getInstallString(string C
790                  sort(returnval.begin(), returnval.end());
791          }
792          else cout << "fail";
793 <        
793 >
794          return returnval;
795   }
796  
# Line 840 | Line 801 | void tokenize(const string& str, vector<
801          string::size_type lastPos = str.find_first_not_of(delimiters, 0);
802          // Find first "non-delimiter".
803          string::size_type pos     = str.find_first_of(delimiters, lastPos);
804 <        
804 >
805          while (string::npos != pos || string::npos != lastPos)
806          {
807                  // Found a token, add it to the vector.
# Line 855 | Line 816 | void tokenize(const string& str, vector<
816   void clearOldDats(void) {
817          directory_iterator end_iter_gdf;
818          for ( directory_iterator dir_itr_gdf( "../GameDataFolder" );
819 <                 dir_itr_gdf != end_iter_gdf;
820 <                 ++dir_itr_gdf )
819 >                dir_itr_gdf != end_iter_gdf;
820 >                ++dir_itr_gdf )
821          {
822                  //cout << dir_itr_gdf->path().extension() << "\n";
823                  if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) {
824                          remove( dir_itr_gdf->path() );
825                  }
826 <                
826 >
827          }
828 <        
828 >
829   }
830  
831   vector<string> globalInstalledMods;
# Line 895 | Line 856 | vector<ModPackage> globalPackages;
856   #endif
857  
858   ////@begin includes
859 < #include "about_window.h"
859 > #include "about.h"
860   ////@end includes
861  
862   #include "main_window.h"
863  
864   ////@begin XPM images
865 < #include "redo.xpm"
865 > #include "aelogosmall.xpm"
866 > #include "undo.xpm"
867   #include "fileopen.xpm"
868   #include "filesaveas.xpm"
869   #include "quit.xpm"
# Line 911 | Line 873 | vector<ModPackage> globalPackages;
873   //#define wxUSE_UNICODE 1;
874  
875   /*
876 < * MainWindow type definition
877 < */
876 > * MainWindow type definition
877 > */
878  
879   IMPLEMENT_CLASS( MainWindow, wxFrame )
880  
881  
882   /*
883 < * MainWindow event table definition
884 < */
883 > * MainWindow event table definition
884 > */
885  
886   BEGIN_EVENT_TABLE( MainWindow, wxFrame )
887  
# Line 939 | Line 901 | BEGIN_EVENT_TABLE( MainWindow, wxFrame )
901  
902      EVT_RADIOBUTTON( NoSep_RadioButton, MainWindow::OnNoSepRadioButtonSelected )
903  
904 <    EVT_RADIOBUTTON( Separated_RadioButton, MainWindow::OnSeparatedRadioButtonSelected )
904 >    EVT_RADIOBUTTON( Seperated_RadioButton, MainWindow::OnSeperatedRadioButtonSelected )
905  
906      EVT_RADIOBUTTON( Complete_RadioButton, MainWindow::OnCompleteRadioButtonSelected )
907  
# Line 961 | Line 923 | END_EVENT_TABLE()
923  
924  
925   /*
926 < * MainWindow constructors
927 < */
926 > * MainWindow constructors
927 > */
928  
929   MainWindow::MainWindow()
930   {
931 <    Init();
931 >        Init();
932   }
933  
934   MainWindow::MainWindow( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
935   {
936 <    Init();
937 <    Create( parent, id, caption, pos, size, style );
936 >        Init();
937 >        Create( parent, id, caption, pos, size, style );
938   }
939  
940  
941   /*
942 < * MainWindow creator
943 < */
942 > * MainWindow creator
943 > */
944  
945   bool MainWindow::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
946   {
947 < ////@begin MainWindow creation
947 >        ////@begin MainWindow creation
948      wxFrame::Create( parent, id, caption, pos, size, style );
949  
950      CreateControls();
951 <    SetIcon(GetIconResource(wxT("oni_special.ico")));
951 >    SetIcon(GetIconResource(wxT("aelogosmall.png")));
952      Centre();
953 < ////@end MainWindow creation
954 <    return true;
953 >        ////@end MainWindow creation
954 >        return true;
955   }
956  
957  
958   /*
959 < * MainWindow destructor
960 < */
959 > * MainWindow destructor
960 > */
961  
962   MainWindow::~MainWindow()
963   {
964 < ////@begin MainWindow destruction
965 < ////@end MainWindow destruction
964 >        ////@begin MainWindow destruction
965 >        ////@end MainWindow destruction
966   }
967  
968  
969   /*
970 < * Member initialisation
971 < */
970 > * Member initialisation
971 > */
972  
973   void MainWindow::Init()
974   {
975 < ////@begin MainWindow member initialisation
975 >        ////@begin MainWindow member initialisation
976      MainSplitter = NULL;
977      SelectAll = NULL;
978      RefreshButton = NULL;
# Line 1024 | Line 986 | void MainWindow::Init()
986      OptionsPanel = NULL;
987      SepRadio = NULL;
988      NoSepRadio = NULL;
989 <    SeparatedRadio = NULL;
989 >    SeperatedRadio = NULL;
990      CompleteRadio = NULL;
991      ReglobalizeButton = NULL;
992 < ////@end MainWindow member initialisation
992 >        ////@end MainWindow member initialisation
993  
994   }
995  
996  
997   /*
998 < * Control creation for MainWindow
999 < */
998 > * Control creation for MainWindow
999 > */
1000   wxStatusBar **TheStatusBar;
1001   wxButton* TheInstallButton;
1002   wxGauge* TheProgressBar;
1003   void MainWindow::CreateControls()
1004   {    
1005 < ////@begin MainWindow content construction
1044 <    // Generated by DialogBlocks, 31/05/2009 19:03:55 (unregistered)
1045 <
1005 >        ////@begin MainWindow content construction
1006      MainWindow* itemFrame1 = this;
1007  
1008      wxMenuBar* menuBar = new wxMenuBar;
# Line 1071 | Line 1031 | void MainWindow::CreateControls()
1031      itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
1032      menuBar->Append(itemMenu42, _("Options"));
1033      wxMenu* itemMenu44 = new wxMenu;
1034 <    itemMenu44->Append(wxID_HELP, _("Help"), wxEmptyString, wxITEM_NORMAL);
1035 <    itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1036 <    menuBar->Append(itemMenu44, _("Help"));
1034 > #ifdef WIN32
1035 >        itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1036 >        menuBar->Append(itemMenu44, _("Help"));
1037 > #else
1038 >        itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1039 > #endif  
1040 >
1041      itemFrame1->SetMenuBar(menuBar);
1042  
1043      wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
1044      itemFrame1->SetSizer(itemBoxSizer2);
1045  
1046      MainSplitter = new wxSplitterWindow( itemFrame1, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 100), wxSP_LIVE_UPDATE|wxNO_BORDER );
1047 <    MainSplitter->SetMinimumPaneSize(150);
1047 >    MainSplitter->SetMinimumPaneSize(1);
1048      MainSplitter->SetName(_T("MainSplitter"));
1049  
1050      wxPanel* itemPanel4 = new wxPanel( MainSplitter, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
# Line 1094 | Line 1058 | void MainWindow::CreateControls()
1058      SelectAll->SetName(_T("SelectAll_Checkbox"));
1059      itemBoxSizer6->Add(SelectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1060  
1061 <    RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("redo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
1061 >    RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("undo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
1062      RefreshButton->SetName(_T("RefreshButton"));
1063      itemBoxSizer6->Add(RefreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
1064  
# Line 1128 | Line 1092 | void MainWindow::CreateControls()
1092      itemStaticLine17->Show(false);
1093      itemBoxSizer11->Add(itemStaticLine17, 0, wxGROW|wxALL, 5);
1094  
1095 <    descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_AUTO_URL );
1095 >    descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_RICH2 );
1096      descriptionText->SetName(_T("DescriptionName"));
1097      descriptionText->SetBackgroundColour(wxColour(240, 240, 240));
1098      itemBoxSizer11->Add(descriptionText, 1, wxGROW|wxLEFT|wxRIGHT, 5);
1099  
1100 <    MainSplitter->SplitVertically(itemPanel4, itemPanel10, 150);
1100 >    MainSplitter->SplitVertically(itemPanel4, itemPanel10, 200);
1101      itemBoxSizer2->Add(MainSplitter, 1, wxGROW|wxALL, 0);
1102  
1103      StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 );
1104      StatusArea->SetName(_T("StatusArea"));
1105      StatusArea->SetFieldsCount(1);
1106 <    StatusArea->SetStatusText(_("Status Area"), 0);
1106 >    StatusArea->SetStatusText(_("AE Installer v1.0"), 0);
1107      itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0);
1108  
1109      wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
1110      itemBoxSizer2->Add(itemBoxSizer20, 0, wxGROW|wxALL, 0);
1111  
1112 <    ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxSize(-1, 30), wxGA_SMOOTH );
1112 >    ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxDefaultSize, wxGA_SMOOTH );
1113      ProgressBar->SetValue(0);
1114      itemBoxSizer20->Add(ProgressBar, 1, wxGROW|wxALL, 0);
1115  
1116 <    InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxSize(-1, 30), 0 );
1116 >    InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxDefaultSize, 0 );
1117      itemBoxSizer20->Add(InstallButton, 0, wxGROW|wxALL, 0);
1118  
1119      wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
# Line 1182 | Line 1146 | void MainWindow::CreateControls()
1146      wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxVERTICAL);
1147      itemBoxSizer25->Add(itemBoxSizer30, 0, wxGROW|wxALL, 5);
1148  
1149 <    SeparatedRadio = new wxRadioButton( OptionsPanel, Separated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
1150 <    SeparatedRadio->SetValue(false);
1151 <    SeparatedRadio->SetName(_T("Separated_RadioButton"));
1152 <    itemBoxSizer30->Add(SeparatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
1149 >    SeperatedRadio = new wxRadioButton( OptionsPanel, Seperated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
1150 >    SeperatedRadio->SetValue(false);
1151 >    SeperatedRadio->SetName(_T("Seperated_RadioButton"));
1152 >    itemBoxSizer30->Add(SeperatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
1153  
1154      CompleteRadio = new wxRadioButton( OptionsPanel, Complete_RadioButton, _("Complete Level0"), wxDefaultPosition, wxDefaultSize, 0 );
1155      CompleteRadio->SetValue(false);
# Line 1204 | Line 1168 | void MainWindow::CreateControls()
1168  
1169      // Connect events and objects
1170      Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this);
1171 < ////@end MainWindow content construction
1172 <        
1173 <        if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
1174 <                static_cast<string>("-import:sep");
1171 >        ////@end MainWindow content construction
1172 > #ifdef WIN32
1173 >        Handle = (HWND)GetHWND();
1174 >        ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList);
1175 > #endif
1176 >
1177 >
1178 >        /*if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
1179 >                strImportOption = "-import:sep";
1180                  splitInstances = NOT_SPLIT;
1181          }
1182          else {
1183 <                static_cast<string>("-import:nosep");
1183 >                strImportOption = "-import:nosep";
1184                  splitInstances = SPLIT;
1185 <        }
1185 >        }*/
1186 >        
1187 >
1188 > #ifndef WIN32
1189 >                strImportOption = "-import:sep";
1190 >                splitInstances = NOT_SPLIT;
1191 > #else
1192 >                strImportOption = "-import:nosep";
1193 >                splitInstances = SPLIT;
1194 > #endif
1195  
1196 + #ifndef WIN32
1197 +        strImportOption = "-import:sep";
1198 +        splitInstances = NOT_SPLIT;
1199 + #else
1200 +        strImportOption = "-import:nosep";
1201 +        splitInstances = SPLIT;
1202 + #endif
1203 +        
1204          globalPackages = getPackages();
1205          globalInstalledMods = getInstallString();
1206 <                for (int i = 0; i < globalPackages.size(); i++) {
1207 <                        Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1208 <                        if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1209 <        }
1210 <                TheStatusBar = &StatusArea;
1211 <                TheInstallButton = InstallButton;
1212 <                TheProgressBar = ProgressBar;
1213 <                OptionsPanel->Hide();
1214 <                if(splitInstances == SPLIT) SeparatedRadio->SetValue(true);
1215 <                else CompleteRadio->SetValue(true);
1216 <                
1217 <                
1218 <                
1219 <                if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
1220 <                else SepRadio->SetValue(true);
1206 >        for (int i = 0; i < globalPackages.size(); i++) {
1207 >                Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1208 >                if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1209 >        }
1210 >
1211 >        TheStatusBar = &StatusArea;
1212 >        TheInstallButton = InstallButton;
1213 >        TheProgressBar = ProgressBar;
1214 >        OptionsPanel->Hide();
1215 >        
1216 > //#ifndef WIN32
1217 > //      itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1218 >        
1219 > //#endif
1220 >        
1221 >        if(splitInstances == SPLIT) SeperatedRadio->SetValue(true);
1222 >        else CompleteRadio->SetValue(true);
1223 >        if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
1224 >        else SepRadio->SetValue(true);
1225 >
1226 >
1227 > #ifdef WIN32
1228 >        RedirectIOToConsole();
1229 >        HWND hWnd = GetConsoleWindow();
1230 >        ShowWindow( hWnd, SW_HIDE );
1231 > #endif
1232  
1233 <                        //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
1233 >        //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
1234   }
1235  
1236 <                
1236 >
1237   /*
1238 < * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
1239 < */
1238 > * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
1239 > */
1240  
1241   void MainWindow::OnSelectAllCheckboxClick( wxCommandEvent& event )
1242   {
1243 <                switch(SelectAll->Get3StateValue()) {
1243 >        switch(SelectAll->Get3StateValue()) {
1244          case wxCHK_UNCHECKED:
1245                  for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
1246                  //SelectAll->Set3StateValue(wxCHK_CHECKED);
# Line 1258 | Line 1255 | void MainWindow::OnSelectAllCheckboxClic
1255                  break;
1256  
1257          }
1258 <        
1258 >
1259   }
1260  
1261  
1262   /*
1263 < * wxEVT_CREATE event handler for Mods_CheckboxList
1264 < */
1263 > * wxEVT_CREATE event handler for Mods_CheckboxList
1264 > */
1265  
1266   void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event )
1267   {
# Line 1274 | Line 1271 | void MainWindow::ModList_OnCreate( wxWin
1271  
1272  
1273   /*
1274 < * Should we show tooltips?
1275 < */
1274 > * Should we show tooltips?
1275 > */
1276  
1277   bool MainWindow::ShowToolTips()
1278   {
1279 <    return true;
1279 >        return true;
1280   }
1281  
1282   /*
1283 < * Get bitmap resources
1284 < */
1283 > * Get bitmap resources
1284 > */
1285  
1286   wxBitmap MainWindow::GetBitmapResource( const wxString& name )
1287   {
1288 <    // Bitmap retrieval
1289 < ////@begin MainWindow bitmap retrieval
1288 >        // Bitmap retrieval
1289 >        ////@begin MainWindow bitmap retrieval
1290      wxUnusedVar(name);
1291 <    if (name == _T("redo.xpm"))
1291 >    if (name == _T("undo.xpm"))
1292      {
1293 <        wxBitmap bitmap(redo_xpm);
1293 >        wxBitmap bitmap( undo_xpm);
1294          return bitmap;
1295      }
1296      else if (name == _T("fileopen.xpm"))
# Line 1312 | Line 1309 | wxBitmap MainWindow::GetBitmapResource(
1309          return bitmap;
1310      }
1311      return wxNullBitmap;
1312 < ////@end MainWindow bitmap retrieval
1312 >        ////@end MainWindow bitmap retrieval
1313   }
1314  
1315   /*
1316 < * Get icon resources
1317 < */
1316 > * Get icon resources
1317 > */
1318  
1319   wxIcon MainWindow::GetIconResource( const wxString& name )
1320   {
1321 <    // Icon retrieval
1322 < ////@begin MainWindow icon retrieval
1321 >
1322 >        // Icon retrieval
1323 >        ////@begin MainWindow icon retrieval
1324      wxUnusedVar(name);
1325 <    if (name == _T("oni_special.ico"))
1325 >    if (name == _T("aelogosmall.png"))
1326      {
1327 <        wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO);
1327 >        wxIcon icon(aelogosmall_xpm);
1328          return icon;
1329      }
1330      return wxNullIcon;
1331 < ////@end MainWindow icon retrieval
1331 >        ////@end MainWindow icon retrieval
1332   }
1333  
1334  
1335   /*
1336 < * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
1337 < */
1336 > * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
1337 > */
1338  
1339   void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event )
1340   {
# Line 1350 | Line 1348 | void MainWindow::OnModsCheckboxList1Sele
1348  
1349  
1350   /*
1351 < * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
1352 < */
1351 > * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
1352 > */
1353  
1354   void MainWindow::OnModsCheckboxList1Toggled( wxCommandEvent& event )
1355   {
1356          SelectAll->Set3StateValue(wxCHK_UNDETERMINED);
1357          if(event.GetInt()) {
1358 <        /*
1358 >                /*
1359                  switch(SelectAll->Get3StateValue()) {
1360 <        case wxCHK_UNCHECKED:
1360 >                case wxCHK_UNCHECKED:
1361                  break;
1362 <        case wxCHK_CHECKED:
1362 >                case wxCHK_CHECKED:
1363                  break;
1364 <        case wxCHK_UNDETERMINED :
1364 >                case wxCHK_UNDETERMINED :
1365                  break;
1366 <        }
1367 <        */
1366 >                }
1367 >                */
1368          }
1369   }
1370  
1371  
1372   /*
1373 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
1374 < */
1373 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
1374 > */
1375  
1376   void MainWindow::OnOptionsClick( wxCommandEvent& event )
1377   {
1380        
1378          if (!event.GetInt() ) {
1379                  OptionsPanel->Hide();
1380 <                MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
1380 >                
1381 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
1382          else {
1383 + //              Uncomment this when we release, it gets annoying if you are testing globalization a lot ;)
1384 +                wxMessageDialog* YesNoDialog = new wxMessageDialog(this,                        "WARNING: These options are for advanced users only, use with caution.",
1385 +                                                                                                                   "AE Installer Alert",  wxOK | wxICON_EXCLAMATION     , wxDefaultPosition);
1386 +                YesNoDialog->ShowModal();
1387                  OptionsPanel->Show();
1388 <                MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight());
1388 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight()+1);
1389 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-1);
1390          }
1391   }
1392  
1393  
1394   /*
1395 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
1396 < */
1395 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
1396 > */
1397  
1398   void MainWindow::OnExitClick( wxCommandEvent& event )
1399   {
1400 < exit(0);
1400 >        exit(0);
1401   }
1402  
1403  
1404   /*
1405 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
1406 < */
1405 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
1406 > */
1407  
1408  
1409   struct recompile
1410   {
1411 <    recompile(vector<string> localPackages) : thePackages(localPackages) { }
1412 <    void operator()()
1413 <    {
1411 >        recompile(vector<string> localPackages) : thePackages(localPackages) { }
1412 >        void operator()()
1413 >        {
1414                  TheInstallButton->Disable();
1415 <       recompileAll(thePackages);
1416 <           TheInstallButton->Enable();
1417 <    }
1415 >                recompileAll(thePackages);
1416 >                TheInstallButton->Enable();
1417 >                
1418 >        }
1419  
1420 <    vector<string> thePackages;
1420 >        vector<string> thePackages;
1421   };
1422  
1423 + void globalize2(void) {
1424 +                TheInstallButton->Disable();
1425 +                globalizeData();
1426 +                TheInstallButton->Enable();
1427 + }
1428 +
1429 +
1430 +
1431   void MainWindow::OnInstallButtonClick( wxCommandEvent& event )
1432   {
1433 <        
1433 >
1434          vector<string> localPackages;
1435 <        localPackages.push_back("Globalize");
1435 >        localPackages.push_back("00000Globalize");
1436          for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
1437          if ( !localPackages.empty() )   {
1438 <                
1438 >                sort(localPackages.begin(), localPackages.end());
1439 >                localPackages[0] = "Globalize";
1440                  //MainWindow::MainWindow().Hide();      
1441 <        //      boost::thread thrd2(recompileAll(localPackages) );
1441 >                //      boost::thread thrd2(recompileAll(localPackages) );
1442                  //MainWindow::MainWindow().Show();
1443 +                this->InstallButton->Disable();
1444 +                this->ReglobalizeButton->Disable();
1445   #ifdef WIN32
1446                  recompile packages(localPackages);
1447                  boost::thread thrd(packages);
1448   #else
1434                this->Disable();
1449                  recompileAll(localPackages);
1436                this->Enable();
1450   #endif
1451  
1452 +                this->InstallButton->Enable();
1453 +                this->ReglobalizeButton->Enable();
1454          }
1455 <        
1456 <        
1455 >
1456 >
1457   }
1458  
1459   /*void setStatusArea( string s ) {
1460 <        //TheStatusBar = MainWindow::StatusArea;
1461 <        (**TheStatusBar).SetStatusText(_(s.c_str()), 0);
1462 <        
1463 <                //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
1464 <                                                
1465 <        //MainWindow::StatusBar->SetLabel("Importing Files...");
1466 <        //StatusBar->SetLabel(s);
1460 > //TheStatusBar = MainWindow::StatusArea;
1461 > (**TheStatusBar).SetStatusText(_(s.c_str()), 0);
1462 >
1463 > //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
1464 >
1465 > //MainWindow::StatusBar->SetLabel("Importing Files...");
1466 > //StatusBar->SetLabel(s);
1467   //->SetLabel(s);
1468 <        
1468 >
1469   }*/
1470  
1471   void setProgressBar( int i ) {
1472 < //TheProgressBar->SetValue(
1472 >        //TheProgressBar->SetValue(
1473 > #ifdef WIN32
1474 >        
1475 >
1476 >
1477 > if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3)))
1478 > {
1479 >        
1480 >        pTaskbarList3->SetProgressValue(Handle,i, 1000);
1481 >        if ( i == 0 ) {
1482  
1483 +        pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS);
1484 +        }
1485 + }
1486 +
1487 +
1488 + #endif
1489          TheProgressBar->SetValue(i);
1490  
1491   }
1492  
1493  
1494   /*
1495 < * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
1496 < */
1495 > * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
1496 > */
1497  
1498   void MainWindow::OnStatusbarUpdate( wxUpdateUIEvent& event )
1499   {
1500 < ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1500 >        ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1501      // Before editing this code, remove the block markers.
1502      event.Skip();
1503 < ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1503 >        ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1504   }
1505  
1506  
1507   /*
1508 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
1509 < */
1508 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
1509 > */
1510  
1511   void MainWindow::OnAboutClick( wxCommandEvent& event )
1512   {
1513 < ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1513 >        ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1514      // Before editing this code, remove the block markers.
1515      About* window = new About(this);
1516      int returnValue = window->ShowModal();
1517      window->Destroy();
1518 < ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1518 >        ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1519   }
1520  
1521  
1522   /*
1523 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
1524 < */
1523 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
1524 > */
1525  
1526   void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event )
1527   {
# Line 1500 | Line 1530 | void MainWindow::OnNoSepRadioButtonSelec
1530  
1531  
1532   /*
1533 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
1534 < */
1533 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
1534 > */
1535  
1536   void MainWindow::OnSepRadioButtonSelected( wxCommandEvent& event )
1537   {
# Line 1510 | Line 1540 | void MainWindow::OnSepRadioButtonSelecte
1540  
1541  
1542   /*
1543 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1544 < */
1515 <
1516 < void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
1517 < {
1518 < splitInstances = SPLIT;
1519 <
1520 < }
1521 <
1543 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1544 > */
1545  
1546   /*
1547 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
1548 < */
1547 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
1548 > */
1549  
1550   void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event )
1551   {
1552 < splitInstances = NOT_SPLIT;
1552 >        splitInstances = NOT_SPLIT;
1553  
1554   }
1555  
1556  
1557   /*
1558 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
1559 < */
1558 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
1559 > */
1560  
1561   void MainWindow::OnRefreshButtonClick( wxCommandEvent& event )
1562   {
# Line 1542 | Line 1565 | void MainWindow::OnRefreshButtonClick( w
1565  
1566  
1567   /*
1568 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
1569 < */
1568 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
1569 > */
1570  
1571  
1572  
1573  
1574   void MainWindow::refreshMods (vector<string> s) {
1575 <        
1575 >
1576          Mods_CheckboxList->Clear();
1577 <                                           //globalInstalledMods = getPackages();
1578 <                for (int i = 0; i < globalPackages.size(); i++) {
1579 <                        Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1580 <                        if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1581 <                        //else Mods_CheckboxList->Check(i,0);
1582 <                
1583 <                }
1577 >        //globalInstalledMods = getPackages();
1578 >        for (int i = 0; i < globalPackages.size(); i++) {
1579 >                Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1580 >                if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1581 >                //else Mods_CheckboxList->Check(i,0);
1582 >
1583 >        }
1584   }
1585  
1586   void MainWindow::OnLoadClick( wxCommandEvent& event )
1587   {
1588 +        if (busy == 1) return;
1589          static const wxChar *FILETYPES = _T(
1590                  "Mod Loadouts (*.cfg)|*.cfg|"
1591                  "All files (*.*)|*.*"
1592 <        );
1593 <        
1592 >                );
1593 >
1594          wxFileDialog* openFileDialog =
1595                  new wxFileDialog( this, _("Open Mod Loadout"), "", "", FILETYPES,
1596 <                                  wxOPEN, wxDefaultPosition);
1597 <
1596 >                wxOPEN, wxDefaultPosition);
1597 >
1598          if ( openFileDialog->ShowModal() == wxID_OK )
1599          {
1600                  refreshMods(getInstallString( string(openFileDialog->GetPath()) ));
# Line 1581 | Line 1605 | void MainWindow::OnLoadClick( wxCommandE
1605  
1606  
1607   /*
1608 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
1609 < */
1608 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
1609 > */
1610  
1611   void MainWindow::OnSaveClick( wxCommandEvent& event )
1612   {
1613 +        if (busy == 1) return;
1614          static const wxChar *FILETYPES = _T(
1615                  "Mod Loadouts (*.cfg)|*.cfg|"
1616                  "All files (*.*)|*.*"
1617 <        );
1617 >                );
1618  
1619 <                wxFileDialog* openFileDialog =
1619 >        wxFileDialog* openFileDialog =
1620                  new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
1621                  wxSAVE, wxDefaultPosition);
1622  
1623          if ( openFileDialog->ShowModal() == wxID_OK )
1624          {
1625  
1626 <                
1627 <                        //Mods_CheckboxList->
1626 >
1627 >                //Mods_CheckboxList->
1628  
1629  
1630  
1631                  //
1632 <                
1632 >
1633                  if ( exists( openFileDialog->GetPath().c_str() ) )
1634 <        {
1635 <                remove( openFileDialog->GetPath().c_str() );
1636 <        }
1634 >                {
1635 >                        remove( openFileDialog->GetPath().c_str() );
1636 >                }
1637  
1638 <        ofstream file(openFileDialog->GetPath().c_str());
1614 <        
1615 <        vector<string>list;
1616 <        for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
1617 <        vector<string>::iterator begin_iter = list.begin();
1618 <        vector<string>::iterator end_iter = list.end();
1638 >                ofstream file(openFileDialog->GetPath().c_str());
1639  
1640 <        sort( list.begin(), list.end() );
1640 >                vector<string>list;
1641 >                for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
1642 >                vector<string>::iterator begin_iter = list.begin();
1643 >                vector<string>::iterator end_iter = list.end();
1644  
1645 <        for( ; begin_iter != end_iter; ++begin_iter) {
1646 <                file << *begin_iter << " ";
1647 <        }
1648 <        
1649 <        file.close();
1650 <        file.clear();
1645 >                sort( list.begin(), list.end() );
1646 >
1647 >                for( ; begin_iter != end_iter; ++begin_iter) {
1648 >                        file << *begin_iter << " ";
1649 >                }
1650 >
1651 >                file.close();
1652 >                file.clear();
1653  
1654                  //SetCurrentFilename(openFileDialog->GetFilename());
1655                  //theText->LoadFile(openFileDialog->GetFilename());
# Line 1634 | Line 1659 | void MainWindow::OnSaveClick( wxCommandE
1659   }
1660  
1661  
1662 +
1663   /*
1664 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
1665 < */
1664 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
1665 > */
1666  
1667   void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event )
1668   {
1669 < globalizeData();
1670 <                setProgressBar(1000);
1671 <                setStatusArea("Done!");
1672 < }
1669 >        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);
1670 >
1671 >        if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no...
1672 >
1673 >        }
1674 >        else {
1675 >        
1676 >                this->InstallButton->Disable();
1677 >                this->ReglobalizeButton->Disable();
1678  
1679 + #ifdef WIN32
1680  
1681 +                boost::thread thrd2(globalizeData);
1682 +                //globalizeData();
1683 +                //boost::thread::create_thread(&globalizeData);
1684 +                //       boost::thread_group Tg;
1685 +                // Tg.create_thread( &globalizeData(), this );
1686 + #else
1687 +                globalizeData();
1688 + #endif
1689 +                
1690 +                this->InstallButton->Enable();
1691 +                this->ReglobalizeButton->Enable();
1692 +        }
1693 +
1694 + }
1695   /*
1696 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1697 < */
1696 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1697 > */
1698  
1699   /*void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
1700   {
1701   ////@begin wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
1702 <    // Before editing this code, remove the block markers.
1703 <    event.Skip();
1702 > // Before editing this code, remove the block markers.
1703 > event.Skip();
1704   ////@end wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
1705   }*/
1706  
1707 +
1708 + /*
1709 + * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Seperated_RadioButton
1710 + */
1711 +
1712 + void MainWindow::OnSeperatedRadioButtonSelected( wxCommandEvent& event )
1713 + {
1714 + splitInstances = SPLIT;
1715 + }
1716 +

Diff Legend

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