hide speedometer text when speed is 0

This commit is contained in:
yuni 2024-04-28 06:40:11 +02:00
parent 133fa9122f
commit 82fd1313b2

View file

@ -474,7 +474,6 @@ fn update_speedometer(
) { ) {
if let Ok(cam_v) = q_camera.get_single() { if let Ok(cam_v) = q_camera.get_single() {
let speed = cam_v.length(); let speed = cam_v.length();
let speed_readable = nature::readable_speed(speed);
let speedometer_split = 5_000.0; let speedometer_split = 5_000.0;
if let Ok(mut speedometer) = q_speedometer.get_single_mut() { 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() { 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() { speed_text.sections[0].value = if let Ok(target_v) = q_target.get_single() {
let delta_v = (target_v.0 - cam_v.0).length(); let delta_v = (target_v.0 - cam_v.0).length();
if delta_v > 0.0001 {
format!("Δv {}\n", nature::readable_speed(delta_v)) format!("Δv {}\n", nature::readable_speed(delta_v))
} else { } else {
"".to_string() "".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;
} }
} }
} }