Subversion Repositories spk

Rev

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