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