From 8933b201f152f0a33da267f137a245aac51a9449 Mon Sep 17 00:00:00 2001 From: Mark Olson Date: Tue, 22 Nov 2011 22:55:27 -0600 Subject: [PATCH] Add buttons to Observe or Leave after a user's game ends. --- .../Widgets/Logic/IngameChromeLogic.cs | 24 ++++++++++- mods/ra/chrome/ingame.yaml | 42 ++++++++++++++++--- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs index 8107afafcc..99de4512ef 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs @@ -45,16 +45,29 @@ namespace OpenRA.Mods.RA.Widgets.Logic optionsBG.GetWidget("RESUME").OnClick = () => optionsBG.Visible = false; optionsBG.GetWidget("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("TEXT"); + var postGameObserve = postgameBG.GetWidget("POSTGAME_OBSERVE"); + + var postgameQuit = postgameBG.GetWidget("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; diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index 339151f396..5f6a7edc35 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -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