From 72eff35e96ea0c9029248d8403c0a37f63642b79 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 01:24:00 +0400 Subject: feat(ui): animate and sound the original radar sweep Draw the native 20-segment outline over the cockpit dial and under its contacts. Read the installed radar period and restart only after two periods, playing the configured RADAR cue independently of mission speech. Check the growing and reset sweep on the stock Fireline start. --- apps/fparkan-game/src/audio.rs | 50 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'apps/fparkan-game/src/audio.rs') diff --git a/apps/fparkan-game/src/audio.rs b/apps/fparkan-game/src/audio.rs index 90ddd6d7..4e180ba2 100644 --- a/apps/fparkan-game/src/audio.rs +++ b/apps/fparkan-game/src/audio.rs @@ -638,6 +638,8 @@ pub(crate) struct GameAudio { music: Player, variations: Player, mission_voice: Player, + radar: Player, + radar_sample: Option, vehicle_capture_voice: capture_voice::VehicleCaptureVoice, mission_cfg: NormalizedPath, weather_loop: NativeSpatialPlayer, @@ -676,6 +678,7 @@ impl GameAudio { let music = Player::connect_new(stream.mixer()); let variations = Player::connect_new(stream.mixer()); let mission_voice = Player::connect_new(stream.mixer()); + let radar = Player::connect_new(stream.mixer()); let listener = Listener::default(); let (left, right) = ear_positions(listener)?; let weather_loop = @@ -686,6 +689,8 @@ impl GameAudio { music, variations, mission_voice, + radar, + radar_sample: None, vehicle_capture_voice: capture_voice::VehicleCaptureVoice::new(random_seed()), mission_cfg, weather_loop, @@ -699,6 +704,15 @@ impl GameAudio { weather_volume: 1.0, weather_position: listener.position, }; + audio.radar_sample = audio + .game_sound_resource("RADAR") + .and_then(|(archive, file)| { + audio + .dynamic_sound(&archive, &file) + .map_err(|error| error.to_string()) + }) + .map_err(|error| eprintln!("radar_audio_unavailable reason={error}")) + .ok(); audio.start_theme()?; audio.play_music_track(DEFAULT_MUSIC_TRACK)?; Ok(audio) @@ -954,6 +968,7 @@ impl GameAudio { &self.music, &self.variations, &self.mission_voice, + &self.radar, ] { if paused { player.pause(); @@ -988,6 +1003,7 @@ impl GameAudio { self.music.stop(); self.variations.stop(); self.mission_voice.stop(); + self.radar.stop(); self.weather_loop.stop(); for player in self.control_sounds.values() { player.stop(); @@ -1028,6 +1044,11 @@ impl GameAudio { } pub(crate) fn queue_game_voice(&mut self, symbol: &str) -> Result { + let (archive, file) = self.game_sound_resource(symbol)?; + self.queue_voice_asset(&archive, &file) + } + + fn game_sound_resource(&self, symbol: &str) -> Result<(String, String), String> { let path = normalize_relative(b"ui/game_resources.cfg", PathPolicy::StrictLegacy) .expect("valid game resources path"); let bytes = self @@ -1035,9 +1056,24 @@ impl GameAudio { .vfs .read(&path) .map_err(|error| error.to_string())?; - let (archive, file) = voice_resource(&bytes, symbol)? - .ok_or_else(|| format!("voice resource {symbol} is missing in {}", path.as_str()))?; - self.queue_voice_asset(&archive, &file) + voice_resource(&bytes, symbol)? + .ok_or_else(|| format!("sound {symbol} is missing in {}", path.as_str())) + } + + /// Plays the original non-positional radar pulse alongside mission speech. + pub(crate) fn play_radar_pulse(&mut self) -> Result<(), AudioError> { + if self.paused { + return Ok(()); + } + let Some(sample) = self.radar_sample.take() else { + return Ok(()); + }; + let source = decoder_for(&sample)?; + self.radar.clear(); + self.radar.append(source); + self.radar.play(); + self.radar_sample = Some(sample); + Ok(()) } fn queue_voice_asset(&mut self, archive: &str, file: &str) -> Result { @@ -1968,6 +2004,13 @@ mod tests { let vfs: Arc = Arc::new(fparkan_vfs::DirectoryVfs::new(&root)); let mut audio = GameAudio::new(vfs, "MISSIONS/Autodemo.00/data.tma").expect("open original game audio"); + let radar_sample = audio.radar_sample.as_ref().expect("original radar sample"); + assert_eq!(radar_sample.resource_name(), "sounds.lib:i_radar.wav"); + audio + .play_radar_pulse() + .expect("play original radar sample"); + assert!(!audio.radar.empty()); + assert!(audio.mission_voice.empty()); audio .handle_sound_event(&SoundEvent { archive: "sounds.lib".to_string(), @@ -2014,6 +2057,7 @@ mod tests { assert!(audio.control_sound_is_playing(ControlSoundId::Effect(1))); assert!(!audio.weather_loop.empty()); audio.set_paused(true); + assert!(audio.radar.is_paused()); assert!(audio .control_sounds .values() -- cgit v1.2.3