From 4864c127796a4b8316021ab3d27b584fcd4dbd90 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 9 Oct 2023 17:09:24 -0700 Subject: [PATCH] settings module --- src/main.rs | 1 + src/settings.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/settings.rs diff --git a/src/main.rs b/src/main.rs index e5c3b57..4823996 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ mod model; mod zeroes; mod worker; mod physics; +mod settings; mod framework; mod primitives; mod instruction; diff --git a/src/settings.rs b/src/settings.rs new file mode 100644 index 0000000..10d7391 --- /dev/null +++ b/src/settings.rs @@ -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; + } + } +} \ No newline at end of file