mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Changes setting type to u32, enforces live in-game updates to setting.
This commit is contained in:
parent
a90d073c22
commit
41f3cd5803
@ -32,9 +32,11 @@ widget_ids! {
|
|||||||
inventory_test_button,
|
inventory_test_button,
|
||||||
inventory_test_button_label,
|
inventory_test_button_label,
|
||||||
mouse_pan_slider,
|
mouse_pan_slider,
|
||||||
mouse_pan_text,
|
mouse_pan_label,
|
||||||
|
mouse_pan_value,
|
||||||
mouse_zoom_slider,
|
mouse_zoom_slider,
|
||||||
mouse_zoom_text,
|
mouse_zoom_label,
|
||||||
|
mouse_zoom_value,
|
||||||
settings_bg,
|
settings_bg,
|
||||||
sound,
|
sound,
|
||||||
test,
|
test,
|
||||||
@ -291,22 +293,25 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
|
|
||||||
// Contents
|
// Contents
|
||||||
if let SettingsTab::Gameplay = self.show.settings_tab {
|
if let SettingsTab::Gameplay = self.show.settings_tab {
|
||||||
|
let display_pan = self.global_state.settings.gameplay.pan_sensitivity;
|
||||||
|
let display_zoom = self.global_state.settings.gameplay.zoom_sensitivity;
|
||||||
|
|
||||||
Text::new("Pan Sensitivity")
|
Text::new("Pan Sensitivity")
|
||||||
.top_left_with_margins_on(state.ids.settings_content, 10.0, 10.0)
|
.top_left_with_margins_on(state.ids.settings_content, 10.0, 10.0)
|
||||||
.font_size(14)
|
.font_size(14)
|
||||||
.font_id(self.fonts.opensans)
|
.font_id(self.fonts.opensans)
|
||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.mouse_pan_text, ui);
|
.set(state.ids.mouse_pan_label, ui);
|
||||||
|
|
||||||
if let Some(new_val) = ImageSlider::discrete(
|
if let Some(new_val) = ImageSlider::discrete(
|
||||||
(self.global_state.settings.gameplay.pan_sensitivity * 100.0) as u32,
|
display_pan,
|
||||||
1,
|
1,
|
||||||
200,
|
200,
|
||||||
self.imgs.slider_indicator,
|
self.imgs.slider_indicator,
|
||||||
self.imgs.slider,
|
self.imgs.slider,
|
||||||
)
|
)
|
||||||
.w_h(208.0, 22.0)
|
.w_h(550.0, 22.0)
|
||||||
.down_from(state.ids.mouse_pan_text, 10.0)
|
.down_from(state.ids.mouse_pan_label, 10.0)
|
||||||
.track_breadth(30.0)
|
.track_breadth(30.0)
|
||||||
.slider_length(10.0)
|
.slider_length(10.0)
|
||||||
.pad_track((5.0, 5.0))
|
.pad_track((5.0, 5.0))
|
||||||
@ -315,22 +320,29 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
events.push(Event::AdjustMousePan(new_val));
|
events.push(Event::AdjustMousePan(new_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text::new(&format!("{}", display_pan))
|
||||||
|
.right_from(state.ids.mouse_pan_slider, 8.0)
|
||||||
|
.font_size(14)
|
||||||
|
.font_id(self.fonts.opensans)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(state.ids.mouse_pan_value, ui);
|
||||||
|
|
||||||
Text::new("Zoom Sensitivity")
|
Text::new("Zoom Sensitivity")
|
||||||
.down_from(state.ids.mouse_pan_slider, 10.0)
|
.down_from(state.ids.mouse_pan_slider, 10.0)
|
||||||
.font_size(14)
|
.font_size(14)
|
||||||
.font_id(self.fonts.opensans)
|
.font_id(self.fonts.opensans)
|
||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.mouse_zoom_text, ui);
|
.set(state.ids.mouse_zoom_label, ui);
|
||||||
|
|
||||||
if let Some(new_val) = ImageSlider::discrete(
|
if let Some(new_val) = ImageSlider::discrete(
|
||||||
(self.global_state.settings.gameplay.zoom_sensitivity * 100.0) as u32,
|
display_zoom,
|
||||||
1,
|
1,
|
||||||
200,
|
200,
|
||||||
self.imgs.slider_indicator,
|
self.imgs.slider_indicator,
|
||||||
self.imgs.slider,
|
self.imgs.slider,
|
||||||
)
|
)
|
||||||
.w_h(208.0, 22.0)
|
.w_h(550.0, 22.0)
|
||||||
.down_from(state.ids.mouse_zoom_text, 10.0)
|
.down_from(state.ids.mouse_zoom_label, 10.0)
|
||||||
.track_breadth(30.0)
|
.track_breadth(30.0)
|
||||||
.slider_length(10.0)
|
.slider_length(10.0)
|
||||||
.pad_track((5.0, 5.0))
|
.pad_track((5.0, 5.0))
|
||||||
@ -338,6 +350,13 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
{
|
{
|
||||||
events.push(Event::AdjustMouseZoom(new_val));
|
events.push(Event::AdjustMouseZoom(new_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text::new(&format!("{}", display_zoom))
|
||||||
|
.right_from(state.ids.mouse_zoom_slider, 8.0)
|
||||||
|
.font_size(14)
|
||||||
|
.font_id(self.fonts.opensans)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(state.ids.mouse_zoom_value, ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3) Controls Tab --------------------------------
|
// 3) Controls Tab --------------------------------
|
||||||
|
@ -186,12 +186,13 @@ impl PlayState for SessionState {
|
|||||||
return PlayStateResult::Shutdown;
|
return PlayStateResult::Shutdown;
|
||||||
}
|
}
|
||||||
HudEvent::AdjustMousePan(sensitivity) => {
|
HudEvent::AdjustMousePan(sensitivity) => {
|
||||||
global_state.settings.gameplay.pan_sensitivity = sensitivity as f32 / 100.0;
|
global_state.window.pan_sensitivity = sensitivity;
|
||||||
|
global_state.settings.gameplay.pan_sensitivity = sensitivity;
|
||||||
global_state.settings.save_to_file();
|
global_state.settings.save_to_file();
|
||||||
}
|
}
|
||||||
HudEvent::AdjustMouseZoom(sensitivity) => {
|
HudEvent::AdjustMouseZoom(sensitivity) => {
|
||||||
global_state.settings.gameplay.zoom_sensitivity =
|
global_state.window.zoom_sensitivity = sensitivity;
|
||||||
sensitivity as f32 / 100.0;
|
global_state.settings.gameplay.zoom_sensitivity = sensitivity;
|
||||||
global_state.settings.save_to_file();
|
global_state.settings.save_to_file();
|
||||||
}
|
}
|
||||||
HudEvent::AdjustViewDistance(view_distance) => {
|
HudEvent::AdjustViewDistance(view_distance) => {
|
||||||
|
@ -48,8 +48,8 @@ pub struct ControlSettings {
|
|||||||
/// `GameplaySettings` contains sensitivity and gameplay options.
|
/// `GameplaySettings` contains sensitivity and gameplay options.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct GameplaySettings {
|
pub struct GameplaySettings {
|
||||||
pub pan_sensitivity: f32,
|
pub pan_sensitivity: u32,
|
||||||
pub zoom_sensitivity: f32,
|
pub zoom_sensitivity: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
@ -109,8 +109,8 @@ impl Default for Settings {
|
|||||||
attack: KeyMouse::Mouse(MouseButton::Left),
|
attack: KeyMouse::Mouse(MouseButton::Left),
|
||||||
},
|
},
|
||||||
gameplay: GameplaySettings {
|
gameplay: GameplaySettings {
|
||||||
pan_sensitivity: 1.0,
|
pan_sensitivity: 100,
|
||||||
zoom_sensitivity: 1.0,
|
zoom_sensitivity: 100,
|
||||||
},
|
},
|
||||||
networking: NetworkingSettings {
|
networking: NetworkingSettings {
|
||||||
username: "Username".to_string(),
|
username: "Username".to_string(),
|
||||||
|
@ -71,8 +71,8 @@ pub struct Window {
|
|||||||
renderer: Renderer,
|
renderer: Renderer,
|
||||||
window: glutin::GlWindow,
|
window: glutin::GlWindow,
|
||||||
cursor_grabbed: bool,
|
cursor_grabbed: bool,
|
||||||
pub pan_sensitivity: f32,
|
pub pan_sensitivity: u32,
|
||||||
pub zoom_sensitivity: f32,
|
pub zoom_sensitivity: u32,
|
||||||
fullscreen: bool,
|
fullscreen: bool,
|
||||||
needs_refresh_resize: bool,
|
needs_refresh_resize: bool,
|
||||||
key_map: HashMap<KeyMouse, GameInput>,
|
key_map: HashMap<KeyMouse, GameInput>,
|
||||||
@ -230,14 +230,14 @@ impl Window {
|
|||||||
glutin::DeviceEvent::MouseMotion {
|
glutin::DeviceEvent::MouseMotion {
|
||||||
delta: (dx, dy), ..
|
delta: (dx, dy), ..
|
||||||
} if cursor_grabbed && *focused => events.push(Event::CursorPan(Vec2::new(
|
} if cursor_grabbed && *focused => events.push(Event::CursorPan(Vec2::new(
|
||||||
dx as f32 * pan_sensitivity,
|
dx as f32 * (pan_sensitivity as f32 / 100.0),
|
||||||
dy as f32 * pan_sensitivity,
|
dy as f32 * (pan_sensitivity as f32 / 100.0),
|
||||||
))),
|
))),
|
||||||
glutin::DeviceEvent::MouseWheel {
|
glutin::DeviceEvent::MouseWheel {
|
||||||
delta: glutin::MouseScrollDelta::LineDelta(_x, y),
|
delta: glutin::MouseScrollDelta::LineDelta(_x, y),
|
||||||
..
|
..
|
||||||
} if cursor_grabbed && *focused => {
|
} if cursor_grabbed && *focused => {
|
||||||
events.push(Event::Zoom(y as f32 * zoom_sensitivity))
|
events.push(Event::Zoom(y * (zoom_sensitivity as f32 / 100.0)))
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user