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