From d5a6f8e1bca9fabfb412d94f8051afbfb9811f35 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 22 Jan 2025 08:54:05 -0800 Subject: [PATCH] compute UserSettings from directories --- engine/settings/src/settings.rs | 6 +++--- strafe-client/Cargo.toml | 1 + strafe-client/src/window.rs | 9 +++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/engine/settings/src/settings.rs b/engine/settings/src/settings.rs index 942c99e3b..ec1e8a328 100644 --- a/engine/settings/src/settings.rs +++ b/engine/settings/src/settings.rs @@ -74,9 +74,9 @@ sensitivity_y_from_x_ratio=1 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(); - 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 fov=match(cfg_fov_x,cfg_fov_y){ (Ok(Some(fov_x)),Ok(Some(fov_y)))=>Fov::Exactly { @@ -136,4 +136,4 @@ pub fn read_user_settings()->UserSettings{ }else{ UserSettings::default() } -} \ No newline at end of file +} diff --git a/strafe-client/Cargo.toml b/strafe-client/Cargo.toml index 091676b3a..64f87fe09 100644 --- a/strafe-client/Cargo.toml +++ b/strafe-client/Cargo.toml @@ -9,6 +9,7 @@ authors = ["Rhys Lloyd "] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] +user-install=[] # as opposed to portable install default = ["snf"] snf = ["dep:strafesnet_snf"] source = ["dep:strafesnet_deferred_loader", "dep:strafesnet_bsp_loader"] diff --git a/strafe-client/src/window.rs b/strafe-client/src/window.rs index 65097b4fd..985291c90 100644 --- a/strafe-client/src/window.rs +++ b/strafe-client/src/window.rs @@ -4,7 +4,7 @@ use strafesnet_common::physics::{MiscInstruction,SetControlInstruction}; use crate::file::LoadFormat; use crate::physics_worker::Instruction as PhysicsWorkerInstruction; use strafesnet_session::session::{self,SessionInputInstruction,SessionControlInstruction,SessionPlaybackInstruction}; -use strafesnet_settings::settings; +use strafesnet_settings::directories::Directories; pub enum Instruction{ Resize(winit::dpi::PhysicalSize), @@ -211,7 +211,12 @@ pub fn worker<'a>( setup_context:crate::setup::SetupContext<'a>, )->crate::compat_worker::QNWorker<'a,TimedInstruction>{ // 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); graphics.load_user_settings(&user_settings);