From 0d8031eccad92190ea01c2c7f9a2cee28adecb62 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 06:49:08 +0400 Subject: fix(ui): validate warbot designs on transfer Keep the selected model open on a failed research check and post the original central-computer message to the shared pager and history. Verified rejection and corrected production order in the Field Camp window with Vulkan validation. --- apps/fparkan-game/src/factory_menu.rs | 36 +++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'apps/fparkan-game/src/factory_menu.rs') diff --git a/apps/fparkan-game/src/factory_menu.rs b/apps/fparkan-game/src/factory_menu.rs index 1b2a084e..46519199 100644 --- a/apps/fparkan-game/src/factory_menu.rs +++ b/apps/fparkan-game/src/factory_menu.rs @@ -14,8 +14,8 @@ use fparkan_assets::factory_projects::{ hit_test, FactoryProjectAction, FactoryProjectImages, EXTENT, ORIGIN, PROJECT_SLOTS, }; use fparkan_runtime::{ - factory_design_bytes, factory_part_variants, factory_project_components, Engine, - FactoryPartChange, + check_factory_design, factory_design_bytes, factory_part_variants, factory_project_components, + Engine, FactoryPartChange, }; use fparkan_world::ObjectHandle; use std::{ @@ -340,6 +340,28 @@ impl FactoryProjectPanel { } impl StaticVulkanApp { + fn send_designer_project(&mut self) { + let (Some(menu), Some(engine), Some(cockpit)) = + (&mut self.factory_menu, &self.mission_engine, self.cockpit) + else { + return; + }; + let Some(designer) = &menu.designer else { + return; + }; + let Some(project) = designer.selected else { + return; + }; + let scheme = menu.choices[designer.slots.start + project].scheme; + if let Err(error) = check_factory_design(engine, cockpit, scheme, &designer.changes) { + eprintln!("designer_transfer_rejected {error}"); + #[cfg(windows)] + self.present_computer_notice(0x83f, self.simulation_time_ms); + return; + } + menu.designer_action(DesignerAction::Send, self.simulation_time_ms); + } + pub(super) fn handle_designer_project_key( &mut self, key: PhysicalKey, @@ -439,9 +461,7 @@ impl StaticVulkanApp { KeyCode::Escape => { menu.designer_action(DesignerAction::Exit, self.simulation_time_ms) } - KeyCode::Enter | KeyCode::NumpadEnter => { - menu.designer_action(DesignerAction::Send, self.simulation_time_ms) - } + KeyCode::Enter | KeyCode::NumpadEnter => self.send_designer_project(), _ => {} } self.update_mission_title(); @@ -641,7 +661,11 @@ impl StaticVulkanApp { } designer.dirty = true; } else if let Some(action) = designer.hover { - menu.designer_action(action, self.simulation_time_ms); + if action == DesignerAction::Send { + self.send_designer_project(); + } else { + menu.designer_action(action, self.simulation_time_ms); + } self.update_mission_title(); } return true; -- cgit v1.2.3