internal static void Run(string[] runtimeArgs) { if (runtimeArgs == null || runtimeArgs.Length != 3) { MessageBox.Show(@"Expected arguments to be '-test <config file path> <output directory path>'."); return; } string testConfigurationFilePath = runtimeArgs[1]; if (!File.Exists(testConfigurationFilePath)) { MessageBox.Show(@"No test configuration file found at: " + testConfigurationFilePath); return; } string relativeOutputPath = runtimeArgs[2]; try { TestConfiguration testConf = SimulatorResources.GetTestConfiguration(testConfigurationFilePath); var simSettings = new SimulationSettings(); simSettings.RenderMode = RenderModes.Normal; // Start the simulator game entry point using (var game = new SimulatorGame(simSettings, IntPtr.Zero, testConf, relativeOutputPath)) { // Enables cameras (poor design, I know..) game.IsCapturingMouse = true; // Make sure the XNA game window (left eye) displays as a full screen window // just as the one we just created for the right eye var gameForm = (Form)System.Windows.Forms.Control.FromHandle(game.Window.Handle); gameForm.FormBorderStyle = FormBorderStyle.None; gameForm.Text = @"A²DS Test Mode"; gameForm.LostFocus += (sender, e) => game.IsCapturingMouse = false; gameForm.GotFocus += (sender, e) => game.IsCapturingMouse = true; // Run the game code game.Run(); } string configfileCopy = Path.Combine(relativeOutputPath, @"TestConfiguration.xml"); File.Copy(testConfigurationFilePath, configfileCopy); } catch (Exception e) { MessageBox.Show(@"Error occured." + e); } }
public static void Run() { try { // SimulationSettings simSettings = SimulatorResources.GetSimulationSettings(); var simSettings = new SimulationSettings(); simSettings.RenderMode = RenderModes.Normal; // Start the simulator game entry point using (var game = new SimulatorGame(simSettings, IntPtr.Zero)) { game.Run(); } } catch (Exception e) { string msg = "Error occured!\n\n" + e; Console.WriteLine(e); // MessageBox.Show(msg); } }
public static void Run() { try { int numScreens = Screen.AllScreens.Length; if (numScreens != 1 && numScreens != 2) throw new NotImplementedException("Only supports single and dual monitor setup!"); SimulationSettings simSettings = SimulatorResources.GetSimulationSettings(); if (simSettings.RenderMode == RenderModes.Stereo && numScreens < 2) { Console.WriteLine(@"Could not run stereo mode. Can't find two monitors connected?"); simSettings.RenderMode = RenderModes.Normal; } IntPtr rightEyeWindow = IntPtr.Zero; if (simSettings.RenderMode == RenderModes.Stereo) rightEyeWindow = SpawnRightEyeWindow(); // Start the simulator game entry point using (var game = new SimulatorGame(simSettings, rightEyeWindow)) { // Make sure the XNA game window (left eye) displays as a full screen window // just as the one we just created for the right eye var gameForm = (Form) System.Windows.Forms.Control.FromHandle(game.Window.Handle); gameForm.FormBorderStyle = FormBorderStyle.None; gameForm.LostFocus += (sender, e) => game.IsCapturingMouse = false; gameForm.GotFocus += (sender, e) => Game_GotFocus(game); gameForm.MouseClick += (sender, e) => { if (e.Button == MouseButtons.Right) Game_MouseRightClick(game); }; // Name the window according to mode gameForm.Text = (simSettings.RenderMode == RenderModes.Stereo) ? "A²DS Stereoscopy (left eye)" : "A²DS"; _settingsController = new SettingsController(gameForm); // Hook the settings controller to the simulator by events, so changes in PID settings causes // autopilot to use new PID settings. _settingsController.PIDSettingsChanged += () => game.SetPIDSetup(_settingsController.CurrentPIDSetup); // Run the game code game.Run(); } } catch (Exception e) { string msg = "Error occured!\n\n" + e; Console.WriteLine(e); MessageBox.Show(msg); } }