From db5fdd5a355619d06b72820705842d306b0ced72 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 8 May 2024 00:15:34 +0200 Subject: [PATCH] move speedometer to the right --- src/hud.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index 9c5e158..522abd0 100644 --- a/src/hud.rs +++ b/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: usize = LOG_MAX_ROWS; 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 AMBIENT_LIGHT: f32 = 0.0; // Space is DARK pub const AMBIENT_LIGHT_AR: f32 = 20.0; @@ -377,6 +377,7 @@ fn setup( style: Style { width: Val::VMin(0.0), height: Val::Percent(100.0), + left: Val::Vw(100.0 - SPEEDOMETER_WIDTH), align_items: AlignItems::End, overflow: Overflow::clip(), ..default() @@ -391,7 +392,7 @@ fn setup( ImageBundle { image: UiImage::new(speedometer_handle), style: Style { - width: Val::VMin(SPEEDOMETER_WIDTH), + width: Val::Vw(SPEEDOMETER_WIDTH), height: Val::VMin(SPEEDOMETER_HEIGHT), ..Default::default() }, @@ -405,6 +406,7 @@ fn setup( style: Style { width: Val::VMin(0.0), height: Val::Percent(100.0), + left: Val::Vw(100.0 - SPEEDOMETER_WIDTH), align_items: AlignItems::End, overflow: Overflow::clip(), ..default() @@ -419,7 +421,7 @@ fn setup( ImageBundle { image: UiImage::new(speedometer_handle), style: Style { - width: Val::VMin(SPEEDOMETER_WIDTH), + width: Val::Vw(SPEEDOMETER_WIDTH), height: Val::VMin(SPEEDOMETER_HEIGHT), ..Default::default() }, @@ -432,7 +434,7 @@ fn setup( TextSection::new("", style_speedometer.clone()), // speed relative to orbit ]).with_style(Style { position_type: PositionType::Absolute, - left: Val::VMin(2.0), + left: Val::Vw(100.0 - SPEEDOMETER_WIDTH + 2.0), bottom: Val::VMin(4.0), ..default() }).with_text_justify(JustifyText::Left); @@ -530,13 +532,13 @@ fn update_speedometer( 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 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() { 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 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() { speed_text.sections[0].value = if let Ok(target_v) = q_target.get_single() {