diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index 530ba350b5..37cb70f1b1 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -411,6 +411,35 @@ namespace OpenRA } + public void DrawMainMenu( World world ) + { + buttons.Clear(); + + var w = 250; + var h = 200; + var r = new Rectangle( (Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h ); + DrawDialogBackground(r, "dialog"); + DrawCentered("OpenRA Main Menu", new int2(r.Left + w / 2, r.Top + 20), Color.White); + + AddUiButton(new int2(r.Left + w/2, r.Top + 70), "Join Server", + _ => + { + Game.JoinServer("localhost", 1234); + }); + + AddUiButton(new int2(r.Left + w/2, r.Top + 105), "Create Server", + _ => + { + + }); + + AddUiButton(new int2(r.Left + w/2, r.Top + 140), "Quit", + _ => + { + Game.Exit(); + }); + } + public void DrawLobby( World world ) { buttons.Clear(); diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 9a0a770089..97cf78a9c2 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -125,19 +125,21 @@ namespace OpenRA PerfHistory.items["batches"].hasNormalTick = false; PerfHistory.items["text"].hasNormalTick = false; Game.controller = controller; - + ChangeMap(mapName); if (Settings.Replay != "") throw new NotImplementedException(); else { - var connection = (string.IsNullOrEmpty(Settings.NetworkHost)) - ? new EchoConnection() - : new NetworkConnection( Settings.NetworkHost, Settings.NetworkPort ); - orderManager = new OrderManager(connection, "replay.rep"); + orderManager = new OrderManager(new EchoConnection()); } } + + internal static void JoinServer(string host, int port) + { + orderManager = new OrderManager(new NetworkConnection( host, port ), "replay.rep"); + } static int lastTime = Environment.TickCount; diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index ba235b448e..12c5eeec3c 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -85,6 +85,9 @@ namespace OpenRA.Graphics switch( Game.orderManager.Connection.ConnectionState ) { + case ConnectionState.PreConnecting: + Game.chrome.DrawMainMenu( world ); + break; case ConnectionState.Connecting: Game.chrome.DrawDialog("Connecting to {0}:{1}...".F( Game.Settings.NetworkHost, Game.Settings.NetworkPort )); break; diff --git a/OpenRA.Game/Network/Connection.cs b/OpenRA.Game/Network/Connection.cs index a6b3533bc0..7df72e25fb 100755 --- a/OpenRA.Game/Network/Connection.cs +++ b/OpenRA.Game/Network/Connection.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -29,6 +29,7 @@ namespace OpenRA.Network { enum ConnectionState { + PreConnecting, NotConnected, Connecting, Connected, @@ -58,7 +59,7 @@ namespace OpenRA.Network public virtual ConnectionState ConnectionState { - get { return ConnectionState.Connected; } + get { return ConnectionState.PreConnecting; } } public virtual void Send( byte[] packet )