From faeb22084ea59194036785d84b68396981dfcbae Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 17:09:19 +0400 Subject: feat(ui): inspect the current factory project --- crates/fparkan-runtime/src/production/batch.rs | 2 +- crates/fparkan-runtime/src/production/strategic.rs | 60 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 9 deletions(-) (limited to 'crates/fparkan-runtime/src/production') diff --git a/crates/fparkan-runtime/src/production/batch.rs b/crates/fparkan-runtime/src/production/batch.rs index c0fb2690..ed8dee9a 100644 --- a/crates/fparkan-runtime/src/production/batch.rs +++ b/crates/fparkan-runtime/src/production/batch.rs @@ -10,7 +10,7 @@ use fparkan_world::{identity_metadata, ObjectHandle, OwnerId}; pub(super) struct BatchOrder { pub(super) plant: ObjectHandle, pub(super) owner: OwnerId, - scheme: usize, + pub(super) scheme: usize, } /// Starts a repeating order at an idle factory and reserves one clan slot. diff --git a/crates/fparkan-runtime/src/production/strategic.rs b/crates/fparkan-runtime/src/production/strategic.rs index 5b4e08f9..83360548 100644 --- a/crates/fparkan-runtime/src/production/strategic.rs +++ b/crates/fparkan-runtime/src/production/strategic.rs @@ -82,6 +82,8 @@ pub struct FactoryPanelPlant { pub free_minds: u32, pub progress: Option, pub batch: bool, + pub active_project: Option, + pub free_build: bool, pub projects: Vec, } @@ -98,7 +100,7 @@ pub fn factory_panel_plants( }; let free_minds = production.free_minds(&engine.world, mission, owner); let mut plants: Vec<_> = owned_factories(&engine.world, mission, production, owner) - .filter_map(|(index, handle, _)| { + .filter_map(|(index, handle, free_build)| { if factory_depleted(mission, handle) { return None; } @@ -113,6 +115,14 @@ pub fn factory_panel_plants( .pending .iter() .find(|order| order.plant == handle && order.owner == owner); + let batch = production + .batches + .iter() + .find(|batch| batch.plant == handle && batch.owner == owner); + let active_project = order + .map(|order| order.scheme) + .or_else(|| batch.map(|batch| batch.scheme)) + .filter(|&scheme| production.player_project(scheme)); let progress = order.map(|order| { let time = ratio( now_ms.wrapping_sub(order.start_ms) as f32, @@ -135,10 +145,9 @@ pub fn factory_panel_plants( label_id: label, free_minds, progress, - batch: production - .batches - .iter() - .any(|batch| batch.plant == handle && batch.owner == owner), + batch: batch.is_some(), + active_project, + free_build, projects, }, )) @@ -162,7 +171,11 @@ pub struct FactoryPanelProject { pub stats: WarbotStats, } -pub fn factory_panel_project(engine: &Engine, scheme: usize) -> Option { +pub fn factory_panel_project( + engine: &Engine, + scheme: usize, + current_factory: Option, +) -> Option { let (mission, production) = loaded_production(engine).ok()?; let root = factory_project_root(engine, scheme)?; let draft = &mission.object_drafts[root]; @@ -180,7 +193,14 @@ pub fn factory_panel_project(engine: &Engine, scheme: usize) -> Option