Subversion Repositories spk

Rev

Rev 86 | Rev 104 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
// PluginManager.cpp : main project file.
2
 
3
#include "stdafx.h"
4
#include "Forms\MainGui.h"
5
#include "Forms\StartUp.h"
6
#include "Languages.h"
7
 
8
using namespace PluginManager;
9
using namespace Microsoft::Win32;
10
using namespace System::IO;
11
 
12
#include <spk.h>
13
#undef GetTempPath
14
#undef GetCurrentDirectory
15
 
16
CPackages	packages;
17
CLanguages	Language;
18
 
19
 
20
 
21
[STAThreadAttribute]
22
int main(array<System::String ^> ^args)
23
{
24
	// Enabling Windows XP visual effects before any controls are created
25
	Application::EnableVisualStyles();
26
	Application::SetCompatibleTextRenderingDefault(false); 
27
 
28
	System::String ^tempDir = System::IO::Path::GetTempPath();
29
	System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
30
	System::String ^progfile = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles );
31
 
32
	CyStringList dirList;
33
	CyStringList remDirList;
34
	System::String ^gameArgs;
35
	System::String ^openPackage;
36
 
37
	Language.SetLanguage(44);
38
 
64 cycrow 39
	bool Advanced = false, fromLauncher = false, silent = false, gamerun = false;
1 cycrow 40
	for ( int i = 0; i < args->Length; i++ )
41
	{
42
		CyString arg = CyStringFromSystemString(args[i]);
43
 
64 cycrow 44
		if ( gamerun ) {
45
			if ( gameArgs && gameArgs->Length ) gameArgs += " ";
46
			gameArgs += args[i];
47
		}
1 cycrow 48
		// its a switch
64 cycrow 49
		else if ( arg.Left(2) == "--" )
1 cycrow 50
		{
51
			CyString argSwitch = arg.GetToken(":", 1, 1).ToLower();
64 cycrow 52
			CyString argSwitchFirst = arg.GetToken(" ", 1, 1).ToLower();
1 cycrow 53
			CyString rest = arg.GetToken(":", 2);
54
			if ( rest[0] == '"' && rest[rest.Length() - 1] != '"' )
55
			{
56
				rest.Erase(0, 1);
57
				while ( i < args->Length )
58
				{
59
					i++;
60
					CyString argCheck = CyStringFromSystemString(args[i]);
61
					rest += " ";
62
					rest += argCheck;
63
					if ( argCheck.Right(1) == "\"" )
64
						break;
65
				}
66
			}
67
 
68
			if ( rest.Right(1) == "\"" )
69
				rest.Truncate(rest.Length() - 1);
70
 
71
			if ( argSwitch == "--dir" && !rest.Empty() )
72
			{
73
				CyString gameName = packages.GetGameName(rest);
74
				if ( !gameName.Empty() )
75
					dirList.PushBack(rest, gameName);
76
			}
77
 
78
			if ( argSwitch == "--advanced" )
79
				Advanced = true;
80
			else if ( argSwitch == "--fromlauncher" )
81
				fromLauncher = true;
82
			else if ( argSwitch == "--silent" )
83
				silent = true;
84
			else if ( argSwitch == "--forceemp" )
85
				packages.SetForceEMP(true);
86
			else if ( argSwitch == "--gamerun" && !rest.Empty() )
87
			{
88
				gameArgs = SystemStringFromCyString(rest);
89
				break;
90
			}
64 cycrow 91
			else if ( argSwitch == "--gamerun" ) {
92
				gamerun = true;
93
			}
94
			else if ( argSwitchFirst == "--gamerun" ) {
95
				gamerun = true;
96
				gameArgs = SystemStringFromCyString(arg.GetToken(" ", 2));
97
			}
1 cycrow 98
			else if ( argSwitch == "--noresume" )
99
			{
100
				RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
101
				if ( searchKey )
102
					searchKey->SetValue("DontAutoResume", 1);
103
			}
104
			else if ( argSwitch == "--resume" )
105
			{
106
				int zero = 0;
107
				RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
108
				if ( searchKey )
109
					searchKey->SetValue("DontAutoResume", zero);
110
			}
55 cycrow 111
			else if ( argSwitch == "--debug" ) {
112
				CFileLog *log = dynamic_cast<CFileLog *>(CFileLog::create());
113
				log->setFile(_S(mydoc) + "/Egosoft/pluginmanager.log");
84 cycrow 114
				log->setFilter(CLog::Log_Install | CLog::Log_Uninstall | CLog::Log_IO | CLog::Log_Directory | CLog::Log_File);
55 cycrow 115
				log->setLevel(rest.ToInt());
116
			}
1 cycrow 117
		}
118
		// otherwise it must be a file to open
119
		else
120
			openPackage = SystemStringFromCyString(arg);
121
	}
122
 
84 cycrow 123
#if _DEBUG
124
	CFileLog *log = dynamic_cast<CFileLog *>(CFileLog::create());
125
	log->setFile(_S(mydoc) + "/Egosoft/pluginmanager.log");
126
	log->setFilter(CLog::Log_Install | CLog::Log_Uninstall | CLog::Log_IO | CLog::Log_Directory | CLog::Log_File);
127
	log->setLevel(5);
86 cycrow 128
	Advanced = true;
84 cycrow 129
#endif
130
 
1 cycrow 131
	//TODO: Load languge xml
132
	//Language.LoadLanguages();
133
 
134
	// get the last language used
135
	RegistryKey ^searchKeyLang = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
136
	if ( searchKeyLang )
137
	{
138
		int lang = System::Convert::ToInt32(searchKeyLang->GetValue("Language"));
139
		if ( lang )
140
			Language.SetLanguage(lang);
141
	}
142
 
143
 
144
	bool firstInstance = false;
145
	System::Threading::Mutex ^mut = gcnew System::Threading::Mutex(false, "Local\\XPluginManagerLite", firstInstance);
146
	if ( !firstInstance )
147
	{
148
		if ( openPackage )
149
		{
150
			if ( File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
151
			{
152
				StreamWriter ^sw = File::AppendText(mydoc + "\\Egosoft\\pluginmanager_load.dat");
153
				try 
154
				{
155
					sw->WriteLine("File: " + openPackage);
156
				}
157
				finally
158
				{
159
					if ( sw )
160
						delete (IDisposable ^)sw;
161
				}
162
			}
163
			else
164
			{
165
				StreamWriter ^sw = File::CreateText(mydoc + "\\Egosoft\\pluginmanager_load.dat");
166
				try 
167
				{
168
					sw->WriteLine("File: " + openPackage);
169
				}
170
				finally
171
				{
172
					if ( sw )
173
						delete (IDisposable ^)sw;
174
				}
175
			}
176
		}
177
		else if ( !silent )
178
			MessageBox::Show(SystemStringFromCyString(Language.GetText_Startup(LANGSTARTUP_ANOTHERINSTANCE)), SystemStringFromCyString(Language.GetText_Startup(LANGSTARTUP_ANOTHERINSTANCE_TITLE)), MessageBoxButtons::OK, MessageBoxIcon::Stop);
179
		return 0;
180
	}
181
 
182
	RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
183
	if ( searchKey )
184
	{
185
		searchKey->SetValue("Run", System::Windows::Forms::Application::ExecutablePath);
186
		searchKey->SetValue("Version", (float)PMLVERSION);
187
		searchKey->SetValue("Beta", (int)PMLBETA);
188
	}
189
 
190
 
191
	if ( File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
192
		File::Delete(mydoc + "\\Egosoft\\pluginmanager_load.dat");
193
	if ( File::Exists(tempDir + "\\AutoUpdater_old.exe") )
194
		File::Delete(tempDir + "\\AutoUpdater_old.exe");
195
 
196
	packages.Startup(".", CyStringFromSystemString(tempDir), CyStringFromSystemString(mydoc), "");
197
	packages.SetRenameText(true);
198
 
199
	// Create the main window and run it
200
	MainGui ^gui = gcnew MainGui(&packages, &dirList, &remDirList, Advanced);
201
	gui->AddGameArgs(gameArgs);
202
 
50 cycrow 203
 
1 cycrow 204
	// load in the config file
205
	CFileIO configFile(CyStringFromSystemString(mydoc) + "/Egosoft/pluginmanager.dat");
206
	bool anyDirs = false;
52 cycrow 207
	if ( configFile.exists() )
1 cycrow 208
	{
209
		std::vector<CyString> *readFile = configFile.ReadLines();
210
		if ( readFile )
211
		{
212
			for ( int i = 0; i < (int)readFile->size(); i++ )
213
			{
214
				CyString line(readFile->at(i));
215
				CyString cmd = line.GetToken(":", 1, 1).lower();
216
				CyString rest = line.GetToken(":", 2).RemoveFirstSpace();
217
 
218
				if ( cmd == "dir" )
219
				{
220
					// first check its on the list
221
					if ( !dirList.FindString(rest) )
222
					{
223
						CyString gameName = packages.GetGameName(rest);
224
						if ( !gameName.Empty() )
225
						{
226
							int lang = packages.GetGameLanguage(rest);
227
							if ( lang )
228
								dirList.PushBack(rest, CyString::Number(lang) + "|" + gameName);
229
							else
230
								dirList.PushBack(rest, gameName);
231
							anyDirs = true;
232
						}
233
					}
234
				}
235
				else if ( cmd == "remdir" )
236
				{
237
					// first check its on the list
238
					if ( !remDirList.FindString(rest) )
239
					{
240
						remDirList.PushBack(rest);
241
						anyDirs = true;
242
					}
243
				}
244
				else if ( cmd == "experimental" )
245
					gui->SetExperimental(true);
246
				else if ( cmd == "filterships" )
247
					gui->SetShips(true);
248
				else if ( cmd == "filtersigned" )
249
					gui->SetOnlySigned(true);
250
				else if ( cmd == "modselectordetails" )
251
					gui->SetModSelectorDetails(true);
252
				else if ( cmd == "cheat" )
253
					gui->SetCheat(true);
254
				else if ( cmd == "downloadable" )
255
					gui->SetDownloadable(true);
256
				else if ( cmd == "noautoupdate" )
257
					gui->SetAutoUpdate(false);
258
				else if ( cmd == "managersize" )
259
					gui->SetSize(rest.GetToken(" ", 2, 2).ToInt(), rest.GetToken(" ", 1, 1).ToInt());
260
				else if ( cmd == "managerpos" )
261
					gui->Location = System::Drawing::Point(rest.GetToken(" ", 1, 1).ToInt(), rest.GetToken(" ", 2, 2).ToInt());
262
				else if ( cmd == "managermax" )
263
					gui->WindowState = FormWindowState::Maximized;
264
				else if ( cmd == "tips" )
265
					gui->SetTips(rest.GetToken(" ", 1, 1).ToInt(), rest.GetToken(" ", 2, 2).ToInt());
266
				else if ( cmd == "ignorejoy" )
267
					gui->SetIgnoreJoy(rest.ToInt());
268
				else if ( cmd == "savegamemanager" )
269
					gui->SetSaveGameManager(rest.ToInt());
270
				else if ( cmd == "restoremodified" ) {
271
					CPackages p;
272
					p.Startup(".", CyStringFromSystemString(tempDir), CyStringFromSystemString(mydoc), "");
273
					if ( p.Read(rest) ) {
274
						p.SetVanilla(false);
275
						p.PrepareEnableFromVanilla();
276
						p.EnablePreparedPackages(0, 0, 0);
277
						p.CloseDir();
278
					}
279
				}
280
			}
281
 
282
			delete readFile;
283
		}
284
	}
285
 
286
	CyStringList gameDirs;
287
	gameDirs.PushBack("HKCU\\Software\\Deepsilver\\X2 The Threat", "INSTALL_DIR");
288
	gameDirs.PushBack("HKCU\\Software\\Deepsilver\\X3 Reunion", "INSTALL_DIR");
289
	gameDirs.PushBack("HKCU\\Software\\Egosoft\\X3TC", "INSTALL_DIR");
290
	gameDirs.PushBack("Steam\\x2 - the threat");
291
	gameDirs.PushBack("Steam\\x3 - reunion");
292
	gameDirs.PushBack("Steam\\x3 terran conflict");
293
	// some custom directories to look for
294
	gameDirs.PushBack("%PROGRAMFILES%\\Egosoft\\X2 The Threat");
295
	gameDirs.PushBack("%PROGRAMFILES%\\Egosoft\\X3 Reunion");
296
	gameDirs.PushBack("%PROGRAMFILES%\\Egosoft\\X3 Terran Conflict");
297
	gameDirs.PushBack("C:\\Games\\X2");
298
	gameDirs.PushBack("C:\\Games\\X3");
299
	gameDirs.PushBack("C:\\Games\\X3TC");
300
	gameDirs.PushBack("D:\\Games\\X2");
301
	gameDirs.PushBack("D:\\Games\\X3");
302
	gameDirs.PushBack("D:\\Games\\X3TC");
303
 
304
	for ( SStringList *strNode = gameDirs.Head(); strNode; strNode = strNode->next )
305
	{
306
		CyString sFirst = strNode->str.GetToken("\\", 1, 1);
307
		CyString sRest = strNode->str.GetToken("\\", 2);
308
 
309
		if ( sFirst.Compare("HKCU") || sFirst.Compare("HKLM") )
310
		{
311
			RegistryKey ^searchKey = nullptr;
312
			if ( sFirst.Compare("HKCU") )
313
				searchKey = Registry::CurrentUser->OpenSubKey(SystemStringFromCyString(sRest));
314
			else if ( sFirst.Compare("HKLM") )
315
				searchKey = Registry::LocalMachine->OpenSubKey(SystemStringFromCyString(sRest));
316
 
317
			if ( searchKey )
318
			{
319
				System::String ^regRead = System::Convert::ToString(searchKey->GetValue(SystemStringFromCyString(strNode->data)));
320
				if ( regRead )
321
				{
322
					CyString dir = CyStringFromSystemString(regRead);
323
					gui->GetGameDirs(dir, anyDirs, anyDirs);
324
				}
325
			}
326
		}
327
		else if ( sFirst.Compare("Steam") )
328
		{
329
			RegistryKey ^steamKey = Registry::CurrentUser->OpenSubKey("Software\\Valve\\Steam");
330
			if ( steamKey )
331
			{
332
				System::String ^regRead = System::Convert::ToString(steamKey->GetValue("SteamPath"));
333
				if ( regRead )
334
				{
335
					CyString steamDir = CyStringFromSystemString(regRead);
336
					CyString dir = steamDir + "\\steamapps\\common\\" + sRest;
337
					dir = dir.FindReplace("/","\\");
338
					dir = dir.FindReplace("\\\\", "\\");
339
					gui->GetGameDirs(dir, anyDirs, anyDirs);
340
				}
341
			}
342
		}
343
		else
344
		{
345
			CyString dir = strNode->str;
346
			dir = dir.FindReplace("/","\\");
347
			dir = dir.FindReplace("\\\\", "\\");
348
			dir = dir.FindReplace("%PROGRAMFILES%", CyStringFromSystemString(progfile));
349
			gui->GetGameDirs(dir, anyDirs, anyDirs);
350
		}
351
	}
352
 
353
	// no directories?
354
	if ( dirList.Empty() )
355
	{
356
		OpenFileDialog ^ofd = gcnew OpenFileDialog();
357
		ofd->Filter = "X-Universe Executable|";
358
		String ^games = "";
359
		for ( int i = 0; i < packages.GetGameExe()->GetNumGames(); i++ )
360
		{
361
			SGameExe *exe = packages.GetGameExe()->GetGame(i);
362
			if ( i ) ofd->Filter += ";";
363
			ofd->Filter += SystemStringFromCyString(exe->sExe);
364
			games += "|" + SystemStringFromCyString(exe->sName) + "|" + SystemStringFromCyString(exe->sExe);
365
		}
366
		ofd->Filter += games;
367
		ofd->FilterIndex = 1;
368
		ofd->RestoreDirectory = true;
369
		if ( ofd->ShowDialog() == System::Windows::Forms::DialogResult::OK )
370
		{
371
			CyString dir = CyStringFromSystemString(IO::FileInfo(ofd->FileName).DirectoryName);
372
			if ( !dir.Empty() )
373
			{
374
				CyString gameName = packages.GetGameName(dir);
375
				if ( !gameName.Empty() )
376
				{
377
					remDirList.Remove(dir);
378
					gui->GetGameDirs(dir, false, true);
379
				}
380
			}
381
		}
382
	}
383
 
384
	// still no directories, quit
385
	if ( dirList.Empty() )
386
		return 1;
387
 
388
	CyString dir = dirList.First();
389
 
390
	StartUp ^startup = gcnew StartUp(&packages, &dir, (openPackage) ? true : false, Advanced);
391
	Application::Run(startup);
392
	if ( packages.IsOldPluginManager() )
393
	{
394
		if ( MessageBox::Show("Game directory: " + SystemStringFromCyString(dir) + "\nIs currently being controled by the old plugin manager\nIf you continue, you will be unable to use the old version again\nDo you wish to continue?", "Update Game Directory", MessageBoxButtons::YesNo, MessageBoxIcon::Question) != System::Windows::Forms::DialogResult::Yes )
395
			return 0;
396
	}
397
 
398
	// opening a package from command line
399
	if ( openPackage )
400
	{
401
		if ( gui->InstallPackage(openPackage, true, false, false) )
402
		{
403
			if ( !packages.GetModKey().Empty() )
404
				PluginManager::WriteRegistryValue(packages.GetModKey(), packages.GetSelectedModName());
405
			packages.CloseDir(0, 0, true);
406
			return 0;
407
		}
408
		return 1;
409
	}
410
 
411
	gui->UpdateDirList();
412
	gui->UpdateControls();
413
	gui->UpdatePackages();
414
	gui->StartCheckTimer();
415
 
416
	System::String ^mod = PluginManager::ReadRegistryValue(packages.GetModKey());
417
	packages.SetMod(CyStringFromSystemString(mod));
418
 
419
	gui->CheckProtectedDir();
420
	Application::Run(gui);
421
 
422
	// close directory 
423
	if ( packages.IsLoaded() )
424
	{
425
		if ( !packages.GetModKey().Empty() )
426
			PluginManager::WriteRegistryValue(packages.GetModKey(), packages.GetSelectedModName());
427
		if ( packages.AnyUnusedShared() )
428
		{
429
			if ( MessageBox::Show("You have some unused shared files, would you like to remove these?", "Remove Shared Files", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes)
430
				packages.RemoveUnusedSharedFiles();
431
		}
432
		packages.CloseDir(0, 0, true);
433
	}
434
 
435
	CyStringList restoreModified;
436
	if ( gui->GetDownloadFile() )
437
	{
438
		if ( System::IO::File::Exists(".\\AutoUpdater.exe") )
439
		{
440
			// rename the autoupdater
441
			System::String ^dir = System::IO::FileInfo(System::Windows::Forms::Application::ExecutablePath).DirectoryName;
442
			if ( System::IO::File::Exists(tempDir + "\\AutoUpdater_old.exe") )
443
				System::IO::File::Delete(tempDir + "\\AutoUpdater_old.exe");
444
			System::IO::File::Copy(dir + "\\AutoUpdater.exe", tempDir + "\\AutoUpdater_old.exe");
445
 
446
			System::Diagnostics::ProcessStartInfo ^info = nullptr;
447
			if ( System::IO::File::Exists(tempDir + "\\AutoUpdater_old.exe") )
448
				info = gcnew System::Diagnostics::ProcessStartInfo(tempDir + "\\AutoUpdater_old.exe");
449
			else 
450
			{
451
				MessageBox::Show("Error trying to update the Plugin Manager\nUnable to load AutoUpdater", "AutoUpdate", MessageBoxButtons::OK, MessageBoxIcon::Warning);
452
				System::Windows::Forms::Application::Restart();
453
				return 0;
454
			}
455
 
456
			if ( info )
457
			{
458
				info->WorkingDirectory = dir;
459
				info->Arguments = "\"" + gui->GetDownloadFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\"";
460
				info->UseShellExecute = false;
461
				info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
462
				System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
463
			}
464
		}
465
		else
466
		{
467
			MessageBox::Show("Error trying to update the Plugin Manager\nUnable to load AutoUpdater", "AutoUpdate", MessageBoxButtons::OK, MessageBoxIcon::Warning);
468
			System::Windows::Forms::Application::Restart();
469
		}
470
	}
471
	else if ( gui->GetRunFile() )
472
	{
473
		System::String ^dir = System::IO::FileInfo(System::Windows::Forms::Application::ExecutablePath).DirectoryName;
474
 
475
		// manager was run from the launcher, ie the launcher is still running, send a message to run the game instead of loading another one
476
		if ( fromLauncher )
477
		{
478
			StreamWriter ^sw = File::CreateText(mydoc + "\\Egosoft\\launchgame.dat");
479
			try 
480
			{
481
				sw->WriteLine("File:" + gui->GetRunFile());
482
				if ( gui->GetGameArgs() && gui->GetGameArgs()->Length )
483
					sw->WriteLine("Args:" + gui->GetGameArgs());
484
			}
485
			finally
486
			{
487
				if ( sw )
488
					delete (IDisposable ^)sw;
489
			}
490
		}
491
		else
492
		{
493
			if ( System::IO::File::Exists(dir + "\\GameLauncher.exe") )
494
			{
495
				System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(dir + "\\GameLauncher.exe");
496
				if ( info )
497
				{
498
					if ( packages.GetCurrentGameFlags() & EXEFLAG_ADDON ) {
499
						CPackages p;
500
						p.Startup(".", CyStringFromSystemString(tempDir), CyStringFromSystemString(mydoc), "");
102 cycrow 501
						CyString baseDir = CFileIO(CyStringFromSystemString(gui->GetRunFile())).dir();
1 cycrow 502
						if ( p.Read(baseDir) ) {
503
							if ( !p.IsVanilla() ) {
504
								p.SetVanilla(true);
505
								p.PrepareDisableForVanilla();
506
								p.EnablePreparedPackages(0, 0, 0);
507
								restoreModified.PushBack(baseDir);
508
							}
509
							p.CloseDir();							
510
						}
511
					}
512
 
513
					info->WorkingDirectory = dir;
514
					if ( gui->GetGameArgs() && gui->GetGameArgs()->Length )
515
						info->Arguments = "\"" + gui->GetRunFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\" \"" + gui->GetGameArgs() + "\"";
516
					else
517
						info->Arguments = "\"" + gui->GetRunFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\"";
518
					info->UseShellExecute = false;
519
					info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
520
					System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
521
				}
522
			}
523
		}
524
	}
525
 
526
	// write config
527
	std::vector<CyString> writeLines;
528
	for ( SStringList *strNode = dirList.Head(); strNode; strNode = strNode->next )
529
	{
530
		writeLines.push_back(CyString("Dir:") + strNode->str);
531
		CyString data;
532
		if ( strNode->data.IsIn("|") )
533
		{
534
			data = CPackages::ConvertLanguage(strNode->data.GetToken("|", 1, 1).ToInt()) + "|";
535
			data += strNode->data.GetToken("|", 2);
536
		}
537
		else
538
			data = strNode->data;
539
 
56 cycrow 540
		CyString exe = CFileIO(packages.GetGameExe()->GetGameRunExe(strNode->str.ToString())).fullFilename();
1 cycrow 541
		writeLines.push_back(CyString("DirExe:") + data + "|" + exe);
542
 
543
		// do the log files
102 cycrow 544
		writeLines.push_back(CyString("GameLog:") + packages.logDirectory(exe.ToString()) + "|" + exe);
1 cycrow 545
 
546
	}
547
	for ( SStringList *strNode = remDirList.Head(); strNode; strNode = strNode->next )
548
		writeLines.push_back(CyString("RemDir:") + strNode->str);
549
	if ( gui->IsExperimental() )
550
		writeLines.push_back("Experimental:");
551
	if ( gui->IsShips() )
552
		writeLines.push_back("FilterShips:");
553
	if ( gui->IsOnlySigned() )
554
		writeLines.push_back("FilterSigned:");
555
	if ( gui->IsCheat() )
556
		writeLines.push_back("Cheat:");
557
	writeLines.push_back(CyString("SaveGameManager:") + (long)gui->GetSaveGameManager());
558
	if ( gui->IsDownloadable() )
559
		writeLines.push_back("Downloadable:");
560
	if ( gui->IsModSelectorDetailsShowing() )
561
		writeLines.push_back("ModSelectorDetails:");
562
	if ( !gui->IsAutoUpdate() )
563
		writeLines.push_back("NoAutoUpdate:");
564
	if ( gui->WindowState == FormWindowState::Normal )
565
	{
566
		writeLines.push_back(CyString("ManagerSize:") + (long)gui->Size.Height + " " + (long)gui->Size.Width);
567
		writeLines.push_back(CyString("ManagerPos:") + (long)gui->Location.X + " " + (long)gui->Location.Y);
568
	}
569
	else
570
	{
571
		writeLines.push_back(CyString("ManagerPos:") + (long)gui->RestoreBounds.Location.X + " " + (long)gui->RestoreBounds.Location.Y);
572
		writeLines.push_back(CyString("ManagerSize:") + (long)gui->RestoreBounds.Size.Height + " " + (long)gui->RestoreBounds.Size.Width);
573
	}
574
 
575
	if ( gui->WindowState == FormWindowState::Maximized )
576
		writeLines.push_back("ManagerMax:");
577
	if ( gui->GetIgnoreJoy() )
578
		writeLines.push_back(CyString("IgnoreJoy:") + gui->GetIgnoreJoy());
579
 
580
	for ( int i = 0; i < gui->GetMaxTips(); i++ )
581
	{
582
		int tips = gui->GetTips(i);
583
		if ( tips == -1 )
584
			continue;
585
		writeLines.push_back(CyString("Tips: ") + (long)i + " " + (long)tips);
586
	}
587
 
588
	for ( SStringList *rm = restoreModified.Head(); rm; rm = rm->next ) {
589
		writeLines.push_back(CyString("RestoreModified: ") + rm->str);
590
	}
591
 
592
	// write settings
593
	configFile.WriteFile(&writeLines);
594
 
595
	return 0;
596
}