From 90490f9aa60649c25624914fa127aefebc1934c1 Mon Sep 17 00:00:00 2001 From: psyGamer Date: Sun, 16 Feb 2025 19:42:26 +0100 Subject: [PATCH] fix: Center camera zooming and rectangle selection not working as intended --- .../Source/Gameplay/CenterCamera.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/CelesteTAS-EverestInterop/Source/Gameplay/CenterCamera.cs b/CelesteTAS-EverestInterop/Source/Gameplay/CenterCamera.cs index b1de7b7c..ee46de2a 100644 --- a/CelesteTAS-EverestInterop/Source/Gameplay/CenterCamera.cs +++ b/CelesteTAS-EverestInterop/Source/Gameplay/CenterCamera.cs @@ -168,11 +168,13 @@ private static void UpdateMeta() { moveOffset.Y += ArrowKeySensitivity; } - if (Hotkeys.CameraZoomIn.Check) { - zoomDirection -= 1; - } - if (Hotkeys.CameraZoomOut.Check) { - zoomDirection += 1; + if (Hotkeys.FreeCamera.Check || Hotkeys.InfoHud.Check) { + if (Hotkeys.CameraZoomIn.Check) { + zoomDirection -= 1; + } + if (Hotkeys.CameraZoomOut.Check) { + zoomDirection += 1; + } } if (zoomDirection == 0) { zoomDirection = -Math.Sign(MouseInput.WheelDelta); @@ -204,7 +206,8 @@ private static void UpdateMeta() { } // Drag support while holding right mouse button - if (MouseInput.Right.Check) { + // Avoid panning while selecting an area + if (MouseInput.Right.Check && !Hotkeys.InfoHud.Check) { float scale = ZoomLevel * level.Camera.Zoom * (Celeste.Celeste.TargetWidth / Celeste.Celeste.GameWidth) * Engine.ViewWidth / Engine.Width; var mouseOffset = MouseInput.PositionDelta / scale; @@ -222,13 +225,11 @@ private static void UpdateMeta() { } // Adjust camera zoom. Use faster speed for zooming out - if (Hotkeys.FreeCamera.Check || Hotkeys.InfoHud.Check) { - float delta = (viewportScale + zoomDirection * 0.1f) switch { - > 1 => zoomDirection * 0.2f, - _ => zoomDirection * 0.1f - }; - viewportScale = Math.Max(0.2f, viewportScale + delta); - } + float delta = (viewportScale + zoomDirection * 0.1f) switch { + > 1 => zoomDirection * 0.2f, + _ => zoomDirection * 0.1f + }; + viewportScale = Math.Max(0.2f, viewportScale + delta); if (cameraTargetPosition is { } target && level.Session.MapData.Bounds is var bounds) { if (changedCamera) {