Add buttons to Observe or Leave after a user's game ends.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user