Add buttons to Observe or Leave after a user's game ends.

This commit is contained in:
Mark Olson
2011-11-22 22:55:27 -06:00
committed by Chris Forbes
parent 2bb968d0d3
commit 8933b201f1
2 changed files with 59 additions and 7 deletions

View File

@@ -45,16 +45,29 @@ namespace OpenRA.Mods.RA.Widgets.Logic
optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = false;
optionsBG.GetWidget<ButtonWidget>("SURRENDER").OnClick = () =>
{
optionsBG.Visible = false;
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
};
optionsBG.GetWidget("SURRENDER").IsVisible = () => (world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined);
var postgameBG = gameRoot.GetWidget("POSTGAME_BG");
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
var postGameObserve = postgameBG.GetWidget<ButtonWidget>("POSTGAME_OBSERVE");
var postgameQuit = postgameBG.GetWidget<ButtonWidget>("POSTGAME_QUIT");
postgameQuit.OnClick = () => LeaveGame(postgameQuit);
postGameObserve.OnClick = () => postgameQuit.Visible = false;
postGameObserve.IsVisible = () => world.LocalPlayer.WinState != WinState.Won;
postgameBG.IsVisible = () =>
{
return world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
return postgameQuit.Visible && world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
};
postgameText.GetText = () =>
{
var state = world.LocalPlayer.WinState;
@@ -63,6 +76,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic
};
}
void LeaveGame(Widget pane)
{
pane.Visible = false;
Game.Disconnect();
Game.LoadShellMap();
Widget.CloseWindow();
Widget.OpenWindow("MAINMENU_BG");
}
void UnregisterEvents()
{
Game.AddChatLine -= AddChatLine;