diff --git a/Subsurface/Content/Items/Button/button.xml b/Subsurface/Content/Items/Button/button.xml index dd741add1..ad9cbab20 100644 --- a/Subsurface/Content/Items/Button/button.xml +++ b/Subsurface/Content/Items/Button/button.xml @@ -2,6 +2,7 @@ name="Button" type="Controller" linkable="true" + tags="smallitem" pickdistance="150.0" price="10"> diff --git a/Subsurface/Content/Items/Diving/divingSuit.ogg b/Subsurface/Content/Items/Diving/divingSuit.ogg new file mode 100644 index 000000000..ba1ecf9c6 Binary files /dev/null and b/Subsurface/Content/Items/Diving/divingSuit.ogg differ diff --git a/Subsurface/Content/Items/Electricity/battery.png b/Subsurface/Content/Items/Electricity/battery.png index a53431f6a..63ad87974 100644 Binary files a/Subsurface/Content/Items/Electricity/battery.png and b/Subsurface/Content/Items/Electricity/battery.png differ diff --git a/Subsurface/Content/Items/Electricity/junctionbox.png b/Subsurface/Content/Items/Electricity/junctionbox.png index ed12d154f..4517fd139 100644 Binary files a/Subsurface/Content/Items/Electricity/junctionbox.png and b/Subsurface/Content/Items/Electricity/junctionbox.png differ diff --git a/Subsurface/Content/Items/Electricity/supercapacitor.png b/Subsurface/Content/Items/Electricity/supercapacitor.png index 46eab4595..cdd2b53c4 100644 Binary files a/Subsurface/Content/Items/Electricity/supercapacitor.png and b/Subsurface/Content/Items/Electricity/supercapacitor.png differ diff --git a/Subsurface/Content/Items/OxygenGenerator/battery.png b/Subsurface/Content/Items/OxygenGenerator/battery.png deleted file mode 100644 index a53431f6a..000000000 Binary files a/Subsurface/Content/Items/OxygenGenerator/battery.png and /dev/null differ diff --git a/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.png b/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.png new file mode 100644 index 000000000..19378f2a4 Binary files /dev/null and b/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.png differ diff --git a/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml b/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml index d8849bf22..61b7d1795 100644 --- a/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml +++ b/Subsurface/Content/Items/OxygenGenerator/oxygengenerator.xml @@ -4,7 +4,7 @@ linkable="true"> - + diff --git a/Subsurface/Content/Items/Reactor/reactor.png b/Subsurface/Content/Items/Reactor/reactor.png index ab6d4d0e7..a2f539128 100644 Binary files a/Subsurface/Content/Items/Reactor/reactor.png and b/Subsurface/Content/Items/Reactor/reactor.png differ diff --git a/Subsurface/Content/Items/Reactor/reactor.xml b/Subsurface/Content/Items/Reactor/reactor.xml index 761987246..faa1e0b76 100644 --- a/Subsurface/Content/Items/Reactor/reactor.xml +++ b/Subsurface/Content/Items/Reactor/reactor.xml @@ -18,7 +18,7 @@ - + diff --git a/Subsurface/Content/Items/Weapons/railgunbarrel.png b/Subsurface/Content/Items/Weapons/railgunbarrel.png index 447886990..8765f90bd 100644 Binary files a/Subsurface/Content/Items/Weapons/railgunbarrel.png and b/Subsurface/Content/Items/Weapons/railgunbarrel.png differ diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs index 1055dd3b3..93e2cc9f4 100644 --- a/Subsurface/Source/Items/CharacterInventory.cs +++ b/Subsurface/Source/Items/CharacterInventory.cs @@ -66,12 +66,14 @@ namespace Subsurface protected override void DropItem(Item item) { - bool enabled = draggingItem.body.Enabled; + if (item.body == null) return; + + bool enabled = item.body.Enabled; item.Drop(character); if (!enabled) { - draggingItem.body.SetTransform(character.SimPosition, 0.0f); + item.SetTransform(character.SimPosition, 0.0f); } } diff --git a/Subsurface/Source/Items/Components/Holdable/Holdable.cs b/Subsurface/Source/Items/Components/Holdable/Holdable.cs index 099b2ff8a..fb253c34d 100644 --- a/Subsurface/Source/Items/Components/Holdable/Holdable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Holdable.cs @@ -101,7 +101,7 @@ namespace Subsurface.Items.Components Msg = ""; } - if (attachedByDefault || Screen.Selected == GameMain.EditMapScreen) Use(1.0f); + if (attachedByDefault || (Screen.Selected == GameMain.EditMapScreen && Submarine.Loaded!=null)) Use(1.0f); //holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f); diff --git a/Subsurface/Source/Items/Components/Machines/Controller.cs b/Subsurface/Source/Items/Components/Machines/Controller.cs index 8959a38ea..4a96bad0a 100644 --- a/Subsurface/Source/Items/Components/Machines/Controller.cs +++ b/Subsurface/Source/Items/Components/Machines/Controller.cs @@ -131,9 +131,9 @@ namespace Subsurface.Items.Components public override bool Use(float deltaTime, Character activator = null) { - if (character.SelectedConstruction != item) + if (activator.SelectedConstruction != item) { - character = null; + activator = null; return false; } diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs index d169f58a4..4cc8d5121 100644 --- a/Subsurface/Source/Items/Components/Signal/Wire.cs +++ b/Subsurface/Source/Items/Components/Signal/Wire.cs @@ -299,7 +299,7 @@ namespace Subsurface.Items.Components if (selectedNodeIndex == null && !MapEntity.SelectedAny) { - if (PlayerInput.LeftButtonDown()) + if (PlayerInput.LeftButtonDown() && PlayerInput.GetOldMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released) { MapEntity.SelectEntity(item); selectedNodeIndex = i; diff --git a/Subsurface/Source/Items/Components/Wearable.cs b/Subsurface/Source/Items/Components/Wearable.cs index 449f4e3d7..94daa00b9 100644 --- a/Subsurface/Source/Items/Components/Wearable.cs +++ b/Subsurface/Source/Items/Components/Wearable.cs @@ -130,10 +130,14 @@ namespace Subsurface.Items.Components { base.Update(deltaTime, cam); + item.SetTransform(picker.SimPosition, 0.0f); + Item[] containedItems = item.ContainedItems; ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker); + PlaySound(ActionType.OnWearing, picker.Position); + if (containedItems == null) return; for (int j = 0; j tags; - - + public Hull CurrentHull; //components that determine the functionality of the item @@ -79,6 +78,22 @@ namespace Subsurface get { return prefab.PickDistance; } } + protected Color spriteColor; + [Editable, HasDefaultValue("1.0,1.0,1.0,1.0", true)] + public string SpriteColor + { + get { return ToolBox.Vector4ToString(spriteColor.ToVector4()); } + set + { + spriteColor = new Color(ToolBox.ParseToVector4(value)); + } + } + + public Color Color + { + get { return spriteColor; } + } + public float Condition { get { return condition; } @@ -104,22 +119,6 @@ namespace Subsurface get { return condition; } } - private Color spriteColor; - [Editable, HasDefaultValue("1.0,1.0,1.0,1.0", true)] - public string SpriteColor - { - get { return ToolBox.Vector4ToString(spriteColor.ToVector4()); } - set - { - spriteColor = new Color(ToolBox.ParseToVector4(value)); - } - } - - public Color Color - { - get { return spriteColor; } - } - [Editable, HasDefaultValue("", true)] public string Tags { @@ -242,6 +241,8 @@ namespace Subsurface { prefab = itemPrefab; + spriteColor = prefab.SpriteColor; + linkedTo = new ObservableCollection(); components = new List(); FixRequirements = new List(); @@ -323,11 +324,15 @@ namespace Subsurface } - public void SetTransform(Vector2 position, float rotation) + public void SetTransform(Vector2 simPosition, float rotation) { - body.SetTransform(position, rotation); + if (body != null) + { + body.SetTransform(simPosition, rotation); + } - Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition); + + Vector2 displayPos = ConvertUnits.ToDisplayUnits(simPosition); rect.X = (int)(displayPos.X - rect.Width / 2.0f); rect.Y = (int)(displayPos.Y + rect.Height / 2.0f); diff --git a/Subsurface/Source/Items/ItemPrefab.cs b/Subsurface/Source/Items/ItemPrefab.cs index 504bd9016..def5e6eb4 100644 --- a/Subsurface/Source/Items/ItemPrefab.cs +++ b/Subsurface/Source/Items/ItemPrefab.cs @@ -157,6 +157,9 @@ namespace Subsurface offsetOnSelected = ToolBox.GetAttributeFloat(element, "offsetonselected", 0.0f); + string spriteColorStr = ToolBox.GetAttributeString(element, "spritecolor", "1.0,1.0,1.0,1.0"); + SpriteColor = new Color(ToolBox.ParseToVector4(spriteColorStr)); + price = ToolBox.GetAttributeInt(element, "price", 0); Triggers = new List(); diff --git a/Subsurface/Source/Map/MapEntity.cs b/Subsurface/Source/Map/MapEntity.cs index bcd902a86..92c8f8263 100644 --- a/Subsurface/Source/Map/MapEntity.cs +++ b/Subsurface/Source/Map/MapEntity.cs @@ -53,7 +53,6 @@ namespace Subsurface } } - public static bool SelectedAny { get { return selectedList.Count > 0; } diff --git a/Subsurface/Source/Map/MapEntityPrefab.cs b/Subsurface/Source/Map/MapEntityPrefab.cs index 3d219c051..946ec34b4 100644 --- a/Subsurface/Source/Map/MapEntityPrefab.cs +++ b/Subsurface/Source/Map/MapEntityPrefab.cs @@ -56,6 +56,12 @@ namespace Subsurface get { return resizeVertical; } } + public Color SpriteColor + { + get; + protected set; + } + public int Price { get { return price; } diff --git a/Subsurface/Source/Map/StructurePrefab.cs b/Subsurface/Source/Map/StructurePrefab.cs index f4b7af9a4..055e1d4a7 100644 --- a/Subsurface/Source/Map/StructurePrefab.cs +++ b/Subsurface/Source/Map/StructurePrefab.cs @@ -68,12 +68,12 @@ namespace Subsurface } } - public static StructurePrefab Load(XElement el) + public static StructurePrefab Load(XElement element) { StructurePrefab sp = new StructurePrefab(); - sp.name = el.Name.ToString(); + sp.name = element.Name.ToString(); - Vector4 sourceVector = ToolBox.GetAttributeVector4(el, "sourcerect", new Vector4(0,0,1,1)); + Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", new Vector4(0,0,1,1)); Rectangle sourceRect = new Rectangle( (int)sourceVector.X, @@ -81,32 +81,35 @@ namespace Subsurface (int)sourceVector.Z, (int)sourceVector.W); - if (el.Attribute("sprite") != null) + if (element.Attribute("sprite") != null) { - sp.sprite = new Sprite(el.Attribute("sprite").Value, sourceRect, Vector2.Zero); + sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero); - sp.sprite.Depth = ToolBox.GetAttributeFloat(el, "depth", 0.0f); + sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f); - if (ToolBox.GetAttributeBool(el, "fliphorizontal", false)) sp.sprite.effects = SpriteEffects.FlipHorizontally; - if (ToolBox.GetAttributeBool(el, "flipvertical", false)) sp.sprite.effects = SpriteEffects.FlipVertically; + if (ToolBox.GetAttributeBool(element, "fliphorizontal", false)) sp.sprite.effects = SpriteEffects.FlipHorizontally; + if (ToolBox.GetAttributeBool(element, "flipvertical", false)) sp.sprite.effects = SpriteEffects.FlipVertically; } sp.size = Vector2.Zero; - sp.size.X = ToolBox.GetAttributeFloat(el, "width", 0.0f); - sp.size.Y = ToolBox.GetAttributeFloat(el, "height", 0.0f); - - sp.maxHealth = ToolBox.GetAttributeFloat(el, "health", 100.0f); - - sp.resizeHorizontal = ToolBox.GetAttributeBool(el, "resizehorizontal", false); - sp.resizeVertical = ToolBox.GetAttributeBool(el, "resizevertical", false); + sp.size.X = ToolBox.GetAttributeFloat(element, "width", 0.0f); + sp.size.Y = ToolBox.GetAttributeFloat(element, "height", 0.0f); - sp.isPlatform = ToolBox.GetAttributeBool(el, "platform", false); - sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(el, "stairdirection", "None")); + string spriteColorStr = ToolBox.GetAttributeString(element, "spritecolor", "1.0,1.0,1.0,1.0"); + sp.SpriteColor = new Color(ToolBox.ParseToVector4(spriteColorStr)); - sp.castShadow = ToolBox.GetAttributeBool(el, "castshadow", false); + sp.maxHealth = ToolBox.GetAttributeFloat(element, "health", 100.0f); + + sp.resizeHorizontal = ToolBox.GetAttributeBool(element, "resizehorizontal", false); + sp.resizeVertical = ToolBox.GetAttributeBool(element, "resizevertical", false); + + sp.isPlatform = ToolBox.GetAttributeBool(element, "platform", false); + sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(element, "stairdirection", "None"), true); + + sp.castShadow = ToolBox.GetAttributeBool(element, "castshadow", false); - sp.hasBody = ToolBox.GetAttributeBool(el, "body", false); + sp.hasBody = ToolBox.GetAttributeBool(element, "body", false); return sp; } diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 81d26c105..7e8224bf2 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -75,6 +75,7 @@ namespace Subsurface.Networking client.Start(); outmsg.Write((byte)PacketTypes.Login); + outmsg.Write(myID); outmsg.Write(password); outmsg.Write(GameMain.Version.ToString()); outmsg.Write(GameMain.SelectedPackage.Name); @@ -244,6 +245,7 @@ namespace Subsurface.Networking if (client.ConnectionStatus == NetConnectionStatus.Disconnected) { + GameMain.NetLobbyScreen.RemovePlayer(myID); if (reconnectBox==null) { reconnectBox = new GUIMessageBox("CONNECTION LOST", "You have been disconnected from the server. Reconnecting...", new string[0]); diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 2cfc95e23..67f8a6358 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -13,6 +13,10 @@ namespace Subsurface.Networking public List connectedClients = new List(); + //for keeping track of disconnected clients in case the reconnect shortly after + private List disconnectedClients = new List(); + + //is the server running bool started; private NetServer server; @@ -30,10 +34,6 @@ namespace Subsurface.Networking private string password; - // private Client myClient; - - //private CharacterInfo myCharacter; - 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 - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD); @@ -217,6 +217,13 @@ namespace Subsurface.Networking inGameHUD.Update((float)Physics.step); } + for (int i = disconnectedClients.Count - 1; i >= 0; i-- ) + { + disconnectedClients[i].deleteDisconnectedTimer -= deltaTime; + if (disconnectedClients[i].deleteDisconnectedTimer > 0.0f) continue; + disconnectedClients.RemoveAt(i); + } + NetIncomingMessage inc = server.ReadMessage(); if (inc != null) { @@ -282,80 +289,7 @@ namespace Subsurface.Networking switch (inc.MessageType) { case NetIncomingMessageType.ConnectionApproval: - if (inc.ReadByte() != (byte)PacketTypes.Login) break; - - DebugConsole.NewMessage("New player has joined the server", Color.White); - - - Client existingClient = connectedClients.Find(c=> c.Connection == inc.SenderConnection); - if (existingClient==null) - { - string userPassword = "", version = "", packageName="", packageHash="", name = ""; - try - { - userPassword = inc.ReadString(); - version = inc.ReadString(); - packageName = inc.ReadString(); - packageHash = inc.ReadString(); - name = inc.ReadString(); - } - catch - { - inc.SenderConnection.Deny("Connection error - server failed to read your ConnectionApproval message"); - DebugConsole.NewMessage("Connection error - server failed to read the ConnectionApproval message", Color.Red); - break; - } - - if (userPassword != password) - { - inc.SenderConnection.Deny("Wrong password!"); - - break; - } - else if (version != GameMain.Version.ToString()) - { - inc.SenderConnection.Deny("Subsurface version " + GameMain.Version + " required to connect to the server (Your version: " + version + ")"); - DebugConsole.NewMessage("Connection error - wrong game version", Color.Red); - break; - } - else if (packageName != GameMain.SelectedPackage.Name) - { - inc.SenderConnection.Deny("Your content package ("+packageName+") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")"); - DebugConsole.NewMessage("Connection error - wrong content package name", Color.Red); - break; - } - else if (packageHash != GameMain.SelectedPackage.MD5hash.Hash) - { - inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")"); - DebugConsole.NewMessage("Connection error - wrong content package hash", Color.Red); - break; - } - else if (connectedClients.Find(c => c.name.ToLower() == name.ToLower())!=null) - { - inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name."); - DebugConsole.NewMessage("Connection error - name already in use", Color.Red); - break; - } - - int id = 1; - while (connectedClients.Find(c => c.ID==id)!=null) - { - id++; - } - Client newClient = new Client(name, id); - newClient.Connection = inc.SenderConnection; - newClient.version = version; - - connectedClients.Add(newClient); - - inc.SenderConnection.Approve(); - } - else - { - inc.SenderConnection.Deny(); - } - //Character ch = new Character("Content/Characters/Human/human.xml"); - + HandleConnectionApproval(inc); break; case NetIncomingMessageType.StatusChanged: Debug.WriteLine(inc.SenderConnection + " status changed. " + (NetConnectionStatus)inc.SenderConnection.Status); @@ -424,6 +358,13 @@ namespace Subsurface.Networking } else if (inc.SenderConnection.Status == NetConnectionStatus.Disconnected) { + var connectedClient = connectedClients.Find(c => c.Connection == inc.SenderConnection); + if (connectedClient != null && !disconnectedClients.Contains(connectedClient)) + { + connectedClient.deleteDisconnectedTimer = NetConfig.DeleteDisconnectedTime; + disconnectedClients.Add(connectedClient); + } + DisconnectClient(inc.SenderConnection); } @@ -476,6 +417,104 @@ namespace Subsurface.Networking } } + private void HandleConnectionApproval(NetIncomingMessage inc) + { + if (inc.ReadByte() != (byte)PacketTypes.Login) return; + + DebugConsole.NewMessage("New player has joined the server", Color.White); + + if (connectedClients.Find(c => c.Connection == inc.SenderConnection)!=null) + { + inc.SenderConnection.Deny("Connection error - already joined"); + return; + } + + int userID; + string userPassword = "", version = "", packageName = "", packageHash = "", name = ""; + try + { + userID = inc.ReadInt32(); + userPassword = inc.ReadString(); + version = inc.ReadString(); + packageName = inc.ReadString(); + packageHash = inc.ReadString(); + name = inc.ReadString(); + } + catch + { + inc.SenderConnection.Deny("Connection error - server failed to read your ConnectionApproval message"); + DebugConsole.NewMessage("Connection error - server failed to read the ConnectionApproval message", Color.Red); + return; + } + + if (userPassword != password) + { + inc.SenderConnection.Deny("Wrong password!"); + DebugConsole.NewMessage(name +" couldn't join the server (wrong password)", Color.Red); + return; + } + else if (version != GameMain.Version.ToString()) + { + inc.SenderConnection.Deny("Subsurface version " + GameMain.Version + " required to connect to the server (Your version: " + version + ")"); + DebugConsole.NewMessage(name + " couldn't join the server (wrong game version)", Color.Red); + return; + } + else if (packageName != GameMain.SelectedPackage.Name) + { + inc.SenderConnection.Deny("Your content package (" + packageName + ") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")"); + DebugConsole.NewMessage(name + " couldn't join the server (wrong content package name)", Color.Red); + return; + } + else if (packageHash != GameMain.SelectedPackage.MD5hash.Hash) + { + inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")"); + DebugConsole.NewMessage(name + " couldn't join the server (wrong content package hash)", Color.Red); + return; + } + else if (connectedClients.Find(c => c.name.ToLower() == name.ToLower() && c.ID!=userID) != null) + { + inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name."); + DebugConsole.NewMessage(name + " couldn't join the server (name already in use)", Color.Red); + return; + } + + //existing user re-joining + if (userID > 0) + { + Client existingClient = connectedClients.Find(c => c.ID == userID); + if (existingClient == null) + { + existingClient = disconnectedClients.Find(c => c.ID == userID); + if (existingClient != null) + { + disconnectedClients.Remove(existingClient); + connectedClients.Add(existingClient); + } + } + if (existingClient != null) + { + existingClient.Connection = inc.SenderConnection; + inc.SenderConnection.Approve(); + return; + } + } + + userID = Rand.Range(1, 1000000); + while (connectedClients.Find(c => c.ID == userID) != null) + { + userID++; + } + + Client newClient = new Client(name, userID); + newClient.Connection = inc.SenderConnection; + newClient.version = version; + + connectedClients.Add(newClient); + + inc.SenderConnection.Approve(); + } + + private void SendMessage(NetOutgoingMessage msg, NetDeliveryMethod deliveryMethod, NetConnection excludedConnection) { List recipients = new List(); @@ -495,7 +534,6 @@ namespace Subsurface.Networking { if (NetworkEvent.events.Count == 0) return; - //System.Diagnostics.Debug.WriteLine("*************************"); foreach (NetworkEvent networkEvent in NetworkEvent.events) { //System.Diagnostics.Debug.WriteLine("networkevent "+networkEvent.ID); @@ -615,13 +653,13 @@ namespace Subsurface.Networking foreach (Client client in connectedClients) { msg.Write(client.ID); - WriteCharacterData(msg, client.name, client.character); + WriteCharacterData(msg, client.character.Name, client.character); } if (myCharacter != null) { msg.Write(-1); - WriteCharacterData(msg, myCharacter.Name, Character.Controlled); + WriteCharacterData(msg, myCharacter.Info.Name, Character.Controlled); } SendMessage(msg, NetDeliveryMethod.ReliableUnordered, null); @@ -648,8 +686,7 @@ namespace Subsurface.Networking { var messageBox = new GUIMessageBox("The round has ended", endMessage); - - + Character.Controlled = null; GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; GameMain.LightManager.LosEnabled = false; @@ -1056,6 +1093,8 @@ namespace Subsurface.Networking public List jobPreferences; public JobPrefab assignedJob; + public float deleteDisconnectedTimer; + public Client(string name, int ID) { this.name = name; diff --git a/Subsurface/Source/Networking/NetConfig.cs b/Subsurface/Source/Networking/NetConfig.cs index e1d19a6c7..7034986d6 100644 --- a/Subsurface/Source/Networking/NetConfig.cs +++ b/Subsurface/Source/Networking/NetConfig.cs @@ -20,5 +20,7 @@ namespace Subsurface.Networking //if the ragdoll is closer than this, don't try to correct its position public const float AllowedRagdollDistance = 0.1f; + + public const float DeleteDisconnectedTime = 10.0f; } } diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index 340fb111e..8e1f8f259 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -120,6 +120,7 @@ namespace Subsurface { GUIImage img = new GUIImage(new Rectangle(0, 0, 40, 40), ep.sprite, Alignment.Left, frame); img.Scale = Math.Min(Math.Min(40.0f / img.SourceRect.Width, 40.0f / img.SourceRect.Height), 1.0f); + img.Color = ep.SpriteColor; } } } diff --git a/Subsurface/Source/Screens/LobbyScreen.cs b/Subsurface/Source/Screens/LobbyScreen.cs index f084175e1..a458f9e78 100644 --- a/Subsurface/Source/Screens/LobbyScreen.cs +++ b/Subsurface/Source/Screens/LobbyScreen.cs @@ -11,25 +11,25 @@ namespace Subsurface { enum PanelTab { Crew = 0, Map = 1, CurrentLocation = 2, Store = 3 } - GUIFrame leftPanel; - GUIFrame[] rightPanel; + private GUIFrame leftPanel; + private GUIFrame[] rightPanel; - GUIButton startButton; + private GUIButton startButton; - int selectedRightPanel; + private int selectedRightPanel; - GUIListBox characterList; - GUIListBox hireList; + private GUIListBox characterList; + private GUIListBox hireList; - GUIListBox selectedItemList, itemList; + private GUIListBox selectedItemList, itemList; - SinglePlayerMode gameMode; + private SinglePlayerMode gameMode; - GUIFrame previewFrame; + private GUIFrame previewFrame; - GUIButton buyButton; + private GUIButton buyButton; - Level selectedLevel; + private Level selectedLevel; float mapZoom = 3.0f; @@ -271,6 +271,7 @@ namespace Subsurface if (ep.sprite != null) { GUIImage img = new GUIImage(new Rectangle(0, 0, 40, 40), ep.sprite, Alignment.Left, frame); + img.Color = ep.SpriteColor; img.Scale = Math.Min(Math.Min(40.0f / img.SourceRect.Width, 40.0f / img.SourceRect.Height), 1.0f); } } @@ -373,8 +374,25 @@ namespace Subsurface public bool SelectRightPanel(GUIButton button, object selection) { - try { selectedRightPanel = (int)selection; } + try + { + selectedRightPanel = (int)selection; + } catch { return false; } + + + if (button != null) + { + button.Selected = true; + foreach (GUIComponent child in leftPanel.children) + { + GUIButton otherButton = child as GUIButton; + if (otherButton == null || otherButton == button) continue; + + otherButton.Selected = false; + } + } + return true; } diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index 9d17a98b8..8df5cd707 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -157,7 +157,8 @@ namespace Subsurface { base.Select(); - selectedTab = 0; + SelectTab(null, 0); + //selectedTab = 0; } public bool SelectTab(GUIButton button, object obj) diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index c8afddeb5..8089d8c56 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -421,7 +421,6 @@ namespace Subsurface return true; } - public void AddPlayer(Client client) { GUITextBlock textBlock = new GUITextBlock( @@ -433,6 +432,17 @@ namespace Subsurface textBlock.UserData = client; } + public void RemovePlayer(int clientID) + { + GUIComponent child = playerList.children.Find(c => + { + Client client = c.UserData as Client; + return (client.ID == clientID); + }); + + if (child != null) playerList.RemoveChild(child); + } + public void RemovePlayer(Client client) { if (client == null) return; diff --git a/Subsurface/Subsurface.csproj b/Subsurface/Subsurface.csproj index 70e1a2df3..9ee136e1e 100644 --- a/Subsurface/Subsurface.csproj +++ b/Subsurface/Subsurface.csproj @@ -370,6 +370,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -613,11 +616,9 @@ PreserveNewest - - PreserveNewest - PreserveNewest + Designer PreserveNewest @@ -807,6 +808,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 468866532..40c75b0e8 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ