aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/strategic_view.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 15:42:10 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 15:42:10 +0300
commitfd42fb7e4fa27d2fe03ee8b6532949b7c1b13ace (patch)
tree2c6fe8e6441566fd5170caa216fcf224383e9a4a /apps/fparkan-game/src/strategic_view.rs
parentaafdd0c398923f51625b632789ff0c7948b006e8 (diff)
downloadfparkan-fd42fb7e4fa27d2fe03ee8b6532949b7c1b13ace.tar.xz
fparkan-fd42fb7e4fa27d2fe03ee8b6532949b7c1b13ace.zip
feat(ui): transfer designer projects to strategic factories
Diffstat (limited to 'apps/fparkan-game/src/strategic_view.rs')
-rw-r--r--apps/fparkan-game/src/strategic_view.rs47
1 files changed, 46 insertions, 1 deletions
diff --git a/apps/fparkan-game/src/strategic_view.rs b/apps/fparkan-game/src/strategic_view.rs
index 7c32f6bc..58fac0df 100644
--- a/apps/fparkan-game/src/strategic_view.rs
+++ b/apps/fparkan-game/src/strategic_view.rs
@@ -57,6 +57,7 @@ impl FactorySelection {
&mut self,
plants: Vec<fparkan_runtime::FactoryPanelPlant>,
now_ms: u32,
+ designer_available: bool,
) -> Option<super::strategic_factory_hud::FactoryFrame> {
let active_plant = plants
.iter()
@@ -79,6 +80,7 @@ impl FactorySelection {
active_plant,
selected,
model_started_ms: self.model_started_ms,
+ designer_available,
})
}
}
@@ -145,6 +147,7 @@ impl StaticVulkanApp {
self.overlay.strategy_cursor.is_some()
&& self.window_focused
&& !self.mission_paused
+ && self.factory_menu.is_none()
&& self
.command_view
.as_ref()
@@ -281,6 +284,9 @@ impl StaticVulkanApp {
}
pub(super) fn handle_strategy_key(&mut self, event: &KeyEvent) -> bool {
+ if self.factory_menu.is_some() {
+ return false;
+ }
let pressed = event.state == ElementState::Pressed && !event.repeat && !self.mission_paused;
if self.command_view.is_none() {
return pressed
@@ -360,6 +366,8 @@ impl StaticVulkanApp {
}
fn click_strategy(&mut self, button: MouseButton) {
+ #[cfg(windows)]
+ let designer_available = self.factory_designer_available();
let Some(view) = self.command_view.as_mut() else {
return;
};
@@ -480,6 +488,7 @@ impl StaticVulkanApp {
self.simulation_time_ms,
),
self.simulation_time_ms,
+ designer_available,
)
.is_some()
{
@@ -501,6 +510,7 @@ impl StaticVulkanApp {
if let Some(frame) = factory.frame(
fparkan_runtime::factory_panel_plants(engine, cockpit, now),
now,
+ designer_available,
) {
let plant = &frame.plants[frame.active_plant];
match strategic_factory::hit_test(
@@ -508,6 +518,7 @@ impl StaticVulkanApp {
frame.plants.len(),
plant.projects.len(),
frame.order_button(),
+ frame.designer_available,
) {
Some(FactoryAction::Close) => view.factory = None,
Some(FactoryAction::Plant(index)) => {
@@ -543,6 +554,10 @@ impl StaticVulkanApp {
eprintln!("strategic_factory_cancel_rejected reason={error}");
}
}
+ Some(FactoryAction::Designer) => {
+ view.pointer = None;
+ self.open_strategic_designer(plant.handle, xy);
+ }
None => {}
}
}
@@ -755,18 +770,48 @@ impl StaticVulkanApp {
&mut self,
now_ms: u32,
) -> Option<super::strategic_factory_hud::FactoryFrame> {
+ if self.factory_menu.is_some() {
+ return None;
+ }
+ let designer_available = self.factory_designer_available();
let view = self.command_view.as_mut()?;
let visible = view.toolbar.layout().sections_visible();
let selection = view.factory.as_mut()?;
let engine = self.mission_engine.as_ref()?;
let plants = fparkan_runtime::factory_panel_plants(engine, self.cockpit?, now_ms);
- let frame = selection.frame(plants, now_ms);
+ let frame = selection.frame(plants, now_ms, designer_available);
if frame.is_none() {
view.factory = None;
}
frame.filter(|_| visible)
}
+ #[cfg(windows)]
+ fn factory_designer_available(&self) -> bool {
+ self.overlay
+ .factory_projects
+ .as_ref()
+ .is_some_and(super::factory_menu::FactoryProjectPanel::designer_available)
+ }
+
+ #[cfg(windows)]
+ pub(super) fn select_transferred_factory_project(
+ &mut self,
+ plant: ObjectHandle,
+ scheme: usize,
+ ) {
+ if let Some(factory) = self
+ .command_view
+ .as_mut()
+ .and_then(|view| view.factory.as_mut())
+ {
+ factory.plant = Some(plant);
+ factory.scheme = Some(scheme);
+ factory.model_started_ms = self.simulation_time_ms;
+ }
+ self.update_mission_title();
+ }
+
fn play_toolbar_latch(&mut self) {
if let Some(audio) = &mut self.audio {
if let Err(error) = audio.play_interface_sound("BAR_OPEN") {