diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 4f7f944a5..6f9f5baaf 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -562,7 +562,20 @@ namespace Barotrauma.Networking GameMain.NetLobbyScreen.TrySelectSub(selectSubName, selectSubHash, GameMain.NetLobbyScreen.SubList); string selectShuttleName = inc.ReadString(); string selectShuttleHash = inc.ReadString(); - GameMain.NetLobbyScreen.TrySelectSub(selectShuttleName, selectShuttleHash, GameMain.NetLobbyScreen.ShuttleList.ListBox); + GameMain.NetLobbyScreen.TrySelectSub(selectShuttleName, selectShuttleHash, GameMain.NetLobbyScreen.ShuttleList.ListBox); + + GameMain.NetLobbyScreen.SetTraitorsEnabled((YesNoMaybe)inc.ReadRangedInteger(0, 2)); + + GameMain.NetLobbyScreen.SetMissionType(inc.ReadRangedInteger(0, Mission.MissionTypes.Count - 1)); + + GameMain.NetLobbyScreen.SelectMode(inc.ReadByte()); + + GameMain.NetLobbyScreen.LevelSeed = inc.ReadString(); + + bool autoRestartEnabled = inc.ReadBoolean(); + float autoRestartTimer = autoRestartEnabled ? inc.ReadFloat() : 0.0f; + + GameMain.NetLobbyScreen.SetAutoRestart(autoRestartEnabled, autoRestartTimer); } lastRecvChatMsgID = inc.ReadUInt32(); break; diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index 8958cb261..49cc48730 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -636,10 +636,23 @@ namespace Barotrauma.Networking { outmsg.Write((UInt16)0); } - outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).Name); - outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).MD5Hash.ToString()); - outmsg.Write((GameMain.NetLobbyScreen.ShuttleList.SelectedData as Submarine).Name); - outmsg.Write((GameMain.NetLobbyScreen.ShuttleList.SelectedData as Submarine).MD5Hash.ToString()); + outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).Name); + outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).MD5Hash.ToString()); + outmsg.Write((GameMain.NetLobbyScreen.ShuttleList.SelectedData as Submarine).Name); + outmsg.Write((GameMain.NetLobbyScreen.ShuttleList.SelectedData as Submarine).MD5Hash.ToString()); + + outmsg.WriteRangedInteger(0, 2, (int)TraitorsEnabled); + + outmsg.WriteRangedInteger(0, Mission.MissionTypes.Count - 1, (GameMain.NetLobbyScreen.MissionTypeIndex)); + + outmsg.Write((byte)GameMain.NetLobbyScreen.ModeList.SelectedIndex); + outmsg.Write(GameMain.NetLobbyScreen.LevelSeed); + + outmsg.Write(AutoRestart); + if (autoRestart) + { + outmsg.Write(AutoRestartTimer); + } } else { diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index a7d87de8a..9d7d1f684 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -53,7 +53,6 @@ namespace Barotrauma public string ServerName; const float NetworkUpdateInterval = 1.0f; - private float networkUpdateTimer; private UInt32 lastUpdateID; public UInt32 LastUpdateID { @@ -151,7 +150,7 @@ namespace Barotrauma { return levelSeed; } - private set + set { if (levelSeed == value) return; @@ -569,6 +568,12 @@ namespace Barotrauma return false; } + public void SetAutoRestart(bool enabled, float timer = 0.0f) + { + autoRestartBox.Selected = enabled; + autoRestartTimer = timer; + } + private bool ToggleAutoRestart(GUITickBox tickBox) { if (GameMain.Server == null) return false; @@ -580,18 +585,18 @@ namespace Barotrauma return true; } - private void SetMissionType(int missionTypeIndex) + public void SetMissionType(int missionTypeIndex) { if (missionTypeIndex < 0 || missionTypeIndex >= Mission.MissionTypes.Count) return; missionTypeBlock.GetChild().Text = Mission.MissionTypes[missionTypeIndex]; missionTypeBlock.UserData = missionTypeIndex; - - lastUpdateID++; } public bool ToggleMissionType(GUIButton button, object userData) { + if (GameMain.Server == null) return false; + int missionTypeIndex = (int)missionTypeBlock.UserData; missionTypeIndex += (int)userData; @@ -609,6 +614,8 @@ namespace Barotrauma { if (GameMain.Server == null) return false; + lastUpdateID++; + int dir = (int)userData; int index = (int)GameMain.Server.TraitorsEnabled + dir; @@ -617,14 +624,12 @@ namespace Barotrauma SetTraitorsEnabled((YesNoMaybe)index); - lastUpdateID++; return true; } - private void SetTraitorsEnabled(YesNoMaybe enabled) + public void SetTraitorsEnabled(YesNoMaybe enabled) { - if (GameMain.Server != null) GameMain.Server.TraitorsEnabled = enabled; (traitorProbabilityText as GUITextBlock).Text = enabled.ToString(); } @@ -642,6 +647,8 @@ namespace Barotrauma private bool SelectSub(GUIComponent component, object obj) { + if (GameMain.Server == null) return false; + lastUpdateID++; var hash = obj is Submarine ? ((Submarine)obj).MD5Hash.Hash : ""; @@ -756,6 +763,7 @@ namespace Barotrauma public bool UpdateServerMessage(GUITextBox textBox, string text) { if (GameMain.Server == null) return false; + lastUpdateID++; return true; @@ -942,20 +950,6 @@ namespace Barotrauma { base.Update(deltaTime); - //Vector2 pos = new Vector2( - // Submarine.Borders.X + Submarine.Borders.Width / 2, - // Submarine.Borders.Y - Submarine.Borders.Height / 2); - - //camAngle += (float)deltaTime / 10.0f; - //Vector2 offset = (new Vector2( - // (float)Math.Cos(camAngle) * (Submarine.Borders.Width / 2.0f), - // (float)Math.Sin(camAngle) * (Submarine.Borders.Height / 2.0f))); - - //pos += offset * 0.8f; - - //GameMain.GameScreen.Cam.TargetPos = pos; - //GameMain.GameScreen.Cam.MoveCamera((float)deltaTime); - if (jobInfoFrame != null) { jobInfoFrame.Update((float)deltaTime); @@ -966,17 +960,13 @@ namespace Barotrauma } else { - - menu.Update((float)deltaTime); - + menu.Update((float)deltaTime); } if (autoRestartTimer != 0.0f && autoRestartBox.Selected) { autoRestartTimer = Math.Max(autoRestartTimer - (float)deltaTime, 0.0f); } - - //durationBar.BarScroll = Math.Max(durationBar.BarScroll, 1.0f / 60.0f); } public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) @@ -1059,6 +1049,13 @@ namespace Barotrauma return true; } + public void SelectMode(int modeIndex) + { + modeList.Select(modeIndex, true); + + missionTypeBlock.Visible = SelectedMode != null && SelectedMode.Name == "Mission"; + } + private bool SelectMode(GUIComponent component, object obj) { if (GameMain.NetworkMember == null) return false; @@ -1081,14 +1078,10 @@ namespace Barotrauma private bool SelectSeed(GUITextBox textBox, string seed) { - if (!string.IsNullOrWhiteSpace(seed)) - { - LevelSeed = seed; - } - - //textBox.Text = LevelSeed; - //textBox.Selected = false; + if (GameMain.Server == null) return false; + if (string.IsNullOrWhiteSpace(seed)) return false; + LevelSeed = seed; lastUpdateID++; return true;