mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'stevedagiraffe/add-option-to-invert-scroll-wheel' into 'master'
Resolve #266 "Add option to invert scroll wheel" Closes #266 See merge request veloren/veloren!528
This commit is contained in:
commit
6715f02a4e
@ -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));
|
||||
}
|
||||
|
@ -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,32 @@ 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 --------------------------------
|
||||
|
@ -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);
|
||||
|
||||
|
@ -95,6 +95,7 @@ impl Default for ControlSettings {
|
||||
pub struct GameplaySettings {
|
||||
pub pan_sensitivity: u32,
|
||||
pub zoom_sensitivity: u32,
|
||||
pub zoom_inversion: bool,
|
||||
pub crosshair_transp: f32,
|
||||
pub crosshair_type: CrosshairType,
|
||||
pub xp_bar: XpBar,
|
||||
@ -108,6 +109,7 @@ impl Default for GameplaySettings {
|
||||
Self {
|
||||
pan_sensitivity: 100,
|
||||
zoom_sensitivity: 100,
|
||||
zoom_inversion: false,
|
||||
crosshair_transp: 0.6,
|
||||
crosshair_type: CrosshairType::Round,
|
||||
xp_bar: XpBar::OnGain,
|
||||
|
@ -91,6 +91,7 @@ pub struct Window {
|
||||
cursor_grabbed: bool,
|
||||
pub pan_sensitivity: u32,
|
||||
pub zoom_sensitivity: u32,
|
||||
pub zoom_inversion: bool,
|
||||
fullscreen: bool,
|
||||
needs_refresh_resize: bool,
|
||||
key_map: HashMap<KeyMouse, Vec<GameInput>>,
|
||||
@ -236,6 +237,7 @@ impl Window {
|
||||
cursor_grabbed: false,
|
||||
pan_sensitivity: settings.gameplay.pan_sensitivity,
|
||||
zoom_sensitivity: settings.gameplay.zoom_sensitivity,
|
||||
zoom_inversion: settings.gameplay.zoom_inversion,
|
||||
fullscreen: false,
|
||||
needs_refresh_resize: false,
|
||||
key_map: map,
|
||||
@ -271,6 +273,10 @@ impl Window {
|
||||
let keypress_map = &mut self.keypress_map;
|
||||
let pan_sensitivity = self.pan_sensitivity;
|
||||
let zoom_sensitivity = self.zoom_sensitivity;
|
||||
let zoom_inversion = match self.zoom_inversion {
|
||||
true => -1.0,
|
||||
false => 1.0,
|
||||
};
|
||||
let mut toggle_fullscreen = false;
|
||||
let mut take_screenshot = false;
|
||||
|
||||
@ -372,9 +378,9 @@ impl Window {
|
||||
glutin::DeviceEvent::MouseWheel {
|
||||
delta: glutin::MouseScrollDelta::LineDelta(_x, y),
|
||||
..
|
||||
} if cursor_grabbed && *focused => {
|
||||
events.push(Event::Zoom(y * (zoom_sensitivity as f32 / 100.0)))
|
||||
}
|
||||
} if cursor_grabbed && *focused => events.push(Event::Zoom(
|
||||
y * (zoom_sensitivity as f32 / 100.0) * zoom_inversion,
|
||||
)),
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
|
Loading…
Reference in New Issue
Block a user