Move winforms crash dialog into an external helper.

This commit is contained in:
Paul Chote
2014-05-03 11:48:00 +12:00
parent 5b8b01950f
commit fe6831a095
9 changed files with 96 additions and 15 deletions

View File

@@ -66,7 +66,7 @@ INSTALL_PROGRAM = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644
# program targets
CORE = rsdl2 rnull game utility irc
CORE = rsdl2 rnull game utility irc crashdialog
TOOLS = editor tsbuild ralint
VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
@@ -108,7 +108,6 @@ rnull_LIBS = $(COMMON_LIBS) $(rnull_DEPS)
PROGRAMS += rsdl2 rnull
renderers: $(rsdl2_TARGET) $(rnull_TARGET)
##### Official Mods #####
STD_MOD_LIBS = $(game_TARGET) thirdparty/KopiLua.dll thirdparty/NLua.dll
@@ -206,6 +205,15 @@ tsbuild: OpenRA.TilesetBuilder.FormBuilder.resources OpenRA.TilesetBuilder.FormN
##### Launchers / Utilities #####
crashdialog_SRCS := $(shell find OpenRA.CrashDialog/ -iname '*.cs')
crashdialog_TARGET = OpenRA.CrashDialog.exe
crashdialog_KIND = exe
crashdialog_DEPS = $(game_TARGET)
crashdialog_LIBS = $(COMMON_LIBS) $(crashdialog_DEPS) System.Windows.Forms.dll
crashdialog_FLAGS = -win32icon:OpenRA.Game/OpenRA.ico
PROGRAMS += crashdialog
crashdialog: $(crashdialog_TARGET)
# Backend for the launcher apps - queries game/mod info and applies actions to an install
utility_SRCS := $(shell find OpenRA.Utility/ -iname '*.cs')
utility_TARGET = OpenRA.Utility.exe
@@ -245,7 +253,7 @@ $(foreach prog,$(PROGRAMS),$(eval $(call BUILD_ASSEMBLY,$(prog))))
#
default: dependencies core
core: game renderers mods utility
core: game renderers mods utility crashdialog
tools: editor tsbuild ralint

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<RootNamespace>OpenRA</RootNamespace>
<AssemblyName>OpenRA.CrashDialog</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
<Name>OpenRA.Game</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 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,
@@ -11,15 +11,21 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Media;
using System.Reflection;
using System.Windows.Forms;
using OpenRA;
namespace OpenRA
namespace OpenRA.CrashDialog
{
public static class FatalErrorDialog
class FatalErrorDialog
{
public static void Show()
static Settings settings;
public static void Main(string[] args)
{
settings = new Settings(Platform.SupportDir + "settings.yaml", new Arguments());
var form = new Form
{
Size = new Size(315, 140),
@@ -27,7 +33,8 @@ namespace OpenRA
MinimizeBox = false,
MaximizeBox = false,
FormBorderStyle = FormBorderStyle.FixedDialog,
StartPosition = FormStartPosition.CenterScreen
StartPosition = FormStartPosition.CenterScreen,
Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)
};
var notice = new Label
@@ -76,8 +83,8 @@ namespace OpenRA
form.FormClosed += (sender, e) =>
{
Game.Settings.Debug.ShowFatalErrorDialog = !dontShowAgain.Checked;
Game.Settings.Save();
settings.Debug.ShowFatalErrorDialog = !dontShowAgain.Checked;
settings.Save();
};
SystemSounds.Exclamation.Play();
@@ -88,7 +95,7 @@ namespace OpenRA
{
try
{
Process.Start(Log.LogPath);
Process.Start(Platform.SupportDir + "Logs" + Path.DirectorySeparatorChar);
}
catch { }
}
@@ -97,7 +104,7 @@ namespace OpenRA
{
try
{
Process.Start(Game.Settings.Debug.FatalErrorDialogFaq);
Process.Start(settings.Debug.FatalErrorDialogFaq);
}
catch { }
}

View File

@@ -154,7 +154,6 @@
<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" />

View File

@@ -92,5 +92,16 @@ namespace OpenRA
return dir + Path.DirectorySeparatorChar;
}
}
public static void ShowFatalErrorDialog()
{
var process = "OpenRA.CrashDialog.exe";
var args = "";
var psi = new ProcessStartInfo(process, args);
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
Process.Start(psi);
}
}
}

View File

@@ -62,7 +62,7 @@ namespace OpenRA
if (Game.Settings.Debug.ShowFatalErrorDialog && !Game.Settings.Server.Dedicated)
{
Game.Renderer.Device.Quit();
FatalErrorDialog.Show();
Platform.ShowFatalErrorDialog();
}
}

View File

@@ -50,6 +50,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tiberian Dawn Lua scripts",
mods\cnc\maps\gdi03\gdi03.lua = mods\cnc\maps\gdi03\gdi03.lua
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.CrashDialog", "OpenRA.CrashDialog\OpenRA.CrashDialog.csproj", "{47F1B0EE-EB35-47F2-93E4-273C70909157}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -105,6 +107,14 @@ Global
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Any CPU.Build.0 = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{33D03738-C154-4028-8EA8-63A3C488A651}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Release|Any CPU.Build.0 = Release|Any CPU
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{47F1B0EE-EB35-47F2-93E4-273C70909157}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU

View File

@@ -28,7 +28,7 @@ markdown CONTRIBUTING.md > CONTRIBUTING.html
markdown DOCUMENTATION.md > DOCUMENTATION.html
# List of files that are packaged on all platforms
FILES=('OpenRA.Game.exe' 'OpenRA.Editor.exe' 'OpenRA.Utility.exe' \
FILES=('OpenRA.Game.exe' 'OpenRA.Editor.exe' 'OpenRA.Utility.exe' 'OpenRA.CrashDialog.exe' \
'OpenRA.Renderer.Sdl2.dll' 'OpenRA.Renderer.Null.dll' 'OpenRA.Irc.dll' \
'FreeSans.ttf' 'FreeSansBold.ttf' 'lua' \
'glsl' 'mods/common' 'mods/ra' 'mods/cnc' 'mods/d2k' 'mods/modchooser' \

View File

@@ -66,6 +66,7 @@ Section "Game" GAME
SetOutPath "$INSTDIR"
File "${SRCDIR}\OpenRA.Game.exe"
File "${SRCDIR}\OpenRA.Utility.exe"
File "${SRCDIR}\OpenRA.CrashDialog.exe"
File "${SRCDIR}\OpenRA.Renderer.Null.dll"
File "${SRCDIR}\OpenRA.Renderer.Sdl2.dll"
File "${SRCDIR}\OpenRA.Irc.dll"
@@ -186,6 +187,7 @@ Function ${UN}Clean
Delete $INSTDIR\OpenRA.Launcher.exe
Delete $INSTDIR\OpenRA.Game.exe
Delete $INSTDIR\OpenRA.Utility.exe
Delete $INSTDIR\OpenRA.CrashDialog.exe
Delete $INSTDIR\OpenRA.Editor.exe
Delete $INSTDIR\OpenRA.Renderer.Null.dll
Delete $INSTDIR\OpenRA.Renderer.Sdl2.dll