move speedometer to the right
This commit is contained in:
parent
310f977fb6
commit
db5fdd5a35
14
src/hud.rs
14
src/hud.rs
|
@ -26,7 +26,7 @@ pub const LOG_MAX_TIME_S: f64 = 30.0;
|
||||||
pub const LOG_MAX_ROWS: usize = 30;
|
pub const LOG_MAX_ROWS: usize = 30;
|
||||||
pub const LOG_MAX: usize = LOG_MAX_ROWS;
|
pub const LOG_MAX: usize = LOG_MAX_ROWS;
|
||||||
pub const MAX_CHOICES: usize = 10;
|
pub const MAX_CHOICES: usize = 10;
|
||||||
pub const SPEEDOMETER_WIDTH: f32 = 40.0;
|
pub const SPEEDOMETER_WIDTH: f32 = 20.0;
|
||||||
pub const SPEEDOMETER_HEIGHT: f32 = 10.0;
|
pub const SPEEDOMETER_HEIGHT: f32 = 10.0;
|
||||||
pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK
|
pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK
|
||||||
pub const AMBIENT_LIGHT_AR: f32 = 20.0;
|
pub const AMBIENT_LIGHT_AR: f32 = 20.0;
|
||||||
|
@ -377,6 +377,7 @@ fn setup(
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::VMin(0.0),
|
width: Val::VMin(0.0),
|
||||||
height: Val::Percent(100.0),
|
height: Val::Percent(100.0),
|
||||||
|
left: Val::Vw(100.0 - SPEEDOMETER_WIDTH),
|
||||||
align_items: AlignItems::End,
|
align_items: AlignItems::End,
|
||||||
overflow: Overflow::clip(),
|
overflow: Overflow::clip(),
|
||||||
..default()
|
..default()
|
||||||
|
@ -391,7 +392,7 @@ fn setup(
|
||||||
ImageBundle {
|
ImageBundle {
|
||||||
image: UiImage::new(speedometer_handle),
|
image: UiImage::new(speedometer_handle),
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::VMin(SPEEDOMETER_WIDTH),
|
width: Val::Vw(SPEEDOMETER_WIDTH),
|
||||||
height: Val::VMin(SPEEDOMETER_HEIGHT),
|
height: Val::VMin(SPEEDOMETER_HEIGHT),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
@ -405,6 +406,7 @@ fn setup(
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::VMin(0.0),
|
width: Val::VMin(0.0),
|
||||||
height: Val::Percent(100.0),
|
height: Val::Percent(100.0),
|
||||||
|
left: Val::Vw(100.0 - SPEEDOMETER_WIDTH),
|
||||||
align_items: AlignItems::End,
|
align_items: AlignItems::End,
|
||||||
overflow: Overflow::clip(),
|
overflow: Overflow::clip(),
|
||||||
..default()
|
..default()
|
||||||
|
@ -419,7 +421,7 @@ fn setup(
|
||||||
ImageBundle {
|
ImageBundle {
|
||||||
image: UiImage::new(speedometer_handle),
|
image: UiImage::new(speedometer_handle),
|
||||||
style: Style {
|
style: Style {
|
||||||
width: Val::VMin(SPEEDOMETER_WIDTH),
|
width: Val::Vw(SPEEDOMETER_WIDTH),
|
||||||
height: Val::VMin(SPEEDOMETER_HEIGHT),
|
height: Val::VMin(SPEEDOMETER_HEIGHT),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
@ -432,7 +434,7 @@ fn setup(
|
||||||
TextSection::new("", style_speedometer.clone()), // speed relative to orbit
|
TextSection::new("", style_speedometer.clone()), // speed relative to orbit
|
||||||
]).with_style(Style {
|
]).with_style(Style {
|
||||||
position_type: PositionType::Absolute,
|
position_type: PositionType::Absolute,
|
||||||
left: Val::VMin(2.0),
|
left: Val::Vw(100.0 - SPEEDOMETER_WIDTH + 2.0),
|
||||||
bottom: Val::VMin(4.0),
|
bottom: Val::VMin(4.0),
|
||||||
..default()
|
..default()
|
||||||
}).with_text_justify(JustifyText::Left);
|
}).with_text_justify(JustifyText::Left);
|
||||||
|
@ -530,13 +532,13 @@ fn update_speedometer(
|
||||||
let custom_c = speedometer_split;
|
let custom_c = speedometer_split;
|
||||||
let fraction = nature::lorenz_factor_custom_c((custom_c - speed).clamp(0.0, custom_c), custom_c).clamp(0.0, 1.0) as f32;
|
let fraction = nature::lorenz_factor_custom_c((custom_c - speed).clamp(0.0, custom_c), custom_c).clamp(0.0, 1.0) as f32;
|
||||||
let wid = (fraction * SPEEDOMETER_WIDTH).clamp(0.0, 100.0);
|
let wid = (fraction * SPEEDOMETER_WIDTH).clamp(0.0, 100.0);
|
||||||
speedometer.width = Val::VMin(wid);
|
speedometer.width = Val::Vw(wid);
|
||||||
}
|
}
|
||||||
if let Ok(mut speedometer2) = q_speedometer2.get_single_mut() {
|
if let Ok(mut speedometer2) = q_speedometer2.get_single_mut() {
|
||||||
let custom_c = nature::C - speedometer_split;
|
let custom_c = nature::C - speedometer_split;
|
||||||
let fraction = nature::lorenz_factor_custom_c((custom_c - speed + speedometer_split).clamp(0.0, custom_c), custom_c).clamp(0.0, 1.0) as f32;
|
let fraction = nature::lorenz_factor_custom_c((custom_c - speed + speedometer_split).clamp(0.0, custom_c), custom_c).clamp(0.0, 1.0) as f32;
|
||||||
let wid = (fraction * SPEEDOMETER_WIDTH).clamp(0.0, 100.0);
|
let wid = (fraction * SPEEDOMETER_WIDTH).clamp(0.0, 100.0);
|
||||||
speedometer2.width = Val::VMin(wid);
|
speedometer2.width = Val::Vw(wid);
|
||||||
}
|
}
|
||||||
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() {
|
||||||
|
|
Loading…
Reference in a new issue