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/sound.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'apps/fparkan-game/src/launch_menu/sound.rs') diff --git a/apps/fparkan-game/src/launch_menu/sound.rs b/apps/fparkan-game/src/launch_menu/sound.rs index 56fc1103..33df5088 100644 --- a/apps/fparkan-game/src/launch_menu/sound.rs +++ b/apps/fparkan-game/src/launch_menu/sound.rs @@ -1,8 +1,9 @@ //! Draft and persistence for the menu's sound controls. +use super::profile; use fparkan_assets::game_settings::GameSettings; use fparkan_vfs::DirectoryVfs; -use std::{fs, io, io::Write, path::Path}; +use std::{io, path::Path}; #[derive(Clone, Copy)] pub(super) enum Volume { @@ -87,22 +88,7 @@ impl SoundSettings { .into_iter() .filter_map(|(key, previous, next)| (previous != next).then_some((key, next))) .collect(); - if !updates.is_empty() { - 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); - } - } + profile::save_integers(root, &updates)?; self.saved = self.draft; self.status = "Сохранено"; Ok(()) -- cgit v1.2.3