diff options
Diffstat (limited to 'apps/fparkan-game/src/strategic_factory_hud.rs')
| -rw-r--r-- | apps/fparkan-game/src/strategic_factory_hud.rs | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/apps/fparkan-game/src/strategic_factory_hud.rs b/apps/fparkan-game/src/strategic_factory_hud.rs index a71793f8..0e865c30 100644 --- a/apps/fparkan-game/src/strategic_factory_hud.rs +++ b/apps/fparkan-game/src/strategic_factory_hud.rs @@ -3,7 +3,9 @@ use super::{ DirectoryVfs, EnvironmentGpuRange, StaticPreviewScene, VulkanSmokeRenderer, }; use fparkan_assets::{ - strategic_factory::{FactoryImages, FactoryOrders, FactoryPicture, FactoryRow, EXTENT, ORIGIN}, + strategic_factory::{ + FactoryControls, FactoryImages, FactoryOrders, FactoryPicture, FactoryRow, EXTENT, ORIGIN, + }, warbot_card::{CardLabels, RatingScale}, }; use fparkan_platform_winit::text::StringResources; @@ -15,24 +17,37 @@ pub(super) struct FactoryFrame { pub plants: Vec<FactoryPanelPlant>, pub active_plant: usize, pub selected: Option<usize>, + pub viewing_active: bool, pub model_started_ms: u32, pub designer_available: bool, } impl FactoryFrame { pub(super) fn scheme(&self) -> Option<usize> { - self.selected - .and_then(|slot| self.plants[self.active_plant].projects.get(slot).copied()) + let plant = &self.plants[self.active_plant]; + if self.viewing_active { + plant.active_project + } else { + self.selected + .and_then(|slot| plant.projects.get(slot).copied()) + } } - pub(super) fn orders(&self) -> FactoryOrders { + pub(super) fn controls(&self) -> FactoryControls { let plant = &self.plants[self.active_plant]; - FactoryOrders::for_plant( - plant.batch, - plant.progress.is_some(), - self.scheme().is_some(), - plant.free_minds, - ) + FactoryControls { + plants: self.plants.len(), + projects: plant.projects.len(), + orders: FactoryOrders::for_plant( + plant.batch, + plant.progress.is_some(), + self.scheme().is_some(), + plant.free_minds, + ), + designer_available: self.designer_available, + active_available: plant.active_project.is_some(), + free_build: plant.free_build, + } } } @@ -132,9 +147,11 @@ impl StrategicFactoryHud { selected: index == frame.active_plant, }) .collect::<Vec<_>>(); + let plant = &frame.plants[frame.active_plant]; + let current_factory = frame.viewing_active.then_some(plant.handle); let project = engine .zip(frame.scheme()) - .and_then(|(engine, scheme)| factory_panel_project(engine, scheme)); + .and_then(|(engine, scheme)| factory_panel_project(engine, scheme, current_factory)); let name = project.as_ref().and_then(|project| { let prefix = project.prefix.iter().collect::<String>(); Some(format!( @@ -153,17 +170,15 @@ impl StrategicFactoryHud { ) }, ); - let plant = &frame.plants[frame.active_plant]; let image = self.images.paint(FactoryPicture { rows: &rows, project_name: name.as_deref(), stats: &stats, - projects: plant.projects.len(), + controls: frame.controls(), selected_project: frame.selected, + viewing_active: frame.viewing_active, progress: plant.progress, free_minds: plant.free_minds, - orders: frame.orders(), - designer_available: frame.designer_available, })?; renderer .update_material_texture(self.range.material_index, 0, &overlay_texture(image)) |
