From 89c5fca0bc1419512f4355f865b58355b8333cfa Mon Sep 17 00:00:00 2001 From: Scott Pruett Date: Wed, 25 May 2022 21:59:59 -0400 Subject: [PATCH] clear races --- src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6d46762..5ce14f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); } }); });