From f4275de1acc0bb194cdfc9585c388f90c0e0f959 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 11 Apr 2019 18:26:56 +0300 Subject: [PATCH] (845cfe372) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev --- Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs | 6 +++--- .../Source/GameSession/CrewManager.cs | 4 +++- .../Source/Networking/GameClient.cs | 4 +++- .../Source/Networking/GameServer.cs | 13 +++++-------- Barotrauma/BarotraumaShared/Source/GameSettings.cs | 10 +++++++++- .../BarotraumaShared/Source/Screens/GameScreen.cs | 1 + 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs b/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs index 26afe00a0..490c0d21a 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/ChatBox.cs @@ -33,7 +33,7 @@ namespace Barotrauma set { if (_toggleOpen == value) { return; } - _toggleOpen = value; + _toggleOpen = GameMain.Config.ChatOpen = value; foreach (GUIComponent child in ToggleButton.Children) { child.SpriteEffects = _toggleOpen == (HUDLayoutSettings.ChatBoxAlignment == Alignment.Right) ? @@ -133,6 +133,8 @@ namespace Barotrauma } return true; }; + + ToggleOpen = GameMain.Config.ChatOpen; } public bool TypingChatMessage(GUITextBox textBox, string text) @@ -322,8 +324,6 @@ namespace Barotrauma prevUIScale = GUI.Scale; } - - if (ToggleOpen || (inputBox != null && inputBox.Selected)) { openState += deltaTime * 5.0f; diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index 32eea4f1d..8f0eb0d56 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -56,7 +56,7 @@ namespace Barotrauma set { if (toggleCrewAreaOpen == value) { return; } - toggleCrewAreaOpen = value; + toggleCrewAreaOpen = GameMain.Config.CrewMenuOpen = value; foreach (GUIComponent child in toggleCrewButton.Children) { child.SpriteEffects = toggleCrewAreaOpen ? SpriteEffects.None : SpriteEffects.FlipHorizontally; @@ -215,6 +215,8 @@ namespace Barotrauma screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight); prevUIScale = GUI.Scale; + + ToggleCrewAreaOpen = GameMain.Config.CrewMenuOpen; } diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 636cd27d4..fa4a2d3b4 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -1114,7 +1114,9 @@ namespace Barotrauma.Networking if (campaign == null) { - GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode, missionIndex < 0 ? null : MissionPrefab.List[missionIndex]); + GameMain.GameSession = missionIndex < 0 ? + new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode, MissionType.None) : + new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode, MissionPrefab.List[missionIndex]); GameMain.GameSession.StartRound(levelSeed, levelDifficulty, loadSecondSub); } else diff --git a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs index 60d7c1e95..d9137afc7 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/GameServer.cs @@ -1754,11 +1754,10 @@ namespace Barotrauma.Networking Log("Game mode: " + selectedMode.Name, ServerLog.MessageType.ServerMessage); Log("Submarine: " + selectedSub.Name, ServerLog.MessageType.ServerMessage); Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, ServerLog.MessageType.ServerMessage); - } + } - bool missionAllowRespawn = campaign == null && - (!(GameMain.GameSession.GameMode is MissionMode) || - ((MissionMode)GameMain.GameSession.GameMode).Mission.AllowRespawn); + MissionMode missionMode = GameMain.GameSession.GameMode as MissionMode; + bool missionAllowRespawn = campaign == null && (missionMode?.Mission == null || missionMode.Mission.AllowRespawn); if (serverSettings.AllowRespawn && missionAllowRespawn) respawnManager = new RespawnManager(this, usingShuttle ? selectedShuttle : null); @@ -1941,10 +1940,8 @@ namespace Barotrauma.Networking MultiPlayerCampaign campaign = GameMain.GameSession?.GameMode as MultiPlayerCampaign; - bool missionAllowRespawn = campaign == null && - (!(GameMain.GameSession.GameMode is MissionMode) || - ((MissionMode)GameMain.GameSession.GameMode).Mission.AllowRespawn); - + MissionMode missionMode = GameMain.GameSession.GameMode as MissionMode; + bool missionAllowRespawn = campaign == null && (missionMode?.Mission == null || missionMode.Mission.AllowRespawn); msg.Write(serverSettings.AllowRespawn && missionAllowRespawn); msg.Write(Submarine.MainSubs[1] != null); //loadSecondSub diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index 2a40edb8a..c555982f3 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -150,6 +150,9 @@ namespace Barotrauma public bool EnableMouseLook { get; set; } = true; + public bool CrewMenuOpen { get; set; } = true; + public bool ChatOpen { get; set; } = true; + private bool unsavedSettings; public bool UnsavedSettings { @@ -847,6 +850,9 @@ namespace Barotrauma AimAssistAmount = doc.Root.GetAttributeFloat("aimassistamount", AimAssistAmount); EnableMouseLook = doc.Root.GetAttributeBool("enablemouselook", EnableMouseLook); + CrewMenuOpen = doc.Root.GetAttributeBool("crewmenuopen", CrewMenuOpen); + ChatOpen = doc.Root.GetAttributeBool("chatopen", ChatOpen); + foreach (XElement subElement in doc.Root.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) @@ -1022,7 +1028,9 @@ namespace Barotrauma new XAttribute("requiresteamauthentication", requireSteamAuthentication), new XAttribute("autoupdateworkshopitems", AutoUpdateWorkshopItems), new XAttribute("aimassistamount", aimAssistAmount), - new XAttribute("enablemouselook", EnableMouseLook)); + new XAttribute("enablemouselook", EnableMouseLook), + new XAttribute("chatopen", ChatOpen), + new XAttribute("crewmenuopen", CrewMenuOpen)); if (!ShowUserStatisticsPrompt) { diff --git a/Barotrauma/BarotraumaShared/Source/Screens/GameScreen.cs b/Barotrauma/BarotraumaShared/Source/Screens/GameScreen.cs index 72bec4a5e..e7a5815ad 100644 --- a/Barotrauma/BarotraumaShared/Source/Screens/GameScreen.cs +++ b/Barotrauma/BarotraumaShared/Source/Screens/GameScreen.cs @@ -44,6 +44,7 @@ namespace Barotrauma base.Deselect(); #if CLIENT + GameMain.Config.SaveNewPlayerConfig(); GameMain.SoundManager.SetCategoryMuffle("default", false); GUI.ClearMessages(); #endif