aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/satellite_map.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 11:48:50 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 11:48:50 +0300
commitdc92ae05f97d84a1681995e0712b01053e48704c (patch)
treec8e203ea9dda6abf0a85241135504a4bf99840df /apps/fparkan-game/src/satellite_map.rs
parent0b0764de47a0a1fef30464fb5e4be496e101b083 (diff)
downloadfparkan-dc92ae05f97d84a1681995e0712b01053e48704c.tar.xz
fparkan-dc92ae05f97d84a1681995e0712b01053e48704c.zip
feat(ui): show live contacts below the strategic satellite map
Use the installed title, close control and contact glyphs. Display the hovered object with clan emblem, name, order and durability in the strategic layout. Compared the Captain and Small Warehouse readouts with the original and checked map closing and cockpit return in stock Two Fortresses.
Diffstat (limited to 'apps/fparkan-game/src/satellite_map.rs')
-rw-r--r--apps/fparkan-game/src/satellite_map.rs89
1 files changed, 80 insertions, 9 deletions
diff --git a/apps/fparkan-game/src/satellite_map.rs b/apps/fparkan-game/src/satellite_map.rs
index 5eb8ec21..a2be6288 100644
--- a/apps/fparkan-game/src/satellite_map.rs
+++ b/apps/fparkan-game/src/satellite_map.rs
@@ -1,5 +1,6 @@
use super::{
mission_overlay::{add_overlay_sprite, overlay_texture},
+ strategic_view::ActiveCommandView,
EnvironmentGpuRange, StaticPreviewScene, VulkanSmokeRenderer, VulkanStaticMesh,
};
use fparkan_assets::{
@@ -30,6 +31,8 @@ pub(super) struct SatelliteMap {
units: Vec<satellite_contacts::UnitContact>,
visible: bool,
command_layout: bool,
+ #[cfg(windows)]
+ chrome: Option<super::satellite_map_chrome::SatelliteMapChrome>,
}
impl SatelliteMap {
@@ -37,6 +40,7 @@ impl SatelliteMap {
root: &Path,
mission: &str,
engine: &Engine,
+ _command_enabled: bool,
preview: &mut StaticPreviewScene,
) -> Result<Option<Self>, String> {
let Some(assets) = load_satellite_map(Arc::new(DirectoryVfs::new(root)), mission)? else {
@@ -53,21 +57,51 @@ impl SatelliteMap {
compass_right,
compass_bottom,
];
+ let frame = add_overlay_sprite(preview, assets.frame, bounds, [1.0; 3], 1.0)?;
+ let background =
+ add_overlay_sprite(preview, assets.background, image, MAP_TINT, MAP_ALPHA)?;
+ let compass = add_overlay_sprite(preview, assets.compass, compass, [1.0; 3], 1.0)?;
+ let contact_layer = add_overlay_sprite(preview, empty_layer(), image, [1.0; 3], 1.0)?;
+ #[cfg(windows)]
+ let chrome = _command_enabled
+ .then(|| {
+ super::satellite_map_chrome::SatelliteMapChrome::load(
+ root,
+ assets.icons.clone(),
+ preview,
+ )
+ })
+ .and_then(|result| {
+ result
+ .inspect_err(|error| {
+ eprintln!("satellite_map_chrome_unavailable reason={error}")
+ })
+ .ok()
+ });
Ok(Some(Self {
- frame: add_overlay_sprite(preview, assets.frame, bounds, [1.0; 3], 1.0)?,
- background: add_overlay_sprite(preview, assets.background, image, MAP_TINT, MAP_ALPHA)?,
- compass: add_overlay_sprite(preview, assets.compass, compass, [1.0; 3], 1.0)?,
- contact_layer: add_overlay_sprite(preview, empty_layer(), image, [1.0; 3], 1.0)?,
+ frame,
+ background,
+ compass,
+ contact_layer,
icons: assets.icons,
extent: satellite_contacts::landscape_extent(engine),
buildings: Vec::new(),
units: Vec::new(),
visible: false,
command_layout: false,
+ #[cfg(windows)]
+ chrome,
}))
}
- pub(super) fn ranges(&self) -> [usize; 4] {
+ pub(super) fn ranges(&self) -> impl Iterator<Item = usize> + '_ {
+ let ranges = self.map_ranges().into_iter();
+ #[cfg(windows)]
+ let ranges = ranges.chain(self.chrome.iter().flat_map(|chrome| chrome.ranges()));
+ ranges
+ }
+
+ fn map_ranges(&self) -> [usize; 4] {
[
self.frame.range_index,
self.background.range_index,
@@ -103,22 +137,55 @@ impl SatelliteMap {
self.visible && (left..right).contains(&x) && (top..bottom).contains(&y)
}
+ pub(super) fn chrome_at(&self, _pointer: [f32; 2]) -> bool {
+ #[cfg(windows)]
+ return self.visible
+ && self.chrome.is_some()
+ && fparkan_assets::satellite_map_chrome::covers_pointer(_pointer);
+ #[cfg(not(windows))]
+ false
+ }
+
+ pub(super) fn close_command_at(&mut self, _pointer: [f32; 2]) -> bool {
+ #[cfg(windows)]
+ if self.visible
+ && self.chrome.is_some()
+ && fparkan_assets::satellite_map_chrome::close_at(_pointer)
+ {
+ return self.hide();
+ }
+ false
+ }
+
pub(super) fn draw(
&mut self,
renderer: &mut VulkanSmokeRenderer,
mesh: &mut VulkanStaticMesh,
player: Option<(&Engine, StartingCockpit, Option<ObjectHandle>)>,
automatic: bool,
- command_layout: bool,
- draft: Option<&[[f32; 2]]>,
+ command: Option<&ActiveCommandView>,
) -> Result<(), String> {
let visible = self.visible || automatic;
let count = if visible { 6 } else { 0 };
- for index in self.ranges() {
+ for index in self.map_ranges() {
renderer
.set_draw_range_index_count(index, count)
.map_err(|error| error.to_string())?;
}
+ let command_layout = command.is_some();
+ #[cfg(windows)]
+ {
+ let contact = command
+ .and_then(ActiveCommandView::pointer)
+ .and_then(|point| self.command_destination(point))
+ .zip(player)
+ .and_then(|(xy, (engine, cockpit, _))| {
+ fparkan_runtime::strategic_map_readout::contact_at(engine, cockpit, xy)
+ });
+ if let Some(chrome) = &mut self.chrome {
+ chrome.draw(renderer, visible && command_layout, contact)?;
+ }
+ }
if !visible {
return Ok(());
}
@@ -141,7 +208,11 @@ impl SatelliteMap {
}
}
}
- self.update_contacts(renderer, player, draft)?;
+ self.update_contacts(
+ renderer,
+ player,
+ command.and_then(ActiveCommandView::route_draft),
+ )?;
Ok(())
}