| 1 |
+ |
/***************************************************************************\ |
| 2 |
+ |
| Project: AE Installer | |
| 3 |
+ |
| By: Gumby & Iritscen | |
| 4 |
+ |
| File: Main_Window.cpp | |
| 5 |
+ |
| Function: Handles the GUI. | |
| 6 |
+ |
| Created: 07/05/2009 20:38:25 | |
| 7 |
+ |
\***************************************************************************/ |
| 8 |
+ |
|
| 9 |
|
#ifndef NTDDI_VERSION |
| 10 |
|
#define NTDDI_VERSION NTDDI_WIN7 |
| 11 |
|
#endif |
| 12 |
|
#ifdef WIN32 |
| 13 |
< |
#include <windows.h> |
| 13 |
> |
#include <windows.h> |
| 14 |
|
#include <shobjidl.h> |
| 15 |
|
HWND Handle; |
| 8 |
– |
|
| 16 |
|
ITaskbarList *pTaskbarList; |
| 17 |
|
ITaskbarList3 *pTaskbarList3; |
| 18 |
|
#endif |
| 19 |
|
|
| 13 |
– |
/* |
| 14 |
– |
AE/Mod Installer |
| 15 |
– |
by Gumby and Iritscen |
| 16 |
– |
*/ |
| 17 |
– |
|
| 18 |
– |
// To-do: - Load credits from text resource file |
| 19 |
– |
// - Institute lots of checks into file-handling |
| 20 |
– |
// - Clear mod info fields when mod is de-selected |
| 21 |
– |
|
| 22 |
– |
#define DEBUG |
| 23 |
– |
#include <stdio.h> |
| 24 |
– |
//#include <conio.h> |
| 25 |
– |
//#include <process.h> |
| 26 |
– |
#include <string> |
| 27 |
– |
#include <iostream> |
| 28 |
– |
#include <cctype> |
| 29 |
– |
#include <vector> |
| 30 |
– |
#include <fstream> |
| 31 |
– |
#include <errno.h> |
| 32 |
– |
#include <sstream> |
| 33 |
– |
|
| 34 |
– |
#include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations |
| 35 |
– |
#include "boost/lexical_cast.hpp" //int -> string |
| 36 |
– |
#include "installer.h" |
| 37 |
– |
|
| 38 |
– |
#ifdef WIN32 |
| 39 |
– |
#include <windows.h> |
| 40 |
– |
#else // assume we're on Mac |
| 41 |
– |
#include <stdlib.h> |
| 42 |
– |
#include <dirent.h> |
| 43 |
– |
#endif |
| 44 |
– |
|
| 45 |
– |
//const string strInstallerVersion = "1.0"; |
| 46 |
– |
const bool SPLIT = 1; |
| 47 |
– |
const bool NOT_SPLIT = 0; |
| 48 |
– |
bool splitInstances = SPLIT; |
| 49 |
– |
bool busy = 0; |
| 50 |
– |
#ifdef WIN32 |
| 51 |
– |
const string strOniSplit = "Onisplit.exe"; |
| 52 |
– |
string strImportOption = "-import:nosep"; |
| 53 |
– |
const char* strClsCmd = "cls"; |
| 54 |
– |
const char* strPauseCmd = "PAUSE"; |
| 55 |
– |
#else // set up Mac equivalents since we're in Mac OS |
| 56 |
– |
const string strOniSplit = "mono Onisplit.exe"; |
| 57 |
– |
string strImportOption = "-import:sep"; |
| 58 |
– |
const char* strClsCmd = "clear"; |
| 59 |
– |
const char* strPauseCmd = "read -n 1 -p \"Press any key to continue\""; |
| 60 |
– |
void Sleep(int ms) { sleep( ms / 1000 ); } |
| 61 |
– |
#endif |
| 62 |
– |
|
| 63 |
– |
using namespace boost::filesystem; |
| 64 |
– |
using namespace std; |
| 65 |
– |
|
| 66 |
– |
|
| 67 |
– |
|
| 68 |
– |
|
| 69 |
– |
#include "boost/date_time/gregorian/gregorian.hpp" |
| 70 |
– |
#include "boost/date_time/date_parsing.hpp" |
| 71 |
– |
#include "boost/date_time/posix_time/posix_time.hpp" |
| 72 |
– |
|
| 73 |
– |
string escapePath(string input) { |
| 74 |
– |
|
| 75 |
– |
string output; |
| 76 |
– |
string escape_me = "& ;()|<>\"'\\#*?$"; |
| 77 |
– |
for(int i = 0; i < input.size(); i++) { |
| 78 |
– |
for(int j = 0; j < escape_me.size(); j++) if (input[i] == escape_me[j]) output += '\\'; |
| 79 |
– |
output += input[i]; |
| 80 |
– |
} |
| 81 |
– |
return output; |
| 82 |
– |
} |
| 83 |
– |
|
| 84 |
– |
int globalizeData(void) |
| 85 |
– |
{ |
| 86 |
– |
busy = 1; |
| 87 |
– |
using boost::lexical_cast; |
| 88 |
– |
using boost::bad_lexical_cast; |
| 89 |
– |
// using namespace boost::posix_time; |
| 90 |
– |
using namespace boost::gregorian; |
| 91 |
– |
using namespace boost::posix_time; |
| 92 |
– |
ptime start_time(second_clock::local_time()); |
| 93 |
– |
|
| 94 |
– |
setStatusArea("Globalizing!"); |
| 95 |
– |
int err = 0; |
| 96 |
– |
int parts_done = 0; |
| 97 |
– |
char Step_x_x[300]; |
| 98 |
– |
//char levels[i][5]; |
| 99 |
– |
remove("Globalize.log"); |
| 100 |
– |
ofstream logfile("Globalize.log"); |
| 101 |
– |
logfile << "Globalization started " << to_simple_string(start_time) << endl; |
| 102 |
– |
try { |
| 103 |
– |
|
| 104 |
– |
char levels_cstr[15][3] = {"0", "1", "2", "3", "4", "6", "8", "9", "10", "11", "12", "13", "14", "18", "19"}; // the levels Oni has...probably should have made a string array. Oops. |
| 105 |
– |
//const vector<double> ck(cv, &cv[CvSize]); |
| 106 |
– |
vector<string> levels; |
| 107 |
– |
for (int f = 0; f < 15; f++) { |
| 108 |
– |
levels.push_back(levels_cstr[f]); |
| 109 |
– |
} |
| 110 |
– |
char choice = 0; |
| 111 |
– |
|
| 112 |
– |
//SetCurrentDirectory("C:/Program Files/Oni/edition/install"); |
| 113 |
– |
///char levels[i][3]; |
| 114 |
– |
path Characters = "../GameDataFolder/level0_Characters"; |
| 115 |
– |
path Particles = "../GameDataFolder/level0_Particles"; |
| 116 |
– |
path Archive = "../GameDataFolder/Archive"; |
| 117 |
– |
path Textures = "../GameDataFolder/level0_Textures"; |
| 118 |
– |
path Sounds = "../GameDataFolder/level0_Sounds"; |
| 119 |
– |
path Animations = "../GameDataFolder/level0_Animations"; |
| 120 |
– |
path TRAC = Animations / "level0_TRAC"; |
| 121 |
– |
path TRAM = Animations / "level0_TRAM"; |
| 122 |
– |
|
| 123 |
– |
vector<path> GDFPaths; |
| 124 |
– |
GDFPaths.push_back(Characters); |
| 125 |
– |
GDFPaths.push_back(Particles); |
| 126 |
– |
GDFPaths.push_back(Textures); |
| 127 |
– |
GDFPaths.push_back(Sounds); |
| 128 |
– |
GDFPaths.push_back(TRAC); |
| 129 |
– |
GDFPaths.push_back(TRAM); |
| 130 |
– |
|
| 131 |
– |
|
| 132 |
– |
path VanillaCharacters = "packages/VanillaDats/level0_Final/level0_Characters/level0_Characters.oni"; |
| 133 |
– |
path VanillaParticles = "packages/VanillaDats/level0_Final/level0_Particles/level0_Particles.oni"; |
| 134 |
– |
path VanillaTextures = "packages/VanillaDats/level0_Final/level0_Textures/level0_Textures.oni"; |
| 135 |
– |
path VanillaSounds = "packages/VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni"; |
| 136 |
– |
path VanillaAnimations = "packages/VanillaDats/level0_Final/level0_Animations/level0_Animations.oni"; |
| 137 |
– |
path VanillaTRAC = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni"; |
| 138 |
– |
path VanillaTRAM = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni"; |
| 139 |
– |
|
| 140 |
– |
vector<path> VanillaPaths; |
| 141 |
– |
|
| 142 |
– |
VanillaPaths.push_back(VanillaCharacters); |
| 143 |
– |
VanillaPaths.push_back(VanillaParticles); |
| 144 |
– |
VanillaPaths.push_back(VanillaTextures); |
| 145 |
– |
VanillaPaths.push_back(VanillaSounds); |
| 146 |
– |
VanillaPaths.push_back(VanillaTRAC); |
| 147 |
– |
VanillaPaths.push_back(VanillaTRAM); |
| 148 |
– |
|
| 149 |
– |
/* |
| 150 |
– |
if (exists("../GameDataFolder/")) |
| 151 |
– |
{ |
| 152 |
– |
//cout << "\nIt looks like you've already globalized Oni's data.\nDo you want to re-globalize?\n(This will erase existing mods installed to the AE's game data.)" |
| 153 |
– |
// << "\n1. Re-globalize" |
| 154 |
– |
// << "\n2. Return to main menu\n"; |
| 155 |
– |
//choice = cin.get(); |
| 156 |
– |
cin.ignore(128, '\n'); |
| 157 |
– |
if (choice == '1') |
| 158 |
– |
remove_all("../GameDataFolder"); // remove AE GDF |
| 159 |
– |
if (choice == '2') |
| 160 |
– |
return 0; |
| 161 |
– |
} |
| 162 |
– |
*/ |
| 163 |
– |
setStatusArea("Removing old GameDataFolder...\n"); |
| 164 |
– |
logfile << "Removing old GameDataFolder...\n"; |
| 165 |
– |
remove_all( "../GameDataFolder/" ); |
| 166 |
– |
setStatusArea("Creating needed directories..."); |
| 167 |
– |
logfile << "Creating needed directories...\n"; |
| 168 |
– |
create_directory( "../GameDataFolder/" ); |
| 169 |
– |
|
| 170 |
– |
create_directory( "packages" ); |
| 171 |
– |
|
| 172 |
– |
if (exists("packages/VanillaDats")) remove_all("packages/VanillaDats"); |
| 173 |
– |
create_directory( "packages/VanillaDats" ); |
| 174 |
– |
create_directory( "packages/VanillaDats/level0_Final/" ); |
| 175 |
– |
//blah blah finish this. |
| 176 |
– |
//logfile << "packages/VanillaDats/level0_Final/ created"; |
| 177 |
– |
create_directory( Characters ); |
| 178 |
– |
create_directory( Particles ); |
| 179 |
– |
create_directory( Archive ); |
| 180 |
– |
create_directory( Textures ); |
| 181 |
– |
create_directory( Sounds ); |
| 182 |
– |
create_directory( Animations ); |
| 183 |
– |
create_directory( TRAC ); |
| 184 |
– |
create_directory( TRAM ); |
| 185 |
– |
int num_levels = 0; |
| 186 |
– |
for(int i = 1; i < 15; i++) |
| 187 |
– |
{ |
| 188 |
– |
if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) { |
| 189 |
– |
num_levels++; |
| 190 |
– |
|
| 191 |
– |
} |
| 192 |
– |
} |
| 193 |
– |
logfile << "Exporting and moving...\n\n"; |
| 194 |
– |
int total_steps = 8 + 2 * num_levels; |
| 195 |
– |
for(int i = 0; i < 15; i++) |
| 196 |
– |
{ |
| 197 |
– |
|
| 198 |
– |
//printf(levels[i],"%d",levels[i]); // int to char array |
| 199 |
– |
|
| 200 |
– |
if (exists("../../GameDataFolder/level" + levels[i] + "_Final.dat")) { |
| 201 |
– |
logfile << "level" << levels[i] << "_Final\n"; |
| 202 |
– |
logfile << "\tExporting level" << levels[i] << "_Final.dat\n"; |
| 203 |
– |
//printf(Step_x_x,"Step %d/%d: exporting level%d_final.dat", parts_done + 1,, levels[i]); setStatusArea((string)Step_x_x); |
| 204 |
– |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " exporting level" + levels[i]+"_Final.dat"); |
| 205 |
– |
create_directory( "../GameDataFolder/level" + levels[i] + "_Final" ); |
| 206 |
– |
// setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat"); |
| 207 |
– |
system((strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat").c_str()); |
| 208 |
– |
create_directory( "packages/VanillaDats/level" + levels[i] + "_Final" ); |
| 209 |
– |
create_directory( "packages/VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" ); |
| 210 |
– |
|
| 211 |
– |
directory_iterator end_iter; |
| 212 |
– |
for ( directory_iterator dir_itr( "../GameDataFolder/level" + levels[i] + "_Final" ); dir_itr != end_iter; ++dir_itr ) |
| 213 |
– |
{ |
| 214 |
– |
//cout << dir_itr->path().filename(); |
| 215 |
– |
if ( is_regular_file( dir_itr->status() ) ) |
| 216 |
– |
{ |
| 217 |
– |
if ( dir_itr->path().filename().substr(0,8) == "TXMPfail" || |
| 218 |
– |
dir_itr->path().filename().substr(0,9) == "TXMPlevel" || |
| 219 |
– |
( dir_itr->path().filename().substr(0,4) == "TXMP" && dir_itr->path().filename().find("intro")!=string::npos) || |
| 220 |
– |
dir_itr->path().filename().substr(0,4) == "TXMB" || |
| 221 |
– |
dir_itr->path().filename() == "M3GMpowerup_lsi.oni" || |
| 222 |
– |
dir_itr->path().filename() == "TXMPlsi_icon.oni" || |
| 223 |
– |
( dir_itr->path().filename().substr(0,4) == "TXMB" && dir_itr->path().filename().find("splash_screen.oni")!=string::npos) ) |
| 224 |
– |
{ |
| 225 |
– |
cout <<dir_itr->path().filename() << "\n"; |
| 226 |
– |
create_directory( dir_itr->path().parent_path() / "NoGlobal"); |
| 227 |
– |
if(!exists( dir_itr->path().parent_path() / "NoGlobal" / dir_itr->filename())) rename(dir_itr->path(), dir_itr->path().parent_path() / "NoGlobal" / |
| 228 |
– |
dir_itr->filename()); |
| 229 |
– |
else remove(dir_itr->path()); |
| 230 |
– |
} |
| 231 |
– |
else if (dir_itr->path().filename().substr(0,4) == "TRAC" |
| 232 |
– |
|| dir_itr->path().filename().substr(0,4) == "ONVL") { |
| 233 |
– |
cout <<dir_itr->path().filename() << "\n"; |
| 234 |
– |
if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename()); |
| 235 |
– |
else remove(dir_itr->path()); |
| 236 |
– |
} |
| 237 |
– |
else if (dir_itr->path().filename().substr(0,4) == "TRAM") { |
| 238 |
– |
cout <<dir_itr->path().filename() << "\n"; |
| 239 |
– |
if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename()); |
| 240 |
– |
else remove(dir_itr->path()); |
| 241 |
– |
} |
| 242 |
– |
else if (dir_itr->path().filename().substr(0,4) == "ONSK" || |
| 243 |
– |
dir_itr->path().filename().substr(0,4) == "TXMP") { |
| 244 |
– |
cout <<dir_itr->path().filename() << "\n";\ |
| 245 |
– |
create_directory( dir_itr->path().parent_path() / "TexFix"); |
| 246 |
– |
if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename()); |
| 247 |
– |
//rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename()); |
| 248 |
– |
} |
| 249 |
– |
else if (dir_itr->path().filename().substr(0,4) == "ONCC" |
| 250 |
– |
|| dir_itr->path().filename().substr(0,4) == "TRBS" |
| 251 |
– |
|| dir_itr->path().filename().substr(0,4) == "ONCV" |
| 252 |
– |
|| dir_itr->path().filename().substr(0,4) == "TRMA" |
| 253 |
– |
|| dir_itr->path().filename().substr(0,4) == "TRSC" |
| 254 |
– |
|| dir_itr->path().filename().substr(0,4) == "TRAS") { |
| 255 |
– |
cout <<dir_itr->path().filename() << "\n"; |
| 256 |
– |
if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename()); |
| 257 |
– |
else remove(dir_itr->path()); |
| 258 |
– |
} |
| 259 |
– |
else if (dir_itr->path().filename().substr(0,4) == "OSBD" |
| 260 |
– |
|| dir_itr->path().filename().substr(0,4) == "SNDD") { |
| 261 |
– |
cout << dir_itr->path().filename() << "\n"; |
| 262 |
– |
if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename()); |
| 263 |
– |
else remove(dir_itr->path()); |
| 264 |
– |
} |
| 265 |
– |
else if (dir_itr->path().filename().substr(0,5) == "BINA3" |
| 266 |
– |
|| dir_itr->path().filename().substr(0,10) == "M3GMdebris" |
| 267 |
– |
|| dir_itr->path().filename() == "M3GMtoxic_bubble.oni" |
| 268 |
– |
|| dir_itr->path().filename().substr(0,8) == "M3GMelec" |
| 269 |
– |
|| dir_itr->path().filename().substr(0,7) == "M3GMrat" |
| 270 |
– |
|| dir_itr->path().filename().substr(0,7) == "M3GMjet" |
| 271 |
– |
|| dir_itr->path().filename().substr(0,9) == "M3GMbomb_" |
| 272 |
– |
|| dir_itr->path().filename() == "M3GMbarab_swave.oni" |
| 273 |
– |
|| dir_itr->path().filename() == "M3GMbloodyfoot.oni" |
| 274 |
– |
){ |
| 275 |
– |
cout <<dir_itr->path().filename() << "\n"; |
| 276 |
– |
if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename()); |
| 277 |
– |
else remove(dir_itr->path()); |
| 278 |
– |
} |
| 279 |
– |
else if (dir_itr->path().filename().substr(0,4) == "AGDB" |
| 280 |
– |
|| dir_itr->path().filename().substr(0,4) == "TRCM") { |
| 281 |
– |
cout <<dir_itr->path().filename() << "\n"; |
| 282 |
– |
|
| 283 |
– |
if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename()); |
| 284 |
– |
else remove(dir_itr->path()); |
| 285 |
– |
} |
| 286 |
– |
else if (dir_itr->path().filename().substr(0,4) == "ONWC") { //fix for buggy ONWC overriding |
| 287 |
– |
cout <<dir_itr->path().filename() << "\n"; |
| 288 |
– |
|
| 289 |
– |
if(!exists( "packages/VanillaDats/level0_Final/level0_Final/" + dir_itr->filename())) rename(dir_itr->path(), "packages/VanillaDats/level0_Final/level0_Final/" + dir_itr->filename()); |
| 290 |
– |
else remove(dir_itr->path()); |
| 291 |
– |
} |
| 292 |
– |
if (exists(dir_itr->path())) { |
| 293 |
– |
|
| 294 |
– |
} |
| 295 |
– |
else { |
| 296 |
– |
logfile << "\tMoved file: " << dir_itr->path().filename() << "\n"; |
| 297 |
– |
} |
| 298 |
– |
} |
| 299 |
– |
|
| 300 |
– |
|
| 301 |
– |
|
| 302 |
– |
} |
| 303 |
– |
logfile << "\tCleaning up TXMPs...\n"; |
| 304 |
– |
system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + levels[i] + "_Final/TXMP*.oni").c_str()); |
| 305 |
– |
parts_done++; |
| 306 |
– |
|
| 307 |
– |
setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); |
| 308 |
– |
|
| 309 |
– |
} |
| 310 |
– |
} |
| 311 |
– |
logfile << "Reimporting levels\n"; |
| 312 |
– |
for (int i = 0; i < 15; i++) |
| 313 |
– |
{ |
| 314 |
– |
logfile << "\tReimporting level" << levels[i] << "_Final.oni\n"; |
| 315 |
– |
//printf(levels[i],"%d",levels[i]); |
| 316 |
– |
//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"); |
| 317 |
– |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni"); |
| 318 |
– |
logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final packages/VanillaDats/level" + levels[i] + "_Final/level" |
| 319 |
– |
+ levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n'; |
| 320 |
– |
string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final packages/VanillaDats/level" + levels[i] + "_Final/level" |
| 321 |
– |
+ levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log"); |
| 322 |
– |
system(sys_str.c_str() ); |
| 323 |
– |
setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); |
| 324 |
– |
parts_done++; |
| 325 |
– |
} |
| 326 |
– |
create_directory( VanillaCharacters.parent_path() ); |
| 327 |
– |
create_directory( VanillaParticles.parent_path() ); |
| 328 |
– |
create_directory( VanillaTextures.parent_path() ); |
| 329 |
– |
create_directory( VanillaSounds.parent_path() ); |
| 330 |
– |
create_directory( VanillaAnimations.remove_filename() ); |
| 331 |
– |
|
| 332 |
– |
for(int j = 0; j < GDFPaths.size(); j++) { |
| 333 |
– |
logfile << "\tReimporting " << GDFPaths[j].filename() << ".oni\n"; |
| 334 |
– |
setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + ": reimporting " + GDFPaths[j].filename() ); |
| 335 |
– |
system((strOniSplit + " " + strImportOption + " " + GDFPaths[j].string() + " " + VanillaPaths[j].string()).c_str()); |
| 336 |
– |
parts_done++; |
| 337 |
– |
setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) )); |
| 338 |
– |
} |
| 339 |
– |
/* |
| 340 |
– |
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) )); |
| 341 |
– |
system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str()); |
| 342 |
– |
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) )); |
| 343 |
– |
system((strOniSplit + " " + strImportOption + " " + Particles.string() + " " + VanillaParticles.string()).c_str()); |
| 344 |
– |
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) )); |
| 345 |
– |
system((strOniSplit + " " + strImportOption + " " + Textures.string() + " " + VanillaTextures.string()).c_str()); |
| 346 |
– |
//system((strOniSplit + " " + strImportOption + (string)" " + Animations.string() + (string)" " + VanillaAnimations.string()).c_str()); |
| 347 |
– |
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) )); |
| 348 |
– |
system((strOniSplit + " " + strImportOption + " " + TRAC.string() + " " + VanillaTRAC.string()).c_str()); |
| 349 |
– |
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) )); |
| 350 |
– |
system((strOniSplit + " " + strImportOption + " " + Sounds.string() + " " + VanillaSounds.string()).c_str()); |
| 351 |
– |
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) )); |
| 352 |
– |
system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str()); |
| 353 |
– |
//parts_done++; setStatusArea((string)"Copying level scripts...");setProgressBar( (int)(1000 * (float)(parts_done) / (float)(7 + 2 * num_levels) )); |
| 354 |
– |
if (exists("../GameDataFolder/IGMD")) remove_all("../GameDataFolder/IGMD"); |
| 355 |
– |
*/ |
| 356 |
– |
create_directory((path)"../GameDataFolder/IGMD"); |
| 357 |
– |
copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder"); |
| 358 |
– |
setProgressBar( 1000 ); |
| 359 |
– |
|
| 360 |
– |
copy("../../persist.dat","../persist.dat"); |
| 361 |
– |
copy("../../key_config.txt","../key_config.txt"); |
| 362 |
– |
|
| 363 |
– |
#ifndef WIN32 |
| 364 |
– |
/* 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). |
| 365 |
– |
Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never |
| 366 |
– |
run Oni before :-p */ |
| 367 |
– |
string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for edition/ |
| 368 |
– |
char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '"; |
| 369 |
– |
strcat(prefsCommand, fullAEpath.c_str()); // get path of edition/ folder (Oni wants the folder that *contains* the GDF) |
| 370 |
– |
strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters |
| 371 |
– |
system(prefsCommand); |
| 372 |
– |
|
| 373 |
– |
#endif |
| 374 |
– |
|
| 375 |
– |
|
| 376 |
– |
setStatusArea((string)"Done! Now select your mod packages and click install."); |
| 377 |
– |
// while(1) Sleep(-1); |
| 378 |
– |
|
| 379 |
– |
} |
| 380 |
– |
catch (exception & ex) { |
| 381 |
– |
setStatusArea("Warning, handled exception: " + (string)ex.what()); |
| 382 |
– |
} |
| 383 |
– |
|
| 384 |
– |
ptime end_time(second_clock::local_time()); |
| 385 |
– |
time_period total_time (start_time, end_time); |
| 386 |
– |
logfile << "\n\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length(); |
| 387 |
– |
//total_time.length().hours(); |
| 388 |
– |
logfile.close(); |
| 389 |
– |
busy = 0; |
| 390 |
– |
return err; |
| 391 |
– |
} |
| 392 |
– |
|
| 393 |
– |
|
| 394 |
– |
vector<ModPackage> getPackages(void) |
| 395 |
– |
{ |
| 396 |
– |
vector<ModPackage> packages; |
| 397 |
– |
packages.reserve(65536); // come on, we shouldn't need this much space...right?! |
| 398 |
– |
fstream file; |
| 399 |
– |
string filename = "\0"; |
| 400 |
– |
string MODINFO_CFG = "Mod_Info.cfg"; |
| 401 |
– |
|
| 402 |
– |
try |
| 403 |
– |
{ |
| 404 |
– |
directory_iterator end_iter; |
| 405 |
– |
for (directory_iterator dir_itr("./packages"); dir_itr != end_iter; ++dir_itr) |
| 406 |
– |
{ |
| 407 |
– |
file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str()); |
| 408 |
– |
//cout << filename << "\n"; |
| 409 |
– |
|
| 410 |
– |
if(!file.fail()) |
| 411 |
– |
{ |
| 412 |
– |
//cout << dir_itr->path().string() + MODINFO_CFG; |
| 413 |
– |
//would prefer to push a pointer to a package, but this will do for now |
| 414 |
– |
packages.push_back(fileToModPackage(file)); |
| 415 |
– |
} |
| 416 |
– |
file.close(); |
| 417 |
– |
file.clear(); |
| 418 |
– |
} |
| 419 |
– |
sort(packages.begin(), packages.end()); |
| 420 |
– |
} |
| 421 |
– |
catch (const std::exception & ex) |
| 422 |
– |
{ |
| 423 |
– |
cout << "Warning, something odd happened!\n"; |
| 424 |
– |
} |
| 425 |
– |
|
| 426 |
– |
return packages; |
| 427 |
– |
} |
| 428 |
– |
|
| 429 |
– |
ModPackage fileToModPackage(fstream &file) |
| 430 |
– |
{ |
| 431 |
– |
/* |
| 432 |
– |
This converts a file to a ModPackage struct. |
| 433 |
– |
|
| 434 |
– |
A few notes... |
| 435 |
– |
"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. |
| 436 |
– |
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 |
| 437 |
– |
slower than reading a variable. |
| 438 |
– |
*/ |
| 439 |
– |
ModPackage package; |
| 440 |
– |
string line; |
| 441 |
– |
static string NameOfMod = "NameOfMod"; //used for comparing to the current token... |
| 442 |
– |
//I could have done it in reverse (*iter).compare("ModString") or |
| 443 |
– |
static string ARROW = "->"; //did something like "ModString".compare(*iter), and it would have been |
| 444 |
– |
static string ModString = "ModString"; //functionably the same. |
| 445 |
– |
static string HasOnis = "HasOnis"; |
| 446 |
– |
static string HasDeltas = "HasDeltas"; |
| 447 |
– |
static string HasBSL = "HasBSL"; |
| 448 |
– |
static string HasDats = "HasDats"; |
| 449 |
– |
static string IsEngine = "IsEngine"; |
| 450 |
– |
static string Readme = "Readme"; |
| 451 |
– |
static string GlobalNeeded = "GlobalNeeded"; |
| 452 |
– |
static string Category = "Category"; |
| 453 |
– |
static string Creator = "Creator"; |
| 454 |
– |
while (! file.eof() ) |
| 455 |
– |
{ |
| 456 |
– |
getline (file,line); |
| 457 |
– |
vector<string> tokens; |
| 458 |
– |
vector<string>::iterator iter; |
| 459 |
– |
tokenize(line, tokens); //string to vector of "words" |
| 460 |
– |
if (tokens.capacity() >= 2) { //make sure they are using enough stuff |
| 461 |
– |
iter = tokens.begin(); //what word we are on, starts at first word |
| 462 |
– |
/* |
| 463 |
– |
if (!AEInstallVersion.compare(*iter)) |
| 464 |
– |
If mod is too old, skip this mod. |
| 465 |
– |
*/ |
| 466 |
– |
/*else*/if (!NameOfMod.compare(*iter)) { //if it contains the name |
| 467 |
– |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment |
| 468 |
– |
if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) { //ignores "->" and "NameOfMod" |
| 469 |
– |
//cout << *iter; |
| 470 |
– |
//cout << " "; |
| 471 |
– |
package.name += *iter + " "; |
| 472 |
– |
} |
| 473 |
– |
} |
| 474 |
– |
|
| 475 |
– |
} |
| 476 |
– |
else if (!ModString.compare(*iter)) { |
| 477 |
– |
iter++; iter++; |
| 478 |
– |
package.modStringName = *iter; |
| 479 |
– |
iter++; |
| 480 |
– |
package.modStringVersion = atoi((*iter).c_str()); |
| 481 |
– |
} |
| 482 |
– |
else if (!HasOnis.compare(*iter)) { |
| 483 |
– |
iter++; iter++; |
| 484 |
– |
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 |
| 485 |
– |
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, |
| 486 |
– |
iter++; iter++;} // using "YFR" would probably set it off. :< |
| 487 |
– |
|
| 488 |
– |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasBSL = 1; |
| 489 |
– |
} |
| 490 |
– |
else if (!HasDeltas.compare(*iter)) { |
| 491 |
– |
iter++; iter++; |
| 492 |
– |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1; |
| 493 |
– |
} |
| 494 |
– |
else if (!HasDats.compare(*iter)) { |
| 495 |
– |
iter++; iter++; |
| 496 |
– |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1; |
| 497 |
– |
} |
| 498 |
– |
else if (!IsEngine.compare(*iter)) { |
| 499 |
– |
iter++; iter++; |
| 500 |
– |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1; |
| 501 |
– |
} |
| 502 |
– |
else if (!GlobalNeeded.compare(*iter)) { |
| 503 |
– |
iter++; iter++; |
| 504 |
– |
if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1; |
| 505 |
– |
else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; //Really the only place where checking for "No" is important atm. |
| 506 |
– |
} |
| 507 |
– |
else if (!Category.compare(*iter)) { |
| 508 |
– |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment |
| 509 |
– |
if (ARROW.compare(*iter) && Category.compare(*iter)) { //ignores "->" and "Category" |
| 510 |
– |
//cout << *iter; |
| 511 |
– |
//cout << " "; |
| 512 |
– |
package.category += *iter + " "; |
| 513 |
– |
} |
| 514 |
– |
} |
| 515 |
– |
} |
| 516 |
– |
else if (!Creator.compare(*iter)) { //if it contains the name |
| 517 |
– |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment |
| 518 |
– |
if (ARROW.compare(*iter) && Creator.compare(*iter)) { //ignores "->" and "Category" |
| 519 |
– |
//cout << *iter; |
| 520 |
– |
//cout << " "; |
| 521 |
– |
package.creator += *iter + " "; |
| 522 |
– |
} |
| 523 |
– |
} |
| 524 |
– |
} |
| 525 |
– |
else if (!Readme.compare(*iter)) { //if it contains the name |
| 526 |
– |
for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) { //interates through the words, ends if it reaches the end of the line or a "//" comment |
| 527 |
– |
if (ARROW.compare(*iter) && Readme.compare(*iter)) { //ignores "->" and "Category" |
| 528 |
– |
if(!(*iter).compare("\\n")) package.readme += '\n'; |
| 529 |
– |
else package.readme += *iter + " "; |
| 530 |
– |
} |
| 531 |
– |
} |
| 532 |
– |
} |
| 533 |
– |
} |
| 534 |
– |
|
| 535 |
– |
} |
| 536 |
– |
package.doOutput(); |
| 537 |
– |
return package; |
| 538 |
– |
} |
| 539 |
– |
|
| 540 |
– |
void recompileAll(vector<string> installedMods) |
| 541 |
– |
{ |
| 542 |
– |
busy = 1; |
| 543 |
– |
using namespace boost::gregorian; |
| 544 |
– |
using namespace boost::posix_time; |
| 545 |
– |
using boost::lexical_cast; |
| 546 |
– |
using boost::bad_lexical_cast; |
| 547 |
– |
|
| 548 |
– |
setStatusArea("Importing levels..."); |
| 549 |
– |
//setStatusArea("Recompiling Data..."); |
| 550 |
– |
path vanilla_dir = "./packages/VanillaDats/"; |
| 551 |
– |
string importCommand = ""; |
| 552 |
– |
char statusString[128]; |
| 553 |
– |
int numberOfDats = 0; |
| 554 |
– |
int j = 1; |
| 555 |
– |
string datString; |
| 556 |
– |
std::stringstream out; |
| 557 |
– |
|
| 558 |
– |
ptime start_time(second_clock::local_time()); |
| 559 |
– |
clearOldDats(); |
| 560 |
– |
remove("Install.log"); |
| 561 |
– |
ofstream logfile("Install.log"); |
| 562 |
– |
logfile << "Mod Installation started " << to_simple_string(start_time) << endl; |
| 563 |
– |
logfile.close(); |
| 564 |
– |
if(splitInstances == SPLIT){ |
| 565 |
– |
recursive_directory_iterator end_iter; |
| 566 |
– |
|
| 567 |
– |
for ( recursive_directory_iterator dir_itr( vanilla_dir ); |
| 568 |
– |
dir_itr != end_iter; |
| 569 |
– |
++dir_itr ) |
| 570 |
– |
{ |
| 571 |
– |
try{ |
| 572 |
– |
if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1) |
| 573 |
– |
{ |
| 574 |
– |
numberOfDats++; |
| 575 |
– |
} |
| 576 |
– |
} |
| 577 |
– |
catch(exception ex) { |
| 578 |
– |
|
| 579 |
– |
} |
| 580 |
– |
} |
| 581 |
– |
|
| 582 |
– |
//recursive_directory_iterator end_iter; |
| 583 |
– |
|
| 584 |
– |
|
| 585 |
– |
out << numberOfDats; |
| 586 |
– |
datString = out.str(); |
| 587 |
– |
try { |
| 588 |
– |
for ( recursive_directory_iterator dir_itr( vanilla_dir ); |
| 589 |
– |
dir_itr != end_iter; |
| 590 |
– |
++dir_itr ) |
| 591 |
– |
{ |
| 592 |
– |
try |
| 593 |
– |
{ |
| 594 |
– |
if ( is_directory( dir_itr->status() ) && dir_itr.level() == 1) |
| 595 |
– |
{ |
| 596 |
– |
importCommand = strOniSplit + " " + strImportOption + " " + dir_itr->path().parent_path().string() + '/' + dir_itr->path().filename(); |
| 597 |
– |
for (int i = 0; i < installedMods.size(); ++i) { |
| 598 |
– |
if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename() )) |
| 599 |
– |
importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename(); |
| 600 |
– |
|
| 601 |
– |
//else cout << " packages/VanillaDats/" + installedMods[i] + "/oni/"; |
| 602 |
– |
} |
| 603 |
– |
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
| 604 |
– |
|
| 605 |
– |
|
| 606 |
– |
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 607 |
– |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 608 |
– |
|
| 609 |
– |
system(importCommand.c_str()); |
| 610 |
– |
//Sleep(1000); |
| 611 |
– |
//cout << importCommand << "\n"; |
| 612 |
– |
j++; |
| 613 |
– |
|
| 614 |
– |
} |
| 615 |
– |
} |
| 616 |
– |
catch ( const std::exception & ex ) |
| 617 |
– |
{ |
| 618 |
– |
|
| 619 |
– |
remove("Install.log"); |
| 620 |
– |
ofstream logfile("Install.log"); |
| 621 |
– |
|
| 622 |
– |
|
| 623 |
– |
logfile << "Warning, exception " << ex.what() << "!"; |
| 624 |
– |
setStatusArea("Warning, exception " + (string)ex.what() + "!"); |
| 625 |
– |
logfile.close(); |
| 626 |
– |
} |
| 627 |
– |
} |
| 628 |
– |
|
| 629 |
– |
} |
| 630 |
– |
catch( const std::exception & ex ) { |
| 631 |
– |
|
| 632 |
– |
remove("Install.log"); |
| 633 |
– |
ofstream logfile("Install.log"); |
| 634 |
– |
|
| 635 |
– |
|
| 636 |
– |
logfile << "Warning, exception " << ex.what() << "!"; |
| 637 |
– |
setStatusArea("Warning, exception " + (string)ex.what() + "!"); |
| 638 |
– |
logfile.close(); |
| 639 |
– |
} |
| 640 |
– |
|
| 641 |
– |
} |
| 642 |
– |
else if(splitInstances == NOT_SPLIT){ |
| 643 |
– |
directory_iterator end_iter; |
| 644 |
– |
|
| 645 |
– |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 646 |
– |
dir_itr != end_iter; |
| 647 |
– |
++dir_itr ) |
| 648 |
– |
{ |
| 649 |
– |
|
| 650 |
– |
if ( is_directory( dir_itr->status() ) ) |
| 651 |
– |
{ |
| 652 |
– |
numberOfDats++; |
| 653 |
– |
} |
| 654 |
– |
|
| 655 |
– |
|
| 656 |
– |
} |
| 657 |
– |
|
| 658 |
– |
out << numberOfDats; |
| 659 |
– |
datString = out.str(); |
| 660 |
– |
|
| 661 |
– |
for ( directory_iterator dir_itr( vanilla_dir ); |
| 662 |
– |
dir_itr != end_iter; |
| 663 |
– |
++dir_itr ) |
| 664 |
– |
{ |
| 665 |
– |
try |
| 666 |
– |
{ |
| 667 |
– |
if ( is_directory( dir_itr->status() ) ) |
| 668 |
– |
{ |
| 669 |
– |
importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " "; |
| 670 |
– |
for (int i = 0; i < installedMods.size(); ++i) { |
| 671 |
– |
if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename() )) |
| 672 |
– |
importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename(); |
| 673 |
– |
} |
| 674 |
– |
importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log"; |
| 675 |
– |
|
| 676 |
– |
|
| 677 |
– |
setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats |
| 678 |
– |
setStatusArea("Step " + lexical_cast<std::string>(j) + '/' + lexical_cast<std::string>(numberOfDats)+ ": Importing " + dir_itr->path().filename() + " "); |
| 679 |
– |
|
| 680 |
– |
system(importCommand.c_str()); |
| 681 |
– |
|
| 682 |
– |
j++; |
| 683 |
– |
} |
| 684 |
– |
} |
| 685 |
– |
catch ( const std::exception & ex ) |
| 686 |
– |
{ |
| 687 |
– |
|
| 688 |
– |
remove("Install.log"); |
| 689 |
– |
ofstream logfile("Install.log"); |
| 690 |
– |
|
| 691 |
– |
|
| 692 |
– |
logfile << "Warning, exception " << ex.what() << "!"; |
| 693 |
– |
setStatusArea("Warning, exception " + (string)ex.what() + "!"); |
| 694 |
– |
logfile.close(); |
| 695 |
– |
}} |
| 696 |
– |
} |
| 697 |
– |
logfile << "Writing config file"; |
| 698 |
– |
writeInstalledMods(installedMods); |
| 699 |
– |
setProgressBar(1000); |
| 700 |
– |
setStatusArea("Done! You can now play Oni."); |
| 701 |
– |
|
| 702 |
– |
ptime end_time(second_clock::local_time()); |
| 703 |
– |
time_period total_time (start_time, end_time); |
| 704 |
– |
|
| 705 |
– |
|
| 706 |
– |
ofstream logfile2("Install.log", ios::app | ios::ate); |
| 707 |
– |
string outstring = (string)"\n\nGlobalization ended " + to_simple_string(end_time) + "\nThe process took ";// + (string)total_time.length(); |
| 708 |
– |
|
| 709 |
– |
logfile2 << "\nGlobalization ended " << to_simple_string(end_time) << "\nThe process took " << total_time.length(); |
| 710 |
– |
|
| 711 |
– |
//logfile2.write(outstring.c_str(), outstring.length()); |
| 712 |
– |
logfile2.close(); |
| 713 |
– |
|
| 714 |
– |
//total_time.length().hours(); |
| 715 |
– |
|
| 716 |
– |
Sleep(1000); |
| 717 |
– |
setProgressBar(0); |
| 718 |
– |
busy = 0; |
| 719 |
– |
} |
| 720 |
– |
|
| 721 |
– |
void writeInstalledMods(vector<string> installedMods) |
| 722 |
– |
{ |
| 723 |
– |
|
| 724 |
– |
if ( exists( strInstallCfg ) ) |
| 725 |
– |
{ |
| 726 |
– |
remove( strInstallCfg ); |
| 727 |
– |
} |
| 728 |
– |
|
| 729 |
– |
ofstream file(strInstallCfg.c_str()); |
| 730 |
– |
|
| 731 |
– |
vector<string>list = installedMods; |
| 732 |
– |
vector<string>::iterator begin_iter = list.begin(); |
| 733 |
– |
vector<string>::iterator end_iter = list.end(); |
| 734 |
– |
|
| 735 |
– |
sort( list.begin(), list.end() ); |
| 736 |
– |
|
| 737 |
– |
for( ; begin_iter != end_iter; ++begin_iter) { |
| 738 |
– |
file << *begin_iter << " "; |
| 739 |
– |
} |
| 740 |
– |
|
| 741 |
– |
file.close(); |
| 742 |
– |
file.clear(); |
| 743 |
– |
|
| 744 |
– |
} |
| 745 |
– |
|
| 746 |
– |
vector<string> getInstallString(string Cfg) |
| 747 |
– |
{ |
| 748 |
– |
//system(strPauseCmd); |
| 749 |
– |
vector<string> returnval; |
| 750 |
– |
|
| 751 |
– |
string line; |
| 752 |
– |
fstream file; |
| 753 |
– |
|
| 754 |
– |
if (exists( Cfg )) |
| 755 |
– |
{ |
| 756 |
– |
file.open(Cfg.c_str()); |
| 757 |
– |
getline(file, line); |
| 758 |
– |
tokenize(line, returnval); |
| 759 |
– |
file.close(); |
| 760 |
– |
file.clear(); |
| 761 |
– |
sort(returnval.begin(), returnval.end()); |
| 762 |
– |
} |
| 763 |
– |
else cout << "fail"; |
| 764 |
– |
|
| 765 |
– |
return returnval; |
| 766 |
– |
} |
| 767 |
– |
|
| 768 |
– |
//stolen token function... |
| 769 |
– |
void tokenize(const string& str, vector<string>& tokens, const string& delimiters) |
| 770 |
– |
{ |
| 771 |
– |
// Skip delimiters at beginning. |
| 772 |
– |
string::size_type lastPos = str.find_first_not_of(delimiters, 0); |
| 773 |
– |
// Find first "non-delimiter". |
| 774 |
– |
string::size_type pos = str.find_first_of(delimiters, lastPos); |
| 775 |
– |
|
| 776 |
– |
while (string::npos != pos || string::npos != lastPos) |
| 777 |
– |
{ |
| 778 |
– |
// Found a token, add it to the vector. |
| 779 |
– |
tokens.push_back(str.substr(lastPos, pos - lastPos)); |
| 780 |
– |
// Skip delimiters. Note the "not_of" |
| 781 |
– |
lastPos = str.find_first_not_of(delimiters, pos); |
| 782 |
– |
// Find next "non-delimiter" |
| 783 |
– |
pos = str.find_first_of(delimiters, lastPos); |
| 784 |
– |
} |
| 785 |
– |
} |
| 786 |
– |
|
| 787 |
– |
void clearOldDats(void) { |
| 788 |
– |
directory_iterator end_iter_gdf; |
| 789 |
– |
for ( directory_iterator dir_itr_gdf( "../GameDataFolder" ); |
| 790 |
– |
dir_itr_gdf != end_iter_gdf; |
| 791 |
– |
++dir_itr_gdf ) |
| 792 |
– |
{ |
| 793 |
– |
//cout << dir_itr_gdf->path().extension() << "\n"; |
| 794 |
– |
if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) { |
| 795 |
– |
remove( dir_itr_gdf->path() ); |
| 796 |
– |
} |
| 797 |
– |
|
| 798 |
– |
} |
| 799 |
– |
|
| 800 |
– |
} |
| 801 |
– |
|
| 802 |
– |
vector<string> globalInstalledMods; |
| 803 |
– |
vector<ModPackage> globalPackages; |
| 804 |
– |
#include "boost/thread.hpp" |
| 20 |
|
#include <boost/thread/mutex.hpp> |
| 806 |
– |
|
| 807 |
– |
///////////////////////////////////////////////////////////////////////////// |
| 808 |
– |
// Name: main_window.cpp |
| 809 |
– |
// Purpose: |
| 810 |
– |
// Author: |
| 811 |
– |
// Modified by: |
| 812 |
– |
// Created: 07/05/2009 20:38:25 |
| 813 |
– |
// RCS-ID: |
| 814 |
– |
// Copyright: |
| 815 |
– |
// Licence: |
| 816 |
– |
///////////////////////////////////////////////////////////////////////////// |
| 817 |
– |
|
| 21 |
|
// For compilers that support precompilation, includes "wx/wx.h". |
| 22 |
|
#include "wx/wxprec.h" |
| 23 |
|
|
| 31 |
|
|
| 32 |
|
////@begin includes |
| 33 |
|
#include "about.h" |
| 831 |
– |
////@end includes |
| 832 |
– |
|
| 34 |
|
#include "main_window.h" |
| 35 |
+ |
#include "installer.h" |
| 36 |
+ |
////@end includes |
| 37 |
|
|
| 38 |
|
////@begin XPM images |
| 39 |
|
#include "aelogosmall.xpm" |
| 43 |
|
#include "quit.xpm" |
| 44 |
|
////@end XPM images |
| 45 |
|
|
| 46 |
< |
//#define wxDebug 1; |
| 47 |
< |
//#define wxUSE_UNICODE 1; |
| 46 |
> |
bool busy = false; |
| 47 |
> |
int updateStatus; |
| 48 |
> |
bool installerJustUpdated = false; |
| 49 |
> |
vector<string> globalInstalledMods; |
| 50 |
> |
vector<ModPackage> globalPackages; |
| 51 |
> |
// Variable declarations |
| 52 |
> |
#ifdef WIN32 |
| 53 |
> |
bool splitInstances = true; |
| 54 |
> |
string strImportOption = "-import:nosep"; |
| 55 |
> |
string strOniSplit = "Onisplit.exe"; |
| 56 |
> |
#else |
| 57 |
> |
bool splitInstances = false; |
| 58 |
> |
string strImportOption = "-import:sep"; |
| 59 |
> |
string strOniSplit = "mono Onisplit.exe"; |
| 60 |
> |
#endif |
| 61 |
|
|
| 62 |
|
/* |
| 63 |
|
* MainWindow type definition |
| 104 |
|
|
| 105 |
|
EVT_MENU( wxID_ABOUT, MainWindow::OnAboutClick ) |
| 106 |
|
|
| 107 |
+ |
EVT_BUTTON( Dir_Button, MainWindow::OnDirButtonClick ) |
| 108 |
|
////@end MainWindow event table entries |
| 109 |
|
|
| 110 |
|
END_EVENT_TABLE() |
| 115 |
|
*/ |
| 116 |
|
|
| 117 |
|
MainWindow::MainWindow() |
| 118 |
< |
{ |
| 118 |
> |
{ |
| 119 |
|
Init(); |
| 120 |
|
} |
| 121 |
|
|
| 142 |
|
return true; |
| 143 |
|
} |
| 144 |
|
|
| 928 |
– |
|
| 145 |
|
/* |
| 146 |
|
* MainWindow destructor |
| 147 |
|
*/ |
| 152 |
|
////@end MainWindow destruction |
| 153 |
|
} |
| 154 |
|
|
| 939 |
– |
|
| 155 |
|
/* |
| 156 |
|
* Member initialisation |
| 157 |
|
*/ |
| 175 |
|
SeperatedRadio = NULL; |
| 176 |
|
CompleteRadio = NULL; |
| 177 |
|
ReglobalizeButton = NULL; |
| 963 |
– |
////@end MainWindow member initialisation |
| 178 |
|
|
| 179 |
+ |
ChangeDirectoryButton = NULL; |
| 180 |
+ |
////@end MainWindow member initialisation |
| 181 |
|
} |
| 182 |
|
|
| 967 |
– |
|
| 183 |
|
/* |
| 184 |
|
* Control creation for MainWindow |
| 185 |
|
*/ |
| 216 |
|
wxMenu* itemMenu42 = new wxMenu; |
| 217 |
|
itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK); |
| 218 |
|
menuBar->Append(itemMenu42, _("Options")); |
| 219 |
< |
wxMenu* itemMenu44 = new wxMenu; |
| 220 |
< |
#ifdef WIN32 |
| 221 |
< |
itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL); |
| 222 |
< |
menuBar->Append(itemMenu44, _("Help")); |
| 1008 |
< |
#else |
| 219 |
> |
//#ifdef WIN32 |
| 220 |
> |
// itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL); |
| 221 |
> |
// menuBar->Append(itemMenu44, _("Help")); |
| 222 |
> |
//#else |
| 223 |
|
itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL); |
| 224 |
< |
#endif |
| 224 |
> |
//#endif |
| 225 |
|
|
| 226 |
|
itemFrame1->SetMenuBar(menuBar); |
| 227 |
|
|
| 288 |
|
StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 ); |
| 289 |
|
StatusArea->SetName(_T("StatusArea")); |
| 290 |
|
StatusArea->SetFieldsCount(1); |
| 291 |
< |
StatusArea->SetStatusText(_("AE Installer v1.0"), 0); |
| 291 |
> |
string versionText = "AE Installer v" + (string)INSTALLER_VERSION; |
| 292 |
> |
StatusArea->SetStatusText(versionText.c_str(), 0); |
| 293 |
|
itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0); |
| 294 |
|
|
| 295 |
|
wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL); |
| 352 |
|
ReglobalizeButton->SetName(_T("Reglobalize_Button")); |
| 353 |
|
itemBoxSizer34->Add(ReglobalizeButton, 0, wxGROW|wxALL, 5); |
| 354 |
|
|
| 355 |
< |
// Connect events and objects |
| 355 |
> |
wxStaticLine* itemStaticLine100 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL ); |
| 356 |
> |
itemBoxSizer25->Add(itemStaticLine100, 0, wxGROW|wxALL, 5); |
| 357 |
> |
|
| 358 |
> |
ChangeDirectoryButton = new wxButton( OptionsPanel, Dir_Button, _("Change Dir"), wxDefaultPosition, wxDefaultSize, 0 ); |
| 359 |
> |
ChangeDirectoryButton->SetName(_T("Dir_Button")); |
| 360 |
> |
itemBoxSizer34->Add(ChangeDirectoryButton, 0, wxGROW|wxALL, 5); |
| 361 |
> |
|
| 362 |
> |
// Connect events and objects |
| 363 |
|
Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this); |
| 364 |
|
////@end MainWindow content construction |
| 365 |
< |
|
| 365 |
> |
#ifdef WIN32 |
| 366 |
|
Handle = (HWND)GetHWND(); |
| 367 |
|
::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList); |
| 368 |
+ |
#endif |
| 369 |
|
|
| 370 |
< |
|
| 1148 |
< |
if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) { |
| 1149 |
< |
strImportOption = "-import:sep"; |
| 1150 |
< |
splitInstances = NOT_SPLIT; |
| 1151 |
< |
} |
| 1152 |
< |
else { |
| 1153 |
< |
strImportOption = "-import:nosep"; |
| 1154 |
< |
splitInstances = SPLIT; |
| 1155 |
< |
} |
| 370 |
> |
updateStatus = GetUpdateStatus(¤tAE, &updateAE, &installerJustUpdated); |
| 371 |
|
|
| 372 |
|
globalPackages = getPackages(); |
| 373 |
|
globalInstalledMods = getInstallString(); |
| 374 |
< |
for (int i = 0; i < globalPackages.size(); i++) { |
| 374 |
> |
for (unsigned int i = 0; i < globalPackages.size(); i++) |
| 375 |
> |
{ |
| 376 |
|
Mods_CheckboxList->Append(globalPackages[i].name.c_str()); |
| 377 |
< |
if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i); |
| 377 |
> |
if (binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName)) Mods_CheckboxList->Check(i); |
| 378 |
|
} |
| 379 |
|
|
| 380 |
|
TheStatusBar = &StatusArea; |
| 382 |
|
TheProgressBar = ProgressBar; |
| 383 |
|
OptionsPanel->Hide(); |
| 384 |
|
|
| 385 |
< |
//#ifndef WIN32 |
| 1170 |
< |
// itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL); |
| 1171 |
< |
|
| 1172 |
< |
//#endif |
| 1173 |
< |
|
| 1174 |
< |
if(splitInstances == SPLIT) SeperatedRadio->SetValue(true); |
| 385 |
> |
if(splitInstances) SeperatedRadio->SetValue(true); |
| 386 |
|
else CompleteRadio->SetValue(true); |
| 387 |
|
if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true); |
| 388 |
|
else SepRadio->SetValue(true); |
| 389 |
|
|
| 1179 |
– |
|
| 390 |
|
#ifdef WIN32 |
| 391 |
|
RedirectIOToConsole(); |
| 392 |
|
HWND hWnd = GetConsoleWindow(); |
| 393 |
|
ShowWindow( hWnd, SW_HIDE ); |
| 394 |
|
#endif |
| 1185 |
– |
|
| 1186 |
– |
//MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() ); |
| 395 |
|
} |
| 396 |
|
|
| 1189 |
– |
|
| 397 |
|
/* |
| 398 |
|
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox |
| 399 |
|
*/ |
| 402 |
|
{ |
| 403 |
|
switch(SelectAll->Get3StateValue()) { |
| 404 |
|
case wxCHK_UNCHECKED: |
| 405 |
< |
for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); |
| 1199 |
< |
//SelectAll->Set3StateValue(wxCHK_CHECKED); |
| 405 |
> |
for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); |
| 406 |
|
break; |
| 407 |
|
case wxCHK_CHECKED: |
| 408 |
< |
for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true); |
| 1203 |
< |
//SelectAll->Set3StateValue(wxCHK_UNCHECKED); |
| 408 |
> |
for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true); |
| 409 |
|
break; |
| 410 |
|
case wxCHK_UNDETERMINED: |
| 411 |
< |
for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); |
| 1207 |
< |
//SelectAll->Set3StateValue(wxCHK_CHECKED); |
| 411 |
> |
for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false); |
| 412 |
|
break; |
| 1209 |
– |
|
| 413 |
|
} |
| 1211 |
– |
|
| 414 |
|
} |
| 415 |
|
|
| 1214 |
– |
|
| 416 |
|
/* |
| 417 |
|
* wxEVT_CREATE event handler for Mods_CheckboxList |
| 418 |
|
*/ |
| 420 |
|
void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event ) |
| 421 |
|
{ |
| 422 |
|
|
| 1222 |
– |
|
| 423 |
|
} |
| 424 |
|
|
| 425 |
|
|
| 471 |
|
|
| 472 |
|
wxIcon MainWindow::GetIconResource( const wxString& name ) |
| 473 |
|
{ |
| 1274 |
– |
|
| 474 |
|
// Icon retrieval |
| 475 |
|
////@begin MainWindow icon retrieval |
| 476 |
|
wxUnusedVar(name); |
| 483 |
|
////@end MainWindow icon retrieval |
| 484 |
|
} |
| 485 |
|
|
| 1287 |
– |
|
| 486 |
|
/* |
| 487 |
|
* wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1 |
| 488 |
|
*/ |
| 489 |
|
|
| 490 |
|
void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event ) |
| 491 |
|
{ |
| 1294 |
– |
//event.GetSelection |
| 492 |
|
titleText->SetValue(globalPackages[event.GetSelection()].name.c_str()); |
| 493 |
|
creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str()); |
| 494 |
|
descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str()); |
| 1298 |
– |
|
| 1299 |
– |
//creatorText->Refresh(); |
| 495 |
|
} |
| 496 |
|
|
| 1302 |
– |
|
| 497 |
|
/* |
| 498 |
|
* wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1 |
| 499 |
|
*/ |
| 527 |
|
|
| 528 |
|
this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());} |
| 529 |
|
else { |
| 530 |
< |
// Uncomment this when we release, it gets annoying if you are testing globalization a lot ;) |
| 1337 |
< |
wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: These options are for advanced users only, use with caution.", |
| 530 |
> |
wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: These options are for advanced users only, use with caution.", |
| 531 |
|
"AE Installer Alert", wxOK | wxICON_EXCLAMATION , wxDefaultPosition); |
| 532 |
|
YesNoDialog->ShowModal(); |
| 533 |
|
OptionsPanel->Show(); |
| 536 |
|
} |
| 537 |
|
} |
| 538 |
|
|
| 1346 |
– |
|
| 539 |
|
/* |
| 540 |
|
* wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT |
| 541 |
|
*/ |
| 545 |
|
exit(0); |
| 546 |
|
} |
| 547 |
|
|
| 1356 |
– |
|
| 548 |
|
/* |
| 549 |
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button |
| 550 |
|
*/ |
| 551 |
|
|
| 1361 |
– |
|
| 552 |
|
struct recompile |
| 553 |
|
{ |
| 554 |
|
recompile(vector<string> localPackages) : thePackages(localPackages) { } |
| 557 |
|
TheInstallButton->Disable(); |
| 558 |
|
recompileAll(thePackages); |
| 559 |
|
TheInstallButton->Enable(); |
| 560 |
+ |
|
| 561 |
|
} |
| 1371 |
– |
|
| 562 |
|
vector<string> thePackages; |
| 563 |
|
}; |
| 564 |
|
|
| 565 |
+ |
void globalize2(void) { |
| 566 |
+ |
TheInstallButton->Disable(); |
| 567 |
+ |
globalizeData(); |
| 568 |
+ |
TheInstallButton->Enable(); |
| 569 |
+ |
} |
| 570 |
+ |
|
| 571 |
|
void MainWindow::OnInstallButtonClick( wxCommandEvent& event ) |
| 572 |
|
{ |
| 1377 |
– |
|
| 573 |
|
vector<string> localPackages; |
| 574 |
< |
localPackages.push_back("Globalize"); |
| 575 |
< |
for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName ); |
| 574 |
> |
localPackages.push_back("00000Globalize"); |
| 575 |
> |
for(unsigned int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName ); |
| 576 |
|
if ( !localPackages.empty() ) { |
| 577 |
< |
|
| 578 |
< |
//MainWindow::MainWindow().Hide(); |
| 1384 |
< |
// boost::thread thrd2(recompileAll(localPackages) ); |
| 1385 |
< |
//MainWindow::MainWindow().Show(); |
| 577 |
> |
sort(localPackages.begin(), localPackages.end()); |
| 578 |
> |
localPackages[0] = "Globalize"; |
| 579 |
|
this->InstallButton->Disable(); |
| 580 |
|
this->ReglobalizeButton->Disable(); |
| 581 |
|
#ifdef WIN32 |
| 584 |
|
#else |
| 585 |
|
recompileAll(localPackages); |
| 586 |
|
#endif |
| 1394 |
– |
|
| 587 |
|
this->InstallButton->Enable(); |
| 588 |
|
this->ReglobalizeButton->Enable(); |
| 589 |
|
} |
| 1398 |
– |
|
| 1399 |
– |
|
| 590 |
|
} |
| 591 |
|
|
| 592 |
< |
/*void setStatusArea( string s ) { |
| 593 |
< |
//TheStatusBar = MainWindow::StatusArea; |
| 1404 |
< |
(**TheStatusBar).SetStatusText(_(s.c_str()), 0); |
| 1405 |
< |
|
| 1406 |
< |
//MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1); |
| 1407 |
< |
|
| 1408 |
< |
//MainWindow::StatusBar->SetLabel("Importing Files..."); |
| 1409 |
< |
//StatusBar->SetLabel(s); |
| 1410 |
< |
//->SetLabel(s); |
| 1411 |
< |
|
| 1412 |
< |
}*/ |
| 1413 |
< |
|
| 1414 |
< |
void setProgressBar( int i ) { |
| 1415 |
< |
//TheProgressBar->SetValue( |
| 592 |
> |
void setProgressBar( int i ) |
| 593 |
> |
{ |
| 594 |
|
#ifdef WIN32 |
| 1417 |
– |
|
| 1418 |
– |
|
| 1419 |
– |
|
| 595 |
|
if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3))) |
| 596 |
|
{ |
| 1422 |
– |
|
| 597 |
|
pTaskbarList3->SetProgressValue(Handle,i, 1000); |
| 598 |
< |
if ( i == 0 ) { |
| 599 |
< |
|
| 600 |
< |
pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS); |
| 598 |
> |
if ( i == 0 ) |
| 599 |
> |
{ |
| 600 |
> |
pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS); |
| 601 |
|
} |
| 602 |
|
} |
| 1429 |
– |
|
| 1430 |
– |
|
| 603 |
|
#endif |
| 604 |
|
TheProgressBar->SetValue(i); |
| 1433 |
– |
|
| 605 |
|
} |
| 606 |
|
|
| 1436 |
– |
|
| 607 |
|
/* |
| 608 |
|
* wxEVT_UPDATE_UI event handler for ID_STATUSBAR |
| 609 |
|
*/ |
| 616 |
|
////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow. |
| 617 |
|
} |
| 618 |
|
|
| 1449 |
– |
|
| 619 |
|
/* |
| 620 |
|
* wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT |
| 621 |
|
*/ |
| 624 |
|
{ |
| 625 |
|
////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow. |
| 626 |
|
// Before editing this code, remove the block markers. |
| 627 |
+ |
// TODO: Make About window work again! |
| 628 |
|
About* window = new About(this); |
| 629 |
< |
int returnValue = window->ShowModal(); |
| 629 |
> |
window->ShowModal(); |
| 630 |
|
window->Destroy(); |
| 631 |
|
////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow. |
| 632 |
|
} |
| 633 |
|
|
| 1464 |
– |
|
| 634 |
|
/* |
| 635 |
|
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton |
| 636 |
|
*/ |
| 637 |
< |
|
| 637 |
> |
|
| 638 |
|
void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event ) |
| 639 |
|
{ |
| 640 |
|
static_cast<string>("-import:nosep"); |
| 641 |
|
} |
| 642 |
|
|
| 1474 |
– |
|
| 643 |
|
/* |
| 644 |
|
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton |
| 645 |
|
*/ |
| 649 |
|
static_cast<string>("-import:sep"); |
| 650 |
|
} |
| 651 |
|
|
| 1484 |
– |
|
| 652 |
|
/* |
| 653 |
|
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton |
| 654 |
|
*/ |
| 659 |
|
|
| 660 |
|
void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event ) |
| 661 |
|
{ |
| 662 |
< |
splitInstances = NOT_SPLIT; |
| 1496 |
< |
|
| 662 |
> |
splitInstances = false; |
| 663 |
|
} |
| 664 |
|
|
| 1499 |
– |
|
| 665 |
|
/* |
| 666 |
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON |
| 667 |
|
*/ |
| 668 |
|
|
| 669 |
|
void MainWindow::OnRefreshButtonClick( wxCommandEvent& event ) |
| 670 |
|
{ |
| 671 |
+ |
globalPackages = getPackages(); |
| 672 |
|
refreshMods(globalInstalledMods); |
| 673 |
|
} |
| 674 |
|
|
| 1509 |
– |
|
| 675 |
|
/* |
| 676 |
|
* wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD |
| 677 |
|
*/ |
| 678 |
|
|
| 679 |
< |
|
| 680 |
< |
|
| 681 |
< |
|
| 1517 |
< |
void MainWindow::refreshMods (vector<string> s) { |
| 1518 |
< |
|
| 679 |
> |
// TODO: Make refreshMods actually refresh the list in the window of available mods so we can see any new package info and deleted mods are removed from the list |
| 680 |
> |
void MainWindow::refreshMods (vector<string> s) |
| 681 |
> |
{ |
| 682 |
|
Mods_CheckboxList->Clear(); |
| 683 |
< |
//globalInstalledMods = getPackages(); |
| 1521 |
< |
for (int i = 0; i < globalPackages.size(); i++) { |
| 683 |
> |
for (unsigned int i = 0; i < globalPackages.size(); i++) { |
| 684 |
|
Mods_CheckboxList->Append(globalPackages[i].name.c_str()); |
| 685 |
< |
if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i); |
| 686 |
< |
//else Mods_CheckboxList->Check(i,0); |
| 1525 |
< |
|
| 685 |
> |
if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) |
| 686 |
> |
Mods_CheckboxList->Check(i); |
| 687 |
|
} |
| 688 |
|
} |
| 689 |
|
|
| 703 |
|
{ |
| 704 |
|
refreshMods(getInstallString( string(openFileDialog->GetPath()) )); |
| 705 |
|
} |
| 1545 |
– |
|
| 1546 |
– |
|
| 706 |
|
} |
| 707 |
|
|
| 1549 |
– |
|
| 708 |
|
/* |
| 709 |
|
* wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE |
| 710 |
|
*/ |
| 723 |
|
|
| 724 |
|
if ( openFileDialog->ShowModal() == wxID_OK ) |
| 725 |
|
{ |
| 1568 |
– |
|
| 1569 |
– |
|
| 1570 |
– |
//Mods_CheckboxList-> |
| 1571 |
– |
|
| 1572 |
– |
|
| 1573 |
– |
|
| 1574 |
– |
// |
| 1575 |
– |
|
| 726 |
|
if ( exists( openFileDialog->GetPath().c_str() ) ) |
| 727 |
|
{ |
| 728 |
|
remove( openFileDialog->GetPath().c_str() ); |
| 731 |
|
ofstream file(openFileDialog->GetPath().c_str()); |
| 732 |
|
|
| 733 |
|
vector<string>list; |
| 734 |
< |
for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName ); |
| 734 |
> |
for(unsigned int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName ); |
| 735 |
|
vector<string>::iterator begin_iter = list.begin(); |
| 736 |
|
vector<string>::iterator end_iter = list.end(); |
| 737 |
|
|
| 743 |
|
|
| 744 |
|
file.close(); |
| 745 |
|
file.clear(); |
| 1596 |
– |
|
| 1597 |
– |
//SetCurrentFilename(openFileDialog->GetFilename()); |
| 1598 |
– |
//theText->LoadFile(openFileDialog->GetFilename()); |
| 1599 |
– |
//SetStatusText(GetCurrentFilename(), 0); |
| 1600 |
– |
//SetStatusText(openFileDialog->GetDirectory(),1); |
| 746 |
|
} |
| 747 |
|
} |
| 748 |
|
|
| 1604 |
– |
|
| 1605 |
– |
|
| 749 |
|
/* |
| 750 |
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button |
| 751 |
|
*/ |
| 752 |
|
|
| 753 |
|
void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event ) |
| 754 |
|
{ |
| 755 |
< |
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); |
| 756 |
< |
|
| 757 |
< |
if (YesNoDialog->ShowModal() == wxID_NO) { //if the user said no... |
| 755 |
> |
string YesNoMsg = "WARNING: This will DELETE the Edition's GameDataFolder and recreate it from the vanilla Oni game data.\n"; |
| 756 |
> |
YesNoMsg = YesNoMsg + "Are you SURE you want to do this?"; |
| 757 |
> |
wxMessageDialog* YesNoDialog = new wxMessageDialog(this, YesNoMsg.c_str(), "AE Installer Alert", wxYES_NO | wxICON_EXCLAMATION , wxDefaultPosition); |
| 758 |
|
|
| 759 |
+ |
if (YesNoDialog->ShowModal() == wxID_NO) |
| 760 |
+ |
{ |
| 761 |
+ |
//if the user said no... |
| 762 |
|
} |
| 763 |
< |
else { |
| 764 |
< |
|
| 763 |
> |
else |
| 764 |
> |
{ |
| 765 |
|
this->InstallButton->Disable(); |
| 766 |
|
this->ReglobalizeButton->Disable(); |
| 1621 |
– |
|
| 767 |
|
#ifdef WIN32 |
| 1623 |
– |
|
| 768 |
|
boost::thread thrd2(globalizeData); |
| 769 |
|
//globalizeData(); |
| 770 |
|
//boost::thread::create_thread(&globalizeData); |
| 773 |
|
#else |
| 774 |
|
globalizeData(); |
| 775 |
|
#endif |
| 1632 |
– |
|
| 776 |
|
this->InstallButton->Enable(); |
| 777 |
|
this->ReglobalizeButton->Enable(); |
| 778 |
|
} |
| 1636 |
– |
|
| 779 |
|
} |
| 780 |
|
/* |
| 781 |
|
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton |
| 782 |
|
*/ |
| 783 |
|
|
| 1642 |
– |
/*void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event ) |
| 1643 |
– |
{ |
| 1644 |
– |
////@begin wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow. |
| 1645 |
– |
// Before editing this code, remove the block markers. |
| 1646 |
– |
event.Skip(); |
| 1647 |
– |
////@end wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow. |
| 1648 |
– |
}*/ |
| 1649 |
– |
|
| 1650 |
– |
|
| 784 |
|
/* |
| 785 |
|
* wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Seperated_RadioButton |
| 786 |
|
*/ |
| 787 |
|
|
| 788 |
|
void MainWindow::OnSeperatedRadioButtonSelected( wxCommandEvent& event ) |
| 789 |
|
{ |
| 790 |
< |
splitInstances = SPLIT; |
| 790 |
> |
splitInstances = true; |
| 791 |
|
} |
| 792 |
|
|
| 793 |
+ |
void MainWindow::OnDirButtonClick( wxCommandEvent& event ) |
| 794 |
+ |
{ |
| 795 |
+ |
wxDirDialog* newDir = new wxDirDialog(this, "Set current directory", "", wxDD_DEFAULT_STYLE, |
| 796 |
+ |
wxDefaultPosition, wxDefaultSize, "wxDirCtrl"); |
| 797 |
+ |
newDir->ShowModal(); |
| 798 |
+ |
if(newDir->GetPath()[0]) current_path( (path)newDir->GetPath() ); |
| 799 |
+ |
OnRefreshButtonClick(event); |
| 800 |
+ |
} |