From ea9051e68a9de762a3d6f79c2e8d26bd1ce4310c Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 09:12:48 +0400 Subject: feat(ui): show the original framed map in AutoDemo --- crates/fparkan-runtime/src/autodemo.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/fparkan-runtime') diff --git a/crates/fparkan-runtime/src/autodemo.rs b/crates/fparkan-runtime/src/autodemo.rs index fe0bfd19..ab793fb2 100644 --- a/crates/fparkan-runtime/src/autodemo.rs +++ b/crates/fparkan-runtime/src/autodemo.rs @@ -431,6 +431,22 @@ fn read_setting(bytes: &[u8], key: &str) -> Option { } impl AutoDemoCamera { + /// Unit selected while the automatic camera shows the strategic map. + pub fn strategy_map_target(&self, snapshot: &WorldSnapshot) -> Option { + if self.phase != 0 || self.last_clock_ms.is_none() { + return None; + } + self.targets + .get(self.target_index) + .copied() + .filter(|target| { + snapshot + .transforms + .iter() + .any(|(handle, _)| *handle == target.handle) + }) + } + /// Replaces the camera target for a reused model slot, or adds a new target. pub fn register_target(&mut self, cockpit: StartingCockpit) { if let Some(target) = self @@ -595,6 +611,11 @@ mod tests { demo.sample_with_height(0, &snapshot, terrain).unwrap(), AutoDemoView::Exterior { bird: false, .. } )); + assert_eq!( + demo.strategy_map_target(&snapshot) + .map(|target| target.handle), + Some(cockpit(0).handle) + ); assert!(matches!( demo.sample_with_height(5_000, &snapshot, terrain).unwrap(), AutoDemoView::Exterior { bird: false, .. } @@ -603,6 +624,7 @@ mod tests { demo.sample_with_height(5_001, &snapshot, terrain).unwrap(), AutoDemoView::Exterior { bird: true, .. } )); + assert!(demo.strategy_map_target(&snapshot).is_none()); assert!(matches!( demo.sample_with_height(15_001, &snapshot, terrain).unwrap(), AutoDemoView::Exterior { bird: true, .. } -- cgit v1.2.3