Merge remote-tracking branch 'refs/remotes/barotrauma/master'

Conflicts:
	Subsurface/Properties/AssemblyInfo.cs
	Subsurface/Source/Characters/Character.cs
This commit is contained in:
juanjp600
2016-09-07 17:35:18 -03:00
14 changed files with 159 additions and 148 deletions
@@ -77,7 +77,7 @@ namespace Barotrauma
{ {
UpdateSineAnim(deltaTime); UpdateSineAnim(deltaTime);
} }
else else if (currentHull != null && CanEnterSubmarine)
{ {
UpdateWalkAnim(deltaTime); UpdateWalkAnim(deltaTime);
} }
@@ -119,7 +119,6 @@ namespace Barotrauma
} }
} }
//if (stunTimer > gameTime.TotalGameTime.TotalMilliseconds) return;
if (!flip) return; if (!flip) return;
flipTimer += deltaTime; flipTimer += deltaTime;
+1 -10
View File
@@ -99,14 +99,6 @@ namespace Barotrauma
} }
character.AddDamage(CauseOfDeath.Husk, 0.5f*deltaTime, null); character.AddDamage(CauseOfDeath.Husk, 0.5f*deltaTime, null);
if (character.AnimController.limbJoints[0].LimitEnabled &&
(character.AnimController.CurrentHull == null ||
character.AnimController.CurrentHull.LethalPressure > 50.0f))
{
character.BreakJoints();
character.AnimController.limbJoints.Last().LimitEnabled = true;
}
} }
@@ -142,11 +134,10 @@ namespace Barotrauma
} }
var torso = character.AnimController.GetLimb(LimbType.Torso); var torso = character.AnimController.GetLimb(LimbType.Torso);
torso.body.SetTransform(torso.SimPosition, 0.0f);
var newLimb = new Limb(character, limbElement); var newLimb = new Limb(character, limbElement);
newLimb.body.Submarine = character.Submarine; newLimb.body.Submarine = character.Submarine;
newLimb.body.SetTransform(torso.SimPosition, 0.0f); newLimb.body.SetTransform(torso.SimPosition, torso.Rotation);
character.AnimController.AddLimb(newLimb); character.AnimController.AddLimb(newLimb);
character.AnimController.AddJoint(jointElement); character.AnimController.AddJoint(jointElement);
+18 -20
View File
@@ -223,26 +223,6 @@ namespace Barotrauma
caretVisible = ((caretTimer * 1000.0f) % 1000) < 500; caretVisible = ((caretTimer * 1000.0f) % 1000) < 500;
} }
if (rect.Contains(PlayerInput.MousePosition))
{
state = ComponentState.Hover;
if (PlayerInput.LeftButtonClicked())
{
if (MouseOn != null && MouseOn != this && MouseOn!=textBlock && !MouseOn.IsParentOf(this)) return;
Select();
if (OnSelected != null) OnSelected(this, Keys.None);
}
}
else
{
state = ComponentState.None;
}
textBlock.State = state;
if (keyboardDispatcher.Subscriber == this) if (keyboardDispatcher.Subscriber == this)
{ {
Character.DisableControls = true; Character.DisableControls = true;
@@ -268,6 +248,24 @@ namespace Barotrauma
{ {
if (!Visible) return; if (!Visible) return;
if (rect.Contains(PlayerInput.MousePosition) && Enabled &&
(MouseOn == null || MouseOn == this || IsParentOf(MouseOn) || MouseOn.IsParentOf(this)))
{
state = ComponentState.Hover;
if (PlayerInput.LeftButtonClicked())
{
Select();
if (OnSelected != null) OnSelected(this, Keys.None);
}
}
else
{
state = ComponentState.None;
}
textBlock.State = state;
DrawChildren(spriteBatch); DrawChildren(spriteBatch);
if (!CaretEnabled) return; if (!CaretEnabled) return;
@@ -133,8 +133,7 @@ namespace Barotrauma.Items.Components
float tempForce; float tempForce;
if (float.TryParse(signal, NumberStyles.Float, CultureInfo.InvariantCulture, out tempForce)) if (float.TryParse(signal, NumberStyles.Float, CultureInfo.InvariantCulture, out tempForce))
{ {
targetForce = tempForce; targetForce = MathHelper.Clamp(tempForce, -100.0f, 100.0f);
targetForce = MathHelper.Clamp(targetForce, -100.0f, 100.0f);
} }
} }
} }
@@ -7,12 +7,13 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
using Voronoi2;
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
{ {
class Steering : Powered class Steering : Powered
{ {
private const float AutopilotRayCastInterval = 5.0f; private const float AutopilotRayCastInterval = 0.5f;
private Vector2 currVelocity; private Vector2 currVelocity;
private Vector2 targetVelocity; private Vector2 targetVelocity;
@@ -179,8 +180,6 @@ namespace Barotrauma.Items.Components
"Depth: " + (int)realWorldDepth + " m", Color.LightGreen, null, 0, GUI.SmallFont); "Depth: " + (int)realWorldDepth + " m", Color.LightGreen, null, 0, GUI.SmallFont);
} }
GUI.DrawLine(spriteBatch, GUI.DrawLine(spriteBatch,
new Vector2(velRect.Center.X,velRect.Center.Y), new Vector2(velRect.Center.X,velRect.Center.Y),
new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y), new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y),
@@ -255,22 +254,72 @@ namespace Barotrauma.Items.Components
SteerTowardsPosition(steeringPath.CurrentNode.WorldPosition); SteerTowardsPosition(steeringPath.CurrentNode.WorldPosition);
} }
float avoidRadius = Math.Max(item.Submarine.Borders.Width, item.Submarine.Borders.Height) * 2.0f;
avoidRadius = Math.Max(avoidRadius, 2000.0f);
Vector2 avoidStrength = Vector2.Zero;
//steer away from nearby walls
var closeCells = Level.Loaded.GetCells(item.Submarine.WorldPosition, 4);
foreach (VoronoiCell cell in closeCells)
{
foreach (GraphEdge edge in cell.edges)
{
var intersection = MathUtils.GetLineIntersection(edge.point1, edge.point2, item.Submarine.WorldPosition, cell.Center);
if (intersection != null)
{
Vector2 diff = item.Submarine.WorldPosition - (Vector2)intersection;
//far enough -> ignore
if (diff.Length() > avoidRadius) continue;
float dot = item.Submarine.Velocity == Vector2.Zero ?
0.0f : Vector2.Dot(Vector2.Normalize(item.Submarine.Velocity), -Vector2.Normalize(diff));
//heading away from the wall -> ignore
if (dot < 0) continue;
Vector2 change = (Vector2.Normalize(diff) * Math.Max((avoidRadius - diff.Length()), 0.0f)) / avoidRadius;
avoidStrength += change * dot;
}
}
}
targetVelocity += avoidStrength * 100.0f;
//steer away from other subs
foreach (Submarine sub in Submarine.Loaded) foreach (Submarine sub in Submarine.Loaded)
{ {
if (sub == item.Submarine) continue; if (sub == item.Submarine) continue;
if (item.Submarine.DockedTo.Contains(sub)) continue;
float thisSize = Math.Max(item.Submarine.Borders.Width, item.Submarine.Borders.Height); float thisSize = Math.Max(item.Submarine.Borders.Width, item.Submarine.Borders.Height);
float otherSize = Math.Max(sub.Borders.Width, sub.Borders.Height); float otherSize = Math.Max(sub.Borders.Width, sub.Borders.Height);
Vector2 diff = sub.WorldPosition - item.Submarine.WorldPosition; Vector2 diff = item.Submarine.WorldPosition - sub.WorldPosition;
float dist = diff == Vector2.Zero ? 0.0f : diff.Length(); float dist = diff == Vector2.Zero ? 0.0f : diff.Length();
//far enough -> ignore
if (dist > thisSize + otherSize) continue; if (dist > thisSize + otherSize) continue;
diff = Vector2.Normalize(diff); diff = Vector2.Normalize(diff);
TargetVelocity = Vector2.Lerp(-diff * 100.0f, TargetVelocity, (dist / (thisSize + otherSize)) - 0.5f); float dot = item.Submarine.Velocity == Vector2.Zero ?
0.0f : Vector2.Dot(Vector2.Normalize(item.Submarine.Velocity), -Vector2.Normalize(diff));
//heading away -> ignore
if (dot < 0.0f) continue;
targetVelocity += diff * 200.0f;
}
//clamp velocity magnitude to 100.0f
float velMagnitude = targetVelocity.Length();
if (velMagnitude > 100.0f)
{
targetVelocity *= 100.0f / velMagnitude;
} }
} }
+8 -12
View File
@@ -113,7 +113,7 @@ namespace Barotrauma
private set; private set;
} }
public Body[] ShaftBodies public Body ShaftBody
{ {
get; get;
private set; private set;
@@ -512,20 +512,16 @@ namespace Barotrauma
} }
} }
ShaftBody = BodyFactory.CreateEdge(GameMain.World,
ConvertUnits.ToSimUnits(new Vector2(borders.X, 0)),
ConvertUnits.ToSimUnits(new Vector2(borders.Right, 0)));
ShaftBodies = new Body[2]; ShaftBody.SetTransform(ConvertUnits.ToSimUnits(new Vector2(0.0f, borders.Height)), 0.0f);
for (int i = 0; i < 2; i++)
{
ShaftBodies[i] = BodyFactory.CreateRectangle(GameMain.World, 200.0f, ConvertUnits.ToSimUnits(ShaftHeight), 5.0f);
ShaftBodies[i].BodyType = BodyType.Static;
ShaftBodies[i].CollisionCategories = Physics.CollisionLevel;
Vector2 shaftPos = (i == 0) ? startPosition : endPosition; ShaftBody.BodyType = BodyType.Static;
shaftPos.Y = borders.Height + 150.0f; ShaftBody.CollisionCategories = Physics.CollisionLevel;
ShaftBodies[i].SetTransform(ConvertUnits.ToSimUnits(shaftPos), 0.0f); bodies.Add(ShaftBody);
bodies.Add(ShaftBodies[i]);
}
foreach (VoronoiCell cell in cells) foreach (VoronoiCell cell in cells)
{ {
+4 -11
View File
@@ -172,11 +172,10 @@ namespace Barotrauma
} }
} }
//RuinGeneration.RuinGenerator.Draw(spriteBatch);
} }
Vector2 pos = new Vector2(0.0f, -level.Size.Y);// level.EndPosition; Vector2 pos = new Vector2(0.0f, -level.Size.Y);
if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y - 1024) return; if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y - 1024) return;
@@ -184,20 +183,14 @@ namespace Barotrauma
int width = (int)(Math.Ceiling(GameMain.GameScreen.Cam.WorldView.Width / 1024 + 4.0f) * 1024); int width = (int)(Math.Ceiling(GameMain.GameScreen.Cam.WorldView.Width / 1024 + 4.0f) * 1024);
GUI.DrawRectangle(spriteBatch,new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)-GameMain.GameScreen.Cam.WorldView.Y, width, (int)(GameMain.GameScreen.Cam.WorldView.Y - level.Size.Y) + 30),Color.Black, true); GUI.DrawRectangle(spriteBatch,new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)-GameMain.GameScreen.Cam.WorldView.Y, width, (int)(GameMain.GameScreen.Cam.WorldView.Y + pos.Y) - 30),Color.Black, true);
spriteBatch.Draw(shaftTexture, spriteBatch.Draw(shaftTexture,
new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)pos.Y, width, 1024), new Rectangle((int)(MathUtils.Round(pos.X, 1024)), (int)pos.Y-1000, width, 1024),
new Rectangle(0, 0, width, 1024), new Rectangle(0, 0, width, -1024),
level.BackgroundColor, 0.0f, level.BackgroundColor, 0.0f,
Vector2.Zero, Vector2.Zero,
SpriteEffects.None, 0.0f); SpriteEffects.None, 0.0f);
//background.DrawTiled(spriteBatch,
// (backgroundPos.Y < 0) ? new Vector2(0.0f, -backgroundPos.Y) : Vector2.Zero,
// new Vector2(GameMain.GraphicsWidth, 1024 - backgroundPos.Y),
// Vector2.Zero, level.BackgroundColor);
} }
+2 -3
View File
@@ -58,8 +58,7 @@ namespace Barotrauma
//Vector2 diff = targetPos - sub.Position; //Vector2 diff = targetPos - sub.Position;
float targetSpeed = 10.0f; float targetSpeed = 10.0f;
Level.Loaded.ShaftBodies[0].Enabled = false; Level.Loaded.ShaftBody.Enabled = false;
Level.Loaded.ShaftBodies[1].Enabled = false;
cam.TargetPos = Vector2.Zero; cam.TargetPos = Vector2.Zero;
float timer = 0.0f; float timer = 0.0f;
@@ -79,7 +78,7 @@ namespace Barotrauma
cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.UnscaledDeltaTime * 0.1f); cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.UnscaledDeltaTime * 0.1f);
Vector2 cameraPos = subs.First().Position + Submarine.MainSub.HiddenSubPosition; Vector2 cameraPos = subs.First().Position + Submarine.MainSub.HiddenSubPosition;
cameraPos.Y = Math.Min(cameraPos.Y, ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBodies[0].Position.Y) - cam.WorldView.Height/2.0f); cameraPos.Y = Math.Min(cameraPos.Y, ConvertUnits.ToDisplayUnits(Level.Loaded.ShaftBody.Position.Y) - cam.WorldView.Height/2.0f);
GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration); GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, timer/duration);
@@ -117,11 +117,6 @@ namespace Barotrauma.Networking
settingsButton.UserData = "settingsButton"; settingsButton.UserData = "settingsButton";
whitelist = new WhiteList(); whitelist = new WhiteList();
GUIButton whitelistButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170 - 170 - 170, 20, 150, 20), "Whitelist", Alignment.TopLeft, GUI.Style, inGameHUD);
whitelistButton.OnClicked = ToggleWhiteListFrame;
whitelistButton.UserData = "whitelistButton";
banList = new BanList(); banList = new BanList();
LoadSettings(); LoadSettings();
@@ -290,7 +285,6 @@ namespace Barotrauma.Networking
{ {
if (ShowNetStats) netStats.Update(deltaTime); if (ShowNetStats) netStats.Update(deltaTime);
if (settingsFrame != null) settingsFrame.Update(deltaTime); if (settingsFrame != null) settingsFrame.Update(deltaTime);
if (whitelist.WhiteListFrame != null) whitelist.WhiteListFrame.Update(deltaTime);
if (!started) return; if (!started) return;
@@ -921,10 +915,6 @@ namespace Barotrauma.Networking
log.LogFrame.Update(0.016f); log.LogFrame.Update(0.016f);
log.LogFrame.Draw(spriteBatch); log.LogFrame.Draw(spriteBatch);
} }
else if (whitelist.WhiteListFrame != null)
{
whitelist.WhiteListFrame.Draw(spriteBatch);
}
if (!ShowNetStats) return; if (!ShowNetStats) return;
@@ -261,14 +261,14 @@ namespace Barotrauma.Networking
new GUITextBlock(new Rectangle(0, -5, 0, 20), "Settings", GUI.Style, innerFrame, GUI.LargeFont); new GUITextBlock(new Rectangle(0, -5, 0, 20), "Settings", GUI.Style, innerFrame, GUI.LargeFont);
string[] tabNames = { "Rounds", "Server", "Banlist" }; string[] tabNames = { "Rounds", "Server", "Banlist", "Whitelist" };
settingsTabs = new GUIFrame[tabNames.Length]; settingsTabs = new GUIFrame[tabNames.Length];
for (int i = 0; i < tabNames.Length; i++) for (int i = 0; i < tabNames.Length; i++)
{ {
settingsTabs[i] = new GUIFrame(new Rectangle(0, 15, 0, innerFrame.Rect.Height - 120), null, Alignment.Center, GUI.Style, innerFrame); settingsTabs[i] = new GUIFrame(new Rectangle(0, 15, 0, innerFrame.Rect.Height - 120), null, Alignment.Center, GUI.Style, innerFrame);
settingsTabs[i].Padding = new Vector4(40.0f, 20.0f, 40.0f, 40.0f); settingsTabs[i].Padding = new Vector4(40.0f, 20.0f, 40.0f, 40.0f);
var tabButton = new GUIButton(new Rectangle(105 * i, 35, 100, 20), tabNames[i], GUI.Style, innerFrame); var tabButton = new GUIButton(new Rectangle(85 * i, 35, 80, 20), tabNames[i], GUI.Style, innerFrame);
tabButton.UserData = i; tabButton.UserData = i;
tabButton.OnClicked = SelectSettingsTab; tabButton.OnClicked = SelectSettingsTab;
} }
@@ -521,6 +521,12 @@ namespace Barotrauma.Networking
banList.CreateBanFrame(settingsTabs[2]); banList.CreateBanFrame(settingsTabs[2]);
//--------------------------------------------------------------------------------
// whitelist
//--------------------------------------------------------------------------------
whitelist.CreateWhiteListFrame(settingsTabs[3]);
} }
public void LoadClientPermissions() public void LoadClientPermissions()
@@ -644,20 +650,6 @@ namespace Barotrauma.Networking
return false; return false;
} }
public bool ToggleWhiteListFrame(GUIButton button, object obj)
{
if (whitelist.WhiteListFrame == null)
{
whitelist.CreateWhiteListFrame();
}
else
{
whitelist.CloseFrame();
}
return false;
}
public void ManagePlayersFrame(GUIFrame infoFrame) public void ManagePlayersFrame(GUIFrame infoFrame)
{ {
GUIListBox cList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.Style, infoFrame); GUIListBox cList = new GUIListBox(new Rectangle(0, 0, 0, 300), Color.White * 0.7f, GUI.Style, infoFrame);
@@ -230,7 +230,7 @@ namespace Barotrauma.Networking
{ {
updateReturnTimer = 0.0f; updateReturnTimer = 0.0f;
respawnShuttle.SubBody.Body.IgnoreCollisionWith(Level.Loaded.ShaftBodies[0]); respawnShuttle.SubBody.Body.IgnoreCollisionWith(Level.Loaded.ShaftBody);
shuttleSteering.AutoPilot = true; shuttleSteering.AutoPilot = true;
shuttleSteering.MaintainPos = false; shuttleSteering.MaintainPos = false;
@@ -298,7 +298,7 @@ namespace Barotrauma.Networking
private IEnumerable<object> ForceShuttleToPos(Vector2 position, float speed) private IEnumerable<object> ForceShuttleToPos(Vector2 position, float speed)
{ {
respawnShuttle.SubBody.Body.IgnoreCollisionWith(Level.Loaded.ShaftBodies[0]); respawnShuttle.SubBody.Body.IgnoreCollisionWith(Level.Loaded.ShaftBody);
while (Math.Abs(position.Y - respawnShuttle.WorldPosition.Y) > 100.0f) while (Math.Abs(position.Y - respawnShuttle.WorldPosition.Y) > 100.0f)
{ {
@@ -309,7 +309,7 @@ namespace Barotrauma.Networking
if (respawnShuttle.SubBody == null) yield return CoroutineStatus.Success; if (respawnShuttle.SubBody == null) yield return CoroutineStatus.Success;
} }
respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBodies[0]); respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBody);
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
@@ -374,7 +374,7 @@ namespace Barotrauma.Networking
respawnShuttle.Velocity = Vector2.Zero; respawnShuttle.Velocity = Vector2.Zero;
respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBodies[0]); respawnShuttle.SubBody.Body.RestoreCollisionWith(Level.Loaded.ShaftBody);
} }
+39 -42
View File
@@ -30,21 +30,15 @@ namespace Barotrauma.Networking
} }
private GUIComponent whitelistFrame; private GUIComponent whitelistFrame;
private GUIComponent innerlistFrame;
private GUITextBox nameBox; private GUITextBox nameBox;
private GUITextBox ipBox; private GUITextBox ipBox;
public bool enabled; public bool Enabled;
public GUIComponent WhiteListFrame
{
get { return whitelistFrame; }
}
public WhiteList() public WhiteList()
{ {
enabled = false; Enabled = false;
whitelistedPlayers = new List<WhiteListedPlayer>(); whitelistedPlayers = new List<WhiteListedPlayer>();
if (File.Exists(SavePath)) if (File.Exists(SavePath))
@@ -69,11 +63,11 @@ namespace Barotrauma.Networking
Int32.TryParse(lineval, out intVal); Int32.TryParse(lineval, out intVal);
if (lineval.ToLower() == "true" || intVal != 0) if (lineval.ToLower() == "true" || intVal != 0)
{ {
enabled = true; Enabled = true;
} }
else else
{ {
enabled = false; Enabled = false;
} }
} }
else else
@@ -96,7 +90,7 @@ namespace Barotrauma.Networking
List<string> lines = new List<string>(); List<string> lines = new List<string>();
if (enabled) if (Enabled)
{ {
lines.Add("#true"); lines.Add("#true");
} }
@@ -121,56 +115,57 @@ namespace Barotrauma.Networking
public bool IsWhiteListed(string name, string ip) public bool IsWhiteListed(string name, string ip)
{ {
if (!enabled) return true; if (!Enabled) return true;
WhiteListedPlayer wlp = whitelistedPlayers.Find(p => p.Name == name); WhiteListedPlayer wlp = whitelistedPlayers.Find(p => p.Name == name);
if (wlp == null) return false; if (wlp == null) return false;
if (wlp.IP != ip && !string.IsNullOrWhiteSpace(wlp.IP)) return false; if (wlp.IP != ip && !string.IsNullOrWhiteSpace(wlp.IP)) return false;
return true; return true;
} }
public GUIComponent CreateWhiteListFrame() public GUIComponent CreateWhiteListFrame(GUIComponent parent)
{ {
whitelistFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f); if (whitelistFrame!=null)
{
whitelistFrame.Parent.ClearChildren();
whitelistFrame = null;
}
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 500, 430), null, Alignment.Center, GUI.Style, whitelistFrame); parent.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
innerFrame.Padding = new Vector4(20.0f, 50.0f, 20.0f, 100.0f);
var closeButton = new GUIButton(new Rectangle(0, 85, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame); var enabledTick = new GUITickBox(new Rectangle(0, 0, 20, 20), "Enabled", Alignment.TopLeft, parent);
closeButton.OnClicked = GameMain.Server.ToggleWhiteListFrame; enabledTick.Selected = Enabled;
new GUITextBlock(new Rectangle(0, -35, 200, 20), "Whitelist", GUI.Style, innerFrame, GUI.LargeFont);
var enabledTick = new GUITickBox(new Rectangle(200, -30, 20, 20), "Enabled", Alignment.Left, innerFrame);
enabledTick.Selected = enabled;
enabledTick.OnSelected = (GUITickBox box) => enabledTick.OnSelected = (GUITickBox box) =>
{ {
enabled = !enabled; Enabled = !Enabled;
if (enabled)
if (Enabled)
{ {
foreach (Client c in GameMain.Server.ConnectedClients) foreach (Client c in GameMain.Server.ConnectedClients)
{ {
if (!IsWhiteListed(c.name,c.Connection.RemoteEndPoint.Address.ToString())) if (!IsWhiteListed(c.name,c.Connection.RemoteEndPoint.Address.ToString()))
{ {
whitelistedPlayers.Add(new WhiteListedPlayer(c.name, c.Connection.RemoteEndPoint.Address.ToString())); whitelistedPlayers.Add(new WhiteListedPlayer(c.name, c.Connection.RemoteEndPoint.Address.ToString()));
CloseFrame(); CreateWhiteListFrame(); if (whitelistFrame != null) CreateWhiteListFrame(whitelistFrame.Parent);
} }
} }
} }
Save(); Save();
return true; return true;
}; };
new GUITextBlock(new Rectangle(0, 35, 90, 25), "Name:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, innerFrame, false, GUI.Font); new GUITextBlock(new Rectangle(0, -25, 90, 20), "Name:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, parent, false, GUI.Font);
nameBox = new GUITextBox(new Rectangle(100, 30, 170, 25), Alignment.BottomLeft, GUI.Style, innerFrame); nameBox = new GUITextBox(new Rectangle(100, -25, 170, 20), Alignment.BottomLeft, GUI.Style, parent);
nameBox.Font = GUI.Font; nameBox.Font = GUI.Font;
new GUITextBlock(new Rectangle(0, 65, 90, 25), "IP Address:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, innerFrame, false, GUI.Font); new GUITextBlock(new Rectangle(0, 5, 90, 20), "IP Address:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, parent, false, GUI.Font);
ipBox = new GUITextBox(new Rectangle(100, 60, 170, 25), Alignment.BottomLeft, GUI.Style, innerFrame); ipBox = new GUITextBox(new Rectangle(100, 5, 170, 20), Alignment.BottomLeft, GUI.Style, parent);
ipBox.Font = GUI.Font; ipBox.Font = GUI.Font;
var addnewButton = new GUIButton(new Rectangle(300, 45, 150, 20), "Add to whitelist", Alignment.BottomLeft, GUI.Style, innerFrame); var addnewButton = new GUIButton(new Rectangle(0, 45, 150, 20), "Add to whitelist", Alignment.BottomLeft, GUI.Style, parent);
addnewButton.OnClicked = AddToWhiteList; addnewButton.OnClicked = AddToWhiteList;
innerlistFrame = new GUIListBox(new Rectangle(0, 0, 0, 0), GUI.Style, innerFrame); whitelistFrame = new GUIListBox(new Rectangle(0, 30, 0, parent.Rect.Height-100), GUI.Style, parent);
foreach (WhiteListedPlayer wlp in whitelistedPlayers) foreach (WhiteListedPlayer wlp in whitelistedPlayers)
{ {
@@ -180,7 +175,7 @@ namespace Barotrauma.Networking
new Rectangle(0, 0, 0, 25), new Rectangle(0, 0, 0, 25),
blockText, blockText,
GUI.Style, GUI.Style,
Alignment.Left, Alignment.Left, innerlistFrame); Alignment.Left, Alignment.Left, whitelistFrame);
textBlock.Padding = new Vector4(10.0f, 10.0f, 0.0f, 0.0f); textBlock.Padding = new Vector4(10.0f, 10.0f, 0.0f, 0.0f);
textBlock.UserData = wlp; textBlock.UserData = wlp;
@@ -189,7 +184,7 @@ namespace Barotrauma.Networking
removeButton.OnClicked = RemoveFromWhiteList; removeButton.OnClicked = RemoveFromWhiteList;
} }
return whitelistFrame; return parent;
} }
private bool RemoveFromWhiteList(GUIButton button, object obj) private bool RemoveFromWhiteList(GUIButton button, object obj)
@@ -202,7 +197,12 @@ namespace Barotrauma.Networking
whitelistedPlayers.Remove(wlp); whitelistedPlayers.Remove(wlp);
Save(); Save();
CloseFrame(); CreateWhiteListFrame();
if (whitelistFrame != null)
{
whitelistFrame.Parent.ClearChildren();
CreateWhiteListFrame(whitelistFrame.Parent);
}
return true; return true;
} }
@@ -210,17 +210,14 @@ namespace Barotrauma.Networking
private bool AddToWhiteList(GUIButton button, object obj) private bool AddToWhiteList(GUIButton button, object obj)
{ {
if (string.IsNullOrWhiteSpace(nameBox.Text)) return false; if (string.IsNullOrWhiteSpace(nameBox.Text)) return false;
if (whitelistedPlayers.Find(x => x.Name.ToLower() == nameBox.Text.ToLower() && x.IP == ipBox.Text) != null) return false; if (whitelistedPlayers.Any(x => x.Name.ToLower() == nameBox.Text.ToLower() && x.IP == ipBox.Text)) return false;
whitelistedPlayers.Add(new WhiteListedPlayer(nameBox.Text,ipBox.Text)); whitelistedPlayers.Add(new WhiteListedPlayer(nameBox.Text,ipBox.Text));
Save(); Save();
CloseFrame(); CreateWhiteListFrame();
return true;
}
public bool CloseFrame(GUIButton button=null, object obj=null)
{
whitelistFrame = null;
if (whitelistFrame != null)
{
CreateWhiteListFrame(whitelistFrame.Parent);
}
return true; return true;
} }
} }
@@ -414,10 +414,6 @@ namespace Barotrauma
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame; settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
settingsButton.UserData = "settingsButton"; settingsButton.UserData = "settingsButton";
GUIButton whitelistButton = new GUIButton(new Rectangle(-200, 0, 80, 30), "Whitelist", Alignment.BottomRight, GUI.Style, infoFrame);
whitelistButton.OnClicked = GameMain.Server.ToggleWhiteListFrame;
whitelistButton.UserData = "whitelistButton";
if (subList.Selected == null) subList.Select(Math.Max(0, prevSelectedSub)); if (subList.Selected == null) subList.Select(Math.Max(0, prevSelectedSub));
if (shuttleList.Selected == null) if (shuttleList.Selected == null)
{ {
+12
View File
@@ -1,3 +1,15 @@
---------------------------------------------------------------------------------------------------------
v0.5.1.3
---------------------------------------------------------------------------------------------------------
- server whitelists
- a new monster
- improved autopilot
- background sprites and creatures can be customized via Content Packages
- Linux clients can connect to Windows servers again (and vice versa)
- fixed the upper boundary of the level occasionally being possible to pass through
- textboxes can't be selected through other UI elements anymore
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
v0.5.1.2 v0.5.1.2
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------