Add keybinding for zooming the camera

This commit is contained in:
Youser Nayme 2023-08-10 16:55:09 +00:00 committed by Isse
parent 02e67a0f4a
commit 5ef300c72c
5 changed files with 33 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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")]

View File

@ -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;

View File

@ -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)),