From 5ef300c72c694e100a75c97b398bdb5483501509 Mon Sep 17 00:00:00 2001 From: Youser Nayme <7685106-NeutralModder@users.noreply.gitlab.com> Date: Thu, 10 Aug 2023 16:55:09 +0000 Subject: [PATCH] Add keybinding for zooming the camera --- CHANGELOG.md | 1 + assets/voxygen/i18n/en/gameinput.ftl | 2 ++ voxygen/src/game_input.rs | 4 ++++ voxygen/src/session/mod.rs | 24 ++++++++++++++++++++++++ voxygen/src/settings/control.rs | 2 ++ 5 files changed, 33 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcaa5234c3..c7b1bfa438 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Hardwood in tropical forests, frostwood in cold forests, and iron wood on the top of giant trees - Recipe for shovel, which is used to dig in mud and graves - Recipe for a new leather pack +- Keybinds for zooming the camera (Defaults: ']' for zooming in and '[' for zooming out) ### Changed diff --git a/assets/voxygen/i18n/en/gameinput.ftl b/assets/voxygen/i18n/en/gameinput.ftl index 7237382e62..485c46c36b 100644 --- a/assets/voxygen/i18n/en/gameinput.ftl +++ b/assets/voxygen/i18n/en/gameinput.ftl @@ -49,6 +49,8 @@ gameinput-togglewield = Toggle Wield gameinput-interact = Interact gameinput-freelook = Free Look gameinput-autowalk = Auto Walk/Swim +gameinput-zoomin = Camera zoom in +gameinput-zoomout = Camera zoom out gameinput-zoomlock = Camera zoom lock gameinput-cameraclamp = Camera Clamp gameinput-dance = Dance diff --git a/voxygen/src/game_input.rs b/voxygen/src/game_input.rs index 80ca3afeee..4e5f9f5554 100644 --- a/voxygen/src/game_input.rs +++ b/voxygen/src/game_input.rs @@ -132,6 +132,10 @@ pub enum GameInput { FreeLook, #[strum(serialize = "gameinput-autowalk")] AutoWalk, + #[strum(serialize = "gameinput-zoomin")] + ZoomIn, + #[strum(serialize = "gameinput-zoomout")] + ZoomOut, #[strum(serialize = "gameinput-zoomlock")] ZoomLock, #[strum(serialize = "gameinput-cameraclamp")] diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index 9ab05c2450..0982c05ba6 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -1067,6 +1067,30 @@ impl PlayState for SessionState { self.key_state.auto_walk = self.auto_walk && !self.client.borrow().is_gliding(); }, + GameInput::ZoomIn => { + if state { + if self.zoom_lock { + self.hud.zoom_lock_reminder(); + } else { + self.scene.handle_input_event( + Event::Zoom(-30.0), + &self.client.borrow(), + ); + } + } + }, + GameInput::ZoomOut => { + if state { + if self.zoom_lock { + self.hud.zoom_lock_reminder(); + } else { + self.scene.handle_input_event( + Event::Zoom(30.0), + &self.client.borrow(), + ); + } + } + }, GameInput::ZoomLock => { if state { global_state.settings.gameplay.zoom_lock ^= true; diff --git a/voxygen/src/settings/control.rs b/voxygen/src/settings/control.rs index 6d15f1f560..9e6268acb4 100644 --- a/voxygen/src/settings/control.rs +++ b/voxygen/src/settings/control.rs @@ -170,6 +170,8 @@ impl ControlSettings { GameInput::ToggleWield => Some(KeyMouse::Key(VirtualKeyCode::R)), GameInput::FreeLook => Some(KeyMouse::Key(VirtualKeyCode::L)), GameInput::AutoWalk => Some(KeyMouse::Key(VirtualKeyCode::Period)), + GameInput::ZoomIn => Some(KeyMouse::Key(VirtualKeyCode::RBracket)), + GameInput::ZoomOut => Some(KeyMouse::Key(VirtualKeyCode::LBracket)), GameInput::ZoomLock => None, GameInput::CameraClamp => Some(KeyMouse::Key(VirtualKeyCode::Apostrophe)), GameInput::CycleCamera => Some(KeyMouse::Key(VirtualKeyCode::Key0)),