aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/satellite_map_chrome.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_chrome.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_chrome.rs')
-rw-r--r--apps/fparkan-game/src/satellite_map_chrome.rs107
1 files changed, 107 insertions, 0 deletions
diff --git a/apps/fparkan-game/src/satellite_map_chrome.rs b/apps/fparkan-game/src/satellite_map_chrome.rs
new file mode 100644
index 00000000..cb02a43f
--- /dev/null
+++ b/apps/fparkan-game/src/satellite_map_chrome.rs
@@ -0,0 +1,107 @@
+use super::{
+ mission_overlay::{add_overlay_sprite, overlay_texture},
+ DirectoryVfs, EnvironmentGpuRange, StaticPreviewScene, VulkanSmokeRenderer,
+};
+use fparkan_assets::{
+ satellite_map_chrome::{Contact, MapChrome, FOOTER, HEADER},
+ RgbaImage,
+};
+use fparkan_platform_winit::text::StringResources;
+use fparkan_runtime::strategic_map_readout::ContactReadout;
+use std::path::Path;
+
+pub(super) struct SatelliteMapChrome {
+ header: EnvironmentGpuRange,
+ footer: EnvironmentGpuRange,
+ art: MapChrome,
+ strings: StringResources,
+ current: Option<ContactReadout>,
+}
+
+impl SatelliteMapChrome {
+ pub(super) fn load(
+ root: &Path,
+ icons: RgbaImage,
+ preview: &mut StaticPreviewScene,
+ ) -> Result<Self, String> {
+ let strings = StringResources::open(&root.join("iron3d.dll"))?;
+ let title = strings.get(0x13d2).ok_or("missing satellite map title")?;
+ let art = MapChrome::load(&DirectoryVfs::new(root), icons)?;
+ Ok(Self {
+ header: add_overlay_sprite(
+ preview,
+ art.header(&title)?,
+ HEADER.map(|n| n as f32),
+ [1.0; 3],
+ 1.0,
+ )?,
+ footer: add_overlay_sprite(
+ preview,
+ art.footer(None)?,
+ FOOTER.map(|n| n as f32),
+ [1.0; 3],
+ 1.0,
+ )?,
+ art,
+ strings,
+ current: None,
+ })
+ }
+
+ pub(super) fn ranges(&self) -> [usize; 2] {
+ [self.header.range_index, self.footer.range_index]
+ }
+
+ pub(super) fn draw(
+ &mut self,
+ renderer: &mut VulkanSmokeRenderer,
+ visible: bool,
+ contact: Option<ContactReadout>,
+ ) -> Result<(), String> {
+ for range in self.ranges() {
+ renderer
+ .set_draw_range_index_count(range, if visible { 6 } else { 0 })
+ .map_err(|error| error.to_string())?;
+ }
+ if visible && (contact != self.current) {
+ let label = contact.map(|entry| self.label(entry)).transpose()?;
+ let entry = contact.zip(label.as_deref()).map(|(entry, label)| Contact {
+ label,
+ class: entry.class,
+ size: entry.size,
+ chassis: entry.chassis,
+ clan: entry.clan,
+ emblem_tint: entry.emblem_tint,
+ durability_percent: entry.durability_percent,
+ });
+ renderer
+ .update_material_texture(
+ self.footer.material_index,
+ 0,
+ &overlay_texture(self.art.footer(entry)?),
+ )
+ .map_err(|error| error.to_string())?;
+ self.current = contact;
+ }
+ Ok(())
+ }
+
+ fn label(&self, contact: ContactReadout) -> Result<String, String> {
+ let mut name = self
+ .strings
+ .get(contact.name_label)
+ .ok_or_else(|| format!("missing map contact string {:#x}", contact.name_label))?;
+ if let Some((prefix, serial)) = contact.callsign {
+ let prefix: String = prefix.into_iter().collect();
+ name = format!("{prefix}-{serial} {name}");
+ }
+ if let Some(order) = contact.order_label {
+ let status = self
+ .strings
+ .get(order)
+ .ok_or_else(|| format!("missing map order string {order:#x}"))?;
+ name.push_str(&format!(" [{status}]"));
+ }
+ Ok(name)
+ }
+}