diff --git a/Barotrauma/BarotraumaClient/Source/Camera.cs b/Barotrauma/BarotraumaClient/Source/Camera.cs index 4fa02a0ed..16cd6e371 100644 --- a/Barotrauma/BarotraumaClient/Source/Camera.cs +++ b/Barotrauma/BarotraumaClient/Source/Camera.cs @@ -8,11 +8,14 @@ namespace Barotrauma { public static bool FollowSub = true; - private float defaultZoom = 1.3f; + private float? defaultZoom; public float DefaultZoom { - get { return defaultZoom; } - set { defaultZoom = MathHelper.Clamp(value, 0.5f, 2.0f); } + get { return defaultZoom ?? (GameMain.Config == null || GameMain.Config.EnableMouseLook ? 1.3f : 1.0f); } + set + { + defaultZoom = MathHelper.Clamp(value, 0.5f, 2.0f); + } } private float zoomSmoothness = 8.0f; diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs index 996a07b55..77ed140e1 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Character.cs @@ -165,6 +165,7 @@ namespace Barotrauma keys[i].SetState(); } + float targetOffsetAmount = 0.0f; if (moveCam) { if (needsAir && @@ -180,12 +181,12 @@ namespace Barotrauma if (IsHumanoid) { - cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, deltaTime); + cam.OffsetAmount = 250.0f;// MathHelper.Lerp(cam.OffsetAmount, 250.0f, deltaTime); } else { //increased visibility range when controlling large a non-humanoid - cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, MathHelper.Clamp(Mass, 250.0f, 800.0f), deltaTime); + cam.OffsetAmount = MathHelper.Clamp(Mass, 250.0f, 1500.0f); } } @@ -198,36 +199,49 @@ namespace Barotrauma Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition); if (GUI.PauseMenuOpen) { + targetOffsetAmount = 0.0f; cam.OffsetAmount = 0.0f; } else if (SelectedConstruction != null && ViewTarget == null && SelectedConstruction.Components.Any(ic => ic?.GuiFrame != null && ic.ShouldDrawHUD(this))) { + targetOffsetAmount = 0.0f; cam.OffsetAmount = 0.0f; cursorPosition = SelectedConstruction.Position + new Vector2(cursorPosition.X % 10.0f, cursorPosition.Y % 10.0f); //apply a little bit of movement to the cursor pos to prevent AFK kicking } + else if (!GameMain.Config.EnableMouseLook) + { + targetOffsetAmount = 0.0f; + cam.OffsetAmount = 0.0f; + } else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f) { if (GUI.PauseMenuOpen || IsUnconscious) { - if (deltaTime > 0.0f) cam.OffsetAmount = 0.0f; + if (deltaTime > 0.0f) + { + targetOffsetAmount = 0.0f; + cam.OffsetAmount = 0.0f; + } } else { Body body = Submarine.CheckVisibility(AnimController.Limbs[0].SimPosition, mouseSimPos); - Structure structure = body == null ? null : body.UserData as Structure; + Structure structure = body?.UserData as Structure; float sightDist = Submarine.LastPickedFraction; if (body?.UserData is Structure && !((Structure)body.UserData).CastShadow) { sightDist = 1.0f; } - cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, Math.Max(250.0f, sightDist * 500.0f), 0.05f); + targetOffsetAmount = Math.Max(250.0f, sightDist * 500.0f); } } + cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, targetOffsetAmount, 0.05f); + if (SelectedConstruction != null && SelectedConstruction.ActiveHUDs.Any(ic => ic.GuiFrame != null && HUD.CloseHUD(ic.GuiFrame.Rect))) { if (GameMain.Client != null) diff --git a/Barotrauma/BarotraumaClient/Source/GameSettings.cs b/Barotrauma/BarotraumaClient/Source/GameSettings.cs index 96d604bff..093a4ceae 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSettings.cs @@ -426,7 +426,7 @@ namespace Barotrauma muteOnFocusLostBox.OnSelected = (tickBox) => { MuteOnFocusLost = tickBox.Selected; - + UnsavedSettings = true; return true; }; @@ -593,7 +593,39 @@ namespace Barotrauma /// Controls tab ------------------------------------------------------------- var controlsLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), tabs[(int)Tab.Controls].RectTransform, Anchor.Center)) - { RelativeSpacing = 0.01f }; + { RelativeSpacing = 0.03f, Stretch = true }; + + GUITextBlock aimAssistText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), controlsLayoutGroup.RectTransform), TextManager.Get("AimAssist")) + { + ToolTip = TextManager.Get("AimAssistToolTip") + }; + GUIScrollBar aimAssistSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), controlsLayoutGroup.RectTransform), + barSize: 0.05f) + { + UserData = aimAssistText, + BarScroll = MathUtils.InverseLerp(0.0f, 5.0f, AimAssistAmount), + ToolTip = TextManager.Get("AimAssistToolTip"), + OnMoved = (scrollBar, scroll) => + { + ChangeSliderText(scrollBar, scroll); + AimAssistAmount = MathHelper.Lerp(0.0f, 5.0f, scroll); + return true; + }, + Step = 0.1f + }; + aimAssistSlider.OnMoved(aimAssistSlider, aimAssistSlider.BarScroll); + + new GUITickBox(new RectTransform(new Vector2(0.5f, 0.05f), controlsLayoutGroup.RectTransform), TextManager.Get("EnableMouseLook")) + { + ToolTip = TextManager.Get("EnableMouseLookToolTip"), + Selected = EnableMouseLook, + OnSelected = (tickBox) => + { + EnableMouseLook = tickBox.Selected; + UnsavedSettings = true; + return true; + } + }; var inputFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.8f), controlsLayoutGroup.RectTransform)) { Stretch = true }; @@ -631,6 +663,9 @@ namespace Barotrauma //spacing new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); + //spacing + new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); + new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft), TextManager.Get("Cancel"), style: "GUIButtonLarge") { diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index 2fd21c4aa..ef1413c3c 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -147,6 +147,8 @@ namespace Barotrauma set { aimAssistAmount = MathHelper.Clamp(value, 0.0f, 5.0f); } } + public bool EnableMouseLook { get; set; } = true; + private bool unsavedSettings; public bool UnsavedSettings { @@ -737,6 +739,7 @@ namespace Barotrauma EnableSplashScreen = doc.Root.GetAttributeBool("enablesplashscreen", EnableSplashScreen); AimAssistAmount = doc.Root.GetAttributeFloat("aimassistamount", AimAssistAmount); + EnableMouseLook = doc.Root.GetAttributeBool("enablemouselook", EnableMouseLook); foreach (XElement subElement in doc.Root.Elements()) { @@ -920,7 +923,8 @@ namespace Barotrauma new XAttribute("quickstartsub", QuickStartSubmarineName), new XAttribute("requiresteamauthentication", requireSteamAuthentication), new XAttribute("autoupdateworkshopitems", AutoUpdateWorkshopItems), - new XAttribute("aimassistamount", aimAssistAmount)); + new XAttribute("aimassistamount", aimAssistAmount), + new XAttribute("enablemouselook", EnableMouseLook)); if (!ShowUserStatisticsPrompt) { diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs index 7845f609c..eebf1146a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/LightComponent.cs @@ -26,6 +26,10 @@ namespace Barotrauma.Items.Components private float blinkTimer; + private bool itemLoaded; + + private float blinkTimer; + public PhysicsBody ParentBody; [Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)]