diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index e349a8c78c..a035d17316 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -113,6 +113,7 @@ pub enum Event { AdjustViewDistance(u32), AdjustVolume(f32), ChangeAudioDevice(String), + MaximumFPS(u32), CharacterSelection, Logout, Quit, @@ -581,6 +582,9 @@ impl Hud { settings_window::Event::AdjustVolume(volume) => { events.push(Event::AdjustVolume(volume)); } + settings_window::Event::MaximumFPS(max_fps) => { + events.push(Event::MaximumFPS(max_fps)); + } settings_window::Event::ChangeAudioDevice(name) => { events.push(Event::ChangeAudioDevice(name)); } diff --git a/voxygen/src/hud/settings_window.rs b/voxygen/src/hud/settings_window.rs index 0acea547e6..d6e661e06f 100644 --- a/voxygen/src/hud/settings_window.rs +++ b/voxygen/src/hud/settings_window.rs @@ -43,6 +43,9 @@ widget_ids! { video, vd_slider, vd_slider_text, + max_fps_slider, + max_fps_text, + max_fps_value, audio_volume_slider, audio_volume_text, audio_device_list, @@ -103,6 +106,7 @@ pub enum Event { AdjustViewDistance(u32), AdjustVolume(f32), ChangeAudioDevice(String), + MaximumFPS(u32), } impl<'a> Widget for SettingsWindow<'a> { @@ -586,7 +590,7 @@ impl<'a> Widget for SettingsWindow<'a> { self.imgs.slider, ) .w_h(104.0, 22.0) - .down_from(state.ids.vd_slider_text, 10.0) + .down_from(state.ids.vd_slider_text, 8.0) .track_breadth(12.0) .slider_length(10.0) .pad_track((5.0, 5.0)) @@ -594,6 +598,29 @@ impl<'a> Widget for SettingsWindow<'a> { { events.push(Event::AdjustViewDistance(new_val)); } + Text::new("Maximum FPS") + .top_left_with_margins_on(state.ids.settings_content, 60.0, 10.0) + .font_size(14) + .font_id(self.fonts.opensans) + .color(TEXT_COLOR) + .set(state.ids.max_fps_text, ui); + + if let Some(new_val) = ImageSlider::discrete( + self.global_state.settings.graphics.view_distance, + 50, + 150, + self.imgs.slider_indicator, + self.imgs.slider, + ) + .w_h(104.0, 22.0) + .down_from(state.ids.max_fps_text, 8.0) + .track_breadth(12.0) + .slider_length(10.0) + .pad_track((5.0, 5.0)) + .set(state.ids.max_fps_slider, ui) + { + events.push(Event::MaximumFPS(new_val)); + } } // 5) Sound Tab ----------------------------------- diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 253737924e..ea1d01d3d3 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -13,7 +13,7 @@ use log::{error, warn}; use std::{cell::RefCell, rc::Rc, time::Duration}; use vek::*; -const FPS: u64 = 60; +const FPS: u64 = 1000; pub struct SessionState { scene: Scene,