Add Game Monitor
Add Game Monitor and update sln. This also removes CrashDialog
This commit is contained in:
committed by
Matthias Mailänder
parent
6a24b28f92
commit
af3e3f795f
@@ -9,23 +9,45 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Media;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace OpenRA.CrashDialog
|
||||
namespace OpenRA
|
||||
{
|
||||
class FatalErrorDialog
|
||||
class GameMonitor
|
||||
{
|
||||
static Settings settings;
|
||||
static string processName = "OpenRA.Game.exe";
|
||||
static Process gameProcess;
|
||||
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
static void Main(string[] args)
|
||||
{
|
||||
settings = new Settings(Platform.ResolvePath("^", "settings.yaml"), new Arguments());
|
||||
var psi = new ProcessStartInfo(processName, string.Join(" ", args));
|
||||
|
||||
try
|
||||
{
|
||||
gameProcess = Process.Start(psi);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameProcess == null)
|
||||
return;
|
||||
|
||||
gameProcess.EnableRaisingEvents = true;
|
||||
gameProcess.Exited += GameProcessExited;
|
||||
|
||||
Application.Run();
|
||||
}
|
||||
|
||||
static void ShowErrorDialog()
|
||||
{
|
||||
var form = new Form
|
||||
{
|
||||
Size = new Size(315, 140),
|
||||
@@ -34,6 +56,7 @@ namespace OpenRA.CrashDialog
|
||||
MaximizeBox = false,
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog,
|
||||
StartPosition = FormStartPosition.CenterScreen,
|
||||
TopLevel = true,
|
||||
Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)
|
||||
};
|
||||
|
||||
@@ -44,69 +67,78 @@ namespace OpenRA.CrashDialog
|
||||
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"
|
||||
Text = "Quit",
|
||||
DialogResult = DialogResult.Cancel
|
||||
};
|
||||
quit.DialogResult = DialogResult.Cancel;
|
||||
|
||||
form.Controls.Add(notice);
|
||||
form.Controls.Add(viewLogs);
|
||||
form.Controls.Add(viewFaq);
|
||||
form.Controls.Add(quit);
|
||||
|
||||
form.FormClosed += (sender, e) =>
|
||||
{
|
||||
settings.Debug.ShowFatalErrorDialog = !dontShowAgain.Checked;
|
||||
settings.Save();
|
||||
};
|
||||
viewLogs.Click += ViewLogsClicked;
|
||||
viewFaq.Click += ViewFaqClicked;
|
||||
form.FormClosed += FormClosed;
|
||||
|
||||
SystemSounds.Exclamation.Play();
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
static void GameProcessExited(object sender, EventArgs e)
|
||||
{
|
||||
if (gameProcess.ExitCode != 0)
|
||||
ShowErrorDialog();
|
||||
|
||||
Exit();
|
||||
}
|
||||
|
||||
static void ViewLogsClicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(Platform.ResolvePath("^", "Logs"));
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
static void ViewFaqClicked(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(settings.Debug.FatalErrorDialogFaq);
|
||||
Process.Start("http://wiki.openra.net/FAQ");
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
static void FormClosed(object sender, EventArgs e)
|
||||
{
|
||||
Exit();
|
||||
}
|
||||
|
||||
static void Exit()
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{47F1B0EE-EB35-47F2-93E4-273C70909157}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{68295755-7902-4602-AC2C-9A8AC36D5EF7}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>OpenRA</RootNamespace>
|
||||
<AssemblyName>OpenRA.CrashDialog</AssemblyName>
|
||||
<AssemblyName>OpenRA</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -34,7 +34,7 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="GameMonitor.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -70,7 +70,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "System Lua scripts", "Syste
|
||||
lua\stacktraceplus.lua = lua\stacktraceplus.lua
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.CrashDialog", "OpenRA.CrashDialog\OpenRA.CrashDialog.csproj", "{47F1B0EE-EB35-47F2-93E4-273C70909157}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.GameMonitor", "OpenRA.GameMonitor\OpenRA.GameMonitor.csproj", "{68295755-7902-4602-AC2C-9A8AC36D5EF7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -101,8 +101,8 @@ Global
|
||||
{5457CBF5-4CE4-421E-A8BF-9FD6C9732E1D}.Debug|x86.Build.0 = Debug|x86
|
||||
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|x86.Build.0 = Debug|x86
|
||||
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Debug|x86.Build.0 = Debug|x86
|
||||
{68295755-7902-4602-AC2C-9A8AC36D5EF7}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{68295755-7902-4602-AC2C-9A8AC36D5EF7}.Debug|x86.Build.0 = Debug|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user