source: AE/Installer/trunk/source/main_window.cpp@ 483

Last change on this file since 483 was 469, checked in by gumby, 15 years ago

Changed level texture stuff

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