Hide ingame menu before showing the confirmation dialog

As a bonus, don't show the confirmation dialog if the game is over.
This commit is contained in:
Pavlos Touboulidis
2014-04-22 22:20:45 +03:00
parent a4b5e25087
commit 6ed6288e53

View File

@@ -19,18 +19,35 @@ namespace OpenRA.Mods.RA.Widgets.Logic
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer) public IngameMenuLogic(Widget widget, World world, Action onExit, WorldRenderer worldRenderer)
{ {
Action onQuit = () =>
{
onExit();
LeaveGame(world);
};
Action onSurrender = () =>
{
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
onExit();
};
widget.Get<ButtonWidget>("DISCONNECT").OnClick = () => widget.Get<ButtonWidget>("DISCONNECT").OnClick = () =>
{ {
ConfirmationDialogs.PromptConfirmAction( bool gameOver = world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
"Abort Mission",
"Leave this game and return to the menu?", if (gameOver)
() => {
{ onQuit();
onExit(); }
LeaveGame(world); else
}, {
null, widget.Visible = false;
"Abort"); ConfirmationDialogs.PromptConfirmAction(
"Abort Mission",
"Leave this game and return to the menu?",
onQuit,
() => widget.Visible = true,
"Abort");
}
}; };
widget.Get<ButtonWidget>("SETTINGS").OnClick = () => widget.Get<ButtonWidget>("SETTINGS").OnClick = () =>
@@ -52,15 +69,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
widget.Get<ButtonWidget>("SURRENDER").OnClick = () => widget.Get<ButtonWidget>("SURRENDER").OnClick = () =>
{ {
widget.Visible = false;
ConfirmationDialogs.PromptConfirmAction( ConfirmationDialogs.PromptConfirmAction(
"Surrender", "Surrender",
"Are you sure you want to surrender?", "Are you sure you want to surrender?",
() => onSurrender,
{ () => widget.Visible = true,
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
onExit();
},
null,
"Surrender"); "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;