From ed75c225e47e825ae050a03f6d2f95b6fa62277e Mon Sep 17 00:00:00 2001 From: yuni Date: Sat, 30 Nov 2024 00:53:54 +0100 Subject: [PATCH] hide Size/Mass in HUD for stars (other than sol) --- src/hud.rs | 25 +++++++++++++++++-------- src/world.rs | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index 4a8cc35..1a76d52 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -265,6 +265,7 @@ pub struct IsClickable { pub name: Option, pub pronoun: Option, pub displayed_mass: Option, + pub hide_size: bool, pub distance: Option, pub disable_in_map: bool, } @@ -1056,16 +1057,24 @@ fn update_hud( } else { "".to_string() }; - let size = nature::readable_si(trans.scale.x as f64 * 2.0); - let mass = if let Some(mass) = clickable.displayed_mass { - nature::readable_mass(mass) - } else if let Some(mass) = mass { - nature::readable_mass(mass.0) + let size = if clickable.hide_size { + "".to_string() } else { - String::from("?") + format!( + "Size: {}m\n", + nature::readable_si(trans.scale.x as f64 * 2.0) + ) }; - text.sections[0].value = - format!("Target: {target_name}\n{pronoun}Distance: {distance}\nSize: {size}m\nMass: {mass}\n\n"); + let mass = if let Some(mass) = clickable.displayed_mass { + format!("Mass: {}\n", nature::readable_mass(mass)) + } else if let Some(mass) = mass { + format!("Mass: {}\n", nature::readable_mass(mass.0)) + } else { + String::from("") + }; + text.sections[0].value = format!( + "Target: {target_name}\n{pronoun}Distance: {distance}\n{size}{mass}\n" + ); } else { text.sections[0].value = "".to_string(); } diff --git a/src/world.rs b/src/world.rs index b776c58..b9f68db 100644 --- a/src/world.rs +++ b/src/world.rs @@ -149,6 +149,7 @@ pub fn setup( name: Some(name), distance, disable_in_map: true, + hide_size: true, ..default() }, PbrBundle {