Subversion Repositories spk

Rev

Rev 64 | Rev 86 | 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);
128
#endif
129
 
1 cycrow 130
	//TODO: Load languge xml
131
	//Language.LoadLanguages();
132
 
133
	// get the last language used
134
	RegistryKey ^searchKeyLang = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
135
	if ( searchKeyLang )
136
	{
137
		int lang = System::Convert::ToInt32(searchKeyLang->GetValue("Language"));
138
		if ( lang )
139
			Language.SetLanguage(lang);
140
	}
141
 
142
 
143
	bool firstInstance = false;
144
	System::Threading::Mutex ^mut = gcnew System::Threading::Mutex(false, "Local\\XPluginManagerLite", firstInstance);
145
	if ( !firstInstance )
146
	{
147
		if ( openPackage )
148
		{
149
			if ( File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
150
			{
151
				StreamWriter ^sw = File::AppendText(mydoc + "\\Egosoft\\pluginmanager_load.dat");
152
				try 
153
				{
154
					sw->WriteLine("File: " + openPackage);
155
				}
156
				finally
157
				{
158
					if ( sw )
159
						delete (IDisposable ^)sw;
160
				}
161
			}
162
			else
163
			{
164
				StreamWriter ^sw = File::CreateText(mydoc + "\\Egosoft\\pluginmanager_load.dat");
165
				try 
166
				{
167
					sw->WriteLine("File: " + openPackage);
168
				}
169
				finally
170
				{
171
					if ( sw )
172
						delete (IDisposable ^)sw;
173
				}
174
			}
175
		}
176
		else if ( !silent )
177
			MessageBox::Show(SystemStringFromCyString(Language.GetText_Startup(LANGSTARTUP_ANOTHERINSTANCE)), SystemStringFromCyString(Language.GetText_Startup(LANGSTARTUP_ANOTHERINSTANCE_TITLE)), MessageBoxButtons::OK, MessageBoxIcon::Stop);
178
		return 0;
179
	}
180
 
181
	RegistryKey ^searchKey = Registry::CurrentUser->CreateSubKey("Software\\Egosoft\\PluginManagerSettings");
182
	if ( searchKey )
183
	{
184
		searchKey->SetValue("Run", System::Windows::Forms::Application::ExecutablePath);
185
		searchKey->SetValue("Version", (float)PMLVERSION);
186
		searchKey->SetValue("Beta", (int)PMLBETA);
187
	}
188
 
189
 
190
	if ( File::Exists(mydoc + "\\Egosoft\\pluginmanager_load.dat") )
191
		File::Delete(mydoc + "\\Egosoft\\pluginmanager_load.dat");
192
	if ( File::Exists(tempDir + "\\AutoUpdater_old.exe") )
193
		File::Delete(tempDir + "\\AutoUpdater_old.exe");
194
 
195
	packages.Startup(".", CyStringFromSystemString(tempDir), CyStringFromSystemString(mydoc), "");
196
	packages.SetRenameText(true);
197
 
198
	// Create the main window and run it
199
	MainGui ^gui = gcnew MainGui(&packages, &dirList, &remDirList, Advanced);
200
	gui->AddGameArgs(gameArgs);
201
 
50 cycrow 202
 
1 cycrow 203
	// load in the config file
204
	CFileIO configFile(CyStringFromSystemString(mydoc) + "/Egosoft/pluginmanager.dat");
205
	bool anyDirs = false;
52 cycrow 206
	if ( configFile.exists() )
1 cycrow 207
	{
208
		std::vector<CyString> *readFile = configFile.ReadLines();
209
		if ( readFile )
210
		{
211
			for ( int i = 0; i < (int)readFile->size(); i++ )
212
			{
213
				CyString line(readFile->at(i));
214
				CyString cmd = line.GetToken(":", 1, 1).lower();
215
				CyString rest = line.GetToken(":", 2).RemoveFirstSpace();
216
 
217
				if ( cmd == "dir" )
218
				{
219
					// first check its on the list
220
					if ( !dirList.FindString(rest) )
221
					{
222
						CyString gameName = packages.GetGameName(rest);
223
						if ( !gameName.Empty() )
224
						{
225
							int lang = packages.GetGameLanguage(rest);
226
							if ( lang )
227
								dirList.PushBack(rest, CyString::Number(lang) + "|" + gameName);
228
							else
229
								dirList.PushBack(rest, gameName);
230
							anyDirs = true;
231
						}
232
					}
233
				}
234
				else if ( cmd == "remdir" )
235
				{
236
					// first check its on the list
237
					if ( !remDirList.FindString(rest) )
238
					{
239
						remDirList.PushBack(rest);
240
						anyDirs = true;
241
					}
242
				}
243
				else if ( cmd == "experimental" )
244
					gui->SetExperimental(true);
245
				else if ( cmd == "filterships" )
246
					gui->SetShips(true);
247
				else if ( cmd == "filtersigned" )
248
					gui->SetOnlySigned(true);
249
				else if ( cmd == "modselectordetails" )
250
					gui->SetModSelectorDetails(true);
251
				else if ( cmd == "cheat" )
252
					gui->SetCheat(true);
253
				else if ( cmd == "downloadable" )
254
					gui->SetDownloadable(true);
255
				else if ( cmd == "noautoupdate" )
256
					gui->SetAutoUpdate(false);
257
				else if ( cmd == "managersize" )
258
					gui->SetSize(rest.GetToken(" ", 2, 2).ToInt(), rest.GetToken(" ", 1, 1).ToInt());
259
				else if ( cmd == "managerpos" )
260
					gui->Location = System::Drawing::Point(rest.GetToken(" ", 1, 1).ToInt(), rest.GetToken(" ", 2, 2).ToInt());
261
				else if ( cmd == "managermax" )
262
					gui->WindowState = FormWindowState::Maximized;
263
				else if ( cmd == "tips" )
264
					gui->SetTips(rest.GetToken(" ", 1, 1).ToInt(), rest.GetToken(" ", 2, 2).ToInt());
265
				else if ( cmd == "ignorejoy" )
266
					gui->SetIgnoreJoy(rest.ToInt());
267
				else if ( cmd == "savegamemanager" )
268
					gui->SetSaveGameManager(rest.ToInt());
269
				else if ( cmd == "restoremodified" ) {
270
					CPackages p;
271
					p.Startup(".", CyStringFromSystemString(tempDir), CyStringFromSystemString(mydoc), "");
272
					if ( p.Read(rest) ) {
273
						p.SetVanilla(false);
274
						p.PrepareEnableFromVanilla();
275
						p.EnablePreparedPackages(0, 0, 0);
276
						p.CloseDir();
277
					}
278
				}
279
			}
280
 
281
			delete readFile;
282
		}
283
	}
284
 
285
	CyStringList gameDirs;
286
	gameDirs.PushBack("HKCU\\Software\\Deepsilver\\X2 The Threat", "INSTALL_DIR");
287
	gameDirs.PushBack("HKCU\\Software\\Deepsilver\\X3 Reunion", "INSTALL_DIR");
288
	gameDirs.PushBack("HKCU\\Software\\Egosoft\\X3TC", "INSTALL_DIR");
289
	gameDirs.PushBack("Steam\\x2 - the threat");
290
	gameDirs.PushBack("Steam\\x3 - reunion");
291
	gameDirs.PushBack("Steam\\x3 terran conflict");
292
	// some custom directories to look for
293
	gameDirs.PushBack("%PROGRAMFILES%\\Egosoft\\X2 The Threat");
294
	gameDirs.PushBack("%PROGRAMFILES%\\Egosoft\\X3 Reunion");
295
	gameDirs.PushBack("%PROGRAMFILES%\\Egosoft\\X3 Terran Conflict");
296
	gameDirs.PushBack("C:\\Games\\X2");
297
	gameDirs.PushBack("C:\\Games\\X3");
298
	gameDirs.PushBack("C:\\Games\\X3TC");
299
	gameDirs.PushBack("D:\\Games\\X2");
300
	gameDirs.PushBack("D:\\Games\\X3");
301
	gameDirs.PushBack("D:\\Games\\X3TC");
302
 
303
	for ( SStringList *strNode = gameDirs.Head(); strNode; strNode = strNode->next )
304
	{
305
		CyString sFirst = strNode->str.GetToken("\\", 1, 1);
306
		CyString sRest = strNode->str.GetToken("\\", 2);
307
 
308
		if ( sFirst.Compare("HKCU") || sFirst.Compare("HKLM") )
309
		{
310
			RegistryKey ^searchKey = nullptr;
311
			if ( sFirst.Compare("HKCU") )
312
				searchKey = Registry::CurrentUser->OpenSubKey(SystemStringFromCyString(sRest));
313
			else if ( sFirst.Compare("HKLM") )
314
				searchKey = Registry::LocalMachine->OpenSubKey(SystemStringFromCyString(sRest));
315
 
316
			if ( searchKey )
317
			{
318
				System::String ^regRead = System::Convert::ToString(searchKey->GetValue(SystemStringFromCyString(strNode->data)));
319
				if ( regRead )
320
				{
321
					CyString dir = CyStringFromSystemString(regRead);
322
					gui->GetGameDirs(dir, anyDirs, anyDirs);
323
				}
324
			}
325
		}
326
		else if ( sFirst.Compare("Steam") )
327
		{
328
			RegistryKey ^steamKey = Registry::CurrentUser->OpenSubKey("Software\\Valve\\Steam");
329
			if ( steamKey )
330
			{
331
				System::String ^regRead = System::Convert::ToString(steamKey->GetValue("SteamPath"));
332
				if ( regRead )
333
				{
334
					CyString steamDir = CyStringFromSystemString(regRead);
335
					CyString dir = steamDir + "\\steamapps\\common\\" + sRest;
336
					dir = dir.FindReplace("/","\\");
337
					dir = dir.FindReplace("\\\\", "\\");
338
					gui->GetGameDirs(dir, anyDirs, anyDirs);
339
				}
340
			}
341
		}
342
		else
343
		{
344
			CyString dir = strNode->str;
345
			dir = dir.FindReplace("/","\\");
346
			dir = dir.FindReplace("\\\\", "\\");
347
			dir = dir.FindReplace("%PROGRAMFILES%", CyStringFromSystemString(progfile));
348
			gui->GetGameDirs(dir, anyDirs, anyDirs);
349
		}
350
	}
351
 
352
	// no directories?
353
	if ( dirList.Empty() )
354
	{
355
		OpenFileDialog ^ofd = gcnew OpenFileDialog();
356
		ofd->Filter = "X-Universe Executable|";
357
		String ^games = "";
358
		for ( int i = 0; i < packages.GetGameExe()->GetNumGames(); i++ )
359
		{
360
			SGameExe *exe = packages.GetGameExe()->GetGame(i);
361
			if ( i ) ofd->Filter += ";";
362
			ofd->Filter += SystemStringFromCyString(exe->sExe);
363
			games += "|" + SystemStringFromCyString(exe->sName) + "|" + SystemStringFromCyString(exe->sExe);
364
		}
365
		ofd->Filter += games;
366
		ofd->FilterIndex = 1;
367
		ofd->RestoreDirectory = true;
368
		if ( ofd->ShowDialog() == System::Windows::Forms::DialogResult::OK )
369
		{
370
			CyString dir = CyStringFromSystemString(IO::FileInfo(ofd->FileName).DirectoryName);
371
			if ( !dir.Empty() )
372
			{
373
				CyString gameName = packages.GetGameName(dir);
374
				if ( !gameName.Empty() )
375
				{
376
					remDirList.Remove(dir);
377
					gui->GetGameDirs(dir, false, true);
378
				}
379
			}
380
		}
381
	}
382
 
383
	// still no directories, quit
384
	if ( dirList.Empty() )
385
		return 1;
386
 
387
	CyString dir = dirList.First();
388
 
389
	StartUp ^startup = gcnew StartUp(&packages, &dir, (openPackage) ? true : false, Advanced);
390
	Application::Run(startup);
391
	if ( packages.IsOldPluginManager() )
392
	{
393
		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 )
394
			return 0;
395
	}
396
 
397
	// opening a package from command line
398
	if ( openPackage )
399
	{
400
		if ( gui->InstallPackage(openPackage, true, false, false) )
401
		{
402
			if ( !packages.GetModKey().Empty() )
403
				PluginManager::WriteRegistryValue(packages.GetModKey(), packages.GetSelectedModName());
404
			packages.CloseDir(0, 0, true);
405
			return 0;
406
		}
407
		return 1;
408
	}
409
 
410
	gui->UpdateDirList();
411
	gui->UpdateControls();
412
	gui->UpdatePackages();
413
	gui->StartCheckTimer();
414
 
415
	System::String ^mod = PluginManager::ReadRegistryValue(packages.GetModKey());
416
	packages.SetMod(CyStringFromSystemString(mod));
417
 
418
	gui->CheckProtectedDir();
419
	Application::Run(gui);
420
 
421
	// close directory 
422
	if ( packages.IsLoaded() )
423
	{
424
		if ( !packages.GetModKey().Empty() )
425
			PluginManager::WriteRegistryValue(packages.GetModKey(), packages.GetSelectedModName());
426
		if ( packages.AnyUnusedShared() )
427
		{
428
			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)
429
				packages.RemoveUnusedSharedFiles();
430
		}
431
		packages.CloseDir(0, 0, true);
432
	}
433
 
434
	CyStringList restoreModified;
435
	if ( gui->GetDownloadFile() )
436
	{
437
		if ( System::IO::File::Exists(".\\AutoUpdater.exe") )
438
		{
439
			// rename the autoupdater
440
			System::String ^dir = System::IO::FileInfo(System::Windows::Forms::Application::ExecutablePath).DirectoryName;
441
			if ( System::IO::File::Exists(tempDir + "\\AutoUpdater_old.exe") )
442
				System::IO::File::Delete(tempDir + "\\AutoUpdater_old.exe");
443
			System::IO::File::Copy(dir + "\\AutoUpdater.exe", tempDir + "\\AutoUpdater_old.exe");
444
 
445
			System::Diagnostics::ProcessStartInfo ^info = nullptr;
446
			if ( System::IO::File::Exists(tempDir + "\\AutoUpdater_old.exe") )
447
				info = gcnew System::Diagnostics::ProcessStartInfo(tempDir + "\\AutoUpdater_old.exe");
448
			else 
449
			{
450
				MessageBox::Show("Error trying to update the Plugin Manager\nUnable to load AutoUpdater", "AutoUpdate", MessageBoxButtons::OK, MessageBoxIcon::Warning);
451
				System::Windows::Forms::Application::Restart();
452
				return 0;
453
			}
454
 
455
			if ( info )
456
			{
457
				info->WorkingDirectory = dir;
458
				info->Arguments = "\"" + gui->GetDownloadFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\"";
459
				info->UseShellExecute = false;
460
				info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
461
				System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
462
			}
463
		}
464
		else
465
		{
466
			MessageBox::Show("Error trying to update the Plugin Manager\nUnable to load AutoUpdater", "AutoUpdate", MessageBoxButtons::OK, MessageBoxIcon::Warning);
467
			System::Windows::Forms::Application::Restart();
468
		}
469
	}
470
	else if ( gui->GetRunFile() )
471
	{
472
		System::String ^dir = System::IO::FileInfo(System::Windows::Forms::Application::ExecutablePath).DirectoryName;
473
 
474
		// manager was run from the launcher, ie the launcher is still running, send a message to run the game instead of loading another one
475
		if ( fromLauncher )
476
		{
477
			StreamWriter ^sw = File::CreateText(mydoc + "\\Egosoft\\launchgame.dat");
478
			try 
479
			{
480
				sw->WriteLine("File:" + gui->GetRunFile());
481
				if ( gui->GetGameArgs() && gui->GetGameArgs()->Length )
482
					sw->WriteLine("Args:" + gui->GetGameArgs());
483
			}
484
			finally
485
			{
486
				if ( sw )
487
					delete (IDisposable ^)sw;
488
			}
489
		}
490
		else
491
		{
492
			if ( System::IO::File::Exists(dir + "\\GameLauncher.exe") )
493
			{
494
				System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(dir + "\\GameLauncher.exe");
495
				if ( info )
496
				{
497
					if ( packages.GetCurrentGameFlags() & EXEFLAG_ADDON ) {
498
						CPackages p;
499
						p.Startup(".", CyStringFromSystemString(tempDir), CyStringFromSystemString(mydoc), "");
500
						CyString baseDir = CFileIO(CyStringFromSystemString(gui->GetRunFile())).GetDir();
501
						if ( p.Read(baseDir) ) {
502
							if ( !p.IsVanilla() ) {
503
								p.SetVanilla(true);
504
								p.PrepareDisableForVanilla();
505
								p.EnablePreparedPackages(0, 0, 0);
506
								restoreModified.PushBack(baseDir);
507
							}
508
							p.CloseDir();							
509
						}
510
					}
511
 
512
					info->WorkingDirectory = dir;
513
					if ( gui->GetGameArgs() && gui->GetGameArgs()->Length )
514
						info->Arguments = "\"" + gui->GetRunFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\" \"" + gui->GetGameArgs() + "\"";
515
					else
516
						info->Arguments = "\"" + gui->GetRunFile() + "\" \"" + System::Windows::Forms::Application::ExecutablePath + "\"";
517
					info->UseShellExecute = false;
518
					info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
519
					System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
520
				}
521
			}
522
		}
523
	}
524
 
525
	// write config
526
	std::vector<CyString> writeLines;
527
	for ( SStringList *strNode = dirList.Head(); strNode; strNode = strNode->next )
528
	{
529
		writeLines.push_back(CyString("Dir:") + strNode->str);
530
		CyString data;
531
		if ( strNode->data.IsIn("|") )
532
		{
533
			data = CPackages::ConvertLanguage(strNode->data.GetToken("|", 1, 1).ToInt()) + "|";
534
			data += strNode->data.GetToken("|", 2);
535
		}
536
		else
537
			data = strNode->data;
538
 
56 cycrow 539
		CyString exe = CFileIO(packages.GetGameExe()->GetGameRunExe(strNode->str.ToString())).fullFilename();
1 cycrow 540
		writeLines.push_back(CyString("DirExe:") + data + "|" + exe);
541
 
542
		// do the log files
543
		writeLines.push_back(CyString("GameLog:") + packages.GetLogDirectory(exe) + "|" + exe);
544
 
545
	}
546
	for ( SStringList *strNode = remDirList.Head(); strNode; strNode = strNode->next )
547
		writeLines.push_back(CyString("RemDir:") + strNode->str);
548
	if ( gui->IsExperimental() )
549
		writeLines.push_back("Experimental:");
550
	if ( gui->IsShips() )
551
		writeLines.push_back("FilterShips:");
552
	if ( gui->IsOnlySigned() )
553
		writeLines.push_back("FilterSigned:");
554
	if ( gui->IsCheat() )
555
		writeLines.push_back("Cheat:");
556
	writeLines.push_back(CyString("SaveGameManager:") + (long)gui->GetSaveGameManager());
557
	if ( gui->IsDownloadable() )
558
		writeLines.push_back("Downloadable:");
559
	if ( gui->IsModSelectorDetailsShowing() )
560
		writeLines.push_back("ModSelectorDetails:");
561
	if ( !gui->IsAutoUpdate() )
562
		writeLines.push_back("NoAutoUpdate:");
563
	if ( gui->WindowState == FormWindowState::Normal )
564
	{
565
		writeLines.push_back(CyString("ManagerSize:") + (long)gui->Size.Height + " " + (long)gui->Size.Width);
566
		writeLines.push_back(CyString("ManagerPos:") + (long)gui->Location.X + " " + (long)gui->Location.Y);
567
	}
568
	else
569
	{
570
		writeLines.push_back(CyString("ManagerPos:") + (long)gui->RestoreBounds.Location.X + " " + (long)gui->RestoreBounds.Location.Y);
571
		writeLines.push_back(CyString("ManagerSize:") + (long)gui->RestoreBounds.Size.Height + " " + (long)gui->RestoreBounds.Size.Width);
572
	}
573
 
574
	if ( gui->WindowState == FormWindowState::Maximized )
575
		writeLines.push_back("ManagerMax:");
576
	if ( gui->GetIgnoreJoy() )
577
		writeLines.push_back(CyString("IgnoreJoy:") + gui->GetIgnoreJoy());
578
 
579
	for ( int i = 0; i < gui->GetMaxTips(); i++ )
580
	{
581
		int tips = gui->GetTips(i);
582
		if ( tips == -1 )
583
			continue;
584
		writeLines.push_back(CyString("Tips: ") + (long)i + " " + (long)tips);
585
	}
586
 
587
	for ( SStringList *rm = restoreModified.Head(); rm; rm = rm->next ) {
588
		writeLines.push_back(CyString("RestoreModified: ") + rm->str);
589
	}
590
 
591
	// write settings
592
	configFile.WriteFile(&writeLines);
593
 
594
	return 0;
595
}