diff --git a/AUTHORS b/AUTHORS
index fe3de9cc40..e69e5760d2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -58,6 +58,7 @@ Also thanks to:
* Olaf van der Spek
* Paolo Chiodi (paolochiodi)
* Paul Dovydaitis (pdovy)
+ * Pavlos Touboulidis (pav)
* Pizzaoverhead
* Psydev
* Raymond Martineau (mart0258)
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index ab8bb3ebb8..97ac3bedb6 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -497,6 +497,7 @@
+
diff --git a/OpenRA.Mods.RA/Widgets/ConfirmationDialogs.cs b/OpenRA.Mods.RA/Widgets/ConfirmationDialogs.cs
new file mode 100644
index 0000000000..a81df9295d
--- /dev/null
+++ b/OpenRA.Mods.RA/Widgets/ConfirmationDialogs.cs
@@ -0,0 +1,42 @@
+#region Copyright & License Information
+/*
+ * 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,
+ * see COPYING.
+ */
+#endregion
+
+using System;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.RA.Widgets
+{
+ public static class ConfirmationDialogs
+ {
+ public static void PromptConfirmAction(string title, string text, Action onConfirm, Action onCancel = null, string confirmText = null, string cancelText = null)
+ {
+ var prompt = Ui.OpenWindow("CONFIRM_PROMPT");
+ prompt.Get("PROMPT_TITLE").GetText = () => title;
+ prompt.Get("PROMPT_TEXT").GetText = () => text;
+ if (!string.IsNullOrEmpty(confirmText))
+ prompt.Get("CONFIRM_BUTTON").GetText = () => confirmText;
+ if (!string.IsNullOrEmpty(cancelText))
+ prompt.Get("CANCEL_BUTTON").GetText = () => cancelText;
+
+ prompt.Get("CONFIRM_BUTTON").OnClick = () =>
+ {
+ Ui.CloseWindow();
+ onConfirm();
+ };
+
+ prompt.Get("CANCEL_BUTTON").OnClick = () =>
+ {
+ Ui.CloseWindow();
+ if (onCancel != null)
+ onCancel();
+ };
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs
index d2e44b17fe..20fc36b20a 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/IngameMenuLogic.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,
@@ -19,11 +19,36 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor]
public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer)
{
- widget.Get("DISCONNECT").OnClick = () =>
+ Action onQuit = () =>
{
onExit();
LeaveGame(world);
};
+ Action onSurrender = () =>
+ {
+ world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
+ onExit();
+ };
+
+ widget.Get("DISCONNECT").OnClick = () =>
+ {
+ bool gameOver = world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
+
+ if (gameOver)
+ {
+ onQuit();
+ }
+ else
+ {
+ widget.Visible = false;
+ ConfirmationDialogs.PromptConfirmAction(
+ "Abort Mission",
+ "Leave this game and return to the menu?",
+ onQuit,
+ () => widget.Visible = true,
+ "Abort");
+ }
+ };
widget.Get("SETTINGS").OnClick = () =>
{
@@ -44,8 +69,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
widget.Get("SURRENDER").OnClick = () =>
{
- world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
- onExit();
+ widget.Visible = false;
+ ConfirmationDialogs.PromptConfirmAction(
+ "Surrender",
+ "Are you sure you want to surrender?",
+ onSurrender,
+ () => widget.Visible = true,
+ "Surrender");
};
widget.Get("SURRENDER").IsVisible = () => world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined;
}
diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml
index b2b5e68141..26226ca239 100644
--- a/mods/d2k/mod.yaml
+++ b/mods/d2k/mod.yaml
@@ -86,6 +86,7 @@ ChromeLayout:
mods/ra/chrome/assetbrowser.yaml
mods/ra/chrome/irc.yaml
mods/ra/chrome/missionbrowser.yaml
+ mods/ra/chrome/confirmation-dialogs.yaml
Weapons:
mods/d2k/weapons.yaml
diff --git a/mods/ra/chrome/confirmation-dialogs.yaml b/mods/ra/chrome/confirmation-dialogs.yaml
new file mode 100644
index 0000000000..972067af83
--- /dev/null
+++ b/mods/ra/chrome/confirmation-dialogs.yaml
@@ -0,0 +1,34 @@
+Background@CONFIRM_PROMPT:
+ X: (WINDOW_RIGHT - WIDTH)/2
+ Y: (WINDOW_BOTTOM - 90)/2
+ Width: 370
+ Height: 175
+ Children:
+ Label@PROMPT_TITLE:
+ Width: PARENT_RIGHT
+ Y: 20
+ Height: 25
+ Font: Bold
+ Align: Center
+ Label@PROMPT_TEXT:
+ X: 15
+ Y: 50
+ Width: PARENT_RIGHT - 30
+ Height: 65
+ Align: Center
+ Button@CONFIRM_BUTTON:
+ X: 20
+ Y: PARENT_BOTTOM - 45
+ Width: 160
+ Height: 25
+ Text: Confirm
+ Font: Bold
+ Key: return
+ Button@CANCEL_BUTTON:
+ X: PARENT_RIGHT - 180
+ Y: PARENT_BOTTOM - 45
+ Width: 160
+ Height: 25
+ Text: Cancel
+ Font: Bold
+ Key: escape
diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml
index d1c158812c..b9100eb0e0 100644
--- a/mods/ra/mod.yaml
+++ b/mods/ra/mod.yaml
@@ -100,6 +100,7 @@ ChromeLayout:
mods/ra/chrome/assetbrowser.yaml
mods/ra/chrome/irc.yaml
mods/ra/chrome/missionbrowser.yaml
+ mods/ra/chrome/confirmation-dialogs.yaml
Weapons:
mods/ra/weapons.yaml
diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml
index ea0fa1de89..be67fd7cbb 100644
--- a/mods/ts/mod.yaml
+++ b/mods/ts/mod.yaml
@@ -126,6 +126,7 @@ ChromeLayout:
mods/ra/chrome/assetbrowser.yaml
mods/ra/chrome/irc.yaml
mods/ra/chrome/missionbrowser.yaml
+ mods/ra/chrome/confirmation-dialogs.yaml
Weapons:
mods/ts/weapons.yaml