Issue #4650: Abort Mission Confirmation
Adapted the confirmation dialog from the CnC mod and wired it to the "Abort" and "Surrender" buttons.
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -58,6 +58,7 @@ Also thanks to:
|
|||||||
* Olaf van der Spek
|
* Olaf van der Spek
|
||||||
* Paolo Chiodi (paolochiodi)
|
* Paolo Chiodi (paolochiodi)
|
||||||
* Paul Dovydaitis (pdovy)
|
* Paul Dovydaitis (pdovy)
|
||||||
|
* Pavlos Touboulidis (pav)
|
||||||
* Pizzaoverhead
|
* Pizzaoverhead
|
||||||
* Psydev
|
* Psydev
|
||||||
* Raymond Martineau (mart0258)
|
* Raymond Martineau (mart0258)
|
||||||
|
|||||||
@@ -497,6 +497,7 @@
|
|||||||
<Compile Include="ModChooserLoadScreen.cs" />
|
<Compile Include="ModChooserLoadScreen.cs" />
|
||||||
<Compile Include="Render\WithBuildingPlacedAnimation.cs" />
|
<Compile Include="Render\WithBuildingPlacedAnimation.cs" />
|
||||||
<Compile Include="StartGameNotification.cs" />
|
<Compile Include="StartGameNotification.cs" />
|
||||||
|
<Compile Include="Widgets\ConfirmationDialogs.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||||
|
|||||||
42
OpenRA.Mods.RA/Widgets/ConfirmationDialogs.cs
Normal file
42
OpenRA.Mods.RA/Widgets/ConfirmationDialogs.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2011 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<LabelWidget>("PROMPT_TITLE").GetText = () => title;
|
||||||
|
prompt.Get<LabelWidget>("PROMPT_TEXT").GetText = () => text;
|
||||||
|
if (!string.IsNullOrEmpty(confirmText))
|
||||||
|
prompt.Get<ButtonWidget>("CONFIRM_BUTTON").GetText = () => confirmText;
|
||||||
|
if (!string.IsNullOrEmpty(cancelText))
|
||||||
|
prompt.Get<ButtonWidget>("CANCEL_BUTTON").GetText = () => cancelText;
|
||||||
|
|
||||||
|
prompt.Get<ButtonWidget>("CONFIRM_BUTTON").OnClick = () =>
|
||||||
|
{
|
||||||
|
Ui.CloseWindow();
|
||||||
|
onConfirm();
|
||||||
|
};
|
||||||
|
|
||||||
|
prompt.Get<ButtonWidget>("CANCEL_BUTTON").OnClick = () =>
|
||||||
|
{
|
||||||
|
Ui.CloseWindow();
|
||||||
|
if (onCancel != null)
|
||||||
|
onCancel();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,8 +21,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
widget.Get<ButtonWidget>("DISCONNECT").OnClick = () =>
|
widget.Get<ButtonWidget>("DISCONNECT").OnClick = () =>
|
||||||
{
|
{
|
||||||
onExit();
|
ConfirmationDialogs.PromptConfirmAction(
|
||||||
LeaveGame(world);
|
"Abort Mission",
|
||||||
|
"Leave this game and return to the menu?",
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
onExit();
|
||||||
|
LeaveGame(world);
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
"Abort");
|
||||||
};
|
};
|
||||||
|
|
||||||
widget.Get<ButtonWidget>("SETTINGS").OnClick = () =>
|
widget.Get<ButtonWidget>("SETTINGS").OnClick = () =>
|
||||||
@@ -44,8 +52,16 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
widget.Get<ButtonWidget>("SURRENDER").OnClick = () =>
|
widget.Get<ButtonWidget>("SURRENDER").OnClick = () =>
|
||||||
{
|
{
|
||||||
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
ConfirmationDialogs.PromptConfirmAction(
|
||||||
onExit();
|
"Surrender",
|
||||||
|
"Are you sure you want to surrender?",
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
|
||||||
|
onExit();
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
"Surrender");
|
||||||
};
|
};
|
||||||
widget.Get("SURRENDER").IsVisible = () => world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined;
|
widget.Get("SURRENDER").IsVisible = () => world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
34
mods/ra/chrome/confirmation-dialogs.yaml
Normal file
34
mods/ra/chrome/confirmation-dialogs.yaml
Normal file
@@ -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
|
||||||
@@ -100,6 +100,7 @@ ChromeLayout:
|
|||||||
mods/ra/chrome/assetbrowser.yaml
|
mods/ra/chrome/assetbrowser.yaml
|
||||||
mods/ra/chrome/irc.yaml
|
mods/ra/chrome/irc.yaml
|
||||||
mods/ra/chrome/missionbrowser.yaml
|
mods/ra/chrome/missionbrowser.yaml
|
||||||
|
mods/ra/chrome/confirmation-dialogs.yaml
|
||||||
|
|
||||||
Weapons:
|
Weapons:
|
||||||
mods/ra/weapons.yaml
|
mods/ra/weapons.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user