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 |
*/ |
17 |
|
18 |
// To-do: - Load credits from text resource file |
19 |
// - Institute lots of checks into file-handling |
20 |
// - Clear mod info fields when mod is de-selected |
21 |
|
22 |
#define DEBUG |
23 |
#include <stdio.h> |
24 |
//#include <conio.h> |
25 |
//#include <process.h> |
26 |
#include <string> |
27 |
#include <iostream> |
28 |
#include <cctype> |
29 |
#include <vector> |
30 |
#include <fstream> |
31 |
#include <errno.h> |
32 |
#include <sstream> |
33 |
|
34 |
#include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations |
35 |
#include "boost/lexical_cast.hpp" //int -> string |
36 |
#include "installer.h" |
37 |
|
38 |
#ifdef WIN32 |
39 |
#include <windows.h> |
40 |
#else // assume we're on Mac |
41 |
#include <stdlib.h> |
42 |
#include <dirent.h> |
43 |
#endif |
44 |
|
45 |
//const string strInstallerVersion = "1.0"; |
46 |
const bool SPLIT = 1; |
47 |
const bool NOT_SPLIT = 0; |
48 |
bool splitInstances = SPLIT; |
49 |
bool busy = 0; |
50 |
#ifdef WIN32 |
51 |
const string strOniSplit = "Onisplit.exe"; |
52 |
string strImportOption = "-import:nosep"; |
53 |
const char* strClsCmd = "cls"; |
54 |
const char* strPauseCmd = "PAUSE"; |
55 |
#else // set up Mac equivalents since we're in Mac OS |
56 |
const string strOniSplit = "mono Onisplit.exe"; |
57 |
string strImportOption = "-import:sep"; |
58 |
const char* strClsCmd = "clear"; |
59 |
const char* strPauseCmd = "read -n 1 -p \"Press any key to continue\""; |
60 |
void Sleep(int ms) { sleep( ms / 1000 ); } |
61 |
#endif |
62 |
|
63 |
using namespace boost::filesystem; |
64 |
using namespace std; |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
#include "boost/date_time/gregorian/gregorian.hpp" |
70 |
#include "boost/date_time/date_parsing.hpp" |
71 |
#include "boost/date_time/posix_time/posix_time.hpp" |
72 |
|
73 |
string escapePath(string input) { |
74 |
|
75 |
string output; |
76 |
string escape_me = "& ;()|<>\"'\\#*?$"; |
77 |
for(int i = 0; i < input.size(); i++) { |
78 |
for(int j = 0; j < escape_me.size(); j++) if (input[i] == escape_me[j]) output += '\\'; |
79 |
output += input[i]; |
80 |
} |
81 |
return output; |
82 |
} |
83 |
|
84 |
int globalizeData(void) |
85 |
{ |
86 |
busy = 1; |
87 |
using boost::lexical_cast; |
88 |
using boost::bad_lexical_cast; |
89 |
// using namespace boost::posix_time; |
90 |
using namespace boost::gregorian; |
91 |
using namespace boost::posix_time; |
92 |
ptime start_time(second_clock::local_time()); |
93 |
|
94 |
setStatusArea("Globalizing!"); |
95 |
int err = 0; |
96 |
int parts_done = 0; |
97 |
char Step_x_x[300]; |
98 |
//char levels[i][5]; |
99 |
remove("Globalize.log"); |
100 |
ofstream logfile("Globalize.log"); |
101 |
logfile << "Globalization started " << to_simple_string(start_time) << endl; |
102 |
try { |
103 |
|
104 |
char levels_cstr[15][3] = {"0", "1", "2", "3", "4", "6", "8", "9", "10", "11", "12", "13", "14", "18", "19"}; // the levels Oni has...probably should have made a string array. Oops. |
105 |
//const vector<double> ck(cv, &cv[CvSize]); |
106 |
vector<string> levels; |
107 |
for (int f = 0; f < 15; f++) { |
108 |
levels.push_back(levels_cstr[f]); |
109 |
} |
110 |
char choice = 0; |
111 |
|
112 |
//SetCurrentDirectory("C:/Program Files/Oni/edition/install"); |
113 |
///char levels[i][3]; |
114 |
path Characters = "../GameDataFolder/level0_Characters"; |
115 |
path Particles = "../GameDataFolder/level0_Particles"; |
116 |
path Archive = "../GameDataFolder/Archive"; |
117 |
path Textures = "../GameDataFolder/level0_Textures"; |
118 |
path Sounds = "../GameDataFolder/level0_Sounds"; |
119 |
path Animations = "../GameDataFolder/level0_Animations"; |
120 |
path TRAC = Animations / "level0_TRAC"; |
121 |
path TRAM = Animations / "level0_TRAM"; |
122 |
|
123 |
vector<path> GDFPaths; |
124 |
//GDFPaths.push_back(Characters); |
125 |
GDFPaths.push_back(Particles); |
126 |
GDFPaths.push_back(Textures); |
127 |
GDFPaths.push_back(Sounds); |
128 |
GDFPaths.push_back(TRAC); |
129 |
GDFPaths.push_back(TRAM); |
130 |
|
131 |
|
132 |
path VanillaCharacters = "VanillaDats/level0_Final/level0_Characters/level0_Characters.oni"; |
133 |
path VanillaParticles = "VanillaDats/level0_Final/level0_Particles/level0_Particles.oni"; |
134 |
path VanillaTextures = "VanillaDats/level0_Final/level0_Textures/level0_Textures.oni"; |
135 |
path VanillaSounds = "VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni"; |
136 |
path VanillaAnimations = "VanillaDats/level0_Final/level0_Animations/level0_Animations.oni"; |
137 |
path VanillaTRAC = "VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni"; |
138 |
path VanillaTRAM = "VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni"; |
139 |
|
140 |
vector<path> VanillaPaths; |
141 |
|
142 |
//VanillaPaths.push_back(VanillaCharacters); |
143 |
VanillaPaths.push_back(VanillaParticles); |
144 |
VanillaPaths.push_back(VanillaTextures); |
145 |
VanillaPaths.push_back(VanillaSounds); |
146 |
VanillaPaths.push_back(VanillaTRAC); |
147 |
VanillaPaths.push_back(VanillaTRAM); |
148 |
|
149 |
/* |
150 |
if (exists("../GameDataFolder/")) |
151 |
{ |
152 |
//cout << "\nIt looks like you've already globalized Oni's data.\nDo you want to re-globalize?\n(This will erase existing mods installed to the AE's game data.)" |
153 |
// << "\n1. Re-globalize" |
154 |
// << "\n2. Return to main menu\n"; |
155 |
//choice = cin.get(); |
156 |
cin.ignore(128, '\n'); |
157 |
if (choice == '1') |
158 |
remove_all("../GameDataFolder"); // remove AE GDF |
159 |
if (choice == '2') |
160 |
return 0; |
161 |
} |
162 |
*/ |
163 |
setStatusArea("Removing old GameDataFolder...\n"); |
164 |
logfile << "Removing old GameDataFolder...\n"; |
165 |
remove_all( "../GameDataFolder/" ); |
166 |
setStatusArea("Creating needed directories..."); |
167 |
logfile << "Creating needed directories...\n"; |
168 |
create_directory( "../GameDataFolder/" ); |
169 |
|
170 |
create_directory( "packages" ); |
171 |
|
172 |
if (exists("VanillaDats")) remove_all("VanillaDats"); |
173 |
create_directory( "VanillaDats" ); |
174 |
create_directory( "VanillaDats/level0_Final/" ); |
175 |
//blah blah finish this. |
176 |
//logfile << "VanillaDats/level0_Final/ created"; |
177 |
create_directory( Characters ); |
178 |
create_directory( Particles ); |
179 |
create_directory( Archive ); |
180 |
create_directory( Textures ); |
181 |
create_directory( Sounds ); |
182 |
create_directory( Animations ); |
183 |
create_directory( TRAC ); |
184 |
create_directory( TRAM ); |
185 |
int num_levels = 0; |
186 |
for(int i = 1; i < 15; i++) |
187 |
{ |
188 |
if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) { |
189 |
num_levels++; |
190 |
|
191 |
} |
192 |
} |
193 |
logfile << "Exporting and moving...\n\n"; |
194 |
int total_steps = 8 + 2 * num_levels; |
195 |
for(int i = 0; i < 15; i++) |
196 |
{ |
197 |
|
198 |
//printf(levels[i],"%d",levels[i]); // int to char array |
199 |
|
200 |
if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) { |
201 |
logfile << "level" << levels[i] << "_Final\n"; |
202 |
logfile << "\tExporting level" << levels[i] << "_Final.dat\n"; |
203 |
//printf(Step_x_x,"Step %d/%d: exporting level%d_final.dat", parts_done + 1,, levels[i]); setStatusArea((string)Step_x_x); |
204 |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " exporting level" + levels[i]+"_Final.dat"); |
205 |
create_directory( "../GameDataFolder/level" + levels[i] + "_Final" ); |
206 |
// setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat"); |
207 |
system((strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat").c_str()); |
208 |
create_directory( "VanillaDats/level" + levels[i] + "_Final" ); |
209 |
create_directory( "VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" ); |
210 |
|
211 |
directory_iterator end_iter; |
212 |
for ( directory_iterator dir_itr( "../GameDataFolder/level" + levels[i] + "_Final" ); dir_itr != end_iter; ++dir_itr ) |
213 |
{ |
214 |
//cout << dir_itr->path().filename(); |
215 |
if ( is_regular_file( dir_itr->status() ) ) |
216 |
{ |
217 |
if ( dir_itr->path().filename().substr(0,8) == "TXMPfail" || |
218 |
dir_itr->path().filename().substr(0,9) == "TXMPlevel" || |
219 |
( dir_itr->path().filename().substr(0,4) == "TXMP" && dir_itr->path().filename().find("intro")!=string::npos) || |
220 |
dir_itr->path().filename().substr(0,4) == "TXMB" || |
221 |
dir_itr->path().filename() == "M3GMpowerup_lsi.oni" || |
222 |
dir_itr->path().filename() == "TXMPlsi_icon.oni" || |
223 |
( dir_itr->path().filename().substr(0,4) == "TXMB" && dir_itr->path().filename().find("splash_screen.oni")!=string::npos) ) |
224 |
{ |
225 |
cout <<dir_itr->path().filename() << "\n"; |
226 |
create_directory( dir_itr->path().parent_path() / "NoGlobal"); |
227 |
if(!exists( dir_itr->path().parent_path() / "NoGlobal" / dir_itr->filename())) rename(dir_itr->path(), dir_itr->path().parent_path() / "NoGlobal" / |
228 |
dir_itr->filename()); |
229 |
else remove(dir_itr->path()); |
230 |
} |
231 |
else if (dir_itr->path().filename().substr(0,4) == "TRAC" |
232 |
) { |
233 |
cout <<dir_itr->path().filename() << "\n"; |
234 |
if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename()); |
235 |
else remove(dir_itr->path()); |
236 |
} |
237 |
else if (dir_itr->path().filename().substr(0,4) == "TRAM") { |
238 |
cout <<dir_itr->path().filename() << "\n"; |
239 |
if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename()); |
240 |
else remove(dir_itr->path()); |
241 |
} |
242 |
else if (dir_itr->path().filename().substr(0,4) == "ONSK" || |
243 |
dir_itr->path().filename().substr(0,4) == "TXMP") { |
244 |
cout <<dir_itr->path().filename() << "\n";\ |
245 |
create_directory( dir_itr->path().parent_path() / "TexFix"); |
246 |
if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename()); |
247 |
//rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename()); |
248 |
} |
249 |
else if (dir_itr->path().filename().substr(0,4) == "ONCC" |
250 |
|| dir_itr->path().filename().substr(0,4) == "TRBS" |
251 |
|| dir_itr->path().filename().substr(0,4) == "ONCV" |
252 |
|| dir_itr->path().filename().substr(0,4) == "ONVL" |
253 |
|| dir_itr->path().filename().substr(0,4) == "TRMA" |
254 |
|| dir_itr->path().filename().substr(0,4) == "TRSC" |
255 |
|| dir_itr->path().filename().substr(0,4) == "TRAS") { |
256 |
cout <<dir_itr->path().filename() << "\n"; |
257 |
if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename()); |
258 |
else remove(dir_itr->path()); |
259 |
} |
260 |
else if (dir_itr->path().filename().substr(0,4) == "OSBD" |
261 |
|| dir_itr->path().filename().substr(0,4) == "SNDD") { |
262 |
cout << dir_itr->path().filename() << "\n"; |
263 |
if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename()); |
264 |
else remove(dir_itr->path()); |
265 |
} |
266 |
else if (dir_itr->path().filename().substr(0,5) == "BINA3" |
267 |
|| dir_itr->path().filename().substr(0,10) == "M3GMdebris" |
268 |
|| dir_itr->path().filename() == "M3GMtoxic_bubble.oni" |
269 |
|| dir_itr->path().filename().substr(0,8) == "M3GMelec" |
270 |
|| dir_itr->path().filename().substr(0,7) == "M3GMrat" |
271 |
|| dir_itr->path().filename().substr(0,7) == "M3GMjet" |
272 |
|| dir_itr->path().filename().substr(0,9) == "M3GMbomb_" |
273 |
|| dir_itr->path().filename() == "M3GMbarab_swave.oni" |
274 |
|| dir_itr->path().filename() == "M3GMbloodyfoot.oni" |
275 |
){ |
276 |
cout <<dir_itr->path().filename() << "\n"; |
277 |
if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename()); |
278 |
else remove(dir_itr->path()); |
279 |
} |
280 |
else if (dir_itr->path().filename().substr(0,4) == "AGDB" |
281 |
|| dir_itr->path().filename().substr(0,4) == "TRCM") { |
282 |
cout <<dir_itr->path().filename() << "\n"; |
283 |
|
284 |
if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename()); |
285 |
else remove(dir_itr->path()); |
286 |
} |
287 |
else if (dir_itr->path().filename().substr(0,4) == "ONWC") { //fix for buggy ONWC overriding |
288 |
cout <<dir_itr->path().filename() << "\n"; |
289 |
|
290 |
if(!exists( "VanillaDats/level0_Final/level0_Final/" + dir_itr->filename())) rename(dir_itr->path(), "VanillaDats/level0_Final/level0_Final/" + dir_itr->filename()); |
291 |
else remove(dir_itr->path()); |
292 |
} |
293 |
|
294 |
if (exists(dir_itr->path())) { |
295 |
|
296 |
} |
297 |
else { |
298 |
logfile << "\tMoved file: " << dir_itr->path().filename() << "\n"; |
299 |
} |
300 |
} |
301 |
|
302 |
|
303 |
|
304 |
} |
305 |
logfile << "\tCleaning up TXMPs...\n"; |
306 |
system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + levels[i] + "_Final/TXMP*.oni").c_str()); |
307 |
parts_done++; |
308 |
|
309 |
setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); |
310 |
|
311 |
} |
312 |
} |
313 |
logfile << "Reimporting levels\n"; |
314 |
for (int i = 0; i < 15; i++) |
315 |
{ |
316 |
logfile << "\tReimporting level" << levels[i] << "_Final.oni\n"; |
317 |
//printf(levels[i],"%d",levels[i]); |
318 |
//printf(Step_x_x,"Step %d/%d: reimporting level", parts_done + 1, 7 + 2 * num_levels); setStatusArea((string)Step_x_x + levels[i] + (string)"_Final.dat"); |
319 |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni"); |
320 |
logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
321 |
+ levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n'; |
322 |
string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level" |
323 |
+ levels[i] + "_Final/level" + levels[i] + "_Final.oni"); |
324 |
system(sys_str.c_str() ); |
325 |
setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); |
326 |
parts_done++; |
327 |
} |
328 |
//create_directory( VanillaCharacters.parent_path() ); |
329 |
create_directory( VanillaParticles.parent_path() ); |
330 |
create_directory( VanillaTextures.parent_path() ); |
331 |
create_directory( VanillaSounds.parent_path() ); |
332 |
create_directory( VanillaAnimations.remove_filename() ); |
333 |
|
334 |
for(int j = 0; j < GDFPaths.size(); j++) { |
335 |
logfile << "\tReimporting " << GDFPaths[j].filename() << ".oni\n"; |
336 |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": reimporting " + GDFPaths[j].filename() ); |
337 |
system((strOniSplit + " " + strImportOption + " " + GDFPaths[j].string() + " " + VanillaPaths[j].string()).c_str()); |
338 |
parts_done++; |
339 |
setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); |
340 |
} |
341 |
logfile << "\nMoving level0_Characters\n"; |
342 |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": moving level0_Characters" ); |
343 |
copy((path)"../GameDataFolder/level0_Characters", (path)("VanillaDats/level0_Final")); |
344 |
/* |
345 |
printf(Step_x_x,"Step %d/%d: reimporting level0_Characters", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); |
346 |
system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str()); |
347 |
parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Particles", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); |
348 |
system((strOniSplit + " " + strImportOption + " " + Particles.string() + " " + VanillaParticles.string()).c_str()); |
349 |
parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Textures", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); |
350 |
system((strOniSplit + " " + strImportOption + " " + Textures.string() + " " + VanillaTextures.string()).c_str()); |
351 |
//system((strOniSplit + " " + strImportOption + (string)" " + Animations.string() + (string)" " + VanillaAnimations.string()).c_str()); |
352 |
parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAC", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); |
353 |
system((strOniSplit + " " + strImportOption + " " + TRAC.string() + " " + VanillaTRAC.string()).c_str()); |
354 |
parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_Sounds", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); |
355 |
system((strOniSplit + " " + strImportOption + " " + Sounds.string() + " " + VanillaSounds.string()).c_str()); |
356 |
parts_done++; printf(Step_x_x,"Step %d/%d: reimporting level0_TRAM", parts_done,7 + 2 * num_levels); setStatusArea((string)Step_x_x);setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); |
357 |
system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str()); |
358 |
//parts_done++; setStatusArea((string)"Copying level scripts...");setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); |
359 |
if (exists("../GameDataFolder/IGMD")) remove_all("../GameDataFolder/IGMD"); |
360 |
*/ |
361 |
create_directory((path)"../GameDataFolder/IGMD"); |
362 |
copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder"); |
363 |
setProgressBar( 1000 ); |
364 |
|
365 |
if(exists("../../persist.dat")) 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 |
|
386 |
} |
387 |
catch (exception & ex) { |
388 |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
389 |
} |
390 |
|
391 |
ptime end_time(second_clock::local_time()); |
392 |
time_period total_time (start_time, end_time); |
393 |
logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length(); |
394 |
//total_time.length().hours(); |
395 |
logfile.close(); |
396 |
busy = 0; |
397 |
return err; |
398 |
} |
399 |
|
400 |
|
401 |
vector<ModPackage> getPackages(void) |
402 |
{ |
403 |
vector<ModPackage> packages; |
404 |
packages.reserve(65536); // come on, we shouldn't need this much space...right?! |
405 |
fstream file; |
406 |
string filename = "\0"; |
407 |
string MODINFO_CFG = "Mod_Info.cfg"; |
408 |
|
409 |
try |
410 |
{ |
411 |
directory_iterator end_iter; |
412 |
for (directory_iterator dir_itr("./packages"); dir_itr != end_iter; ++dir_itr) |
413 |
{ |
414 |
file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str()); |
415 |
//cout << filename << "\n"; |
416 |
|
417 |
if(!file.fail()) |
418 |
{ |
419 |
//cout << dir_itr->path().string() + MODINFO_CFG; |
420 |
//would prefer to push a pointer to a package, but this will do for now |
421 |
packages.push_back(fileToModPackage(file)); |
422 |
} |
423 |
file.close(); |
424 |
file.clear(); |
425 |
} |
426 |
sort(packages.begin(), packages.end()); |
427 |
} |
428 |
catch (const std::exception & ex) |
429 |
{ |
430 |
cout << "Warning, something odd happened!\n"; |
431 |
} |
432 |
|
433 |
return packages; |
434 |
} |
435 |
|
436 |
ModPackage fileToModPackage(fstream &file) |
437 |
{ |
438 |
/* |
439 |
This converts a file to a ModPackage struct. |
440 |
|
441 |
A few notes... |
442 |
"iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok. |
443 |
I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much |
444 |
slower than reading a variable. |
445 |
*/ |
446 |
ModPackage package; |
447 |
string line; |
448 |
static string NameOfMod = "NameOfMod"; //used for comparing to the current token... |
449 |
//I could have done it in reverse (*iter).compare("ModString") or |
450 |
static string ARROW = "->"; //did something like "ModString".compare(*iter), and it would have been |
451 |
static string ModString = "ModString"; //functionably the same. |
452 |
static string HasOnis = "HasOnis"; |
453 |
static string HasDeltas = "HasDeltas"; |
454 |
static string HasBSL = "HasBSL"; |
455 |
static string HasDats = "HasDats"; |
456 |
static string IsEngine = "IsEngine"; |
457 |
static string Readme = "Readme"; |
458 |
static string GlobalNeeded = "GlobalNeeded"; |
459 |
static string Category = "Category"; |
460 |
static string Creator = "Creator"; |
461 |
while (! file.eof() ) |
462 |
{ |
463 |
getline (file,line); |
464 |
vector<string> tokens; |
465 |
vector<string>::iterator iter; |
466 |
tokenize(line, tokens); //string to vector of "words" |
467 |
if (tokens.capacity() >= 2) { //make sure they are using enough stuff |
468 |
iter = tokens.begin(); //what word we are on, starts at first word |
469 |
/* |
470 |
if (!AEInstallVersion.compare(*iter)) |
471 |
If mod is too old, skip this mod. |
472 |
*/ |
473 |
/*else*/if (!NameOfMod.compare(*iter)) { //if it contains the name |
474 |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment |
475 |
if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) { //ignores "->" and "NameOfMod" |
476 |
//cout << *iter; |
477 |
//cout << " "; |
478 |
package.name += *iter + " "; |
479 |
} |
480 |
} |
481 |
|
482 |
} |
483 |
else if (!ModString.compare(*iter)) { |
484 |
iter++; iter++; |
485 |
package.modStringName = *iter; |
486 |
iter++; |
487 |
package.modStringVersion = atoi((*iter).c_str()); |
488 |
} |
489 |
else if (!HasOnis.compare(*iter)) { |
490 |
iter++; iter++; |
491 |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasOnis = 1; //Gotta love c++'s lack of a standard case-insensitive |
492 |
else if (!HasBSL.compare(*iter)) { // string comparer...I know my implementation here sucks. I need to change it to check each character one by one. At the moment, |
493 |
iter++; iter++;} // using "YFR" would probably set it off. :< |
494 |
|
495 |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasBSL = 1; |
496 |
} |
497 |
else if (!HasDeltas.compare(*iter)) { |
498 |
iter++; iter++; |
499 |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1; |
500 |
} |
501 |
else if (!HasDats.compare(*iter)) { |
502 |
iter++; iter++; |
503 |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1; |
504 |
} |
505 |
else if (!IsEngine.compare(*iter)) { |
506 |
iter++; iter++; |
507 |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1; |
508 |
} |
509 |
else if (!GlobalNeeded.compare(*iter)) { |
510 |
iter++; iter++; |
511 |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1; |
512 |
else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; //Really the only place where checking for "No" is important atm. |
513 |
} |
514 |
else if (!Category.compare(*iter)) { |
515 |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment |
516 |
if (ARROW.compare(*iter) && Category.compare(*iter)) { //ignores "->" and "Category" |
517 |
//cout << *iter; |
518 |
//cout << " "; |
519 |
package.category += *iter + " "; |
520 |
} |
521 |
} |
522 |
} |
523 |
else if (!Creator.compare(*iter)) { //if it contains the name |
524 |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment |
525 |
if (ARROW.compare(*iter) && Creator.compare(*iter)) { //ignores "->" and "Category" |
526 |
//cout << *iter; |
527 |
//cout << " "; |
528 |
package.creator += *iter + " "; |
529 |
} |
530 |
} |
531 |
} |
532 |
else if (!Readme.compare(*iter)) { //if it contains the name |
533 |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment |
534 |
if (ARROW.compare(*iter) && Readme.compare(*iter)) { //ignores "->" and "Category" |
535 |
if(!(*iter).compare("\\n")) package.readme += '\n'; |
536 |
else package.readme += *iter + " "; |
537 |
} |
538 |
} |
539 |
} |
540 |
} |
541 |
|
542 |
} |
543 |
package.doOutput(); |
544 |
return package; |
545 |
} |
546 |
|
547 |
void recompileAll(vector<string> installedMods) |
548 |
{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; |
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 |
|
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 |
|
579 |
for ( recursive_directory_iterator dir_itr( vanilla_dir ); |
580 |
dir_itr != end_iter; |
581 |
++dir_itr ) |
582 |
{ |
583 |
try{ |
584 |
if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1) |
585 |
{ |
586 |
numberOfDats++; |
587 |
} |
588 |
} |
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 |
try { |
600 |
//recursive_directory_iterator end_iter; |
601 |
|
602 |
|
603 |
out << numberOfDats; |
604 |
datString = out.str(); |
605 |
for ( recursive_directory_iterator dir_itr( vanilla_dir ); |
606 |
dir_itr != end_iter; |
607 |
++dir_itr ) |
608 |
{ |
609 |
try |
610 |
{ |
611 |
if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1) |
612 |
{ |
613 |
importCommand = strOniSplit + " " + strImportOption + " " + dir_itr->path().parent_path().string() + '/' + dir_itr->path().filename(); |
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 << " VanillaDats/" + installedMods[i] + "/oni/"; |
619 |
} |
620 |
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
621 |
|
622 |
|
623 |
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
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 |
|
631 |
} |
632 |
} |
633 |
catch ( const std::exception & ex ) |
634 |
{ |
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 |
|
646 |
} |
647 |
catch( const std::exception & ex ) { |
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 |
|
658 |
} |
659 |
else if(splitInstances == NOT_SPLIT){ |
660 |
directory_iterator end_iter; |
661 |
|
662 |
for ( directory_iterator dir_itr( vanilla_dir ); |
663 |
dir_itr != end_iter; |
664 |
++dir_itr ) |
665 |
{ |
666 |
|
667 |
if ( is_directory( dir_itr->status() ) ) |
668 |
{ |
669 |
numberOfDats++; |
670 |
} |
671 |
|
672 |
|
673 |
} |
674 |
|
675 |
out << numberOfDats; |
676 |
datString = out.str(); |
677 |
|
678 |
for ( directory_iterator dir_itr( vanilla_dir ); |
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() + " "; |
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 >> Install.log"; |
692 |
|
693 |
|
694 |
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
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 |
|
699 |
j++; |
700 |
} |
701 |
} |
702 |
catch ( const std::exception & ex ) |
703 |
{ |
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! 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 |
|
753 |
if ( exists( strInstallCfg ) ) |
754 |
{ |
755 |
remove( strInstallCfg ); |
756 |
} |
757 |
|
758 |
ofstream file(strInstallCfg.c_str()); |
759 |
|
760 |
vector<string>list = installedMods; |
761 |
vector<string>::iterator begin_iter = list.begin(); |
762 |
vector<string>::iterator end_iter = list.end(); |
763 |
|
764 |
sort( list.begin(), list.end() ); |
765 |
|
766 |
for( ; begin_iter != end_iter; ++begin_iter) { |
767 |
file << *begin_iter << " "; |
768 |
} |
769 |
|
770 |
file.close(); |
771 |
file.clear(); |
772 |
|
773 |
} |
774 |
|
775 |
vector<string> getInstallString(string Cfg) |
776 |
{ |
777 |
//system(strPauseCmd); |
778 |
vector<string> returnval; |
779 |
|
780 |
string line; |
781 |
fstream file; |
782 |
|
783 |
if (exists( Cfg )) |
784 |
{ |
785 |
file.open(Cfg.c_str()); |
786 |
getline(file, line); |
787 |
tokenize(line, returnval); |
788 |
file.close(); |
789 |
file.clear(); |
790 |
sort(returnval.begin(), returnval.end()); |
791 |
} |
792 |
else cout << "fail"; |
793 |
|
794 |
return returnval; |
795 |
} |
796 |
|
797 |
//stolen token function... |
798 |
void tokenize(const string& str, vector<string>& tokens, const string& delimiters) |
799 |
{ |
800 |
// Skip delimiters at beginning. |
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 |
|
805 |
while (string::npos != pos || string::npos != lastPos) |
806 |
{ |
807 |
// Found a token, add it to the vector. |
808 |
tokens.push_back(str.substr(lastPos, pos - lastPos)); |
809 |
// Skip delimiters. Note the "not_of" |
810 |
lastPos = str.find_first_not_of(delimiters, pos); |
811 |
// Find next "non-delimiter" |
812 |
pos = str.find_first_of(delimiters, lastPos); |
813 |
} |
814 |
} |
815 |
|
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 ) |
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 |
|
827 |
} |
828 |
|
829 |
} |
830 |
|
831 |
vector<string> globalInstalledMods; |
832 |
vector<ModPackage> globalPackages; |
833 |
#include "boost/thread.hpp" |
834 |
#include <boost/thread/mutex.hpp> |
835 |
|
836 |
///////////////////////////////////////////////////////////////////////////// |
837 |
// Name: main_window.cpp |
838 |
// Purpose: |
839 |
// Author: |
840 |
// Modified by: |
841 |
// Created: 07/05/2009 20:38:25 |
842 |
// RCS-ID: |
843 |
// Copyright: |
844 |
// Licence: |
845 |
///////////////////////////////////////////////////////////////////////////// |
846 |
|
847 |
// For compilers that support precompilation, includes "wx/wx.h". |
848 |
#include "wx/wxprec.h" |
849 |
|
850 |
#ifdef __BORLANDC__ |
851 |
#pragma hdrstop |
852 |
#endif |
853 |
|
854 |
#ifndef WX_PRECOMP |
855 |
#include "wx/wx.h" |
856 |
#endif |
857 |
|
858 |
////@begin includes |
859 |
#include "about.h" |
860 |
////@end includes |
861 |
|
862 |
#include "main_window.h" |
863 |
|
864 |
////@begin XPM images |
865 |
#include "aelogosmall.xpm" |
866 |
#include "undo.xpm" |
867 |
#include "fileopen.xpm" |
868 |
#include "filesaveas.xpm" |
869 |
#include "quit.xpm" |
870 |
////@end XPM images |
871 |
|
872 |
//#define wxDebug 1; |
873 |
//#define wxUSE_UNICODE 1; |
874 |
|
875 |
/* |
876 |
* MainWindow type definition |
877 |
*/ |
878 |
|
879 |
IMPLEMENT_CLASS( MainWindow, wxFrame ) |
880 |
|
881 |
|
882 |
/* |
883 |
* MainWindow event table definition |
884 |
*/ |
885 |
|
886 |
BEGIN_EVENT_TABLE( MainWindow, wxFrame ) |
887 |
|
888 |
////@begin MainWindow event table entries |
889 |
EVT_CHECKBOX( SelectAll_Checkbox, MainWindow::OnSelectAllCheckboxClick ) |
890 |
|
891 |
EVT_BUTTON( Refresh_Button, MainWindow::OnRefreshButtonClick ) |
892 |
|
893 |
EVT_LISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Selected ) |
894 |
EVT_CHECKLISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Toggled ) |
895 |
|
896 |
EVT_UPDATE_UI( ID_STATUSBAR, MainWindow::OnStatusbarUpdate ) |
897 |
|
898 |
EVT_BUTTON( Install_Button, MainWindow::OnInstallButtonClick ) |
899 |
|
900 |
EVT_RADIOBUTTON( Sep_RadioButton, MainWindow::OnSepRadioButtonSelected ) |
901 |
|
902 |
EVT_RADIOBUTTON( NoSep_RadioButton, MainWindow::OnNoSepRadioButtonSelected ) |
903 |
|
904 |
EVT_RADIOBUTTON( Seperated_RadioButton, MainWindow::OnSeperatedRadioButtonSelected ) |
905 |
|
906 |
EVT_RADIOBUTTON( Complete_RadioButton, MainWindow::OnCompleteRadioButtonSelected ) |
907 |
|
908 |
EVT_BUTTON( ReGlobalize_Button, MainWindow::OnReGlobalizeButtonClick ) |
909 |
|
910 |
EVT_MENU( wxID_LOAD, MainWindow::OnLoadClick ) |
911 |
|
912 |
EVT_MENU( wxID_SAVE, MainWindow::OnSaveClick ) |
913 |
|
914 |
EVT_MENU( wxID_EXIT, MainWindow::OnExitClick ) |
915 |
|
916 |
EVT_MENU( wxID_OPTIONS, MainWindow::OnOptionsClick ) |
917 |
|
918 |
EVT_MENU( wxID_ABOUT, MainWindow::OnAboutClick ) |
919 |
|
920 |
////@end MainWindow event table entries |
921 |
|
922 |
END_EVENT_TABLE() |
923 |
|
924 |
|
925 |
/* |
926 |
* MainWindow constructors |
927 |
*/ |
928 |
|
929 |
MainWindow::MainWindow() |
930 |
{ |
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 ); |
938 |
} |
939 |
|
940 |
|
941 |
/* |
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 |
948 |
wxFrame::Create( parent, id, caption, pos, size, style ); |
949 |
|
950 |
CreateControls(); |
951 |
SetIcon(GetIconResource(wxT("aelogosmall.png"))); |
952 |
Centre(); |
953 |
////@end MainWindow creation |
954 |
return true; |
955 |
} |
956 |
|
957 |
|
958 |
/* |
959 |
* MainWindow destructor |
960 |
*/ |
961 |
|
962 |
MainWindow::~MainWindow() |
963 |
{ |
964 |
////@begin MainWindow destruction |
965 |
////@end MainWindow destruction |
966 |
} |
967 |
|
968 |
|
969 |
/* |
970 |
* Member initialisation |
971 |
*/ |
972 |
|
973 |
void MainWindow::Init() |
974 |
{ |
975 |
////@begin MainWindow member initialisation |
976 |
MainSplitter = NULL; |
977 |
SelectAll = NULL; |
978 |
RefreshButton = NULL; |
979 |
Mods_CheckboxList = NULL; |
980 |
titleText = NULL; |
981 |
creatorText = NULL; |
982 |
descriptionText = NULL; |
983 |
StatusArea = NULL; |
984 |
ProgressBar = NULL; |
985 |
InstallButton = NULL; |
986 |
OptionsPanel = NULL; |
987 |
SepRadio = NULL; |
988 |
NoSepRadio = NULL; |
989 |
SeperatedRadio = NULL; |
990 |
CompleteRadio = NULL; |
991 |
ReglobalizeButton = NULL; |
992 |
////@end MainWindow member initialisation |
993 |
|
994 |
} |
995 |
|
996 |
|
997 |
/* |
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 |
1006 |
MainWindow* itemFrame1 = this; |
1007 |
|
1008 |
wxMenuBar* menuBar = new wxMenuBar; |
1009 |
wxMenu* itemMenu37 = new wxMenu; |
1010 |
{ |
1011 |
wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_LOAD, _("&Load Configuration..."), wxEmptyString, wxITEM_NORMAL); |
1012 |
wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("fileopen.xpm"))); |
1013 |
menuItem->SetBitmap(bitmap); |
1014 |
itemMenu37->Append(menuItem); |
1015 |
} |
1016 |
{ |
1017 |
wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_SAVE, _("&Save Configuration..."), wxEmptyString, wxITEM_NORMAL); |
1018 |
wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("filesaveas.xpm"))); |
1019 |
menuItem->SetBitmap(bitmap); |
1020 |
itemMenu37->Append(menuItem); |
1021 |
} |
1022 |
itemMenu37->AppendSeparator(); |
1023 |
{ |
1024 |
wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_EXIT, _("Exit"), wxEmptyString, wxITEM_NORMAL); |
1025 |
wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("quit.xpm"))); |
1026 |
menuItem->SetBitmap(bitmap); |
1027 |
itemMenu37->Append(menuItem); |
1028 |
} |
1029 |
menuBar->Append(itemMenu37, _("&File")); |
1030 |
wxMenu* itemMenu42 = new wxMenu; |
1031 |
itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK); |
1032 |
menuBar->Append(itemMenu42, _("Options")); |
1033 |
wxMenu* itemMenu44 = new wxMenu; |
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(1); |
1048 |
MainSplitter->SetName(_T("MainSplitter")); |
1049 |
|
1050 |
wxPanel* itemPanel4 = new wxPanel( MainSplitter, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); |
1051 |
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL); |
1052 |
itemPanel4->SetSizer(itemBoxSizer5); |
1053 |
|
1054 |
wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL); |
1055 |
itemBoxSizer5->Add(itemBoxSizer6, 0, wxGROW|wxALL, 0); |
1056 |
SelectAll = new wxCheckBox( itemPanel4, SelectAll_Checkbox, _("Select All/None"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); |
1057 |
SelectAll->SetValue(false); |
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("undo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); |
1062 |
RefreshButton->SetName(_T("RefreshButton")); |
1063 |
itemBoxSizer6->Add(RefreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5); |
1064 |
|
1065 |
wxArrayString Mods_CheckboxListStrings; |
1066 |
Mods_CheckboxList = new wxCheckListBox( itemPanel4, Mods_CheckboxList1, wxDefaultPosition, wxDefaultSize, Mods_CheckboxListStrings, wxLB_HSCROLL ); |
1067 |
Mods_CheckboxList->SetName(_T("Mods_CheckboxList")); |
1068 |
itemBoxSizer5->Add(Mods_CheckboxList, 1, wxGROW|wxALL, 0); |
1069 |
|
1070 |
wxPanel* itemPanel10 = new wxPanel( MainSplitter, DescriptionHolder_Panel, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); |
1071 |
itemPanel10->SetName(_T("DescriptionHolder_Panel")); |
1072 |
wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL); |
1073 |
itemPanel10->SetSizer(itemBoxSizer11); |
1074 |
|
1075 |
wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL); |
1076 |
itemBoxSizer11->Add(itemBoxSizer12, 0, wxGROW|wxALL, 0); |
1077 |
wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL); |
1078 |
itemBoxSizer12->Add(itemBoxSizer13, 1, wxALIGN_CENTER_VERTICAL|wxALL, 0); |
1079 |
titleText = new wxTextCtrl( itemPanel10, Title_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); |
1080 |
titleText->SetName(_T("Title_Text")); |
1081 |
titleText->SetBackgroundColour(wxColour(240, 240, 240)); |
1082 |
itemBoxSizer13->Add(titleText, 1, wxGROW|wxLEFT, 5); |
1083 |
|
1084 |
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL); |
1085 |
itemBoxSizer12->Add(itemBoxSizer15, 1, wxGROW|wxALL, 0); |
1086 |
creatorText = new wxTextCtrl( itemPanel10, Author_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_RIGHT ); |
1087 |
creatorText->SetName(_T("Author_Text")); |
1088 |
creatorText->SetBackgroundColour(wxColour(240, 240, 240)); |
1089 |
itemBoxSizer15->Add(creatorText, 1, wxGROW|wxRIGHT, 5); |
1090 |
|
1091 |
wxStaticLine* itemStaticLine17 = new wxStaticLine( itemPanel10, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); |
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_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, 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(_("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, 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, wxDefaultSize, 0 ); |
1117 |
itemBoxSizer20->Add(InstallButton, 0, wxGROW|wxALL, 0); |
1118 |
|
1119 |
wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL); |
1120 |
itemBoxSizer2->Add(itemBoxSizer23, 0, wxGROW|wxALL, 0); |
1121 |
|
1122 |
OptionsPanel = new wxPanel( itemFrame1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); |
1123 |
itemBoxSizer2->Add(OptionsPanel, 0, wxGROW, 0); |
1124 |
|
1125 |
wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL); |
1126 |
OptionsPanel->SetSizer(itemBoxSizer25); |
1127 |
|
1128 |
wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxVERTICAL); |
1129 |
itemBoxSizer25->Add(itemBoxSizer26, 0, wxGROW|wxALL, 5); |
1130 |
|
1131 |
SepRadio = new wxRadioButton( OptionsPanel, Sep_RadioButton, _("Sep"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); |
1132 |
SepRadio->SetValue(false); |
1133 |
if (MainWindow::ShowToolTips()) |
1134 |
SepRadio->SetToolTip(_("For PC Demo and Mac")); |
1135 |
itemBoxSizer26->Add(SepRadio, 0, wxALIGN_LEFT|wxALL, 5); |
1136 |
|
1137 |
NoSepRadio = new wxRadioButton( OptionsPanel, NoSep_RadioButton, _("NoSep"), wxDefaultPosition, wxDefaultSize, 0 ); |
1138 |
NoSepRadio->SetValue(false); |
1139 |
if (MainWindow::ShowToolTips()) |
1140 |
NoSepRadio->SetToolTip(_("For PC Retail")); |
1141 |
itemBoxSizer26->Add(NoSepRadio, 0, wxALIGN_LEFT|wxALL, 5); |
1142 |
|
1143 |
wxStaticLine* itemStaticLine29 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); |
1144 |
itemBoxSizer25->Add(itemStaticLine29, 0, wxGROW|wxALL, 5); |
1145 |
|
1146 |
wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxVERTICAL); |
1147 |
itemBoxSizer25->Add(itemBoxSizer30, 0, wxGROW|wxALL, 5); |
1148 |
|
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); |
1156 |
CompleteRadio->SetName(_T("Complete_RadioButton")); |
1157 |
itemBoxSizer30->Add(CompleteRadio, 0, wxALIGN_LEFT|wxALL, 5); |
1158 |
|
1159 |
wxStaticLine* itemStaticLine33 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); |
1160 |
itemBoxSizer25->Add(itemStaticLine33, 0, wxGROW|wxALL, 5); |
1161 |
|
1162 |
wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL); |
1163 |
itemBoxSizer25->Add(itemBoxSizer34, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
1164 |
|
1165 |
ReglobalizeButton = new wxButton( OptionsPanel, ReGlobalize_Button, _("Reglobalize"), wxDefaultPosition, wxDefaultSize, 0 ); |
1166 |
ReglobalizeButton->SetName(_T("Reglobalize_Button")); |
1167 |
itemBoxSizer34->Add(ReglobalizeButton, 0, wxGROW|wxALL, 5); |
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 |
#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 |
strImportOption = "-import:nosep"; |
1184 |
splitInstances = SPLIT; |
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 |
|
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() ); |
1234 |
} |
1235 |
|
1236 |
|
1237 |
/* |
1238 |
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox |
1239 |
*/ |
1240 |
|
1241 |
void MainWindow::OnSelectAllCheckboxClick( wxCommandEvent& event ) |
1242 |
{ |
1243 |
switch(SelectAll->Get3StateValue()) { |
1244 |
case wxCHK_UNCHECKED: |
1245 |
for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); |
1246 |
//SelectAll->Set3StateValue(wxCHK_CHECKED); |
1247 |
break; |
1248 |
case wxCHK_CHECKED: |
1249 |
for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true); |
1250 |
//SelectAll->Set3StateValue(wxCHK_UNCHECKED); |
1251 |
break; |
1252 |
case wxCHK_UNDETERMINED: |
1253 |
for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); |
1254 |
//SelectAll->Set3StateValue(wxCHK_CHECKED); |
1255 |
break; |
1256 |
|
1257 |
} |
1258 |
|
1259 |
} |
1260 |
|
1261 |
|
1262 |
/* |
1263 |
* wxEVT_CREATE event handler for Mods_CheckboxList |
1264 |
*/ |
1265 |
|
1266 |
void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event ) |
1267 |
{ |
1268 |
|
1269 |
|
1270 |
} |
1271 |
|
1272 |
|
1273 |
/* |
1274 |
* Should we show tooltips? |
1275 |
*/ |
1276 |
|
1277 |
bool MainWindow::ShowToolTips() |
1278 |
{ |
1279 |
return true; |
1280 |
} |
1281 |
|
1282 |
/* |
1283 |
* Get bitmap resources |
1284 |
*/ |
1285 |
|
1286 |
wxBitmap MainWindow::GetBitmapResource( const wxString& name ) |
1287 |
{ |
1288 |
// Bitmap retrieval |
1289 |
////@begin MainWindow bitmap retrieval |
1290 |
wxUnusedVar(name); |
1291 |
if (name == _T("undo.xpm")) |
1292 |
{ |
1293 |
wxBitmap bitmap( undo_xpm); |
1294 |
return bitmap; |
1295 |
} |
1296 |
else if (name == _T("fileopen.xpm")) |
1297 |
{ |
1298 |
wxBitmap bitmap( fileopen_xpm); |
1299 |
return bitmap; |
1300 |
} |
1301 |
else if (name == _T("filesaveas.xpm")) |
1302 |
{ |
1303 |
wxBitmap bitmap( filesaveas_xpm); |
1304 |
return bitmap; |
1305 |
} |
1306 |
else if (name == _T("quit.xpm")) |
1307 |
{ |
1308 |
wxBitmap bitmap( quit_xpm); |
1309 |
return bitmap; |
1310 |
} |
1311 |
return wxNullBitmap; |
1312 |
////@end MainWindow bitmap retrieval |
1313 |
} |
1314 |
|
1315 |
/* |
1316 |
* Get icon resources |
1317 |
*/ |
1318 |
|
1319 |
wxIcon MainWindow::GetIconResource( const wxString& name ) |
1320 |
{ |
1321 |
|
1322 |
// Icon retrieval |
1323 |
////@begin MainWindow icon retrieval |
1324 |
wxUnusedVar(name); |
1325 |
if (name == _T("aelogosmall.png")) |
1326 |
{ |
1327 |
wxIcon icon(aelogosmall_xpm); |
1328 |
return icon; |
1329 |
} |
1330 |
return wxNullIcon; |
1331 |
////@end MainWindow icon retrieval |
1332 |
} |
1333 |
|
1334 |
|
1335 |
/* |
1336 |
* wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1 |
1337 |
*/ |
1338 |
|
1339 |
void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event ) |
1340 |
{ |
1341 |
//event.GetSelection |
1342 |
titleText->SetValue(globalPackages[event.GetSelection()].name.c_str()); |
1343 |
creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str()); |
1344 |
descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str()); |
1345 |
|
1346 |
//creatorText->Refresh(); |
1347 |
} |
1348 |
|
1349 |
|
1350 |
/* |
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 |
/* |
1359 |
switch(SelectAll->Get3StateValue()) { |
1360 |
case wxCHK_UNCHECKED: |
1361 |
break; |
1362 |
case wxCHK_CHECKED: |
1363 |
break; |
1364 |
case wxCHK_UNDETERMINED : |
1365 |
break; |
1366 |
} |
1367 |
*/ |
1368 |
} |
1369 |
} |
1370 |
|
1371 |
|
1372 |
/* |
1373 |
* wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS |
1374 |
*/ |
1375 |
|
1376 |
void MainWindow::OnOptionsClick( wxCommandEvent& event ) |
1377 |
{ |
1378 |
if (!event.GetInt() ) { |
1379 |
OptionsPanel->Hide(); |
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 |
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 |
*/ |
1397 |
|
1398 |
void MainWindow::OnExitClick( wxCommandEvent& event ) |
1399 |
{ |
1400 |
exit(0); |
1401 |
} |
1402 |
|
1403 |
|
1404 |
/* |
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 |
{ |
1414 |
TheInstallButton->Disable(); |
1415 |
recompileAll(thePackages); |
1416 |
TheInstallButton->Enable(); |
1417 |
|
1418 |
} |
1419 |
|
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 |
|
1434 |
vector<string> localPackages; |
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 |
sort(localPackages.begin(), localPackages.end()); |
1439 |
localPackages[0] = "Globalize"; |
1440 |
//MainWindow::MainWindow().Hide(); |
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 |
1449 |
recompileAll(localPackages); |
1450 |
#endif |
1451 |
|
1452 |
this->InstallButton->Enable(); |
1453 |
this->ReglobalizeButton->Enable(); |
1454 |
} |
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); |
1467 |
//->SetLabel(s); |
1468 |
|
1469 |
}*/ |
1470 |
|
1471 |
void setProgressBar( int i ) { |
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 |
*/ |
1497 |
|
1498 |
void MainWindow::OnStatusbarUpdate( wxUpdateUIEvent& event ) |
1499 |
{ |
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. |
1504 |
} |
1505 |
|
1506 |
|
1507 |
/* |
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. |
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. |
1519 |
} |
1520 |
|
1521 |
|
1522 |
/* |
1523 |
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton |
1524 |
*/ |
1525 |
|
1526 |
void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event ) |
1527 |
{ |
1528 |
static_cast<string>("-import:nosep"); |
1529 |
} |
1530 |
|
1531 |
|
1532 |
/* |
1533 |
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton |
1534 |
*/ |
1535 |
|
1536 |
void MainWindow::OnSepRadioButtonSelected( wxCommandEvent& event ) |
1537 |
{ |
1538 |
static_cast<string>("-import:sep"); |
1539 |
} |
1540 |
|
1541 |
|
1542 |
/* |
1543 |
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton |
1544 |
*/ |
1545 |
|
1546 |
/* |
1547 |
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton |
1548 |
*/ |
1549 |
|
1550 |
void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event ) |
1551 |
{ |
1552 |
splitInstances = NOT_SPLIT; |
1553 |
|
1554 |
} |
1555 |
|
1556 |
|
1557 |
/* |
1558 |
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON |
1559 |
*/ |
1560 |
|
1561 |
void MainWindow::OnRefreshButtonClick( wxCommandEvent& event ) |
1562 |
{ |
1563 |
refreshMods(globalInstalledMods); |
1564 |
} |
1565 |
|
1566 |
|
1567 |
/* |
1568 |
* wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD |
1569 |
*/ |
1570 |
|
1571 |
|
1572 |
|
1573 |
|
1574 |
void MainWindow::refreshMods (vector<string> s) { |
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 |
} |
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 |
|
1594 |
wxFileDialog* openFileDialog = |
1595 |
new wxFileDialog( this, _("Open Mod Loadout"), "", "", FILETYPES, |
1596 |
wxOPEN, wxDefaultPosition); |
1597 |
|
1598 |
if ( openFileDialog->ShowModal() == wxID_OK ) |
1599 |
{ |
1600 |
refreshMods(getInstallString( string(openFileDialog->GetPath()) )); |
1601 |
} |
1602 |
|
1603 |
|
1604 |
} |
1605 |
|
1606 |
|
1607 |
/* |
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 |
); |
1618 |
|
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-> |
1628 |
|
1629 |
|
1630 |
|
1631 |
// |
1632 |
|
1633 |
if ( exists( openFileDialog->GetPath().c_str() ) ) |
1634 |
{ |
1635 |
remove( openFileDialog->GetPath().c_str() ); |
1636 |
} |
1637 |
|
1638 |
ofstream file(openFileDialog->GetPath().c_str()); |
1639 |
|
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 |
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()); |
1656 |
//SetStatusText(GetCurrentFilename(), 0); |
1657 |
//SetStatusText(openFileDialog->GetDirectory(),1); |
1658 |
} |
1659 |
} |
1660 |
|
1661 |
|
1662 |
|
1663 |
/* |
1664 |
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button |
1665 |
*/ |
1666 |
|
1667 |
void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event ) |
1668 |
{ |
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 |
*/ |
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(); |
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 |
|