smaller FoV when zooming
This commit is contained in:
parent
ba09e1c378
commit
3ed8a9b8b0
157
src/hud.rs
157
src/hud.rs
|
@ -151,7 +151,16 @@ fn setup(
|
||||||
};
|
};
|
||||||
let mut bundle_fps = TextBundle::from_sections([
|
let mut bundle_fps = TextBundle::from_sections([
|
||||||
TextSection::new(
|
TextSection::new(
|
||||||
"OutFly Augmented Reality 电量 ",
|
"",
|
||||||
|
TextStyle {
|
||||||
|
font: asset_server.load(FONT),
|
||||||
|
font_size: settings.font_size_hud,
|
||||||
|
color: Color::GRAY,
|
||||||
|
..default()
|
||||||
|
}
|
||||||
|
),
|
||||||
|
TextSection::new(
|
||||||
|
" ⚡ ",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load(FONT),
|
font: asset_server.load(FONT),
|
||||||
font_size: settings.font_size_hud,
|
font_size: settings.font_size_hud,
|
||||||
|
@ -169,7 +178,7 @@ fn setup(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TextSection::new(
|
TextSection::new(
|
||||||
" 时 ",
|
" ☣ ",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load(FONT),
|
font: asset_server.load(FONT),
|
||||||
font_size: settings.font_size_hud,
|
font_size: settings.font_size_hud,
|
||||||
|
@ -186,33 +195,6 @@ fn setup(
|
||||||
..default()
|
..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(
|
|
||||||
"\n木星中心 ",
|
|
||||||
TextStyle {
|
|
||||||
font: asset_server.load(FONT),
|
|
||||||
font_size: settings.font_size_hud,
|
|
||||||
color: Color::GRAY,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextSection::new(
|
TextSection::new(
|
||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
|
@ -240,42 +222,6 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TextSection::new(
|
|
||||||
"\nAdrenaline水平 ",
|
|
||||||
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(
|
|
||||||
"\nVitals ",
|
|
||||||
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(
|
TextSection::new(
|
||||||
"\nProximity 警告 ",
|
"\nProximity 警告 ",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
|
@ -313,7 +259,7 @@ fn setup(
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TextSection::new(
|
TextSection::new(
|
||||||
"\n相对的v ",
|
"\nVitals ",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load(FONT),
|
font: asset_server.load(FONT),
|
||||||
font_size: settings.font_size_hud,
|
font_size: settings.font_size_hud,
|
||||||
|
@ -330,16 +276,7 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TextSection::new(
|
TextSection::new( // Target
|
||||||
"\nTarget: ",
|
|
||||||
TextStyle {
|
|
||||||
font: asset_server.load(FONT),
|
|
||||||
font_size: settings.font_size_hud,
|
|
||||||
color: Color::GRAY,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextSection::new(
|
|
||||||
"",
|
"",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font: asset_server.load(FONT),
|
font: asset_server.load(FONT),
|
||||||
|
@ -348,23 +285,6 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
TextSection::new(
|
|
||||||
"\n☢ HAZARD\n\n",
|
|
||||||
TextStyle {
|
|
||||||
font: asset_server.load(FONT),
|
|
||||||
font_size: settings.font_size_hud,
|
|
||||||
color: Color::GRAY,
|
|
||||||
..default()
|
|
||||||
}
|
|
||||||
),
|
|
||||||
TextSection::from_style(
|
|
||||||
TextStyle {
|
|
||||||
font: asset_server.load(FONT),
|
|
||||||
font_size: settings.font_size_hud,
|
|
||||||
color: Color::GRAY,
|
|
||||||
..default()
|
|
||||||
}
|
|
||||||
),
|
|
||||||
]).with_style(Style {
|
]).with_style(Style {
|
||||||
top: Val::VMin(2.0),
|
top: Val::VMin(2.0),
|
||||||
left: Val::VMin(3.0),
|
left: Val::VMin(3.0),
|
||||||
|
@ -473,7 +393,7 @@ fn update_hud(
|
||||||
diagnostics: Res<DiagnosticsStore>,
|
diagnostics: Res<DiagnosticsStore>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
mut log: ResMut<Log>,
|
mut log: ResMut<Log>,
|
||||||
player: Query<(&actor::HitPoints, &actor::Suit, &actor::LifeForm, &actor::ExperiencesGForce), With<actor::Player>>,
|
player: Query<(&actor::HitPoints, &actor::Suit, &actor::ExperiencesGForce), With<actor::Player>>,
|
||||||
q_camera: Query<(&Position, &LinearVelocity), With<actor::PlayerCamera>>,
|
q_camera: Query<(&Position, &LinearVelocity), With<actor::PlayerCamera>>,
|
||||||
mut timer: ResMut<FPSUpdateTimer>,
|
mut timer: ResMut<FPSUpdateTimer>,
|
||||||
mut query: Query<&mut Text, With<GaugesText>>,
|
mut query: Query<&mut Text, With<GaugesText>>,
|
||||||
|
@ -488,47 +408,45 @@ fn update_hud(
|
||||||
let q_camera_result = q_camera.get_single();
|
let q_camera_result = q_camera.get_single();
|
||||||
let player = player.get_single();
|
let player = player.get_single();
|
||||||
if player.is_ok() && q_camera_result.is_ok() {
|
if player.is_ok() && q_camera_result.is_ok() {
|
||||||
let (hp, suit, lifeform, gforce) = player.unwrap();
|
let (hp, suit, gforce) = player.unwrap();
|
||||||
let (pos, cam_v) = q_camera_result.unwrap();
|
let (pos, cam_v) = q_camera_result.unwrap();
|
||||||
for mut text in &mut query {
|
for mut text in &mut query {
|
||||||
text.sections[3].value = format!("2524-03-12 03:02");
|
text.sections[0].value = format!("2524-03-12 03:02");
|
||||||
if let Some(fps) = diagnostics.get(&FrameTimeDiagnosticsPlugin::FPS) {
|
if let Some(fps) = diagnostics.get(&FrameTimeDiagnosticsPlugin::FPS) {
|
||||||
if let Some(value) = fps.smoothed() {
|
if let Some(value) = fps.smoothed() {
|
||||||
// Update the value of the second section
|
// Update the value of the second section
|
||||||
text.sections[5].value = format!("{value:.0}");
|
text.sections[4].value = format!("{value:.0}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let power = suit.power / suit.power_max * 100.0;
|
let power = suit.power / suit.power_max * 100.0;
|
||||||
text.sections[1].value = format!("{power:}%");
|
text.sections[2].value = format!("{power:}%");
|
||||||
let oxy_percent = suit.oxygen / suit.oxygen_max * 100.0;
|
let oxy_percent = suit.oxygen / suit.oxygen_max * 100.0;
|
||||||
let oxy_total = suit.oxygen * 1e6;
|
|
||||||
|
|
||||||
// the remaining oxygen hud info ignores leaking suits from low integrity
|
// the remaining oxygen hud info ignores leaking suits from low integrity
|
||||||
if suit.oxygen > nature::OXY_H {
|
if suit.oxygen > nature::OXY_H {
|
||||||
let oxy_hour = suit.oxygen / nature::OXY_H;
|
let oxy_hour = suit.oxygen / nature::OXY_H;
|
||||||
text.sections[9].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_hour:.1} hours]");
|
text.sections[7].value = format!("{oxy_percent:.1}% [lasts {oxy_hour:.1} hours]");
|
||||||
} else {
|
} else {
|
||||||
let oxy_min = suit.oxygen / nature::OXY_M;
|
let oxy_min = suit.oxygen / nature::OXY_M;
|
||||||
text.sections[9].value = format!("{oxy_percent:.1}% [{oxy_total:.0}mg] [lasts {oxy_min:.1} min]");
|
text.sections[7].value = format!("{oxy_percent:.1}% [lasts {oxy_min:.1} min]");
|
||||||
}
|
}
|
||||||
let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
|
//let adrenaline = lifeform.adrenaline * 990.0 + 10.0;
|
||||||
text.sections[11].value = format!("{adrenaline:.0}pg/mL");
|
//text.sections[11].value = format!("{adrenaline:.0}pg/mL");
|
||||||
let vitals = 100.0 * hp.current / hp.max;
|
let vitals = 100.0 * hp.current / hp.max;
|
||||||
let gforce = gforce.gforce;
|
text.sections[13].value = format!("{vitals:.0}%");
|
||||||
text.sections[13].value = format!("{vitals:.0}% [{gforce:.1}g]");
|
|
||||||
let all_actors = query_all_actors.iter().len();
|
let all_actors = query_all_actors.iter().len();
|
||||||
text.sections[15].value = format!("{all_actors:.0}");
|
text.sections[9].value = format!("{all_actors:.0}");
|
||||||
let integrity = suit.integrity * 100.0;
|
let integrity = suit.integrity * 100.0;
|
||||||
text.sections[17].value = format!("{integrity:.0}%");
|
text.sections[11].value = format!("{integrity:.0}%");
|
||||||
let speed = cam_v.length();
|
let speed = cam_v.length();
|
||||||
let kmh = speed * 60.0 * 60.0 / 1000.0;
|
let kmh = speed * 60.0 * 60.0 / 1000.0;
|
||||||
let speed_readable = nature::readable_distance(speed);
|
let speed_readable = nature::readable_distance(speed);
|
||||||
text.sections[19].value = format!("{speed_readable}/s | {kmh:.0}km/h");
|
let gforce = gforce.gforce;
|
||||||
|
//text.sections[17].value = format!("{speed_readable}/s / {kmh:.0}km/h / {gforce:.1}g");
|
||||||
|
|
||||||
// Target display
|
// Target display
|
||||||
let (x, y, z, dist_scalar) : (f64, f64, f64, f64);
|
let dist_scalar: f64;
|
||||||
if let Ok((_, IsClickable { distance: Some(dist), .. })) = q_target.get_single() {
|
if let Ok((_, IsClickable { distance: Some(dist), .. })) = q_target.get_single() {
|
||||||
(x, y, z) = (0.0, 0.0, 0.0);
|
|
||||||
dist_scalar = *dist;
|
dist_scalar = *dist;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -544,37 +462,34 @@ fn update_hud(
|
||||||
}
|
}
|
||||||
if let Some(target_pos) = target {
|
if let Some(target_pos) = target {
|
||||||
let dist = pos.0 - target_pos;
|
let dist = pos.0 - target_pos;
|
||||||
(x, y, z) = (dist.x, dist.y, dist.z);
|
|
||||||
dist_scalar = dist.length();
|
dist_scalar = dist.length();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(x, y, z) = (0.0, 0.0, 0.0);
|
|
||||||
dist_scalar = 0.0;
|
dist_scalar = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let target_name: String;
|
||||||
|
let distance: String;
|
||||||
if dist_scalar.is_nan() {
|
if dist_scalar.is_nan() {
|
||||||
text.sections[7].value = format!("distance: UNKNOWN");
|
distance = "UNKNOWN".to_string();
|
||||||
}
|
}
|
||||||
else if dist_scalar != 0.0 {
|
else if dist_scalar != 0.0 {
|
||||||
let x_readable = nature::readable_distance(x);
|
distance = nature::readable_distance(dist_scalar);
|
||||||
let y_readable = nature::readable_distance(y);
|
|
||||||
let z_readable = nature::readable_distance(z);
|
|
||||||
let distance_readable = nature::readable_distance(dist_scalar);
|
|
||||||
text.sections[7].value = format!("{x_readable} / {z_readable} / {y_readable} / distance: {distance_readable}");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
text.sections[7].value = format!("TARGET ERROR");
|
distance = "ERROR".to_string();
|
||||||
}
|
}
|
||||||
if q_target.is_empty() {
|
if q_target.is_empty() {
|
||||||
text.sections[21].value = "Jupiter".to_string();
|
text.sections[14].value = format!("\nv {speed_readable}/s + {gforce:.1}g");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let targets: Vec<String> = q_target
|
let targets: Vec<String> = q_target
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, clickable)| clickable.name.clone().unwrap_or("<unnamed>".to_string()))
|
.map(|(_, clickable)| clickable.name.clone().unwrap_or("<unnamed>".to_string()))
|
||||||
.collect();
|
.collect();
|
||||||
text.sections[21].value = targets.join(", ");
|
target_name = targets.join(", ");
|
||||||
|
text.sections[14].value = format!("\n\nTarget: {target_name}\nDistance: {distance}\nΔv {speed_readable}/s + {gforce:.1}g");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ impl Default for Settings {
|
||||||
mouse_sensitivity: 0.7,
|
mouse_sensitivity: 0.7,
|
||||||
fov: 50.0,
|
fov: 50.0,
|
||||||
fov_highspeed: 25.0,
|
fov_highspeed: 25.0,
|
||||||
zoom_fov: 20.0,
|
zoom_fov: 15.0,
|
||||||
zoom_sensitivity_factor: 0.25,
|
zoom_sensitivity_factor: 0.25,
|
||||||
font_size_hud: 32.0,
|
font_size_hud: 32.0,
|
||||||
font_size_conversations: 32.0,
|
font_size_conversations: 32.0,
|
||||||
|
|
Loading…
Reference in a new issue