Subversion Repositories spk

Rev

Rev 15 | Rev 105 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15 Rev 85
Line 1... Line 1...
1
#pragma once
1
#pragma once
2
 
2
 
3
#include "X3Data.h"
3
#include "../X3Data.h"
4
 
4
 
5
#include "ViewData.h"
5
#include "ViewData.h"
6
#include "EZ_LCD.h"
6
#include "EZ_LCD.h"
7
#include "LCDDisplay.h"
7
#include "../LCDDisplay.h"
8
 
8
 
9
#define LOGFILE		902
9
#define LOGFILE		902
10
#define VERSION		"1.30"
10
#define VERSION		"1.30"
11
#define DATE		"01/01/2012"
11
#define DATE		"01/01/2012"
12
 
12
 
Line 34... Line 34...
34
	///          resources associated with this form.
34
	///          resources associated with this form.
35
	/// </summary>
35
	/// </summary>
36
	public ref class Form1 : public System::Windows::Forms::Form
36
	public ref class Form1 : public System::Windows::Forms::Form
37
	{
37
	{
38
	public:
38
	public:
39
		Form1(System::String ^runGame, System::String ^arguments, System::String ^runManager)
39
		Form1(System::String ^runGame, System::String ^arguments, System::String ^runManager);
40
		{
-
 
41
			InitializeComponent();
-
 
42
 
-
 
43
			m_sGame = runGame;
-
 
44
			m_sArgs = arguments;
-
 
45
			m_sManager = runManager;
-
 
46
 
-
 
47
			this->label3->Text = "Version: V" + VERSION + " (" + DATE + ")";
-
 
48
 
-
 
49
			this->gameDataToolStripMenuItem->Visible = false;
-
 
50
			m_bClosing = false;
-
 
51
			m_bGameClosed = true;
-
 
52
			m_bWaitingSteam = false;
-
 
53
			m_bRunSteam = false;
-
 
54
			m_bCheckProcess = false;
-
 
55
			m_bAutoClose = true;
-
 
56
			m_bAutoResume = true;
-
 
57
			m_bNoLCD = false;
-
 
58
			m_bResume = false;
-
 
59
			m_bClose = false;
-
 
60
			m_bUpdateLCD = true;
-
 
61
			m_bCustomGui = true;
-
 
62
			m_bGuiHooked = false;
-
 
63
			m_iGameLog = LOGFILE;
-
 
64
 
-
 
65
			// create the game data container
-
 
66
			m_pGameData = new CX3Data(CyStringFromSystemString(System::IO::FileInfo(System::Windows::Forms::Application::ExecutablePath).DirectoryName));
-
 
67
 
-
 
68
			// read the launchers settings
-
 
69
			RegistryKey ^searchKey = Registry::CurrentUser->OpenSubKey("Software\\Egosoft\\PluginManagerSettings");
-
 
70
			if ( searchKey )
-
 
71
			{
-
 
72
				if ( System::Convert::ToInt32(searchKey->GetValue("DontAutoResume")) )
-
 
73
					m_bAutoResume = false;
-
 
74
				if ( System::Convert::ToInt32(searchKey->GetValue("DontAutoClose")) )
-
 
75
					m_bAutoClose = false;
-
 
76
				if ( System::Convert::ToInt32(searchKey->GetValue("DontUpdateLCD")) )
-
 
77
					m_bUpdateLCD = false;
-
 
78
				if ( System::Convert::ToInt32(searchKey->GetValue("DontDoGUI")) )
-
 
79
					m_bCustomGui = false;
-
 
80
				if ( System::Convert::ToInt32(searchKey->GetValue("GameDataLog")) )
-
 
81
					m_iGameLog = System::Convert::ToInt32(searchKey->GetValue("GameDataLog"));
-
 
82
			}
-
 
83
 
-
 
84
			// update the UI
-
 
85
			this->ContextResume->Checked = m_bAutoResume;
-
 
86
			this->ContextAutoClose->Checked = m_bAutoClose;
-
 
87
			this->updateLCDToolStripMenuItem->Checked = m_bUpdateLCD;
-
 
88
			this->gUIOverlayToolStripMenuItem->Checked = m_bCustomGui;
-
 
89
			SetGameLogDisplay();
-
 
90
 
-
 
91
			this->AddGames();
-
 
92
 
-
 
93
			m_pLCD = NULL;
-
 
94
		}
-
 
95
 
40
 
96
		void SetGameLogDisplay()
41
		void SetGameLogDisplay()
97
		{
42
		{
98
			CyString display = "Game Log: ";
43
			CyString display = "Game Log: ";
99
			display += CyString((long)m_iGameLog).PadNumber(5);
44
			display += CyString((long)m_iGameLog).PadNumber(5);
Line 344... Line 289...
344
			{
289
			{
345
				m_pLCD->UpdateDisplay(updated);
290
				m_pLCD->UpdateDisplay(updated);
346
			}
291
			}
347
		}
292
		}
348
 
293
 
349
		void StartGame(String ^game, String ^args, String ^name)
294
		void StartGame(String ^originalGame, String ^args, String ^name)
350
		{
295
		{
-
 
296
			System::String ^game = originalGame;
351
			if ( !game )
297
			if ( !game )
352
				return;
298
				return;
-
 
299
 
-
 
300
			String ^noSteamExe = System::IO::FileInfo(game).DirectoryName + "\\" + System::IO::Path::GetFileNameWithoutExtension(game) + "_n.exe";
-
 
301
			if ( System::IO::File::Exists(noSteamExe) ) {
-
 
302
				game = noSteamExe;
-
 
303
			}
-
 
304
 
353
			System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(game);
305
			System::Diagnostics::ProcessStartInfo ^info = gcnew System::Diagnostics::ProcessStartInfo(game);
354
			info->WorkingDirectory = System::IO::FileInfo(game).DirectoryName;
306
			info->WorkingDirectory = System::IO::FileInfo(game).DirectoryName;
-
 
307
			
355
			m_bRunSteam = game->Contains("steamapps");
308
			m_bRunSteam = game->Contains("steamapps");
356
			m_sGameRunExe = System::IO::FileInfo(game).Name;
309
			m_sGameRunExe = System::IO::FileInfo(game).Name;
357
			m_sGameName = name;
310
			m_sGameName = name;
358
			m_bWaitingSteam = m_bRunSteam;
311
			m_bWaitingSteam = m_bRunSteam;
-
 
312
 
359
			info->Arguments = args;
313
			info->Arguments = args;
360
			info->UseShellExecute = false;
314
			info->UseShellExecute = false;
361
			info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
315
			info->WindowStyle = System::Diagnostics::ProcessWindowStyle::Normal;
362
			System::Diagnostics::Process ^process = gcnew System::Diagnostics::Process;
316
			System::Diagnostics::Process ^process = gcnew System::Diagnostics::Process;
363
			process->StartInfo = info;
317
			process->StartInfo = info;
364
			process->StartInfo->CreateNoWindow = true;
318
			process->StartInfo->CreateNoWindow = true;
365
			process->EnableRaisingEvents = true;
319
			process->EnableRaisingEvents = true;
366
			process->Exited += gcnew EventHandler(this, &Form1::ProgramClosedEvent);
320
			process->Exited += gcnew EventHandler(this, &Form1::ProgramClosedEvent);
367
 
321
 
368
			// setup game to read log files
322
			// setup game to read log files
369
			SetLogDirForGame(game);
323
			SetLogDirForGame(originalGame);
370
			m_pGameData->Reset();
324
			m_pGameData->Reset();
371
			m_pGameData->SetGameName(CyStringFromSystemString(name));
325
			m_pGameData->SetGameName(CyStringFromSystemString(name));
372
			m_pGameData->SetGameDirectory(CyStringFromSystemString(System::IO::FileInfo(game).DirectoryName));
326
			m_pGameData->SetGameDirectory(CyStringFromSystemString(System::IO::FileInfo(game).DirectoryName));
373
			m_bGameClosed = false;
327
			m_bGameClosed = false;
374
 
328