clean up car/track lists
This commit is contained in:
parent
9923b95deb
commit
c4d9cf341a
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
Piccino
|
Piccino
|
||||||
Superlight
|
Superlight
|
||||||
Eurotruck
|
Eurotruck
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
Whistle Valley
|
Whistle Valley
|
||||||
Sugar Hill
|
Sugar Hill
|
||||||
Maple Ridge
|
Maple Ridge
|
||||||
|
|
59
src/main.rs
59
src/main.rs
|
@ -81,17 +81,23 @@ fn format_time(time: Duration) -> String {
|
||||||
|
|
||||||
fn label_time_delta(ui: &mut Ui, time: Duration, old: Option<Duration>) {
|
fn label_time_delta(ui: &mut Ui, time: Duration, old: Option<Duration>) {
|
||||||
if let Some(old) = old {
|
if let Some(old) = old {
|
||||||
if time > old {
|
match time.cmp(&old) {
|
||||||
ui.colored_label(
|
std::cmp::Ordering::Less => {
|
||||||
Color32::LIGHT_RED,
|
|
||||||
"+".to_owned() + &format_time(time - old),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ui.colored_label(
|
ui.colored_label(
|
||||||
Color32::LIGHT_GREEN,
|
Color32::LIGHT_GREEN,
|
||||||
"-".to_owned() + &format_time(old - time),
|
"-".to_owned() + &format_time(old - time),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
std::cmp::Ordering::Equal => {
|
||||||
|
ui.colored_label(
|
||||||
|
Color32::LIGHT_RED,
|
||||||
|
"+".to_owned() + &format_time(time - old),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
std::cmp::Ordering::Greater => {
|
||||||
|
ui.label("--");
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ui.label("--");
|
ui.label("--");
|
||||||
}
|
}
|
||||||
|
@ -119,11 +125,20 @@ struct UiData {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn split_lines(data: &str) -> Vec<String> {
|
fn split_lines(data: &str) -> Vec<String> {
|
||||||
data.split('\n').map(|line| line.trim().to_owned()).collect()
|
let mut lines: Vec<String> = data
|
||||||
|
.split('\n')
|
||||||
|
.map(|line| line.trim().to_owned())
|
||||||
|
.collect();
|
||||||
|
lines.push("".to_owned());
|
||||||
|
lines.reverse();
|
||||||
|
lines
|
||||||
}
|
}
|
||||||
impl UiData {
|
impl UiData {
|
||||||
fn load() -> Self {
|
fn load() -> Self {
|
||||||
Self { cars: split_lines(include_str!("data/car-classes.txt")), tracks: split_lines(include_str!("data/tracklist.txt")) }
|
Self {
|
||||||
|
cars: split_lines(include_str!("data/car-classes.txt")),
|
||||||
|
tracks: split_lines(include_str!("data/tracklist.txt")),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +184,7 @@ fn show_race_state(
|
||||||
ui.label(format!("#{}", lap.lap.unwrap_or(i + 1)));
|
ui.label(format!("#{}", lap.lap.unwrap_or(i + 1)));
|
||||||
|
|
||||||
if Some(lap_time) == fastest_lap {
|
if Some(lap_time) == fastest_lap {
|
||||||
ui.colored_label(Color32::from_rgb(255, 0, 255), format_time(lap_time));
|
ui.colored_label(Color32::GREEN, format_time(lap_time));
|
||||||
} else {
|
} else {
|
||||||
ui.label(format_time(lap_time));
|
ui.label(format_time(lap_time));
|
||||||
};
|
};
|
||||||
|
@ -281,12 +296,7 @@ fn open_debug_lap(
|
||||||
ocr_cache: Arc<OcrCache>,
|
ocr_cache: Arc<OcrCache>,
|
||||||
) {
|
) {
|
||||||
if let Some(screenshot) = &lap.screenshot {
|
if let Some(screenshot) = &lap.screenshot {
|
||||||
let ocr_results = ocr::ocr_all_regions(
|
let ocr_results = ocr::ocr_all_regions(screenshot, config.clone(), learned, ocr_cache);
|
||||||
screenshot,
|
|
||||||
config.clone(),
|
|
||||||
learned,
|
|
||||||
ocr_cache,
|
|
||||||
);
|
|
||||||
let debug_lap = DebugLap {
|
let debug_lap = DebugLap {
|
||||||
screenshot: RetainedImage::from_image_bytes("debug-lap", &to_png_bytes(screenshot))
|
screenshot: RetainedImage::from_image_bytes("debug-lap", &to_png_bytes(screenshot))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -297,15 +307,10 @@ fn open_debug_lap(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_combo_box(
|
fn show_combo_box(ui: &mut Ui, name: &str, label: &str, options: &[String], value: &mut String) {
|
||||||
ui: &mut Ui,
|
|
||||||
name: &str,
|
|
||||||
label: &str,
|
|
||||||
options: &[String],
|
|
||||||
value: &mut String
|
|
||||||
) {
|
|
||||||
let mut index = options.iter().position(|e| e == value).unwrap_or(0);
|
let mut index = options.iter().position(|e| e == value).unwrap_or(0);
|
||||||
egui::ComboBox::new(name, label).show_index(ui, &mut index, options.len(), |i| options[i].clone());
|
egui::ComboBox::new(name, label)
|
||||||
|
.show_index(ui, &mut index, options.len(), |i| options[i].clone());
|
||||||
*value = options[index].clone();
|
*value = options[index].clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +402,13 @@ impl eframe::App for AppUi {
|
||||||
}
|
}
|
||||||
if !race.exported {
|
if !race.exported {
|
||||||
show_combo_box(ui, "car-combo", "Car", &self.data.cars, &mut race.car);
|
show_combo_box(ui, "car-combo", "Car", &self.data.cars, &mut race.car);
|
||||||
show_combo_box(ui, "track-combo", "Track", &self.data.tracks, &mut race.track);
|
show_combo_box(
|
||||||
|
ui,
|
||||||
|
"track-combo",
|
||||||
|
"Track",
|
||||||
|
&self.data.tracks,
|
||||||
|
&mut race.track,
|
||||||
|
);
|
||||||
ui.label("Comments:");
|
ui.label("Comments:");
|
||||||
ui.text_edit_singleline(&mut race.comments);
|
ui.text_edit_singleline(&mut race.comments);
|
||||||
if ui.button("Export").clicked() {
|
if ui.button("Export").clicked() {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
- Recognize
|
- Recognize
|
||||||
- Penalties
|
- Penalties
|
||||||
- Pit stops
|
- Pit stops
|
||||||
- ComboBox for car/track
|
- [DONE] ComboBox for car/track
|
||||||
- [DONE] Global best time not current best
|
- [DONE] Global best time not current best
|
||||||
|
- Best time from other racers
|
||||||
|
- Editable lap stats
|
Loading…
Reference in New Issue