예제 #1
0
        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());
        }
예제 #2
0
 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);
     }
 }