public Lobby(Backend.IHandleEvent parent, SpriteBatch spriteBatch, ContentManager content, Rectangle displayRect, NetPlayer netplayer = null)
: base(parent, spriteBatch, content, displayRect)
{
string myGUID = "";
if (Properties.Settings.Default.guid != "NONE")
{
myGUID = Properties.Settings.Default.guid;
}
else
{
myGUID = Guid.NewGuid().ToString();
Properties.Settings.Default.guid = myGUID;
Properties.Settings.Default.Save();
}
AddChild(_ipEntry = new TextInput(this, spriteBatch, content, new Rectangle(_displayRect.Left + 5, _displayRect.Top + 5, _displayRect.Width - 250, 30), "Server:", "localhost", "Enter a server to connect to or localhost to test locally", -1, true));
AddChild(_playerName = new TextInput(this, spriteBatch, content, new Rectangle(_displayRect.Left + 5, _displayRect.Top + 50, _displayRect.Width - 250, 30), "Computer-ID:", myGUID, "Enter a unique ID for your computer", -1, true));
AddChild(_listPlayers = new Statusbox(this, spriteBatch, content, new Rectangle(_displayRect.Left + 5, _displayRect.Top + 100, _displayRect.Width - 10, _displayRect.Height - 160), true, true));
//_ok = new Button(this, spriteBatch, content, new Rectangle(_displayRect.Right - 90, _displayRect.Bottom - 50, 80, 40), "Ok", (int)Backend.Buttons.Close);
AddChild(_launchServer = new Button(this, spriteBatch, content, new Rectangle(_displayRect.Right - 210, _displayRect.Top + 5, 200, 40), "Launch Server", (int)Backend.Buttons.StartServer));
AddChild(_cancel = new Button(this, spriteBatch, content, new Rectangle(_displayRect.Left + 10, _displayRect.Bottom - 50, 80, 40), "Cancel", (int)Backend.Buttons.Cancel));
AddChild(_connect = new Button(this, spriteBatch, content, new Rectangle(_displayRect.Right - 160, _displayRect.Top + 50, 150, 40), "Connect", (int)Backend.Buttons.Connect));
if (netplayer == null)
{
_network = new NetPlayer(this);
_network.playername = _playerName.text;
}
else
{
_launchServer.Hide();
_network = netplayer;
_network.parent = this;
_ipEntry.text = _network.server;
_playerName.text = _network.playername;
if (netplayer.connected)
{
_connect.label = "Disconnect";
_listPlayers.AddLine("Connected.", Color.Green);
}
else
{
_connect.label = "Connect";
_listPlayers.AddLine("Disconnected.", Color.Red);
}
}
// IP-Entry-Field (Dropdown?)
// Button to launch server
// Entry fField for player name
// List of players
}