diff --git a/Subsurface/Source/GUI/GUIDropDown.cs b/Subsurface/Source/GUI/GUIDropDown.cs index 2a5ecc541..b4ae51dc7 100644 --- a/Subsurface/Source/GUI/GUIDropDown.cs +++ b/Subsurface/Source/GUI/GUIDropDown.cs @@ -10,7 +10,7 @@ namespace Barotrauma public class GUIDropDown : GUIComponent { - public delegate bool OnSelectedHandler(GUIComponent selected); + public delegate bool OnSelectedHandler(GUIComponent selected, object obj = null); public OnSelectedHandler OnSelected; private GUIButton button; @@ -126,7 +126,7 @@ namespace Barotrauma Dropped = false; - if (OnSelected != null) OnSelected(component); + if (OnSelected != null) OnSelected(component, component.UserData); return true; } diff --git a/Subsurface/Source/GameSettings.cs b/Subsurface/Source/GameSettings.cs index 6417e200e..b965a7e8e 100644 --- a/Subsurface/Source/GameSettings.cs +++ b/Subsurface/Source/GameSettings.cs @@ -348,7 +348,7 @@ namespace Barotrauma displayModeDD.SelectItem(GameMain.Config.WindowMode); - displayModeDD.OnSelected = (guiComponent) => { GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData; return true; }; + displayModeDD.OnSelected = (guiComponent, obj) => { GameMain.Config.WindowMode = (WindowMode)guiComponent.UserData; return true; }; y += 70; @@ -408,7 +408,7 @@ namespace Barotrauma return true; } - private bool SelectResolution(GUIComponent selected) + private bool SelectResolution(GUIComponent selected, object userData) { DisplayMode mode = selected.UserData as DisplayMode; if (mode == null) return false; diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index a11d2c2b1..c52151942 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -57,14 +57,14 @@ namespace Barotrauma.Networking } - [HasDefaultValue(120.0f, true)] + [HasDefaultValue(300.0f, true)] public float RespawnInterval { get; private set; } - [HasDefaultValue(60.0f, true)] + [HasDefaultValue(180.0f, true)] public float MaxTransportTime { get; @@ -236,7 +236,7 @@ namespace Barotrauma.Networking { settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f); - GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 420), null, Alignment.Center, GUI.Style, settingsFrame); + GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 430), null, Alignment.Center, GUI.Style, settingsFrame); innerFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f); new GUITextBlock(new Rectangle(0, -5, 0, 20), "Settings", GUI.Style, innerFrame, GUI.LargeFont); @@ -361,14 +361,44 @@ namespace Barotrauma.Networking minRespawnSlider.BarScroll = MinRespawnRatio; minRespawnSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => { - GUITextBlock voteText = scrollBar.UserData as GUITextBlock; + GUITextBlock txt = scrollBar.UserData as GUITextBlock; MinRespawnRatio = barScroll; - voteText.Text = "Minimum players to respawn: " + (int)MathUtils.Round(MinRespawnRatio * 100.0f, 10.0f) + " %"; + txt.Text = "Minimum players to respawn: " + (int)MathUtils.Round(MinRespawnRatio * 100.0f, 10.0f) + " %"; return true; }; minRespawnSlider.OnMoved(minRespawnSlider, MinRespawnRatio); + y += 35; + + var respawnDurationText = new GUITextBlock(new Rectangle(0, y, 200, 20), "Duration of respawn transport", GUI.Style, settingsTabs[0]); + respawnDurationText.ToolTip = "The amount of time respawned players have to navigate the respawn shuttle to the main submarine. " + + "After the duration expires, the shuttle will automatically head back out of the level."; + + var respawnDurationSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[0]); + respawnDurationSlider.ToolTip = minRespawnText.ToolTip; + respawnDurationSlider.UserData = respawnDurationText; + respawnDurationSlider.Step = 0.1f; + respawnDurationSlider.BarScroll = MinRespawnRatio; + respawnDurationSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => + { + GUITextBlock txt = scrollBar.UserData as GUITextBlock; + + if (barScroll == 1.0f) + { + MaxTransportTime = 0; + txt.Text = "Duration of respawn transport: unlimited"; + } + else + { + MaxTransportTime = barScroll * 600.0f + 60.0f; + txt.Text = "Duration of respawn transport: " + ToolBox.SecondsToReadableTime(MaxTransportTime); + } + + return true; + }; + respawnDurationSlider.OnMoved(respawnDurationSlider, (MaxTransportTime - 60.0f)/600.0f); + y += 40; diff --git a/Subsurface/Source/Networking/NetworkMember.cs b/Subsurface/Source/Networking/NetworkMember.cs index 733a3ceac..6130f118f 100644 --- a/Subsurface/Source/Networking/NetworkMember.cs +++ b/Subsurface/Source/Networking/NetworkMember.cs @@ -391,10 +391,9 @@ namespace Barotrauma.Networking string respawnInfo = ""; if (respawnManager.CurrentState == RespawnManager.State.Waiting && - respawnManager.CountdownStarted && - myCharacter != null && myCharacter.IsDead) + respawnManager.CountdownStarted) { - respawnInfo = respawnManager.RespawnTimer <= 0.0f ? "" : "Respawning in " + ToolBox.SecondsToReadableTime(respawnManager.RespawnTimer); + respawnInfo = respawnManager.RespawnTimer <= 0.0f ? "" : "Respawn Shuttle dispatching in " + ToolBox.SecondsToReadableTime(respawnManager.RespawnTimer); } else if (respawnManager.CurrentState == RespawnManager.State.Transporting) @@ -405,7 +404,7 @@ namespace Barotrauma.Networking if (!string.IsNullOrEmpty(respawnInfo)) { GUI.DrawString(spriteBatch, - new Vector2(GameMain.GraphicsWidth - 300.0f, 20), + new Vector2(GameMain.GraphicsWidth - 400.0f, 20), respawnInfo, Color.White, null, 0, GUI.SmallFont); } diff --git a/Subsurface/Source/Networking/RespawnManager.cs b/Subsurface/Source/Networking/RespawnManager.cs index e27e0827f..c4fa6be6d 100644 --- a/Subsurface/Source/Networking/RespawnManager.cs +++ b/Subsurface/Source/Networking/RespawnManager.cs @@ -178,6 +178,9 @@ namespace Barotrauma.Networking networkMember.AddChatMessage("The shuttle will automatically return back to the outpost. Please leave the shuttle immediately.", ChatMessageType.Server); } + //infinite transport time -> shuttle wont return + if (maxTransportTime < 0.1f) return; + var server = networkMember as GameServer; if (server == null) return; @@ -196,15 +199,6 @@ namespace Barotrauma.Networking shuttleReturnTimer = maxTransportTime; shuttleTransportTimer = maxTransportTime; } - - //shuttleReturnTimer += deltaTime; - //if (shuttleReturnTimer > 10.0f) - //{ - // state = State.Returning; - - // server.SendRespawnManagerMsg(); - // shuttleReturnTimer = 0.0f; - //} } private void UpdateReturning(float deltaTime) @@ -477,7 +471,7 @@ namespace Barotrauma.Networking CoroutineManager.StartCoroutine(ForceShuttleToPos(Level.Loaded.StartPosition - Vector2.UnitY * Level.ShaftHeight, 100.0f), "forcepos"); break; case State.Waiting: - CountdownStarted = true; + CountdownStarted = inc.ReadBoolean(); ResetShuttle(); diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index ffb0010d8..0cb58aea0 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -363,7 +363,7 @@ namespace Barotrauma new GUITextBlock(new Rectangle(0,y,150,20), "Name:", GUI.Style, saveFrame); y += 20; - nameBox = new GUITextBox(new Rectangle(5, y, 150, 20), GUI.Style, saveFrame); + nameBox = new GUITextBox(new Rectangle(5, y, 250, 20), GUI.Style, saveFrame); nameBox.OnEnterPressed = ChangeSubName; nameBox.Text = GetSubName(); @@ -376,8 +376,7 @@ namespace Barotrauma Alignment.TopLeft, GUI.Style, saveFrame); descriptionBox.Wrap = true; descriptionBox.Text = Submarine.MainSub == null ? "" : Submarine.MainSub.Description; - descriptionBox.OnSelected += ExpandDescriptionBox; - descriptionBox.OnTextChanged = ChangeSubDescription; + descriptionBox.OnEnterPressed = ChangeSubDescription; y += descriptionBox.Rect.Height + 15; new GUITextBlock(new Rectangle(0, y, 150, 20), "Settings:", GUI.Style, saveFrame); @@ -675,7 +674,7 @@ namespace Barotrauma return frame; } - private bool SelectLinkedSub(GUIComponent selected) + private bool SelectLinkedSub(GUIComponent selected, object userData) { var submarine = selected.UserData as Submarine; if (submarine == null) return false; @@ -747,7 +746,7 @@ namespace Barotrauma textBox.UserData = text; } - textBox.Rect = new Rectangle(textBox.Rect.Location, new Point(textBox.Rect.Width, 20)); + // textBox.Rect = new Rectangle(textBox.Rect.Location, new Point(textBox.Rect.Width, 20)); textBox.Text = ToolBox.LimitString(text, 15); @@ -756,21 +755,7 @@ namespace Barotrauma return true; } - - private void ExpandDescriptionBox(GUITextBox textBox, Keys key) - { - if (Submarine.MainSub != null) - { - textBox.Text = Submarine.MainSub.Description; - } - else if (textBox.UserData is string) - { - textBox.Text = (string)textBox.UserData; - } - - textBox.Rect = new Rectangle(textBox.Rect.Location, new Point(textBox.Rect.Width, 150)); - } - + private bool SelectPrefab(GUIComponent component, object obj) { AddPreviouslyUsed(obj as MapEntityPrefab); diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index f61f6daa6..99e3dbe7b 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Barotrauma.Networking; +using System.Linq; using System.Xml.Linq; using System.IO; @@ -91,6 +92,8 @@ namespace Barotrauma new GUITextBlock(new Rectangle(0, 0, 0, 30), "Selected submarine:", null, null, Alignment.Left, GUI.Style, menuTabs[(int)Tab.NewGame]); mapList = new GUIListBox(new Rectangle(0, 30, 200, panelRect.Height-100), GUI.Style, menuTabs[(int)Tab.NewGame]); + var subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)); + foreach (Submarine sub in Submarine.SavedSubmarines) { new GUITextBlock( diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index 49dc1770c..d7ee819ae 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -224,7 +224,7 @@ namespace Barotrauma new GUITextBlock(new Rectangle(columnX, 120, 20, 20), "Respawn shuttle:", GUI.Style, infoFrame); shuttleList = new GUIDropDown(new Rectangle(columnX, 150, 200, 20), "", GUI.Style, infoFrame); - + //gamemode ------------------------------------------------------------------ @@ -345,7 +345,7 @@ namespace Barotrauma //GameMain.GameScreen.Cam.TargetPos = Vector2.Zero; subList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowSubVoting; - shuttleList.Enabled = subList.Enabled; + shuttleList.Enabled = subList.Enabled; playerList.Enabled = GameMain.Server != null; modeList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowModeVoting; seedBox.Enabled = GameMain.Server != null; @@ -368,17 +368,21 @@ namespace Barotrauma if (IsServer && GameMain.Server != null) { + List subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus)).ToList(); + int prevSelectedSub = subList.SelectedIndex; - UpdateSubList(subList, Submarine.SavedSubmarines); + UpdateSubList(subList, subsToShow); int prevSelectedShuttle = shuttleList.SelectedIndex; - UpdateSubList(shuttleList, Submarine.SavedSubmarines); + UpdateSubList(shuttleList, subsToShow); modeList.OnSelected = VotableClicked; modeList.OnSelected = SelectMode; subList.OnSelected = VotableClicked; subList.OnSelected = SelectSub; + shuttleList.OnSelected = SelectSub; + traitorProbabilityButtons[0].OnClicked = ToggleTraitorsEnabled; traitorProbabilityButtons[1].OnClicked = ToggleTraitorsEnabled; @@ -613,10 +617,10 @@ namespace Barotrauma { valueChanged = true; - var hash = (obj as Submarine).MD5Hash; + var hash = obj is Submarine ? ((Submarine)obj).MD5Hash.Hash : ""; //hash will be null if opening the sub file failed -> don't select the sub - if (string.IsNullOrWhiteSpace(hash.Hash)) + if (string.IsNullOrWhiteSpace(hash)) { (component as GUITextBlock).TextColor = Color.DarkRed * 0.8f; component.CanBeFocused = false;