aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/mission_overlay.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 00:14:54 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 00:14:54 +0300
commit3efc5ba5d3389da168b00f8fe47d3478821e5d7f (patch)
tree8b222a05c28944eb05e815198872ae5f514db3b0 /apps/fparkan-game/src/mission_overlay.rs
parent752d34af83acf9a818e22c621fb034913079acff (diff)
downloadfparkan-3efc5ba5d3389da168b00f8fe47d3478821e5d7f.tar.xz
fparkan-3efc5ba5d3389da168b00f8fe47d3478821e5d7f.zip
feat(ui): restore the original cockpit radar dial
Use the mirrored source atlas halves and show the installed sensor range with the original font. The stock Fireline cockpit reads 300 and the Two Fortresses cockpit reads 400. The range query agrees with the original libraries for both inactive and missing devices.
Diffstat (limited to 'apps/fparkan-game/src/mission_overlay.rs')
-rw-r--r--apps/fparkan-game/src/mission_overlay.rs62
1 files changed, 27 insertions, 35 deletions
diff --git a/apps/fparkan-game/src/mission_overlay.rs b/apps/fparkan-game/src/mission_overlay.rs
index 66c0f837..7eec86b2 100644
--- a/apps/fparkan-game/src/mission_overlay.rs
+++ b/apps/fparkan-game/src/mission_overlay.rs
@@ -1,10 +1,12 @@
use super::{
- altimeter_hud::AltimeterHud, cockpit_radar_hud::CockpitRadarHud, course_hud::CourseHud,
- horizontal_fov, satellite_map::SatelliteMap, StaticPreviewScene, StaticVulkanApp,
+ cockpit_dial::CockpitDial, cockpit_radar_hud::CockpitRadarHud, horizontal_fov,
+ satellite_map::SatelliteMap, StaticPreviewScene, StaticVulkanApp,
};
#[cfg(windows)]
use super::{mission_hints::MissionHints, weapon_hud::WeaponHud};
-use fparkan_runtime::{cockpit_altimeter::cockpit_altimeter, Engine, StartingCockpit};
+use fparkan_runtime::{
+ cockpit_altimeter::cockpit_altimeter, radar::cockpit_range_readout, Engine, StartingCockpit,
+};
use std::path::Path;
/// Source-over composition for original sprite texels and their alpha masks.
@@ -26,8 +28,7 @@ pub(super) fn source_over(pixel: &mut [u8], source: &[u8]) {
#[derive(Default)]
pub(super) struct MissionOverlay {
pub(super) satellite_map: Option<SatelliteMap>,
- course: Option<CourseHud>,
- altimeter: Option<AltimeterHud>,
+ dial: Option<CockpitDial>,
pub(super) radar: Option<CockpitRadarHud>,
#[cfg(windows)]
pub(super) hints: Option<MissionHints>,
@@ -47,24 +48,16 @@ impl MissionOverlay {
return Self::default();
};
// The original draws the cockpit instruments before the satellite map.
- let course = cockpit.and_then(|_| {
- CourseHud::load(root, preview)
- .map(Some)
- .unwrap_or_else(|error| {
- eprintln!("course_hud_unavailable reason={error}");
- None
- })
- });
- let altimeter = cockpit.and_then(|_| {
- AltimeterHud::load(root, preview)
+ let dial = cockpit.and_then(|_| {
+ CockpitDial::load(root, preview)
.map(Some)
.unwrap_or_else(|error| {
- eprintln!("altimeter_unavailable reason={error}");
+ eprintln!("cockpit_dial_unavailable reason={error}");
None
})
});
let radar = cockpit.and_then(|_| {
- CockpitRadarHud::load(preview)
+ CockpitRadarHud::load(root, preview)
.map(Some)
.unwrap_or_else(|error| {
eprintln!("cockpit_radar_unavailable reason={error}");
@@ -94,8 +87,7 @@ impl MissionOverlay {
});
Self {
satellite_map,
- course,
- altimeter,
+ dial,
radar,
#[cfg(windows)]
hints,
@@ -120,14 +112,13 @@ impl MissionOverlay {
remove(range, ranges, counts);
}
}
- if let Some(altimeter) = &self.altimeter {
- remove(altimeter.range_index(), ranges, counts);
- }
if let Some(radar) = &self.radar {
- remove(radar.range_index, ranges, counts);
+ for range in radar.ranges() {
+ remove(range, ranges, counts);
+ }
}
- if let Some(course) = &self.course {
- for range in course.ranges() {
+ if let Some(dial) = &self.dial {
+ for range in dial.ranges() {
remove(range, ranges, counts);
}
}
@@ -155,20 +146,21 @@ impl StaticVulkanApp {
.map(|(engine, cockpit)| (engine, cockpit, self.boarding_target));
map.draw(renderer, &mut self.mesh, frame.viewport, player)?;
}
- if let Some(altimeter) = &mut self.overlay.altimeter {
- let state = self
- .mission_engine
- .as_ref()
- .zip(self.cockpit)
- .and_then(|(engine, cockpit)| cockpit_altimeter(engine, cockpit));
- altimeter.draw(renderer, &mut self.mesh, frame.viewport, state)?;
- }
- if let Some(course) = &self.overlay.course {
+ let occupant = self.mission_engine.as_ref().zip(self.cockpit);
+ if let Some(dial) = &mut self.overlay.dial {
let view = self.cockpit.map(|_| {
let [x, y, _] = frame.camera.forward();
([x, y], horizontal_fov(&frame.camera, frame.aspect))
});
- course.draw(renderer, &mut self.mesh, view)?;
+ let altitude =
+ occupant.and_then(|(engine, cockpit)| cockpit_altimeter(engine, cockpit));
+ dial.draw(renderer, &mut self.mesh, frame.viewport, view, altitude)?;
+ }
+ if let Some(radar) = &mut self.overlay.radar {
+ radar.draw_readout(
+ renderer,
+ occupant.map(|(engine, cockpit)| cockpit_range_readout(engine, cockpit)),
+ )?;
}
#[cfg(windows)]
if let Some(hints) = &mut self.overlay.hints {