From 714dbc9c6f95228c596ebb92ba5d4efd9a3b5f89 Mon Sep 17 00:00:00 2001 From: Woeful_Wolf <54476280+WoefulWolf@users.noreply.github.com> Date: Sun, 28 Jan 2024 16:11:21 +0200 Subject: [PATCH] Added x and y aiming offsets to settings --- voxygen/src/hud/settings_window/gameplay.rs | 74 ++++++++++++++++++++- voxygen/src/session/settings_change.rs | 9 +++ voxygen/src/settings/gameplay.rs | 4 ++ 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/voxygen/src/hud/settings_window/gameplay.rs b/voxygen/src/hud/settings_window/gameplay.rs index d64d4614c6..6645e350a6 100644 --- a/voxygen/src/hud/settings_window/gameplay.rs +++ b/voxygen/src/hud/settings_window/gameplay.rs @@ -59,6 +59,12 @@ widget_ids! { bow_zoom_label, zoom_lock_button, zoom_lock_label, + aim_offset_x_slider, + aim_offset_x_label, + aim_offset_x_value, + aim_offset_y_slider, + aim_offset_y_label, + aim_offset_y_value, } } @@ -662,12 +668,78 @@ impl<'a> Widget for Gameplay<'a> { .color(TEXT_COLOR) .set(state.ids.zoom_lock_label, ui); + // Aim offset x + let display_aim_offset_x = self.global_state.settings.gameplay.aim_offset_x; + Text::new("Aim Offset X") + .down_from(state.ids.zoom_lock_behavior_list, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.aim_offset_x_label, ui); + + if let Some(new_val) = ImageSlider::continuous( + display_aim_offset_x, + -3.0, + 3.0, + self.imgs.slider_indicator, + self.imgs.slider, + ) + .w_h(550.0, 22.0) + .down_from(state.ids.aim_offset_x_label, 10.0) + .track_breadth(30.0) + .slider_length(10.0) + .pad_track((5.0, 5.0)) + .set(state.ids.aim_offset_x_slider, ui) + { + events.push(AdjustAimOffsetX(new_val)); + } + + Text::new(&format!("{:.2}", display_aim_offset_x)) + .right_from(state.ids.aim_offset_x_slider, 8.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.aim_offset_x_value, ui); + + // Aim offset y + let display_aim_offset_y = self.global_state.settings.gameplay.aim_offset_y; + Text::new("Aim Offset Y") + .down_from(state.ids.aim_offset_x_slider, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.aim_offset_y_label, ui); + + if let Some(new_val) = ImageSlider::continuous( + display_aim_offset_y, + -3.0, + 3.0, + self.imgs.slider_indicator, + self.imgs.slider, + ) + .w_h(550.0, 22.0) + .down_from(state.ids.aim_offset_y_label, 10.0) + .track_breadth(30.0) + .slider_length(10.0) + .pad_track((5.0, 5.0)) + .set(state.ids.aim_offset_y_slider, ui) + { + events.push(AdjustAimOffsetY(new_val)); + } + + Text::new(&format!("{:.2}", display_aim_offset_y)) + .right_from(state.ids.aim_offset_y_slider, 8.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.aim_offset_y_value, ui); + // Reset the gameplay settings to the default settings if Button::image(self.imgs.button) .w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT) .hover_image(self.imgs.button_hover) .press_image(self.imgs.button_press) - .down_from(state.ids.zoom_lock_behavior_list, 12.0) + .down_from(state.ids.aim_offset_y_slider, 12.0) .label( &self .localized_strings diff --git a/voxygen/src/session/settings_change.rs b/voxygen/src/session/settings_change.rs index a4be0be0d8..0e7096230a 100644 --- a/voxygen/src/session/settings_change.rs +++ b/voxygen/src/session/settings_change.rs @@ -77,6 +77,9 @@ pub enum Gameplay { ChangeBowZoom(bool), ChangeZoomLock(bool), + AdjustAimOffsetX(f32), + AdjustAimOffsetY(f32), + ResetGameplaySettings, } #[derive(Clone)] @@ -427,6 +430,12 @@ impl SettingsChange { Gameplay::ChangeZoomLock(state) => { settings.gameplay.zoom_lock = state; }, + Gameplay::AdjustAimOffsetX(offset) => { + settings.gameplay.aim_offset_x = offset; + }, + Gameplay::AdjustAimOffsetY(offset) => { + settings.gameplay.aim_offset_y = offset; + }, Gameplay::ResetGameplaySettings => { // Reset Gameplay Settings settings.gameplay = GameplaySettings::default(); diff --git a/voxygen/src/settings/gameplay.rs b/voxygen/src/settings/gameplay.rs index ebb06d6627..839d50c260 100644 --- a/voxygen/src/settings/gameplay.rs +++ b/voxygen/src/settings/gameplay.rs @@ -21,6 +21,8 @@ pub struct GameplaySettings { pub auto_camera: bool, pub bow_zoom: bool, pub zoom_lock: bool, + pub aim_offset_x: f32, + pub aim_offset_y: f32, } impl Default for GameplaySettings { @@ -42,6 +44,8 @@ impl Default for GameplaySettings { auto_camera: false, bow_zoom: true, zoom_lock: false, + aim_offset_x: 1.0, + aim_offset_y: 0.0, } } }