Subversion Repositories spk

Rev

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