aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/hero_look.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-03 12:27:37 +0300
committerValentin Popov <valentin@popov.link>2026-12-03 12:27:37 +0300
commite59c55289c494a5bd0126b6c40bc4e07a52b8a28 (patch)
tree9b968144498a0339b98f1d583f23bb574b8e3e03 /crates/fparkan-runtime/src/hero_look.rs
parente9ba4a3e0a039715fdf1c169edd7f56faa8570b1 (diff)
downloadfparkan-e59c55289c494a5bd0126b6c40bc4e07a52b8a28.tar.xz
fparkan-e59c55289c494a5bd0126b6c40bc4e07a52b8a28.zip
feat(ui): use the installed display mode at game startup
Diffstat (limited to 'crates/fparkan-runtime/src/hero_look.rs')
-rw-r--r--crates/fparkan-runtime/src/hero_look.rs29
1 files changed, 5 insertions, 24 deletions
diff --git a/crates/fparkan-runtime/src/hero_look.rs b/crates/fparkan-runtime/src/hero_look.rs
index 2e923d20..a31512d1 100644
--- a/crates/fparkan-runtime/src/hero_look.rs
+++ b/crates/fparkan-runtime/src/hero_look.rs
@@ -1,3 +1,4 @@
+use fparkan_assets::game_settings::GameSettings;
use fparkan_path::{normalize_relative, PathPolicy};
use fparkan_vfs::Vfs;
use std::f32::consts::{PI, TAU};
@@ -29,9 +30,8 @@ impl HeroLook {
vfs.read(&path).ok()
};
let table_bytes = read(table_name);
- let settings_bytes = read(b"Iron_3D.ini");
let table = String::from_utf8_lossy(table_bytes.as_deref().unwrap_or_default());
- let settings = String::from_utf8_lossy(settings_bytes.as_deref().unwrap_or_default());
+ let settings = GameSettings::load(vfs).unwrap_or_default();
Self {
yaw_turns: mouse_binding(
&table,
@@ -71,8 +71,9 @@ impl HeroLook {
)
.unwrap_or(0.15),
],
- reverse_y: control_setting(&settings, "MOUSE_REV_Y").unwrap_or(0) != 0,
- sensitivity: control_setting(&settings, "MOUSE_SENS")
+ reverse_y: settings.integer("MOUSE_REV_Y").unwrap_or(0) != 0,
+ sensitivity: settings
+ .integer("MOUSE_SENS")
.map_or(1.0, |value| value as f32 * 0.01),
filtered: [0.0; 2],
phase: 0.5,
@@ -198,23 +199,6 @@ fn mouse_binding(
})
}
-fn control_setting(settings: &str, key: &str) -> Option<i32> {
- let mut controls = false;
- for line in settings.lines().map(str::trim) {
- if let Some(section) = line.strip_prefix('[').and_then(|line| line.split_once(']')) {
- controls = section.0.eq_ignore_ascii_case("CS");
- }
- if controls {
- if let Some((name, value)) = line.split_once('=') {
- if name.trim().eq_ignore_ascii_case(key) {
- return value.trim().parse().ok();
- }
- }
- }
- }
- None
-}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -262,9 +246,6 @@ MOUSE SCAN_NULL SCAN_MOUSE_Y 1 CICLS_TURRET MCMD_ANGLE_Y 0.30 1 MAN_NOTWRAP 0.0
),
Some(0.30)
);
- let settings = "[VIDEO]\nMOUSE_SENS=100\n[cs]\n mouse_sens = 50\n mouse_rev_y=1";
- assert_eq!(control_setting(settings, "MOUSE_SENS"), Some(50));
- assert_eq!(control_setting(settings, "MOUSE_REV_Y"), Some(1));
}
#[test]