diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 17:50:37 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 17:50:37 +0300 |
| commit | 3b5a8aa4e6465ca56763cb96b4100bb1ff1c0ccf (patch) | |
| tree | 7ccd3b6b20a2211d3c2f72f0707f2d28f9faaf2c /apps/fparkan-game/src/strategic_view.rs | |
| parent | bd7811533a348e56d2be9c7281d0533fc8c46024 (diff) | |
| download | fparkan-3b5a8aa4e6465ca56763cb96b4100bb1ff1c0ccf.tar.xz fparkan-3b5a8aa4e6465ca56763cb96b4100bb1ff1c0ccf.zip | |
feat(ui): link the other buildings panel to the satellite map
Use the installed compound controls, font, and class glyphs for live clan buildings and their durability. Compare the stock Two Fortresses list order, first selection, two-way map selection, and close behavior in the original and in FParkan with Vulkan validation.
Diffstat (limited to 'apps/fparkan-game/src/strategic_view.rs')
| -rw-r--r-- | apps/fparkan-game/src/strategic_view.rs | 152 |
1 files changed, 151 insertions, 1 deletions
diff --git a/apps/fparkan-game/src/strategic_view.rs b/apps/fparkan-game/src/strategic_view.rs index ffb806ab..a7da38da 100644 --- a/apps/fparkan-game/src/strategic_view.rs +++ b/apps/fparkan-game/src/strategic_view.rs @@ -3,6 +3,8 @@ use super::{ PreviewCameraFrame, StaticVulkanApp, }; #[cfg(windows)] +use fparkan_assets::strategic_buildings::{self, Hit as BuildingHit}; +#[cfg(windows)] use fparkan_assets::strategic_factory::FactoryAction; use fparkan_assets::strategic_roster::{ covers_pointer, hit_test, order_at, CockpitControl, ListHit, RosterOrder, @@ -11,6 +13,8 @@ use fparkan_assets::strategy_cursor::StrategyCursor; use fparkan_assets::strategy_toolbar::{ command_button_at, ToolbarAction, ToolbarFold, ToolbarLayout, }; +#[cfg(windows)] +use fparkan_runtime::strategic_buildings::{other_buildings, BuildingRow}; use fparkan_runtime::strategic_roster::{warbot_rows, WarbotRow}; use fparkan_runtime::strategic_view::{ command_post, mobile_command_post, CommandCamera, CommandCameraInput, COMMAND_FOV, @@ -43,6 +47,10 @@ pub(super) struct ActiveCommandView { pub(super) warbots_open: bool, #[cfg(windows)] factory: Option<FactorySelection>, + #[cfg(windows)] + other_buildings_open: bool, + #[cfg(windows)] + selected_building: Option<ObjectHandle>, pub(super) selected_warbot: Option<ObjectHandle>, order_input: Option<OrderInput>, } @@ -103,6 +111,45 @@ impl FactorySelection { } impl ActiveCommandView { + pub(super) fn other_buildings_open(&self) -> bool { + #[cfg(windows)] + return self.other_buildings_open; + #[cfg(not(windows))] + false + } + + pub(super) fn selected_building(&self) -> Option<ObjectHandle> { + #[cfg(windows)] + return self.selected_building; + #[cfg(not(windows))] + None + } + + #[cfg(windows)] + fn select_building(&mut self, row: BuildingRow) -> Option<BuildingRow> { + if self.selected_building == Some(row.handle) { + return None; + } + self.selected_building = Some(row.handle); + self.selected_warbot = None; + Some(row) + } + + #[cfg(windows)] + fn refresh_building_selection(&mut self, rows: &[BuildingRow]) -> Option<BuildingRow> { + if rows + .iter() + .any(|row| Some(row.handle) == self.selected_building) + { + return None; + } + if let Some(&row) = rows.first() { + return self.select_building(row); + } + self.selected_building = None; + None + } + pub(super) fn factories_open(&self) -> bool { #[cfg(windows)] { @@ -221,6 +268,10 @@ impl StaticVulkanApp { warbots_open: false, #[cfg(windows)] factory: None, + #[cfg(windows)] + other_buildings_open: false, + #[cfg(windows)] + selected_building: None, selected_warbot: None, order_input: None, }); @@ -338,7 +389,9 @@ impl StaticVulkanApp { self.command_view.as_mut().filter(|view| view.warbots_open) { view.warbots_open = false; - } else if self.close_strategic_factory_panel() { + } else if self.close_strategic_buildings() + || self.close_strategic_factory_panel() + { return true; } else { self.close_strategy(); @@ -490,6 +543,8 @@ impl StaticVulkanApp { #[cfg(windows)] { view.factory = None; + view.other_buildings_open = false; + view.selected_building = None; } if let Some(row) = view.refresh_warbots(&warbot_rows(engine, cockpit)) { self.play_warbot_selection(row); @@ -513,13 +568,61 @@ impl StaticVulkanApp { { view.factory = Some(factory); view.warbots_open = false; + view.other_buildings_open = false; + view.selected_building = None; view.selected_warbot = None; view.order_input = None; } } } + Some(ToolbarAction::OtherBuildings) => + { + #[cfg(windows)] + if view.other_buildings_open { + view.other_buildings_open = false; + } else if self.overlay.strategic_buildings.is_some() { + let rows = other_buildings(engine, cockpit); + if !rows.is_empty() { + view.other_buildings_open = true; + view.factory = None; + view.warbots_open = false; + view.selected_warbot = None; + view.order_input = None; + if let Some(row) = view.refresh_building_selection(&rows) { + self.play_building_selection(row); + } + } + } + } None => { #[cfg(windows)] + if !view.warbots_open && view.factory.is_none() && view.order_input.is_none() { + let map_hit = map + .as_deref() + .and_then(|map| map.command_destination(xy)) + .and_then(|point| satellite_contacts::pick_contact(engine, cockpit, point)); + let list_visible = + view.other_buildings_open && view.toolbar_layout().sections_visible(); + if list_visible || map_hit.is_some() { + let rows = other_buildings(engine, cockpit); + let row = match list_visible + .then(|| strategic_buildings::hit_test(xy, rows.len())) + .flatten() + { + Some(BuildingHit::Close) => { + view.other_buildings_open = false; + return; + } + Some(BuildingHit::Row(index)) => rows.get(index).copied(), + None => rows.into_iter().find(|row| Some(row.handle) == map_hit), + }; + if let Some(row) = row.and_then(|row| view.select_building(row)) { + self.play_building_selection(row); + } + return; + } + } + #[cfg(windows)] if let Some(factory) = view .factory .as_mut() @@ -751,6 +854,20 @@ impl StaticVulkanApp { } } + #[cfg(windows)] + fn play_building_selection(&mut self, row: BuildingRow) { + if let Some(audio) = self.audio.as_mut() { + let voice = match row.size { + 1 | 2 => "VOICE_SELECTED_S", + 4 | 5 => "VOICE_SELECTED_B", + _ => "VOICE_SELECTED", + }; + if let Err(error) = audio.queue_game_voice(voice) { + eprintln!("sim_coverage mission_voice_unavailable=1 notice={voice} reason={error}"); + } + } + } + pub(super) fn advance_strategy_toolbar(&mut self, now_ms: u32) { let Some(view) = self .command_view @@ -786,6 +903,39 @@ impl StaticVulkanApp { } } + fn close_strategic_buildings(&mut self) -> bool { + #[cfg(windows)] + return self + .command_view + .as_mut() + .is_some_and(|view| std::mem::take(&mut view.other_buildings_open)); + #[cfg(not(windows))] + false + } + + #[cfg(windows)] + pub(super) fn strategic_buildings_frame( + &mut self, + ) -> Option<super::strategic_buildings_hud::BuildingsFrame> { + let view = self + .command_view + .as_mut() + .filter(|view| view.other_buildings_open)?; + let (engine, cockpit) = self.mission_engine.as_ref().zip(self.cockpit)?; + let rows = other_buildings(engine, cockpit); + let changed = view.refresh_building_selection(&rows); + let frame = view.toolbar_layout().sections_visible().then_some( + super::strategic_buildings_hud::BuildingsFrame { + rows, + selected: view.selected_building, + }, + ); + if let Some(row) = changed { + self.play_building_selection(row); + } + frame + } + #[cfg(windows)] pub(super) fn strategic_factory_frame( &mut self, |
