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