mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
#966 - Add setting to invert controller camera Y axis
This commit is contained in:
parent
914266c705
commit
d4e3a3f29f
@ -41,6 +41,7 @@
|
||||
"hud.settings.zoom_sensitivity": "Zoom Sensitivity",
|
||||
"hud.settings.invert_scroll_zoom": "Invert Scroll Zoom",
|
||||
"hud.settings.invert_mouse_y_axis": "Invert Mouse Y Axis",
|
||||
"hud.settings.invert_controller_y_axis": "Invert Controller Y Axis",
|
||||
"hud.settings.enable_mouse_smoothing": "Camera Smoothing",
|
||||
"hud.settings.free_look_behavior": "Free look behavior",
|
||||
"hud.settings.auto_walk_behavior": "Auto walk behavior",
|
||||
|
@ -207,6 +207,7 @@ Enjoy your stay in the World of Veloren."#,
|
||||
"hud.settings.zoom_sensitivity": "Zoom Sensitivity",
|
||||
"hud.settings.invert_scroll_zoom": "Invert Scroll Zoom",
|
||||
"hud.settings.invert_mouse_y_axis": "Invert Mouse Y Axis",
|
||||
"hud.settings.invert_controller_y_axis": "Invert Controller Y Axis",
|
||||
|
||||
"hud.settings.view_distance": "View Distance",
|
||||
"hud.settings.maximum_fps": "Maximum FPS",
|
||||
|
@ -17,6 +17,7 @@ pub struct ControllerSettings {
|
||||
pub game_axis_map: HashMap<Axis, Vec<AxisGameAction>>,
|
||||
pub menu_axis_map: HashMap<Axis, Vec<AxisMenuAction>>,
|
||||
pub pan_sensitivity: u32,
|
||||
pub pan_invert_y: bool,
|
||||
pub axis_deadzones: HashMap<Axis, f32>,
|
||||
pub button_deadzones: HashMap<AnalogButton, f32>,
|
||||
pub mouse_emulation_sensitivity: u32,
|
||||
@ -259,6 +260,7 @@ impl From<&crate::settings::GamepadSettings> for ControllerSettings {
|
||||
map
|
||||
},
|
||||
pan_sensitivity: settings.pan_sensitivity,
|
||||
pan_invert_y: settings.pan_invert_y,
|
||||
axis_deadzones: settings.axis_deadzones.clone(),
|
||||
button_deadzones: settings.button_deadzones.clone(),
|
||||
mouse_emulation_sensitivity: settings.mouse_emulation_sensitivity,
|
||||
|
@ -348,6 +348,7 @@ pub enum Event {
|
||||
AdjustMouseZoom(u32),
|
||||
ToggleZoomInvert(bool),
|
||||
ToggleMouseYInvert(bool),
|
||||
ToggleControllerYInvert(bool),
|
||||
ToggleSmoothPan(bool),
|
||||
AdjustViewDistance(u32),
|
||||
AdjustLodDetail(u32),
|
||||
@ -2328,6 +2329,9 @@ impl Hud {
|
||||
settings_window::Event::ToggleMouseYInvert(mouse_y_inverted) => {
|
||||
events.push(Event::ToggleMouseYInvert(mouse_y_inverted));
|
||||
},
|
||||
settings_window::Event::ToggleControllerYInvert(controller_y_inverted) => {
|
||||
events.push(Event::ToggleControllerYInvert(controller_y_inverted));
|
||||
},
|
||||
settings_window::Event::ToggleSmoothPan(smooth_pan_enabled) => {
|
||||
events.push(Event::ToggleSmoothPan(smooth_pan_enabled));
|
||||
},
|
||||
|
@ -95,6 +95,8 @@ widget_ids! {
|
||||
mouse_zoom_invert_label,
|
||||
mouse_y_invert_button,
|
||||
mouse_y_invert_label,
|
||||
controller_y_invert_button,
|
||||
controller_y_invert_label,
|
||||
smooth_pan_toggle_button,
|
||||
smooth_pan_toggle_label,
|
||||
ch_title,
|
||||
@ -296,6 +298,7 @@ pub enum Event {
|
||||
AdjustMouseZoom(u32),
|
||||
ToggleZoomInvert(bool),
|
||||
ToggleMouseYInvert(bool),
|
||||
ToggleControllerYInvert(bool),
|
||||
ToggleSmoothPan(bool),
|
||||
AdjustViewDistance(u32),
|
||||
AdjustSpriteRenderDistance(u32),
|
||||
@ -1455,6 +1458,36 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.mouse_y_invert_label, ui);
|
||||
|
||||
// Controller Y Pan Inversion
|
||||
let controller_y_inverted = ToggleButton::new(
|
||||
self.global_state.settings.controller.pan_invert_y,
|
||||
self.imgs.checkbox,
|
||||
self.imgs.checkbox_checked,
|
||||
)
|
||||
.w_h(18.0, 18.0)
|
||||
.right_from(state.ids.mouse_y_invert_label, 10.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.controller_y_invert_button, ui);
|
||||
|
||||
if self.global_state.settings.controller.pan_invert_y != controller_y_inverted {
|
||||
events.push(Event::ToggleControllerYInvert(
|
||||
!self.global_state.settings.controller.pan_invert_y,
|
||||
));
|
||||
}
|
||||
|
||||
Text::new(
|
||||
&self
|
||||
.localized_strings
|
||||
.get("hud.settings.invert_controller_y_axis"),
|
||||
)
|
||||
.right_from(state.ids.controller_y_invert_button, 10.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.graphics_for(state.ids.controller_y_invert_button)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.controller_y_invert_label, ui);
|
||||
|
||||
// Mouse Smoothing Toggle
|
||||
let smooth_pan_enabled = ToggleButton::new(
|
||||
self.global_state.settings.gameplay.smooth_pan_enable,
|
||||
@ -1462,7 +1495,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
self.imgs.checkbox_checked,
|
||||
)
|
||||
.w_h(18.0, 18.0)
|
||||
.right_from(state.ids.mouse_y_invert_label, 10.0)
|
||||
.right_from(state.ids.controller_y_invert_label, 10.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.smooth_pan_toggle_button, ui);
|
||||
|
@ -906,6 +906,12 @@ impl PlayState for SessionState {
|
||||
global_state.settings.gameplay.mouse_y_inversion = mouse_y_inverted;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ToggleControllerYInvert(controller_y_inverted) => {
|
||||
global_state.window.controller_settings.pan_invert_y =
|
||||
controller_y_inverted;
|
||||
global_state.settings.controller.pan_invert_y = controller_y_inverted;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ToggleSmoothPan(smooth_pan_enabled) => {
|
||||
global_state.settings.gameplay.smooth_pan_enable = smooth_pan_enabled;
|
||||
global_state.settings.save_to_file_warn();
|
||||
|
@ -513,7 +513,7 @@ pub struct Window {
|
||||
events: Vec<Event>,
|
||||
focused: bool,
|
||||
gilrs: Option<Gilrs>,
|
||||
controller_settings: ControllerSettings,
|
||||
pub controller_settings: ControllerSettings,
|
||||
cursor_position: winit::dpi::PhysicalPosition<f64>,
|
||||
mouse_emulation_vec: Vec2<f32>,
|
||||
// Currently used to send and receive screenshot result messages
|
||||
@ -776,13 +776,18 @@ impl Window {
|
||||
));
|
||||
},
|
||||
AxisGameAction::CameraY => {
|
||||
let pan_invert_y =
|
||||
match self.controller_settings.pan_invert_y {
|
||||
true => -1.0,
|
||||
false => 1.0,
|
||||
};
|
||||
|
||||
self.events.push(Event::AnalogGameInput(
|
||||
AnalogGameInput::CameraY(
|
||||
// TODO: Use pan_invert_y here. Remove - in
|
||||
// front of `value` as well
|
||||
-value
|
||||
* self.controller_settings.pan_sensitivity
|
||||
as f32
|
||||
* pan_invert_y
|
||||
/ 100.0,
|
||||
),
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user