aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/cockpit_radar_hud.rs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/fparkan-game/src/cockpit_radar_hud.rs')
-rw-r--r--apps/fparkan-game/src/cockpit_radar_hud.rs42
1 files changed, 39 insertions, 3 deletions
diff --git a/apps/fparkan-game/src/cockpit_radar_hud.rs b/apps/fparkan-game/src/cockpit_radar_hud.rs
index 832d126d..1488edea 100644
--- a/apps/fparkan-game/src/cockpit_radar_hud.rs
+++ b/apps/fparkan-game/src/cockpit_radar_hud.rs
@@ -2,19 +2,55 @@ use super::{
append_environment_gradient_material, append_environment_range, environment_vertex,
environment_vertex_with_alpha, quad_indices, screen_tl_quad_vertices_pixels,
world_pipeline_state, DirectoryVfs, EnvironmentGpuRange, LegacyBlendMode, LegacyDepthMode,
- StaticPreviewScene, VulkanDynamicDrawRange, VulkanSmokeRenderer, VulkanStaticMesh,
- VulkanStaticTexture,
+ StaticPreviewScene, StaticVulkanApp, VulkanDynamicDrawRange, VulkanSmokeRenderer,
+ VulkanStaticMesh, VulkanStaticTexture,
};
use fparkan_assets::game_font::{load_layout_font, BitmapFont};
use fparkan_render::cockpit_radar::{
contact_pixel, mark_rectangles, sweep_outline, RadarSweep, SWEEP_EDGES,
};
-use fparkan_runtime::{radar::cockpit_contacts, Engine, StartingCockpit};
+use fparkan_runtime::{
+ radar::{
+ cockpit_contacts, refresh_cockpit_target, select_cockpit_target, CockpitTargetCommand,
+ },
+ Engine, StartingCockpit,
+};
use fparkan_world::ObjectHandle;
use std::path::Path;
+use winit::keyboard::KeyCode;
const LABEL_SIZE: [u32; 2] = [37, 11];
+impl StaticVulkanApp {
+ pub(super) fn refresh_cockpit_contact(&mut self) {
+ if self.demo_camera.is_none() && self.command_view.is_none() {
+ if let Some((engine, cockpit)) = self.mission_engine.as_ref().zip(self.cockpit) {
+ self.selected_contact =
+ refresh_cockpit_target(engine, cockpit, self.selected_contact);
+ }
+ }
+ }
+
+ pub(super) fn select_cockpit_contact(&mut self, key: KeyCode) {
+ if self.demo_camera.is_some() {
+ return;
+ }
+ let command = match key {
+ KeyCode::Tab => CockpitTargetCommand::Next,
+ KeyCode::KeyE => CockpitTargetCommand::Enemy,
+ KeyCode::KeyF => CockpitTargetCommand::Friend,
+ _ => return,
+ };
+ if let Some((engine, cockpit)) = self.mission_engine.as_ref().zip(self.cockpit) {
+ if let Some(target) =
+ select_cockpit_target(engine, cockpit, self.selected_contact, command)
+ {
+ self.selected_contact = Some(target);
+ }
+ }
+ }
+}
+
pub(super) struct CockpitRadarHud {
sweep: EnvironmentGpuRange,
sweep_clock: RadarSweep,