settings module

This commit is contained in:
Quaternions 2023-10-09 17:09:24 -07:00
parent f3dd43b171
commit 4864c12779
2 changed files with 34 additions and 0 deletions

View File

@ -10,6 +10,7 @@ mod model;
mod zeroes; mod zeroes;
mod worker; mod worker;
mod physics; mod physics;
mod settings;
mod framework; mod framework;
mod primitives; mod primitives;
mod instruction; mod instruction;

33
src/settings.rs Normal file
View File

@ -0,0 +1,33 @@
enum DerivedFov{
FromScreenAspect,
FromAspect{num:u32,den:u32},
}
enum Fov{
Exactly{x:f32,y:f32},
DeriveX{x:DerivedFov,y:f32},
DeriveY{x:f32,y:DerivedFov},
}
struct DerivedSensitivity{
ratio:f32,
}
enum Sensitivity{
Exactly{x:f32,y:f32},
DeriveX{x:DerivedSensitivity,y:f32},
DeriveY{x:f32,y:DerivedSensitivity},
}
pub struct UserSettings{
fov:Fov,
sensitivity:Sensitivity,
}
pub fn read_user_settings(){
let mut sensitivity=1.0/1024.0;
if let Ok(file)=std::fs::File::open("settings.conf"){
let cfg=configparser::ini::Ini::new();
if let Ok(Some(sens))=cfg.getfloat("user","sensitivity_x"){
sensitivity=sens;
}
}
}