forked from StrafesNET/strafe-project
compute UserSettings from directories
This commit is contained in:
parent
95fb43b908
commit
d5a6f8e1bc
@ -74,9 +74,9 @@ sensitivity_y_from_x_ratio=1
|
|||||||
Sensitivity::DeriveY{x:0.0.001,y:DerivedSensitivity{ratio:1.0}}
|
Sensitivity::DeriveY{x:0.0.001,y:DerivedSensitivity{ratio:1.0}}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub fn read_user_settings()->UserSettings{
|
pub fn load_user_settings(path:&std::path::Path)->UserSettings{
|
||||||
let mut cfg=configparser::ini::Ini::new();
|
let mut cfg=configparser::ini::Ini::new();
|
||||||
if let Ok(_)=cfg.load("settings.conf"){
|
if let Ok(_)=cfg.load(path){
|
||||||
let (cfg_fov_x,cfg_fov_y)=(cfg.getfloat("camera","fov_x"),cfg.getfloat("camera","fov_y"));
|
let (cfg_fov_x,cfg_fov_y)=(cfg.getfloat("camera","fov_x"),cfg.getfloat("camera","fov_y"));
|
||||||
let fov=match(cfg_fov_x,cfg_fov_y){
|
let fov=match(cfg_fov_x,cfg_fov_y){
|
||||||
(Ok(Some(fov_x)),Ok(Some(fov_y)))=>Fov::Exactly {
|
(Ok(Some(fov_x)),Ok(Some(fov_y)))=>Fov::Exactly {
|
||||||
@ -136,4 +136,4 @@ pub fn read_user_settings()->UserSettings{
|
|||||||
}else{
|
}else{
|
||||||
UserSettings::default()
|
UserSettings::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ authors = ["Rhys Lloyd <krakow20@gmail.com>"]
|
|||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
[features]
|
[features]
|
||||||
|
user-install=[] # as opposed to portable install
|
||||||
default = ["snf"]
|
default = ["snf"]
|
||||||
snf = ["dep:strafesnet_snf"]
|
snf = ["dep:strafesnet_snf"]
|
||||||
source = ["dep:strafesnet_deferred_loader", "dep:strafesnet_bsp_loader"]
|
source = ["dep:strafesnet_deferred_loader", "dep:strafesnet_bsp_loader"]
|
||||||
|
@ -4,7 +4,7 @@ use strafesnet_common::physics::{MiscInstruction,SetControlInstruction};
|
|||||||
use crate::file::LoadFormat;
|
use crate::file::LoadFormat;
|
||||||
use crate::physics_worker::Instruction as PhysicsWorkerInstruction;
|
use crate::physics_worker::Instruction as PhysicsWorkerInstruction;
|
||||||
use strafesnet_session::session::{self,SessionInputInstruction,SessionControlInstruction,SessionPlaybackInstruction};
|
use strafesnet_session::session::{self,SessionInputInstruction,SessionControlInstruction,SessionPlaybackInstruction};
|
||||||
use strafesnet_settings::settings;
|
use strafesnet_settings::directories::Directories;
|
||||||
|
|
||||||
pub enum Instruction{
|
pub enum Instruction{
|
||||||
Resize(winit::dpi::PhysicalSize<u32>),
|
Resize(winit::dpi::PhysicalSize<u32>),
|
||||||
@ -211,7 +211,12 @@ pub fn worker<'a>(
|
|||||||
setup_context:crate::setup::SetupContext<'a>,
|
setup_context:crate::setup::SetupContext<'a>,
|
||||||
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTimeInner>>{
|
)->crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTimeInner>>{
|
||||||
// WindowContextSetup::new
|
// WindowContextSetup::new
|
||||||
let user_settings=settings::read_user_settings();
|
#[cfg(feature="user-install")]
|
||||||
|
let directories=Directories::user().unwrap();
|
||||||
|
#[cfg(not(feature="user-install"))]
|
||||||
|
let directories=Directories::portable().unwrap();
|
||||||
|
|
||||||
|
let user_settings=directories.settings();
|
||||||
|
|
||||||
let mut graphics=strafesnet_graphics::graphics::GraphicsState::new(&setup_context.device,&setup_context.queue,&setup_context.config);
|
let mut graphics=strafesnet_graphics::graphics::GraphicsState::new(&setup_context.device,&setup_context.queue,&setup_context.config);
|
||||||
graphics.load_user_settings(&user_settings);
|
graphics.load_user_settings(&user_settings);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user