Game loads to main menu; "Connect to server" connects to localhost:1234. "Quit" quits.
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user