diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index 9e90602e02..4a17f5289b 100755 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -237,8 +237,8 @@ namespace OpenRA.Widgets.Delegates if (slot.Spectator) { template = EmptySlotTemplateHost.Clone(); - var btn = template.GetWidget("JOIN"); var name = template.GetWidget("NAME"); + var btn = template.GetWidget("JOIN"); btn.GetText = () => "Spectate in this slot"; name.GetText = () => s.Closed ? "Closed" : "Open"; name.OnMouseUp = _ => @@ -282,6 +282,12 @@ namespace OpenRA.Widgets.Delegates template = EmptySlotTemplate.Clone(); var name = template.GetWidget("NAME"); name.GetText = () => s.Closed ? "Closed" : "Open"; + + if (slot.Spectator) + { + var btn = template.GetWidget("JOIN"); + btn.GetText = () => "Spectate in this slot"; + } } var join = template.GetWidget("JOIN"); @@ -384,6 +390,15 @@ namespace OpenRA.Widgets.Delegates var status = template.GetWidget("STATUS"); status.Checked = () => c.State == Session.ClientState.Ready; if (c.Index == orderManager.LocalClient.Index) status.OnMouseDown = CycleReady; + + + Session.Slot slot1 = slot; + color.IsVisible = () => !slot1.Spectator; + //colorBlock.IsVisible = () => !slot1.Spectator; + faction.IsVisible = () => !slot1.Spectator; + factionname.IsVisible = () => !slot1.Spectator; + factionflag.IsVisible = () => !slot1.Spectator; + team.IsVisible = () => !slot1.Spectator; } template.Id = "SLOT_{0}".F(s.Index); diff --git a/OpenRA.Mods.RA/Widgets/Delegates/IngameObserverChromeDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/IngameObserverChromeDelegate.cs new file mode 100644 index 0000000000..28db774303 --- /dev/null +++ b/OpenRA.Mods.RA/Widgets/Delegates/IngameObserverChromeDelegate.cs @@ -0,0 +1,85 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see LICENSE. + */ +#endregion + +using OpenRA.Traits; +using OpenRA.Widgets; + +namespace OpenRA.Mods.RA.Widgets.Delegates +{ + public class IngameObserverChromeDelegate : IWidgetDelegate + { + [ObjectCreator.UseCtor] + public IngameObserverChromeDelegate([ObjectCreator.Param] World world) + { + var r = Widget.RootWidget; + var gameRoot = r.GetWidget("OBSERVER_ROOT"); + var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG"); + + r.GetWidget("INGAME_OPTIONS_BUTTON").OnMouseUp = mi => { + optionsBG.Visible = !optionsBG.Visible; + return true; + }; + + optionsBG.GetWidget("DISCONNECT").OnMouseUp = mi => { + optionsBG.Visible = false; + Game.Disconnect(); + return true; + }; + + optionsBG.GetWidget("SETTINGS").OnMouseUp = mi => { + Widget.OpenWindow("SETTINGS_MENU"); + return true; + }; + + optionsBG.GetWidget("MUSIC").OnMouseUp = mi => { + Widget.OpenWindow("MUSIC_MENU"); + return true; + }; + + optionsBG.GetWidget("RESUME").OnMouseUp = mi => + { + optionsBG.Visible = false; + return true; + }; + /* + optionsBG.GetWidget("SURRENDER").OnMouseUp = mi => + { + world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor)); + return true; + }; + */ + optionsBG.GetWidget("SURRENDER").IsVisible = () => false; + + optionsBG.GetWidget("QUIT").OnMouseUp = mi => { + Game.Exit(); + return true; + }; + + Game.AddChatLine += gameRoot.GetWidget("CHAT_DISPLAY").AddLine; + + /* + var postgameBG = gameRoot.GetWidget("POSTGAME_BG"); + var postgameText = postgameBG.GetWidget("TEXT"); + postgameBG.IsVisible = () => + { + return world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined; + }; + + postgameText.GetText = () => + { + if (world.LocalPlayer == null) + return ""; + var state = world.LocalPlayer.WinState; + return (state == WinState.Undefined)? "" : + ((state == WinState.Lost)? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS"); + };*/ + } + } +} diff --git a/mods/ra/chrome/gamelobby.yaml b/mods/ra/chrome/gamelobby.yaml index 96d22546f9..10f6cc57fd 100644 --- a/mods/ra/chrome/gamelobby.yaml +++ b/mods/ra/chrome/gamelobby.yaml @@ -157,7 +157,7 @@ Background@SERVER_LOBBY: Bold: false Checkbox@STATUS: Id:STATUS - X:455 + X:450 Y:2 Width:20 Height:20