Subversion Repositories spk

Rev

Rev 105 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
// GameLauncher.cpp : main project file.
2
 
3
#include "stdafx.h"
4
#include "Forms/Form1.h"
5
#include "X3Data.h"
6
 
7
using namespace GameLauncher;
8
 
9
[STAThreadAttribute]
10
int main(array<System::String ^> ^args)
11
{
12
	// Enabling Windows XP visual effects before any controls are created
13
	Application::EnableVisualStyles();
14
	Application::SetCompatibleTextRenderingDefault(false); 
15
 
16
	System::String ^runFile;
17
	System::String ^gameFile;
18
	System::String ^arguments;
19
 
20
	bool intoArgs = false;
105 cycrow 21
	bool advanced = false;
1 cycrow 22
	for ( int i = 0; i < args->Length; i++ )
23
	{
105 cycrow 24
		if ( String::Compare(args[i], "--gameargs", false) == 0 )
106 cycrow 25
			intoArgs = true;
1 cycrow 26
		else
27
		{
106 cycrow 28
			if ( String::Compare(args[i]->Substring(0, 2), "--", false) == 0 ) {
29
				if ( String::Compare(args[i], "--advanced", false) == 0 )
30
					advanced = true;
31
			}
32
			else if ( !intoArgs && !gameFile )
1 cycrow 33
				gameFile = args[i];
105 cycrow 34
			else if ( !intoArgs && !runFile )
1 cycrow 35
				runFile = args[i];
36
			else if ( arguments )
37
				arguments += " " + args[i];
38
			else
39
				arguments = args[i];
40
		}
41
	}
106 cycrow 42
 
43
	if ( !gameFile && args->Length >= 1 )
1 cycrow 44
		gameFile = args[0];
106 cycrow 45
	if ( !runFile && args->Length > 1 )
1 cycrow 46
		runFile = args[1];
106 cycrow 47
 
1 cycrow 48
	// Create the main window and run it
49
	if ( !runFile || !runFile->Length )
50
	{
51
		RegistryKey ^searchKey = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
52
		if ( searchKey )
53
			runFile = System::Convert::ToString(searchKey->GetValue("Run"));
54
	}
55
 
56
	Form1 ^form = gcnew Form1(gameFile, arguments, runFile);
57
	Application::Run(form);
58
 
59
 
60
	if ( runFile && form->Resume())
61
	{
62
		System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(runFile);
63
		info->WorkingDirectory = System::IO::FileInfo(runFile).DirectoryName;
105 cycrow 64
		if ( advanced )
65
			info->Arguments = "--advanced";
1 cycrow 66
		info->UseShellExecute = false;
67
		info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
68
		System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
69
	}
70
 
71
	return 0;
72
}