From dda84190134cf656d6f43c938a63098c0aa3486f Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 3 Dec 2026 14:09:16 +0400 Subject: feat(ui): apply graphics settings from the menu --- apps/fparkan-game/src/launch_menu/profile.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 apps/fparkan-game/src/launch_menu/profile.rs (limited to 'apps/fparkan-game/src/launch_menu/profile.rs') diff --git a/apps/fparkan-game/src/launch_menu/profile.rs b/apps/fparkan-game/src/launch_menu/profile.rs new file mode 100644 index 00000000..366f499f --- /dev/null +++ b/apps/fparkan-game/src/launch_menu/profile.rs @@ -0,0 +1,24 @@ +use fparkan_assets::game_settings::GameSettings; +use fparkan_vfs::DirectoryVfs; +use std::{fs, io, io::Write, path::Path}; + +pub(super) fn save_integers(root: &Path, updates: &[(&str, i32)]) -> io::Result<()> { + if updates.is_empty() { + return Ok(()); + } + let profile = GameSettings::load(&DirectoryVfs::new(root)).map_err(io::Error::other)?; + let updated = profile.with_cs_integers(updates); + let path = root.join("Iron_3D.ini"); + let temporary = root.join(format!("Iron_3D.ini.fparkan-{}.tmp", std::process::id())); + let mut file = fs::OpenOptions::new() + .write(true) + .create_new(true) + .open(&temporary)?; + let written = file.write_all(&updated).and_then(|()| file.sync_all()); + drop(file); + if let Err(error) = written.and_then(|()| fs::rename(&temporary, path)) { + let _ = fs::remove_file(&temporary); + return Err(error); + } + Ok(()) +} -- cgit v1.2.3