Rev 105 | Blame | Compare with Previous | Last modification | View Log | RSS feed
// GameLauncher.cpp : main project file.
#include "stdafx.h"
#include "Forms/Form1.h"
#include "X3Data.h"
using namespace GameLauncher;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
System::String ^runFile;
System::String ^gameFile;
System::String ^arguments;
bool intoArgs = false;
bool advanced = false;
for ( int i = 0; i < args->Length; i++ )
{
if ( String::Compare(args[i], "--gameargs", false) == 0 )
intoArgs = true;
else
{
if ( String::Compare(args[i]->Substring(0, 2), "--", false) == 0 ) {
if ( String::Compare(args[i], "--advanced", false) == 0 )
advanced = true;
}
else if ( !intoArgs && !gameFile )
gameFile = args[i];
else if ( !intoArgs && !runFile )
runFile = args[i];
else if ( arguments )
arguments += " " + args[i];
else
arguments = args[i];
}
}
if ( !gameFile && args->Length >= 1 )
gameFile = args[0];
if ( !runFile && args->Length > 1 )
runFile = args[1];
// Create the main window and run it
if ( !runFile || !runFile->Length )
{
RegistryKey ^searchKey = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
if ( searchKey )
runFile = System::Convert::ToString(searchKey->GetValue("Run"));
}
Form1 ^form = gcnew Form1(gameFile, arguments, runFile);
Application::Run(form);
if ( runFile && form->Resume())
{
System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(runFile);
info->WorkingDirectory = System::IO::FileInfo(runFile).DirectoryName;
if ( advanced )
info->Arguments = "--advanced";
info->UseShellExecute = false;
info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
System::Diagnostics::Process ^process = System::Diagnostics::Process::Start(info);
}
return 0;
}