diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 17bdcadfd..433b4b0a5 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 c820b087c..b9eb14f65 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -640,6 +640,19 @@ namespace Barotrauma.Networking 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..c054f4b3a 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,7 +585,7 @@ namespace Barotrauma return true; } - private void SetMissionType(int missionTypeIndex) + public void SetMissionType(int missionTypeIndex) { if (missionTypeIndex < 0 || missionTypeIndex >= Mission.MissionTypes.Count) return; @@ -609,6 +614,8 @@ namespace Barotrauma { if (GameMain.Server == null) return false; + lastUpdateID++; + int dir = (int)userData; int index = (int)GameMain.Server.TraitorsEnabled + dir; @@ -622,9 +629,8 @@ namespace Barotrauma 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(); } @@ -942,20 +948,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 +958,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 +1047,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;