Subversion Repositories spk

Rev

Rev 1 | Go to most recent revision | 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 )
1 cycrow 25
			intoArgs;
26
		else
27
		{
105 cycrow 28
			if ( !intoArgs && !gameFile )
1 cycrow 29
				gameFile = args[i];
105 cycrow 30
			else if ( !intoArgs && !runFile )
1 cycrow 31
				runFile = args[i];
105 cycrow 32
			else if ( String::Compare(args[i], "--advanced", false) == 0 )
33
				advanced = true;
1 cycrow 34
			else if ( arguments )
35
				arguments += " " + args[i];
36
			else
37
				arguments = args[i];
38
		}
39
	}
40
	if ( args->Length >= 1 )
41
		gameFile = args[0];
42
	if ( args->Length > 1 )
43
		runFile = args[1];
44
	// Create the main window and run it
45
	if ( args->Length > 2 )
46
		arguments = args[2];
47
 
48
	if ( !runFile || !runFile->Length )
49
	{
50
		RegistryKey ^searchKey = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
51
		if ( searchKey )
52
			runFile = System::Convert::ToString(searchKey->GetValue("Run"));
53
	}
54
 
55
	Form1 ^form = gcnew Form1(gameFile, arguments, runFile);
56
	Application::Run(form);
57
 
58
 
59
	if ( runFile && form->Resume())
60
	{
61
		System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(runFile);
62
		info->WorkingDirectory = System::IO::FileInfo(runFile).DirectoryName;
105 cycrow 63
		if ( advanced )
64
			info->Arguments = "--advanced";
1 cycrow 65
		info->UseShellExecute = false;
66
		info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
67
		System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
68
	}
69
 
70
	return 0;
71
}