Configurable max fps

This commit is contained in:
Monty Marz 2019-06-06 17:54:11 +00:00 committed by Cody
parent 41f3cd5803
commit 8a19a6f2a3
No known key found for this signature in database
GPG Key ID: 4953DADF9B6AD3C8
3 changed files with 33 additions and 2 deletions

View File

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

View File

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

View File

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