Added x and y aiming offsets to settings

This commit is contained in:
Woeful_Wolf 2024-01-28 16:11:21 +02:00
parent 43566bca32
commit e270992bda
3 changed files with 86 additions and 1 deletions

View File

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

View File

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

View File

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