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 )
|
public void DrawLobby( World world )
|
||||||
{
|
{
|
||||||
buttons.Clear();
|
buttons.Clear();
|
||||||
|
|||||||
@@ -125,19 +125,21 @@ namespace OpenRA
|
|||||||
PerfHistory.items["batches"].hasNormalTick = false;
|
PerfHistory.items["batches"].hasNormalTick = false;
|
||||||
PerfHistory.items["text"].hasNormalTick = false;
|
PerfHistory.items["text"].hasNormalTick = false;
|
||||||
Game.controller = controller;
|
Game.controller = controller;
|
||||||
|
|
||||||
ChangeMap(mapName);
|
ChangeMap(mapName);
|
||||||
|
|
||||||
if (Settings.Replay != "")
|
if (Settings.Replay != "")
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var connection = (string.IsNullOrEmpty(Settings.NetworkHost))
|
orderManager = new OrderManager(new EchoConnection());
|
||||||
? new EchoConnection()
|
|
||||||
: new NetworkConnection( Settings.NetworkHost, Settings.NetworkPort );
|
|
||||||
orderManager = new OrderManager(connection, "replay.rep");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void JoinServer(string host, int port)
|
||||||
|
{
|
||||||
|
orderManager = new OrderManager(new NetworkConnection( host, port ), "replay.rep");
|
||||||
|
}
|
||||||
|
|
||||||
static int lastTime = Environment.TickCount;
|
static int lastTime = Environment.TickCount;
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
switch( Game.orderManager.Connection.ConnectionState )
|
switch( Game.orderManager.Connection.ConnectionState )
|
||||||
{
|
{
|
||||||
|
case ConnectionState.PreConnecting:
|
||||||
|
Game.chrome.DrawMainMenu( world );
|
||||||
|
break;
|
||||||
case ConnectionState.Connecting:
|
case ConnectionState.Connecting:
|
||||||
Game.chrome.DrawDialog("Connecting to {0}:{1}...".F( Game.Settings.NetworkHost, Game.Settings.NetworkPort ));
|
Game.chrome.DrawDialog("Connecting to {0}:{1}...".F( Game.Settings.NetworkHost, Game.Settings.NetworkPort ));
|
||||||
break;
|
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.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -29,6 +29,7 @@ namespace OpenRA.Network
|
|||||||
{
|
{
|
||||||
enum ConnectionState
|
enum ConnectionState
|
||||||
{
|
{
|
||||||
|
PreConnecting,
|
||||||
NotConnected,
|
NotConnected,
|
||||||
Connecting,
|
Connecting,
|
||||||
Connected,
|
Connected,
|
||||||
@@ -58,7 +59,7 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
public virtual ConnectionState ConnectionState
|
public virtual ConnectionState ConnectionState
|
||||||
{
|
{
|
||||||
get { return ConnectionState.Connected; }
|
get { return ConnectionState.PreConnecting; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Send( byte[] packet )
|
public virtual void Send( byte[] packet )
|
||||||
|
|||||||
Reference in New Issue
Block a user