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
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
|
||||||
using System.Media;
|
using System.Media;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows.Forms;
|
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]
|
[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
|
var form = new Form
|
||||||
{
|
{
|
||||||
Size = new Size(315, 140),
|
Size = new Size(315, 140),
|
||||||
@@ -34,6 +56,7 @@ namespace OpenRA.CrashDialog
|
|||||||
MaximizeBox = false,
|
MaximizeBox = false,
|
||||||
FormBorderStyle = FormBorderStyle.FixedDialog,
|
FormBorderStyle = FormBorderStyle.FixedDialog,
|
||||||
StartPosition = FormStartPosition.CenterScreen,
|
StartPosition = FormStartPosition.CenterScreen,
|
||||||
|
TopLevel = true,
|
||||||
Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)
|
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),
|
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
|
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
|
var viewLogs = new Button
|
||||||
{
|
{
|
||||||
Location = new Point(10, 80),
|
Location = new Point(10, 80),
|
||||||
Size = new Size(75, 23),
|
Size = new Size(75, 23),
|
||||||
Text = "View Logs"
|
Text = "View Logs"
|
||||||
};
|
};
|
||||||
viewLogs.Click += ViewLogsClicked;
|
|
||||||
form.Controls.Add(viewLogs);
|
|
||||||
|
|
||||||
var viewFaq = new Button
|
var viewFaq = new Button
|
||||||
{
|
{
|
||||||
Location = new Point(90, 80),
|
Location = new Point(90, 80),
|
||||||
Size = new Size(75, 23),
|
Size = new Size(75, 23),
|
||||||
Text = "View FAQ"
|
Text = "View FAQ"
|
||||||
};
|
};
|
||||||
viewFaq.Click += ViewFaqClicked;
|
|
||||||
form.Controls.Add(viewFaq);
|
|
||||||
|
|
||||||
var quit = new Button
|
var quit = new Button
|
||||||
{
|
{
|
||||||
Location = new Point(225, 80),
|
Location = new Point(225, 80),
|
||||||
Size = new Size(75, 23),
|
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.Controls.Add(quit);
|
||||||
|
|
||||||
form.FormClosed += (sender, e) =>
|
viewLogs.Click += ViewLogsClicked;
|
||||||
{
|
viewFaq.Click += ViewFaqClicked;
|
||||||
settings.Debug.ShowFatalErrorDialog = !dontShowAgain.Checked;
|
form.FormClosed += FormClosed;
|
||||||
settings.Save();
|
|
||||||
};
|
|
||||||
|
|
||||||
SystemSounds.Exclamation.Play();
|
SystemSounds.Exclamation.Play();
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void GameProcessExited(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (gameProcess.ExitCode != 0)
|
||||||
|
ShowErrorDialog();
|
||||||
|
|
||||||
|
Exit();
|
||||||
|
}
|
||||||
|
|
||||||
static void ViewLogsClicked(object sender, EventArgs e)
|
static void ViewLogsClicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.Start(Platform.ResolvePath("^", "Logs"));
|
Process.Start(Platform.ResolvePath("^", "Logs"));
|
||||||
}
|
}
|
||||||
catch { }
|
catch
|
||||||
|
{ }
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ViewFaqClicked(object sender, EventArgs e)
|
static void ViewFaqClicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
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">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
<ProjectGuid>{47F1B0EE-EB35-47F2-93E4-273C70909157}</ProjectGuid>
|
<ProjectGuid>{68295755-7902-4602-AC2C-9A8AC36D5EF7}</ProjectGuid>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>OpenRA</RootNamespace>
|
<RootNamespace>OpenRA</RootNamespace>
|
||||||
<AssemblyName>OpenRA.CrashDialog</AssemblyName>
|
<AssemblyName>OpenRA</AssemblyName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="GameMonitor.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -70,7 +70,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "System Lua scripts", "Syste
|
|||||||
lua\stacktraceplus.lua = lua\stacktraceplus.lua
|
lua\stacktraceplus.lua = lua\stacktraceplus.lua
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -101,8 +101,8 @@ Global
|
|||||||
{5457CBF5-4CE4-421E-A8BF-9FD6C9732E1D}.Debug|x86.Build.0 = Debug|x86
|
{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.ActiveCfg = Debug|x86
|
||||||
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|x86.Build.0 = Debug|x86
|
{33D03738-C154-4028-8EA8-63A3C488A651}.Debug|x86.Build.0 = Debug|x86
|
||||||
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Debug|x86.ActiveCfg = Debug|x86
|
{68295755-7902-4602-AC2C-9A8AC36D5EF7}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Debug|x86.Build.0 = Debug|x86
|
{68295755-7902-4602-AC2C-9A8AC36D5EF7}.Debug|x86.Build.0 = Debug|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user