private void ButtonLaunch_Click(object sender, EventArgs e) { if (gameLaunch != null) { return; } ButtonLaunch.Enabled = false; RECT selected = new RECT(0, 0, 640, 480); if (resolutions != null && InputResoSelect.Enabled) { selected = resolutions[InputResoSelect.SelectedIndex]; } this.settings.SetDefaultWindowPos(Math.Max(selected.Width, 640), Math.Max(selected.Height, 480)); gameLaunch = FlatOut2.CreateSplitScreenSession(this.settings); gameLaunch.ContinueWith(t => { using (Stream s = File.Open(settingsFile, FileMode.Create)) { this.settings.SaveSettings(s); } Application.Exit(); }, TaskContinuationOptions.OnlyOnRanToCompletion); gameLaunch.ContinueWith(t => { throw t.Exception.InnerException; }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext()); }
private static void StartSplitScreenSession(FlatOut2 fo2) { using (fo2) { fo2.StartGame(); } }
static void Main(string[] args) { try { if (args.Contains("-noConfig")) { using (var s = File.OpenRead(Setup.settingsFile)) { using (var settings = Settings.LoadSettings(s)) { FlatOut2.CreateSplitScreenSession(settings).Wait(); Application.Exit(); return; } } } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); Application.ThreadException += Application_ThreadException; Application.Run(new Setup()); } } catch (Exception e) { ShowFatalExceptionDialog(e); } }
private void TabController_Enter(object sender, EventArgs e) { ControllerPlayerList.Enabled = false; ControllerOptionsPanel.Enabled = false; ControllerBTResetAll.Enabled = false; Task <List <GamePad> > getControllers = FlatOut2.GetGamePads(); getControllers.ContinueWith(UpdateControllerList, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); ControllerPlayerList.Clear(); for (int player = 0; player < settings.InstanceCount; player++) { ControllerPlayerList.Items.Add($"Player {player + 1}"); } }
private void EnterConfigTab() { Task <List <RECT> > getResolutions = FlatOut2.GetResolutions(); getResolutions.ContinueWith(UpdateResolutionList, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
/// <summary> /// Asynchronously starts a new split-screen session with the specified settings. /// </summary> /// <param name="settings">The settings used to setup the session.</param> /// <returns>Returns a task that represents the session startup process.</returns> public static Task CreateSplitScreenSession(Settings settings) { FlatOut2 fo2 = new FlatOut2(settings); return(Task.Factory.StartNew(() => { StartSplitScreenSession(fo2); })); }