Merge branch 'master' into new-netcode
Conflicts: Subsurface/Properties/AssemblyInfo.cs Subsurface/Source/Characters/Animation/HumanoidAnimController.cs Subsurface/Source/Characters/Character.cs Subsurface/Source/Items/Components/Door.cs Subsurface/Source/Items/Components/Power/PowerContainer.cs Subsurface/Source/Items/Components/Signal/Wire.cs Subsurface/Source/Items/Item.cs Subsurface/Source/Networking/ChatMessage.cs Subsurface/Source/Networking/GameClient.cs Subsurface/Source/Networking/GameServer.cs Subsurface/Source/Networking/GameServerLogin.cs Subsurface/Source/Networking/GameServerSettings.cs Subsurface/Source/Networking/NetworkMember.cs
This commit is contained in:
@@ -25,6 +25,8 @@ namespace Barotrauma
|
||||
|
||||
private GUITextBox nameBox;
|
||||
|
||||
private GUIFrame hullVolumeFrame;
|
||||
|
||||
const int PreviouslyUsedCount = 10;
|
||||
private GUIListBox previouslyUsedList;
|
||||
|
||||
@@ -63,6 +65,41 @@ namespace Barotrauma
|
||||
return "Structures: " + (MapEntity.mapEntityList.Count - Item.ItemList.Count);
|
||||
}
|
||||
|
||||
private string GetTotalHullVolume()
|
||||
{
|
||||
float totalVol = 0.0f;
|
||||
Hull.hullList.ForEach(h => { totalVol += h.FullVolume; });
|
||||
return "Total Hull Volume:\n" + totalVol;
|
||||
}
|
||||
|
||||
private string GetSelectedHullVolume()
|
||||
{
|
||||
float buoyancyVol = 0.0f;
|
||||
float selectedVol = 0.0f;
|
||||
float neutralPercentage = 0.07f;
|
||||
Hull.hullList.ForEach(h => {
|
||||
buoyancyVol += h.FullVolume;
|
||||
if (h.IsSelected)
|
||||
{
|
||||
selectedVol += h.FullVolume;
|
||||
}
|
||||
});
|
||||
buoyancyVol *= neutralPercentage;
|
||||
string retVal = "Selected Hull Volume:\n" + selectedVol;
|
||||
if (selectedVol>0.0f && buoyancyVol>0.0f)
|
||||
{
|
||||
if (buoyancyVol / selectedVol < 1.0f)
|
||||
{
|
||||
retVal += " (optimal NeutralBallastLevel is " + (buoyancyVol / selectedVol).ToString("0.00") + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal += " (insufficient volume for buoyancy control)";
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private string GetPhysicsBodyCount()
|
||||
{
|
||||
return "Physics bodies: " + GameMain.World.BodyList.Count;
|
||||
@@ -89,6 +126,16 @@ namespace Barotrauma
|
||||
topPanel = new GUIFrame(new Rectangle(0, 0, 0, 31), GUI.Style);
|
||||
topPanel.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
|
||||
hullVolumeFrame = new GUIFrame(new Rectangle(145, 26, 280, 70), GUI.Style, topPanel);
|
||||
hullVolumeFrame.Visible = false;
|
||||
hullVolumeFrame.Padding = new Vector4(3.0f, 3.0f, 3.0f, 3.0f);
|
||||
|
||||
GUITextBlock totalHullVolume = new GUITextBlock(new Rectangle(0, 0, 0, 20), "", GUI.Style, hullVolumeFrame, GUI.SmallFont);
|
||||
totalHullVolume.TextGetter = GetTotalHullVolume;
|
||||
|
||||
GUITextBlock selectedHullVolume = new GUITextBlock(new Rectangle(0, 30, 0, 20), "", GUI.Style, hullVolumeFrame, GUI.SmallFont);
|
||||
selectedHullVolume.TextGetter = GetSelectedHullVolume;
|
||||
|
||||
var button = new GUIButton(new Rectangle(0, 0, 70, 20), "Open...", GUI.Style, topPanel);
|
||||
button.OnClicked = CreateLoadScreen;
|
||||
|
||||
@@ -250,8 +297,8 @@ namespace Barotrauma
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
|
||||
GUIComponent.MouseOn = null;
|
||||
|
||||
GUIComponent.ForceMouseOn(null);
|
||||
characterMode = false;
|
||||
|
||||
if (Submarine.MainSub != null)
|
||||
@@ -278,7 +325,7 @@ namespace Barotrauma
|
||||
{
|
||||
base.Deselect();
|
||||
|
||||
GUIComponent.MouseOn = null;
|
||||
GUIComponent.ForceMouseOn(null);
|
||||
|
||||
MapEntityPrefab.Selected = null;
|
||||
|
||||
@@ -298,7 +345,7 @@ namespace Barotrauma
|
||||
|
||||
private void CreateDummyCharacter()
|
||||
{
|
||||
if (dummyCharacter != null) dummyCharacter.Remove();
|
||||
if (dummyCharacter != null) RemoveDummyCharacter();
|
||||
|
||||
dummyCharacter = Character.Create(Character.HumanConfigFile, Vector2.Zero);
|
||||
|
||||
@@ -588,7 +635,7 @@ namespace Barotrauma
|
||||
characterMode = !characterMode;
|
||||
//button.Color = (characterMode) ? Color.Gold : Color.White;
|
||||
|
||||
wiringMode = false;
|
||||
wiringMode = false;
|
||||
|
||||
if (characterMode)
|
||||
{
|
||||
@@ -602,7 +649,6 @@ namespace Barotrauma
|
||||
foreach (MapEntity me in MapEntity.mapEntityList)
|
||||
{
|
||||
me.IsHighlighted = false;
|
||||
me.IsSelected = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -658,7 +704,7 @@ namespace Barotrauma
|
||||
|
||||
private GUIFrame CreateWiringPanel()
|
||||
{
|
||||
GUIFrame frame = new GUIFrame(new Rectangle(0,0,50,300), null, Alignment.Right | Alignment.CenterY, GUI.Style);
|
||||
GUIFrame frame = new GUIFrame(new Rectangle(0,0,65,300), null, Alignment.Right | Alignment.CenterY, GUI.Style);
|
||||
frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
|
||||
GUIListBox listBox = new GUIListBox(Rectangle.Empty, GUI.Style, frame);
|
||||
@@ -769,7 +815,7 @@ namespace Barotrauma
|
||||
|
||||
MapEntityPrefab.SelectPrefab(obj);
|
||||
selectedTab = -1;
|
||||
GUIComponent.MouseOn = null;
|
||||
GUIComponent.ForceMouseOn(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -804,6 +850,43 @@ namespace Barotrauma
|
||||
previouslyUsedList.children.Insert(0, textBlock);
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
if (tutorial != null) tutorial.AddToGUIUpdateList();
|
||||
|
||||
if (MapEntity.SelectedList.Count == 1)
|
||||
{
|
||||
MapEntity.SelectedList[0].AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
leftPanel.AddToGUIUpdateList();
|
||||
topPanel.AddToGUIUpdateList();
|
||||
|
||||
if (wiringMode)
|
||||
{
|
||||
wiringToolPanel.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
if (loadFrame != null)
|
||||
{
|
||||
loadFrame.AddToGUIUpdateList();
|
||||
}
|
||||
else if (saveFrame != null)
|
||||
{
|
||||
saveFrame.AddToGUIUpdateList();
|
||||
}
|
||||
else if (selectedTab > -1)
|
||||
{
|
||||
GUItabs[selectedTab].AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
if ((characterMode || wiringMode) && dummyCharacter != null)
|
||||
{
|
||||
CharacterHUD.AddToGUIUpdateList(dummyCharacter);
|
||||
}
|
||||
|
||||
GUI.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to run logic such as updating the world,
|
||||
@@ -814,15 +897,11 @@ namespace Barotrauma
|
||||
{
|
||||
if (tutorial != null) tutorial.Update((float)deltaTime);
|
||||
|
||||
hullVolumeFrame.Visible = MapEntity.SelectedList.Any(s => s is Hull);
|
||||
|
||||
if (GUIComponent.MouseOn == null)
|
||||
{
|
||||
//if (nameBox.Selected && PlayerInput.LeftButtonClicked())
|
||||
//{
|
||||
// ChangeSubName(nameBox, nameBox.Text);
|
||||
//}
|
||||
|
||||
cam.MoveCamera((float)deltaTime);
|
||||
//cam.Zoom = MathHelper.Clamp(cam.Zoom + (PlayerInput.ScrollWheelSpeed / 1000.0f)*cam.Zoom, 0.1f, 2.0f);
|
||||
}
|
||||
|
||||
if (characterMode || wiringMode)
|
||||
@@ -845,6 +924,7 @@ namespace Barotrauma
|
||||
{
|
||||
limb.body.SetTransform(mouseSimPos, 0.0f);
|
||||
}
|
||||
dummyCharacter.AnimController.Collider.SetTransform(mouseSimPos, 0.0f);
|
||||
}
|
||||
|
||||
dummyCharacter.ControlLocalPlayer((float)deltaTime, cam, false);
|
||||
@@ -853,22 +933,20 @@ namespace Barotrauma
|
||||
dummyCharacter.Submarine = Submarine.MainSub;
|
||||
|
||||
cam.TargetPos = Vector2.Zero;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
MapEntity.UpdateSelecting(cam);
|
||||
}
|
||||
|
||||
GUIComponent.MouseOn = null;
|
||||
//GUIComponent.ForceMouseOn(null);
|
||||
|
||||
if (!characterMode && !wiringMode)
|
||||
{
|
||||
if (MapEntityPrefab.Selected != null) MapEntityPrefab.Selected.UpdatePlacing(cam);
|
||||
|
||||
MapEntity.UpdateEditor(cam);
|
||||
|
||||
MapEntity.UpdateEditor(cam);
|
||||
}
|
||||
|
||||
leftPanel.Update((float)deltaTime);
|
||||
@@ -906,9 +984,10 @@ namespace Barotrauma
|
||||
foreach (Item item in dummyCharacter.SelectedItems)
|
||||
{
|
||||
if (item == null) continue;
|
||||
item.SetTransform(dummyCharacter.SimPosition, 0.0f);
|
||||
|
||||
item.SetTransform(dummyCharacter.SimPosition, 0.0f);
|
||||
item.Update(cam, (float)deltaTime);
|
||||
item.SetTransform(item.body.SimPosition, 0.0f);
|
||||
}
|
||||
|
||||
if (dummyCharacter.SelectedConstruction != null)
|
||||
|
||||
@@ -90,7 +90,22 @@ namespace Barotrauma
|
||||
|
||||
Sounds.SoundManager.LowPassHFGain = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null)
|
||||
{
|
||||
if (Character.Controlled.SelectedConstruction == Character.Controlled.ClosestItem)
|
||||
{
|
||||
Character.Controlled.SelectedConstruction.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
|
||||
if (GameMain.GameSession != null) GameMain.GameSession.AddToGUIUpdateList();
|
||||
|
||||
Character.AddAllToGUIUpdateList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to run logic such as updating the world,
|
||||
/// checking for collisions, gathering input, and playing audio.
|
||||
@@ -117,6 +132,11 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
{
|
||||
e.IsHighlighted = false;
|
||||
}
|
||||
|
||||
if (GameMain.GameSession != null) GameMain.GameSession.Update((float)deltaTime);
|
||||
|
||||
if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime);
|
||||
@@ -129,7 +149,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
Character.UpdateAll(cam, (float)deltaTime);
|
||||
|
||||
|
||||
BackgroundCreatureManager.Update(cam, (float)deltaTime);
|
||||
|
||||
GameMain.ParticleManager.Update((float)deltaTime);
|
||||
@@ -220,22 +240,6 @@ namespace Barotrauma
|
||||
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
|
||||
}
|
||||
|
||||
List<Submarine> visibleSubs = new List<Submarine>();
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
{
|
||||
Rectangle worldBorders = new Rectangle(
|
||||
sub.Borders.X + (int)sub.WorldPosition.X - 500,
|
||||
sub.Borders.Y + (int)sub.WorldPosition.Y + 500,
|
||||
sub.Borders.Width + 1000,
|
||||
sub.Borders.Height + 1000);
|
||||
|
||||
|
||||
if (Submarine.RectsOverlap(worldBorders, cam.WorldView))
|
||||
{
|
||||
visibleSubs.Add(sub);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//1. draw the background, characters and the parts of the submarine that are behind them
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
@@ -341,6 +341,14 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
base.AddToGUIUpdateList();
|
||||
|
||||
topPanel.AddToGUIUpdateList();
|
||||
bottomPanel[selectedRightPanel].AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
@@ -467,6 +467,12 @@ namespace Barotrauma
|
||||
menuTabs[(int)Tab.LoadGame].RemoveChild(prevFrame);
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
buttonsTab.AddToGUIUpdateList();
|
||||
if (selectedTab > 0) menuTabs[selectedTab].AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
//GameMain.TitleScreen.Update();
|
||||
|
||||
@@ -9,6 +9,8 @@ using FarseerPhysics.Dynamics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -61,10 +63,15 @@ namespace Barotrauma
|
||||
private Sprite backgroundSprite;
|
||||
|
||||
private GUITextBox serverMessage;
|
||||
public string ServerMessage
|
||||
//public string ServerMessage
|
||||
//{
|
||||
// get { return serverMessage.Text; }
|
||||
// set { if (GameMain.Server != null) return; serverMessage.Text = value; }
|
||||
//}
|
||||
|
||||
public GUITextBox ServerMessage
|
||||
{
|
||||
get { return serverMessage.Text; }
|
||||
set { if (GameMain.Server != null) return; serverMessage.Text = value; }
|
||||
get { return serverMessage; }
|
||||
}
|
||||
|
||||
public GUIListBox SubList
|
||||
@@ -793,12 +800,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
playerFrame = new GUIFrame(new Rectangle(0, 0, 0, 0), Color.Black * 0.3f);
|
||||
playerFrame = new GUIFrame(new Rectangle(0, 0, 0, 0), Color.Black * 0.6f);
|
||||
|
||||
var playerFrameInner = new GUIFrame(new Rectangle(0, 0, 300, 250), null, Alignment.Center, GUI.Style, playerFrame);
|
||||
var playerFrameInner = new GUIFrame(new Rectangle(0, 0, 300, 280), null, Alignment.Center, GUI.Style, playerFrame);
|
||||
playerFrameInner.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
||||
|
||||
new GUITextBlock(new Rectangle(0,0,200,20), component.UserData.ToString(),
|
||||
new GUITextBlock(new Rectangle(0, 0, 200, 20), component.UserData.ToString(),
|
||||
GUI.Style, Alignment.TopLeft, Alignment.TopLeft,
|
||||
playerFrameInner, false, GUI.LargeFont);
|
||||
|
||||
@@ -808,50 +815,50 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 25, 150, 15), selectedClient.Connection.RemoteEndPoint.Address.ToString(), GUI.Style, playerFrameInner);
|
||||
|
||||
//var permissionsBox = new GUIFrame(new Rectangle(0, 60, 0, 85), GUI.Style, playerFrameInner);
|
||||
//permissionsBox.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
//permissionsBox.UserData = selectedClient;
|
||||
var permissionsBox = new GUIFrame(new Rectangle(0, 60, 0, 90), GUI.Style, playerFrameInner);
|
||||
permissionsBox.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
permissionsBox.UserData = selectedClient;
|
||||
|
||||
//new GUITextBlock(new Rectangle(0, 0, 0, 15), "Permissions:", GUI.Style, permissionsBox);
|
||||
//int x = 0, y = 0;
|
||||
//foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
|
||||
//{
|
||||
// if (permission == ClientPermissions.None) continue;
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 15), "Permissions:", GUI.Style, permissionsBox);
|
||||
int x = 0, y = 0;
|
||||
foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
|
||||
{
|
||||
if (permission == ClientPermissions.None) continue;
|
||||
|
||||
// FieldInfo fi = typeof(ClientPermissions).GetField(permission.ToString());
|
||||
// DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
FieldInfo fi = typeof(ClientPermissions).GetField(permission.ToString());
|
||||
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
|
||||
// string permissionStr = attributes.Length > 0 ? attributes[0].Description : permission.ToString();
|
||||
|
||||
// var permissionTick = new GUITickBox(new Rectangle(x,y+20,15,15), permissionStr, Alignment.TopLeft, GUI.SmallFont, permissionsBox);
|
||||
// permissionTick.UserData = permission;
|
||||
// permissionTick.Selected = selectedClient.HasPermission(permission);
|
||||
string permissionStr = attributes.Length > 0 ? attributes[0].Description : permission.ToString();
|
||||
|
||||
// permissionTick.OnSelected = (tickBox) =>
|
||||
// {
|
||||
// var client = tickBox.Parent.UserData as Client;
|
||||
// if (client == null) return false;
|
||||
var permissionTick = new GUITickBox(new Rectangle(x, y + 20, 15, 15), permissionStr, Alignment.TopLeft, GUI.SmallFont, permissionsBox);
|
||||
permissionTick.UserData = permission;
|
||||
permissionTick.Selected = selectedClient.HasPermission(permission);
|
||||
|
||||
// var thisPermission = (ClientPermissions)tickBox.UserData;
|
||||
permissionTick.OnSelected = (tickBox) =>
|
||||
{
|
||||
var client = tickBox.Parent.UserData as Client;
|
||||
if (client == null) return false;
|
||||
|
||||
// if (tickBox.Selected)
|
||||
// client.GivePermission(thisPermission);
|
||||
// else
|
||||
// client.RemovePermission(thisPermission);
|
||||
var thisPermission = (ClientPermissions)tickBox.UserData;
|
||||
|
||||
// GameMain.Server.UpdateClientPermissions(client);
|
||||
if (tickBox.Selected)
|
||||
client.GivePermission(thisPermission);
|
||||
else
|
||||
client.RemovePermission(thisPermission);
|
||||
|
||||
// return true;
|
||||
// };
|
||||
GameMain.Server.UpdateClientPermissions(client);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
// y += 20;
|
||||
// if (y >= permissionsBox.Rect.Height -20)
|
||||
// {
|
||||
// y = 0;
|
||||
// x += 100;
|
||||
// }
|
||||
//}
|
||||
y += 20;
|
||||
if (y >= permissionsBox.Rect.Height-40)
|
||||
{
|
||||
y = 0;
|
||||
x += 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GameMain.Server != null || GameMain.Client.HasPermission(ClientPermissions.Kick))
|
||||
@@ -941,6 +948,24 @@ namespace Barotrauma
|
||||
playerList.ClearChildren();
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
base.AddToGUIUpdateList();
|
||||
|
||||
if (jobInfoFrame != null)
|
||||
{
|
||||
jobInfoFrame.AddToGUIUpdateList();
|
||||
}
|
||||
else if (playerFrame != null)
|
||||
{
|
||||
playerFrame.AddToGUIUpdateList();
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
@@ -33,6 +33,10 @@ namespace Barotrauma
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public virtual void AddToGUIUpdateList()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Update(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -334,6 +334,11 @@ namespace Barotrauma
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
menu.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
//GameMain.TitleScreen.Update();
|
||||
|
||||
Reference in New Issue
Block a user