diff --git a/learned.json b/learned.json index ee7ccf6..4db0596 100644 --- a/learned.json +++ b/learned.json @@ -1,9 +1,12 @@ { "learned_images": { - "bGxobGhkZAg=": "92", - "AAAAAAAAAAA=": "", "bGzs3MhsbEA=": "90", - "bGzMbMjsbBA=": "98" + "bGzMbMjsbBA=": "98", + "bGzI3MhsbFA=": "90", + "AAAAAAAAAAA=": "", + "bGxobGhsbAg=": "91", + "bGxobGhkZAg=": "92", + "ZGxobEhsZEg=": "93" }, "learned_tracks": {} } \ No newline at end of file diff --git a/race_stats.csv b/race_stats.csv index d3695bb..810a330 100644 --- a/race_stats.csv +++ b/race_stats.csv @@ -1,3 +1,11 @@ 2022-05-22-20:39,whistle valley,gp,1,22.349,22.349,100,, 2022-05-22-20:39,whistle valley,gp,2,21.888,21.888,99,83,82 2022-05-22-20:39,whistle valley,gp,3,22.031,21.888,99,75,73 +2022-05-24-02:51 (Bullseye),Bullseye,GP,1,14.573,14.573,99,91,96,test +2022-05-24-02:51 (Bullseye),Bullseye,GP,2,14.536,14.573,99,82,92,test +2022-05-24-02:51 (Bullseye),Bullseye,GP,3,13.907,14.573,96,75,88,test +2022-05-24-02:56 (Bullseye),Bullseye,GP,1,15.197,14.053,100,,96,test +2022-05-24-02:56 (Bullseye),Bullseye,GP,2,14.140,14.053,100,83,23,test +2022-05-24-02:56 (Bullseye),Bullseye,GP,3,14.053,14.053,100,75,88,test +2022-05-24-03:10 (Whistle Valley),Whistle Valley,B,1,22.790,22.790,97,91,91,test +2022-05-24-03:10 (Whistle Valley),Whistle Valley,B,2,23.015,22.790,97,84,83,test diff --git a/car-classes.txt b/src/data/car-classes.txt similarity index 88% rename from car-classes.txt rename to src/data/car-classes.txt index 3fb5432..a8312d5 100644 --- a/car-classes.txt +++ b/src/data/car-classes.txt @@ -1,14 +1,15 @@ -Piccino -Superlight -Eurotruck -Muscle Car -Stock Car -Super Truck -Rally -50s GT -Touring Car -GT -Prototype -60s GP -80s GP + +Piccino +Superlight +Eurotruck +Muscle Car +Stock Car +Super Truck +Rally +50s GT +Touring Car +GT +Prototype +60s GP +80s GP GP \ No newline at end of file diff --git a/tracklist.txt b/src/data/tracklist.txt similarity index 85% rename from tracklist.txt rename to src/data/tracklist.txt index 0a8a100..ef50cbb 100644 --- a/tracklist.txt +++ b/src/data/tracklist.txt @@ -1,19 +1,20 @@ -Whistle Valley -Sugar Hill -Maple Ridge -Rennvoort -Magdalena GP -Magdalena Club -Copperwood GP -Copperwood Club -Interstate -Buffalo Hill -Lost Lagoons -Bullseye Speedway -Speedopolis -Faenza -Siena -Thunder Point -Tilksport GP -Tilksport Club + +Whistle Valley +Sugar Hill +Maple Ridge +Rennvoort +Magdalena GP +Magdalena Club +Copperwood GP +Copperwood Club +Interstate +Buffalo Hill +Lost Lagoons +Bullseye Speedway +Speedopolis +Faenza +Siena +Thunder Point +Tilksport GP +Tilksport Club Tilksport Rallycross \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index c05f8d9..3c85b11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,16 +112,33 @@ struct UiState { debug_lap: Option, } +#[derive(Default)] +struct UiData { + cars: Vec, + tracks: Vec, +} + +fn split_lines(data: &str) -> Vec { + data.split('\n').map(|line| line.trim().to_owned()).collect() +} +impl UiData { + fn load() -> Self { + Self { cars: split_lines(include_str!("data/car-classes.txt")), tracks: split_lines(include_str!("data/tracklist.txt")) } + } +} + #[derive(Default)] struct AppUi { state: SharedAppState, ui_state: UiState, + data: UiData, } impl AppUi { pub fn new(state: SharedAppState) -> Self { Self { state, + data: UiData::load(), ..Default::default() } } @@ -280,6 +297,18 @@ fn open_debug_lap( } } +fn show_combo_box( + ui: &mut Ui, + name: &str, + label: &str, + options: &[String], + value: &mut String +) { + 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()); + *value = options[index].clone(); +} + impl eframe::App for AppUi { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { let mut state = self.state.lock().unwrap(); @@ -353,11 +382,11 @@ impl eframe::App for AppUi { let len = state.past_races.len(); for (i, race) in state.past_races.iter_mut().enumerate() { ui.separator(); - ui.heading(format!("Race #{}", len - i)); + ui.heading(format!("Race #{}: {}", len - i, race.name())); show_race_state( ui, &mut self.ui_state, - &format!("{}: {}", i, race.name()), + &format!("race {}:", i), race, config.clone(), learned.clone(), @@ -367,10 +396,8 @@ impl eframe::App for AppUi { img.show_max_size(ui, Vec2::new(600.0, 500.0)); } if !race.exported { - ui.label("Car:"); - ui.text_edit_singleline(&mut race.car); - ui.label("Track:"); - ui.text_edit_singleline(&mut race.track); + 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); ui.label("Comments:"); ui.text_edit_singleline(&mut race.comments); if ui.button("Export").clicked() { diff --git a/src/state.rs b/src/state.rs index 7215760..982fbb4 100644 --- a/src/state.rs +++ b/src/state.rs @@ -91,7 +91,7 @@ impl RaceState { } pub fn fastest_lap(&self) -> Option { - self.laps.iter().filter_map(|lap| lap.lap_time.clone()).max() + self.laps.iter().filter_map(|lap| lap.lap_time).min() } } diff --git a/suggestions.md b/suggestions.md index ddef102..5a1c418 100644 --- a/suggestions.md +++ b/suggestions.md @@ -2,4 +2,4 @@ - Penalties - Pit stops - ComboBox for car/track - - GLobal best time not current best \ No newline at end of file + - [DONE] Global best time not current best \ No newline at end of file