@@ -78,6 +78,9 @@ namespace OpenRA.GameRules
|
||||
public int Samples = 25;
|
||||
public bool IgnoreVersionMismatch = false;
|
||||
public bool DeveloperMenu = false;
|
||||
|
||||
public bool ShowFatalErrorDialog = true;
|
||||
public string FatalErrorDialogFaq = "http://github.com/OpenRA/OpenRA/wiki/FAQ";
|
||||
}
|
||||
|
||||
public class GraphicSettings
|
||||
|
||||
@@ -155,6 +155,7 @@
|
||||
<Compile Include="Server\TraitInterfaces.cs" />
|
||||
<Compile Include="Sound.cs" />
|
||||
<Compile Include="Support\Arguments.cs" />
|
||||
<Compile Include="Support\FatalErrorDialog.cs" />
|
||||
<Compile Include="Support\PerfHistory.cs" />
|
||||
<Compile Include="Support\Program.cs" />
|
||||
<Compile Include="Sync.cs" />
|
||||
|
||||
105
OpenRA.Game/Support/FatalErrorDialog.cs
Normal file
105
OpenRA.Game/Support/FatalErrorDialog.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Media;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
public static class FatalErrorDialog
|
||||
{
|
||||
public static void Show()
|
||||
{
|
||||
var form = new Form
|
||||
{
|
||||
Size = new Size(315, 140),
|
||||
Text = "Fatal Error",
|
||||
MinimizeBox = false,
|
||||
MaximizeBox = false,
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog,
|
||||
StartPosition = FormStartPosition.CenterScreen
|
||||
};
|
||||
|
||||
var notice = new Label
|
||||
{
|
||||
Location = new Point(10, 10),
|
||||
AutoSize = true,
|
||||
Text = "OpenRA has encountered a fatal error and must close.{0}Refer to the crash logs and FAQ for more information.".F(Environment.NewLine),
|
||||
TextAlign = ContentAlignment.TopCenter
|
||||
};
|
||||
form.Controls.Add(notice);
|
||||
|
||||
var dontShowAgain = new CheckBox
|
||||
{
|
||||
Location = new Point(25, 50),
|
||||
AutoSize = true,
|
||||
Text = "Don't show this message again",
|
||||
};
|
||||
form.Controls.Add(dontShowAgain);
|
||||
|
||||
var viewLogs = new Button
|
||||
{
|
||||
Location = new Point(10, 80),
|
||||
Size = new Size(75, 23),
|
||||
Text = "View Logs"
|
||||
};
|
||||
viewLogs.Click += ViewLogsClicked;
|
||||
form.Controls.Add(viewLogs);
|
||||
|
||||
var viewFaq = new Button
|
||||
{
|
||||
Location = new Point(90, 80),
|
||||
Size = new Size(75, 23),
|
||||
Text = "View FAQ"
|
||||
};
|
||||
viewFaq.Click += ViewFaqClicked;
|
||||
form.Controls.Add(viewFaq);
|
||||
|
||||
var quit = new Button
|
||||
{
|
||||
Location = new Point(225, 80),
|
||||
Size = new Size(75, 23),
|
||||
Text = "Quit"
|
||||
};
|
||||
quit.DialogResult = DialogResult.Cancel;
|
||||
form.Controls.Add(quit);
|
||||
|
||||
form.FormClosed += (sender, e) =>
|
||||
{
|
||||
Game.Settings.Debug.ShowFatalErrorDialog = !dontShowAgain.Checked;
|
||||
Game.Settings.Save();
|
||||
};
|
||||
|
||||
SystemSounds.Exclamation.Play();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
static void ViewLogsClicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(Log.LogPath);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
static void ViewFaqClicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(Game.Settings.Debug.FatalErrorDialogFaq);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA
|
||||
return;
|
||||
}
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => LogException((Exception)e.ExceptionObject);
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => FatalError((Exception)e.ExceptionObject);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -39,16 +39,19 @@ namespace OpenRA
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogException(e);
|
||||
FatalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void LogException(Exception e)
|
||||
static void FatalError(Exception e)
|
||||
{
|
||||
Log.AddChannel("exception", "exception.log");
|
||||
var rpt = BuildExceptionReport(e).ToString();
|
||||
Log.Write("exception", "{0}", rpt);
|
||||
Console.Error.WriteLine(rpt);
|
||||
|
||||
if (Game.Settings.Debug.ShowFatalErrorDialog)
|
||||
FatalErrorDialog.Show();
|
||||
}
|
||||
|
||||
static StringBuilder BuildExceptionReport(Exception e)
|
||||
|
||||
@@ -75,6 +75,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
checkunsyncedCheckbox.IsChecked = () => debugSettings.SanityCheckUnsyncedCode;
|
||||
checkunsyncedCheckbox.OnClick = () => debugSettings.SanityCheckUnsyncedCode ^= true;
|
||||
|
||||
var showFatalErrorDialog = generalPane.Get<CheckboxWidget>("SHOW_FATAL_ERROR_DIALOG_CHECKBOX");
|
||||
showFatalErrorDialog.IsChecked = () => Game.Settings.Debug.ShowFatalErrorDialog;
|
||||
showFatalErrorDialog.OnClick = () => Game.Settings.Debug.ShowFatalErrorDialog ^= true;
|
||||
|
||||
// Video
|
||||
var windowModeDropdown = generalPane.Get<DropDownButtonWidget>("MODE_DROPDOWN");
|
||||
windowModeDropdown.OnMouseDown = _ => SettingsMenuLogic.ShowWindowModeDropdown(windowModeDropdown, graphicsSettings);
|
||||
|
||||
@@ -239,6 +239,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
developerMenuCheckbox.IsChecked = () => Game.Settings.Debug.DeveloperMenu;
|
||||
developerMenuCheckbox.OnClick = () => Game.Settings.Debug.DeveloperMenu ^= true;
|
||||
|
||||
var showFatalErrorDialog = debug.Get<CheckboxWidget>("SHOW_FATAL_ERROR_DIALOG_CHECKBOX");
|
||||
showFatalErrorDialog.IsChecked = () => Game.Settings.Debug.ShowFatalErrorDialog;
|
||||
showFatalErrorDialog.OnClick = () => Game.Settings.Debug.ShowFatalErrorDialog ^= true;
|
||||
|
||||
bg.Get<ButtonWidget>("BUTTON_CLOSE").OnClick = () =>
|
||||
{
|
||||
int x, y;
|
||||
|
||||
@@ -92,6 +92,13 @@ Container@SETTINGS_PANEL:
|
||||
Height:20
|
||||
Font:Regular
|
||||
Text:Check Sync around Unsynced Code
|
||||
Checkbox@SHOW_FATAL_ERROR_DIALOG_CHECKBOX:
|
||||
X:15
|
||||
Y:260
|
||||
Width:300
|
||||
Height:20
|
||||
Font:Regular
|
||||
Text:Show Fatal Error dialog
|
||||
Label@VIDEO_TITLE:
|
||||
Y:20
|
||||
X:375
|
||||
|
||||
@@ -389,4 +389,10 @@ Background@SETTINGS_MENU:
|
||||
Y:180
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Enable Asset Browser (requires restart)
|
||||
Text:Enable Asset Browser (requires restart)
|
||||
Checkbox@SHOW_FATAL_ERROR_DIALOG_CHECKBOX:
|
||||
X:0
|
||||
Y:210
|
||||
Width:200
|
||||
Height:20
|
||||
Text:Show Fatal Error dialog
|
||||
Reference in New Issue
Block a user