Subversion Repositories spk

Rev

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