From 82fd1313b24feb8b575a98537aabaf44e86d4cca Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 28 Apr 2024 06:40:11 +0200 Subject: [PATCH] hide speedometer text when speed is 0 --- src/hud.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index 2351378..a778022 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -474,7 +474,6 @@ fn update_speedometer( ) { if let Ok(cam_v) = q_camera.get_single() { let speed = cam_v.length(); - let speed_readable = nature::readable_speed(speed); let speedometer_split = 5_000.0; if let Ok(mut speedometer) = q_speedometer.get_single_mut() { @@ -492,11 +491,19 @@ fn update_speedometer( if let Ok(mut speed_text) = q_node_speed.get_single_mut() { speed_text.sections[0].value = if let Ok(target_v) = q_target.get_single() { let delta_v = (target_v.0 - cam_v.0).length(); - format!("Δv {}\n", nature::readable_speed(delta_v)) + if delta_v > 0.0001 { + format!("Δv {}\n", nature::readable_speed(delta_v)) + } else { + "".to_string() + } + } else { + "".to_string() + }; + speed_text.sections[1].value = if speed > 0.0001 { + nature::readable_speed(speed) } else { "".to_string() }; - speed_text.sections[1].value = speed_readable; } } }