From bdaf6f56d754ffe25a0c53cc9e3d60d30816a230 Mon Sep 17 00:00:00 2001 From: Scott Pruett Date: Thu, 9 Jun 2022 18:24:45 -0400 Subject: [PATCH] pit lap detection in UI --- src/main.rs | 11 +++++++++++ src/state.rs | 2 +- suggestions.md | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0b5585c..b79aefb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -207,6 +207,17 @@ fn show_race_state( let mut prev_lap: Option<&LapState> = None; let fastest_lap = race.fastest_lap(); for (i, lap) in race.laps.iter_mut().enumerate() { + if let Some(prev) = &prev_lap { + if lap.gas.unwrap_or_default() > prev.gas.unwrap_or(usize::MAX) || lap.tyres.unwrap_or_default() > prev.tyres.unwrap_or(usize::MAX) { + ui.separator(); + ui.separator(); + ui.separator(); + ui.separator(); + ui.separator(); + ui.separator(); + ui.end_row(); + } + } if let Some(lap_time) = lap.lap_time { ui.label(format!("#{}", lap.lap.unwrap_or(i + 1))); ui.label(format!("P{}", lap.position.unwrap_or_default())); diff --git a/src/state.rs b/src/state.rs index 36a34dd..e5316dd 100644 --- a/src/state.rs +++ b/src/state.rs @@ -143,7 +143,7 @@ impl RaceState { } pub fn fastest_lap(&self) -> Option { - self.laps.iter().filter_map(|lap| lap.lap_time).min() + self.laps.iter().filter(|lap| !lap.striked).filter_map(|lap| lap.lap_time).min() } pub fn tyre_wear(&self) -> Option { diff --git a/suggestions.md b/suggestions.md index cded99a..5388da4 100644 --- a/suggestions.md +++ b/suggestions.md @@ -6,8 +6,8 @@ - Detect car name from load screen - Post race metric charts - Show during race instead of table (?) - - Fix 0 tyres parsing as ".0" - [PARTIAL] TTS for pit strategies + - [DONE] Fix 0 tyres parsing as ".0" - [DONE] Show delta positions - [DONE] Track penalties - [DONE] Re-do debug/learn functionality