add static clock to HUD

This commit is contained in:
yuni 2024-04-05 04:08:26 +02:00
parent e577a5084c
commit 7130d1e684

View file

@ -137,6 +137,24 @@ fn setup(
..default()
}
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
},
),
TextSection::new(
"",
TextStyle {
font: asset_server.load(FONT),
font_size: settings.font_size_hud,
color: Color::GRAY,
..default()
}
),
TextSection::new(
" 帧率 ",
TextStyle {
@ -411,10 +429,11 @@ fn update(
let (hp, suit, lifeform) = player.unwrap();
let (pos, cam_v) = q_camera_result.unwrap();
for mut text in &mut query {
text.sections[3].value = format!("2524-03-12 03:02");
if let Some(fps) = diagnostics.get(&FrameTimeDiagnosticsPlugin::FPS) {
if let Some(value) = fps.smoothed() {
// Update the value of the second section
text.sections[3].value = format!("{value:.0}");
text.sections[5].value = format!("{value:.0}");
}
}
let power = suit.power / suit.power_max * 100.0;
@ -425,24 +444,24 @@ fn update(
// the remaining oxygen hud info ignores leaking suits from low integrity
if suit.oxygen > nature::OXY_H {
let oxy_hour = suit.oxygen / nature::OXY_H;
text.sections[7].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_hour:.1} hours]");
text.sections[9].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_hour:.1} hours]");
} else {
let oxy_min = suit.oxygen / nature::OXY_M;
text.sections[7].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_min:.1} min]");
text.sections[9].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_min:.1} min]");
}
let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
text.sections[9].value = format!("{adrenaline:.0}pg/mL");
text.sections[11].value = format!("{adrenaline:.0}pg/mL");
let vitals = 100.0 * hp.current / hp.max;
text.sections[11].value = format!("{vitals:.0}%");
text.sections[13].value = format!("{vitals:.0}%");
let all_actors = query_all_actors.iter().len();
text.sections[13].value = format!("{all_actors:.0}");
text.sections[15].value = format!("{all_actors:.0}");
let (x, y, z) = (pos.x / 1.0e3, pos.y / 1.0e3, pos.z / 1.0e3);
text.sections[5].value = format!("{x:.0}km / {z:.0}km / {y:.0}km");
text.sections[7].value = format!("{x:.0}km / {z:.0}km / {y:.0}km");
let integrity = suit.integrity * 100.0;
text.sections[15].value = format!("{integrity:.0}%");
text.sections[17].value = format!("{integrity:.0}%");
let speed = cam_v.length();
let kmh = speed * 60.0 * 60.0 / 1000.0;
text.sections[17].value = format!("{speed:.0}m/s | {kmh:.0}km/h");
text.sections[19].value = format!("{speed:.0}m/s | {kmh:.0}km/h");
}
}