aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/launch_menu/sound.rs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/fparkan-game/src/launch_menu/sound.rs')
-rw-r--r--apps/fparkan-game/src/launch_menu/sound.rs20
1 files changed, 3 insertions, 17 deletions
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(())