Skip to content

Commit

Permalink
fix: Center camera zooming and rectangle selection not working as int…
Browse files Browse the repository at this point in the history
…ended
  • Loading branch information
psyGamer committed Feb 16, 2025
1 parent 5db0f02 commit 90490f9
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions CelesteTAS-EverestInterop/Source/Gameplay/CenterCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 90490f9

Please sign in to comment.