fastest lap in purple and global
This commit is contained in:
parent
70ad975866
commit
35415d2724
|
@ -52,5 +52,12 @@
|
||||||
"height": 410,
|
"height": 410,
|
||||||
"threshold": 0.85
|
"threshold": 0.85
|
||||||
},
|
},
|
||||||
|
"penalty_orange_region": {
|
||||||
|
"name": "penalty",
|
||||||
|
"x": 989,
|
||||||
|
"y": 117,
|
||||||
|
"width": 30,
|
||||||
|
"height": 30
|
||||||
|
},
|
||||||
"ocr_server_endpoint": "https://tesserver.spruett.dev/"
|
"ocr_server_endpoint": "https://tesserver.spruett.dev/"
|
||||||
}
|
}
|
|
@ -146,13 +146,18 @@ fn show_race_state(
|
||||||
ui.label("Tyres");
|
ui.label("Tyres");
|
||||||
ui.end_row();
|
ui.end_row();
|
||||||
let mut prev_lap: Option<&LapState> = None;
|
let mut prev_lap: Option<&LapState> = None;
|
||||||
|
let fastest_lap = race.fastest_lap();
|
||||||
for (i, lap) in race.laps.iter_mut().enumerate() {
|
for (i, lap) in race.laps.iter_mut().enumerate() {
|
||||||
if let Some(lap_time) = lap.lap_time {
|
if let Some(lap_time) = lap.lap_time {
|
||||||
ui.label(format!("#{}", lap.lap.unwrap_or(i + 1)));
|
ui.label(format!("#{}", lap.lap.unwrap_or(i + 1)));
|
||||||
|
|
||||||
|
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));
|
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, 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(
|
show_optional_usize_with_diff(
|
||||||
ui,
|
ui,
|
||||||
|
|
|
@ -89,6 +89,10 @@ impl RaceState {
|
||||||
}
|
}
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fastest_lap(&self) -> Option<Duration> {
|
||||||
|
self.laps.iter().filter_map(|lap| lap.lap_time.clone()).max()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DebugOcrFrame {
|
pub struct DebugOcrFrame {
|
||||||
|
|
|
@ -18,6 +18,7 @@ pub fn export_race_stats(race_stats: &mut RaceState) -> Result<()> {
|
||||||
let writer = BufWriter::new(file);
|
let writer = BufWriter::new(file);
|
||||||
let mut csv_writer = csv::Writer::from_writer(writer);
|
let mut csv_writer = csv::Writer::from_writer(writer);
|
||||||
|
|
||||||
|
let fastest_lap = race_stats.fastest_lap();
|
||||||
for lap in &race_stats.laps {
|
for lap in &race_stats.laps {
|
||||||
if lap.striked {
|
if lap.striked {
|
||||||
continue;
|
continue;
|
||||||
|
@ -36,7 +37,7 @@ pub fn export_race_stats(race_stats: &mut RaceState) -> Result<()> {
|
||||||
),
|
),
|
||||||
format!(
|
format!(
|
||||||
"{:.3}",
|
"{:.3}",
|
||||||
lap.best_time
|
fastest_lap
|
||||||
.unwrap_or(Duration::from_secs(0))
|
.unwrap_or(Duration::from_secs(0))
|
||||||
.as_secs_f64()
|
.as_secs_f64()
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue