diff --git a/config.json b/config.json index a13ec06..33890fe 100644 --- a/config.json +++ b/config.json @@ -52,5 +52,12 @@ "height": 410, "threshold": 0.85 }, + "penalty_orange_region": { + "name": "penalty", + "x": 989, + "y": 117, + "width": 30, + "height": 30 + }, "ocr_server_endpoint": "https://tesserver.spruett.dev/" } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 12c2035..c05f8d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -146,13 +146,18 @@ fn show_race_state( ui.label("Tyres"); ui.end_row(); 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(lap_time) = lap.lap_time { ui.label(format!("#{}", lap.lap.unwrap_or(i + 1))); - ui.label(format_time(lap_time)); + if Some(lap_time) == fastest_lap { + ui.colored_label(Color32::from_rgb(255, 0, 255), format_time(lap_time)); + } else { + ui.label(format_time(lap_time)); + }; label_time_delta(ui, lap_time, prev_lap.and_then(|p| p.lap_time)); - label_time_delta(ui, lap_time, lap.best_time); + label_time_delta(ui, lap_time, fastest_lap); show_optional_usize_with_diff( ui, diff --git a/src/state.rs b/src/state.rs index b1a85b0..7215760 100644 --- a/src/state.rs +++ b/src/state.rs @@ -89,6 +89,10 @@ impl RaceState { } name } + + pub fn fastest_lap(&self) -> Option { + self.laps.iter().filter_map(|lap| lap.lap_time.clone()).max() + } } pub struct DebugOcrFrame { diff --git a/src/stats_writer.rs b/src/stats_writer.rs index d5db4f6..4878ebc 100644 --- a/src/stats_writer.rs +++ b/src/stats_writer.rs @@ -18,6 +18,7 @@ pub fn export_race_stats(race_stats: &mut RaceState) -> Result<()> { let writer = BufWriter::new(file); let mut csv_writer = csv::Writer::from_writer(writer); + let fastest_lap = race_stats.fastest_lap(); for lap in &race_stats.laps { if lap.striked { continue; @@ -36,7 +37,7 @@ pub fn export_race_stats(race_stats: &mut RaceState) -> Result<()> { ), format!( "{:.3}", - lap.best_time + fastest_lap .unwrap_or(Duration::from_secs(0)) .as_secs_f64() ),