From fe6831a095043a8f78c425a0a00a16c359134035 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 3 May 2014 11:48:00 +1200 Subject: [PATCH] Move winforms crash dialog into an external helper. --- Makefile | 14 ++++-- OpenRA.CrashDialog/OpenRA.CrashDialog.csproj | 44 +++++++++++++++++++ .../Program.cs | 25 +++++++---- OpenRA.Game/OpenRA.Game.csproj | 1 - OpenRA.Game/Platform.cs | 11 +++++ OpenRA.Game/Support/Program.cs | 2 +- OpenRA.sln | 10 +++++ packaging/package-all.sh | 2 +- packaging/windows/OpenRA.nsi | 2 + 9 files changed, 96 insertions(+), 15 deletions(-) create mode 100644 OpenRA.CrashDialog/OpenRA.CrashDialog.csproj rename OpenRA.Game/Support/FatalErrorDialog.cs => OpenRA.CrashDialog/Program.cs (74%) diff --git a/Makefile b/Makefile index 555bda430a..9257b20c46 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/OpenRA.CrashDialog/OpenRA.CrashDialog.csproj b/OpenRA.CrashDialog/OpenRA.CrashDialog.csproj new file mode 100644 index 0000000000..c843a1388b --- /dev/null +++ b/OpenRA.CrashDialog/OpenRA.CrashDialog.csproj @@ -0,0 +1,44 @@ + + + + Debug + AnyCPU + {47F1B0EE-EB35-47F2-93E4-273C70909157} + Exe + OpenRA + OpenRA.CrashDialog + + + true + full + false + ..\ + DEBUG;TRACE + prompt + 4 + true + + + full + true + ..\ + prompt + 4 + true + + + + + + + + + {0DFB103F-2962-400F-8C6D-E2C28CCBA633} + OpenRA.Game + + + + + + + \ No newline at end of file diff --git a/OpenRA.Game/Support/FatalErrorDialog.cs b/OpenRA.CrashDialog/Program.cs similarity index 74% rename from OpenRA.Game/Support/FatalErrorDialog.cs rename to OpenRA.CrashDialog/Program.cs index da08c990d5..78111f1511 100644 --- a/OpenRA.Game/Support/FatalErrorDialog.cs +++ b/OpenRA.CrashDialog/Program.cs @@ -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 { } } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 14e6702f1b..c3d0a909df 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -154,7 +154,6 @@ - diff --git a/OpenRA.Game/Platform.cs b/OpenRA.Game/Platform.cs index ba07eb512b..dc9b81b33c 100644 --- a/OpenRA.Game/Platform.cs +++ b/OpenRA.Game/Platform.cs @@ -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); + } } } diff --git a/OpenRA.Game/Support/Program.cs b/OpenRA.Game/Support/Program.cs index 7d85451537..6f08505c5f 100644 --- a/OpenRA.Game/Support/Program.cs +++ b/OpenRA.Game/Support/Program.cs @@ -62,7 +62,7 @@ namespace OpenRA if (Game.Settings.Debug.ShowFatalErrorDialog && !Game.Settings.Server.Dedicated) { Game.Renderer.Device.Quit(); - FatalErrorDialog.Show(); + Platform.ShowFatalErrorDialog(); } } diff --git a/OpenRA.sln b/OpenRA.sln index 78426b87a9..339ff8f46b 100644 --- a/OpenRA.sln +++ b/OpenRA.sln @@ -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 diff --git a/packaging/package-all.sh b/packaging/package-all.sh index 42c94ce194..27493d24f6 100755 --- a/packaging/package-all.sh +++ b/packaging/package-all.sh @@ -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' \ diff --git a/packaging/windows/OpenRA.nsi b/packaging/windows/OpenRA.nsi index 800cea47f9..070ecb245c 100644 --- a/packaging/windows/OpenRA.nsi +++ b/packaging/windows/OpenRA.nsi @@ -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