Subversion Repositories spk

Rev

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