Control settings, more server settings, selecting character face

This commit is contained in:
Regalis
2015-10-28 19:07:17 +02:00
parent 9ed2963cd9
commit 948285f6ab
46 changed files with 789 additions and 325 deletions
+6 -43
View File
@@ -9,10 +9,8 @@ using Barotrauma.Networking.ReliableMessages;
namespace Barotrauma.Networking
{
class GameServer : NetworkMember
partial class GameServer : NetworkMember
{
public bool ShowNetStats;
public List<Client> connectedClients = new List<Client>();
//for keeping track of disconnected clients in case the reconnect shortly after
@@ -24,41 +22,13 @@ namespace Barotrauma.Networking
bool started;
private NetServer server;
private NetPeerConfiguration config;
private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
private DateTime sparseUpdateTimer;
private NetPeerConfiguration config;
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 40);
private DateTime sparseUpdateTimer;
private DateTime refreshMasterTimer;
private BanList banList;
private bool masterServerResponded;
private bool registeredToMaster;
private string password;
private bool autoRestart;
public bool AutoRestart
{
get { return (connectedClients.Count==0) ? false : autoRestart; }
set
{
autoRestart = value;
AutoRestartTimer = autoRestart ? 20.0f : 0.0f;
}
}
public float AutoRestartTimer;
public BanList BanList
{
get { return banList; }
}
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
{
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
@@ -238,6 +208,7 @@ namespace Barotrauma.Networking
public override void Update(float deltaTime)
{
if (ShowNetStats) netStats.Update(deltaTime);
if (settingsFrame != null) settingsFrame.Update(deltaTime);
if (!started) return;
@@ -1033,6 +1004,8 @@ namespace Barotrauma.Networking
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
base.Draw(spriteBatch);
if (settingsFrame != null) settingsFrame.Draw(spriteBatch);
if (!ShowNetStats) return;
@@ -1292,16 +1265,6 @@ namespace Barotrauma.Networking
return preferredClient;
}
private byte PlayerCountToByte(int playerCount, int maxPlayers)
{
byte byteVal = (byte)playerCount;
byteVal |= (byte)((maxPlayers-1) << 4);
return byteVal;
}
/// <summary>
/// sends some random data to the clients
/// use for debugging purposes
+10 -12
View File
@@ -109,7 +109,7 @@ namespace Barotrauma.Networking
new Rectangle(chatBox.Rect.X, chatBox.Rect.Y + chatBox.Rect.Height + 20, chatBox.Rect.Width, 25),
Color.White * 0.5f, Color.Black, Alignment.TopLeft, Alignment.Left, GUI.Style, inGameHUD);
chatMsgBox.Font = GUI.SmallFont;
chatMsgBox.OnEnter = EnterChatMessage;
chatMsgBox.OnEnterPressed = EnterChatMessage;
crewButton = new GUIButton(new Rectangle(chatBox.Rect.Right-80, chatBox.Rect.Y-30, 80, 20), "Crew", GUI.Style, inGameHUD);
crewButton.OnClicked = ToggleCrewFrame;
@@ -175,17 +175,6 @@ namespace Barotrauma.Networking
return true;
}
//protected void UpdateCrewFrame(List<Client> connectedClients)
//{
// List<Character> characterList = new List<Character>();
// foreach (Client c in connectedClients)
// {
// if (c.character != null && c.inGame) characterList.Add(c.character);
// }
// CreateCrewFrame(characterList);
//}
public bool EnterChatMessage(GUITextBox textBox, string message)
{
if (string.IsNullOrWhiteSpace(message)) return false;
@@ -268,6 +257,15 @@ namespace Barotrauma.Networking
public virtual void Disconnect() { }
protected byte PlayerCountToByte(int playerCount, int maxPlayers)
{
byte byteVal = (byte)playerCount;
byteVal |= (byte)((maxPlayers - 1) << 4);
return byteVal;
}
public static int ByteToPlayerCount(byte byteVal, out int maxPlayers)
{
maxPlayers = (byteVal >> 4)+1;