hide Size/Mass in HUD for stars (other than sol)

This commit is contained in:
yuni 2024-11-30 00:53:54 +01:00
parent 1344392a92
commit ed75c225e4
2 changed files with 18 additions and 8 deletions

View file

@ -265,6 +265,7 @@ pub struct IsClickable {
pub name: Option<String>,
pub pronoun: Option<String>,
pub displayed_mass: Option<f64>,
pub hide_size: bool,
pub distance: Option<f64>,
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();
}

View file

@ -149,6 +149,7 @@ pub fn setup(
name: Some(name),
distance,
disable_in_map: true,
hide_size: true,
..default()
},
PbrBundle {