Debug FPS display with rendering backend info
This commit is contained in:
1 parent
ee7b76fa6a
commit
07371cc893
8 files changed
+133
-4
No files matched your search
@@ -150,6 +150,7 @@ pub struct Settings {
|
||||
pub ui_factor: u8, // interface size: 0 = automatic, 1..4 = fixed integer factor
|
||||
pub render_scale: u8, // 3D world resolution divisor: 1 = full, 2..16 = pixel look
|
||||
pub touch_ui: u8, // touch interface: 0 = automatic (after the first touch), 1 = on, 2 = off
|
||||
pub debug_fps: bool, // show FPS and rendering backend
|
||||
// game
|
||||
pub game_speed: f32, // 1 or 2
|
||||
pub hints: bool,
|
||||
@@ -179,6 +180,7 @@ impl Default for Settings {
|
||||
ui_factor: 0,
|
||||
render_scale: 1,
|
||||
touch_ui: 0,
|
||||
debug_fps: false,
|
||||
game_speed: 1.0,
|
||||
hints: true,
|
||||
difficulty: 1,
|
||||
@@ -225,3 +227,19 @@ impl Settings {
|
||||
serde_json::from_str(s).ok()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn debug_fps_round_trips() {
|
||||
let mut s = Settings::default();
|
||||
assert!(!s.debug_fps);
|
||||
s.debug_fps = true;
|
||||
let l = Settings::from_json(&s.to_json()).expect("settings serialize back");
|
||||
assert!(l.debug_fps);
|
||||
let old = Settings::from_json(r#"{"language":"en","map_w":64,"map_h":64}"#).expect("old settings remain readable");
|
||||
assert!(!old.debug_fps);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user