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;
|
||||
|
||||
@@ -38,11 +38,26 @@ Container@INGAME_ROOT:
|
||||
Label@TEXT:
|
||||
Id:TEXT
|
||||
X:(PARENT_RIGHT - WIDTH)/2
|
||||
Y:(PARENT_BOTTOM - HEIGHT)/2
|
||||
Y:0
|
||||
Width:200
|
||||
Height:40
|
||||
Height:80
|
||||
Align:Center
|
||||
Button@POSTGAME_OBSERVE:
|
||||
Id:POSTGAME_OBSERVE
|
||||
X:10
|
||||
Y:(PARENT_BOTTOM - HEIGHT - 10)
|
||||
Width:150
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Observe
|
||||
Button@POSTGAME_QUIT:
|
||||
Id:POSTGAME_QUIT
|
||||
X:(PARENT_RIGHT - WIDTH - 10)
|
||||
Y:(PARENT_BOTTOM - HEIGHT - 10)
|
||||
Width:150
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Leave
|
||||
SupportPowerBin@INGAME_POWERS_BIN:
|
||||
Id:INGAME_POWERS_BIN
|
||||
X:0
|
||||
@@ -162,7 +177,7 @@ Container@INGAME_ROOT:
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Music
|
||||
Font:Bold
|
||||
Font:Bold
|
||||
Button@SURRENDER:
|
||||
Id:SURRENDER
|
||||
X:(PARENT_RIGHT - WIDTH)/2
|
||||
@@ -346,11 +361,26 @@ Container@OBSERVER_ROOT:
|
||||
Label@TEXT:
|
||||
Id:TEXT
|
||||
X:(PARENT_RIGHT - WIDTH)/2
|
||||
Y:(PARENT_BOTTOM - HEIGHT)/2
|
||||
Y:0
|
||||
Width:200
|
||||
Height:40
|
||||
Height:80
|
||||
Align:Center
|
||||
Button@POSTGAME_OBSERVE:
|
||||
Id:POSTGAME_OBSERVE
|
||||
X:10
|
||||
Y:(PARENT_BOTTOM - HEIGHT - 10)
|
||||
Width:150
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Observe
|
||||
Button@POSTGAME_QUIT:
|
||||
Id:POSTGAME_QUIT
|
||||
X:(PARENT_RIGHT - WIDTH - 10)
|
||||
Y:(PARENT_BOTTOM - HEIGHT - 10)
|
||||
Width:150
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:Leave
|
||||
SupportPowerBin@INGAME_POWERS_BIN:
|
||||
Id:INGAME_POWERS_BIN
|
||||
X:0
|
||||
@@ -404,7 +434,7 @@ Container@OBSERVER_ROOT:
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Music
|
||||
Font:Bold
|
||||
Font:Bold
|
||||
Button@SURRENDER:
|
||||
Id:SURRENDER
|
||||
X:(PARENT_RIGHT - WIDTH)/2
|
||||
|
||||
Reference in New Issue
Block a user