clear races

This commit is contained in:
Scott Pruett 2022-05-25 21:59:59 -04:00
parent 33d4024d2c
commit 89c5fca0bc
1 changed files with 9 additions and 2 deletions

View File

@ -43,9 +43,9 @@ fn main() -> anyhow::Result<()> {
}
let options = eframe::NativeOptions::default();
let exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("supper.exe"));
let current_exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("supper.exe"));
eframe::run_native(
&format!("Supper OCR ({:?})", exe),
&format!("Supper OCR ({})", current_exe.file_name().unwrap().to_string_lossy()),
options,
Box::new(|_cc| Box::new(AppUi::new(state))),
);
@ -386,6 +386,7 @@ impl eframe::App for AppUi {
);
}
let len = state.past_races.len();
let mut races_to_remove = Vec::new();
for (i, race) in state.past_races.iter_mut().enumerate() {
ui.separator();
ui.heading(format!("Race #{}: {}", len - i, race.name()));
@ -429,6 +430,12 @@ impl eframe::App for AppUi {
} else {
ui.label("Exported ✅");
}
if ui.button("Clear").clicked() {
races_to_remove.push(i);
}
}
for index in races_to_remove {
state.past_races.remove(index);
}
});
});