diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index d18c58ab13..0d6195ba4d 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -152,6 +152,7 @@ pub enum Event { SendMessage(String), AdjustMousePan(u32), AdjustMouseZoom(u32), + ToggleZoomInvert(bool), AdjustViewDistance(u32), AdjustMusicVolume(f32), AdjustSfxVolume(f32), @@ -797,6 +798,9 @@ impl Hud { settings_window::Event::AdjustMouseZoom(sensitivity) => { events.push(Event::AdjustMouseZoom(sensitivity)); } + settings_window::Event::ToggleZoomInvert(zoom_inverted) => { + events.push(Event::ToggleZoomInvert(zoom_inverted)); + } settings_window::Event::AdjustViewDistance(view_distance) => { events.push(Event::AdjustViewDistance(view_distance)); } diff --git a/voxygen/src/hud/settings_window.rs b/voxygen/src/hud/settings_window.rs index 1fe4289c4b..0cce7bc7db 100644 --- a/voxygen/src/hud/settings_window.rs +++ b/voxygen/src/hud/settings_window.rs @@ -50,6 +50,8 @@ widget_ids! { mouse_zoom_slider, mouse_zoom_label, mouse_zoom_value, + mouse_zoom_invert_button, + mouse_zoom_invert_label, ch_title, ch_transp_slider, ch_transp_label, @@ -154,6 +156,7 @@ pub enum Event { Close, AdjustMousePan(u32), AdjustMouseZoom(u32), + ToggleZoomInvert(bool), AdjustViewDistance(u32), AdjustFOV(u16), ChangeAaMode(AaMode), @@ -885,6 +888,30 @@ impl<'a> Widget for SettingsWindow<'a> { .font_id(self.fonts.opensans) .color(TEXT_COLOR) .set(state.ids.mouse_zoom_value, ui); + + // Zoom Inversion + let zoom_inverted = ToggleButton::new( + self.global_state.settings.gameplay.zoom_inversion, + self.imgs.checkbox, + self.imgs.checkbox_checked, + ) + .w_h(18.0, 18.0) + .down_from(state.ids.mouse_zoom_slider, 20.0) + .hover_images(self.imgs.checkbox_mo, self.imgs.checkbox_checked_mo) + .press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked) + .set(state.ids.mouse_zoom_invert_button, ui); + + if self.global_state.settings.gameplay.zoom_inversion != zoom_inverted { + events.push(Event::ToggleZoomInvert(!self.global_state.settings.gameplay.zoom_inversion)); + } + + Text::new("Invert Scroll Zoom") + .right_from(state.ids.mouse_zoom_invert_button, 10.0) + .font_size(14) + .font_id(self.fonts.opensans) + .graphics_for(state.ids.button_help) + .color(TEXT_COLOR) + .set(state.ids.mouse_zoom_invert_label, ui); } // 3) Controls Tab -------------------------------- diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index fbdd326786..613c19085a 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -392,6 +392,11 @@ impl PlayState for SessionState { global_state.settings.gameplay.zoom_sensitivity = sensitivity; global_state.settings.save_to_file_warn(); } + HudEvent::ToggleZoomInvert(zoom_inverted) => { + global_state.window.zoom_inversion = zoom_inverted; + global_state.settings.gameplay.zoom_inversion = zoom_inverted; + global_state.settings.save_to_file_warn(); + } HudEvent::AdjustViewDistance(view_distance) => { self.client.borrow_mut().set_view_distance(view_distance);