Subversion Repositories spk

Rev

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