add combo boxes for export

This commit is contained in:
Scott Pruett 2022-05-23 23:22:48 -04:00
parent 35415d2724
commit 9923b95deb
7 changed files with 82 additions and 42 deletions

View File

@ -1,9 +1,12 @@
{ {
"learned_images": { "learned_images": {
"bGxobGhkZAg=": "92",
"AAAAAAAAAAA=": "",
"bGzs3MhsbEA=": "90", "bGzs3MhsbEA=": "90",
"bGzMbMjsbBA=": "98" "bGzMbMjsbBA=": "98",
"bGzI3MhsbFA=": "90",
"AAAAAAAAAAA=": "",
"bGxobGhsbAg=": "91",
"bGxobGhkZAg=": "92",
"ZGxobEhsZEg=": "93"
}, },
"learned_tracks": {} "learned_tracks": {}
} }

View File

@ -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,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,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-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

1 2022-05-22-20:39 2022-05-22-20:39,whistle valley,gp,1,22.349,22.349,100,, whistle valley gp 1 22.349 22.349 100
2 2022-05-22-20:39 2022-05-22-20:39,whistle valley,gp,2,21.888,21.888,99,83,82 whistle valley gp 2 21.888 21.888 99 83 82
3 2022-05-22-20:39 2022-05-22-20:39,whistle valley,gp,3,22.031,21.888,99,75,73 whistle valley gp 3 22.031 21.888 99 75 73
4 2022-05-24-02:51 (Bullseye),Bullseye,GP,1,14.573,14.573,99,91,96,test
5 2022-05-24-02:51 (Bullseye),Bullseye,GP,2,14.536,14.573,99,82,92,test
6 2022-05-24-02:51 (Bullseye),Bullseye,GP,3,13.907,14.573,96,75,88,test
7 2022-05-24-02:56 (Bullseye),Bullseye,GP,1,15.197,14.053,100,,96,test
8 2022-05-24-02:56 (Bullseye),Bullseye,GP,2,14.140,14.053,100,83,23,test
9 2022-05-24-02:56 (Bullseye),Bullseye,GP,3,14.053,14.053,100,75,88,test
10 2022-05-24-03:10 (Whistle Valley),Whistle Valley,B,1,22.790,22.790,97,91,91,test
11 2022-05-24-03:10 (Whistle Valley),Whistle Valley,B,2,23.015,22.790,97,84,83,test

View File

@ -1,14 +1,15 @@
Piccino
Superlight Piccino
Eurotruck Superlight
Muscle Car Eurotruck
Stock Car Muscle Car
Super Truck Stock Car
Rally Super Truck
50s GT Rally
Touring Car 50s GT
GT Touring Car
Prototype GT
60s GP Prototype
80s GP 60s GP
80s GP
GP GP

View File

@ -1,19 +1,20 @@
Whistle Valley
Sugar Hill Whistle Valley
Maple Ridge Sugar Hill
Rennvoort Maple Ridge
Magdalena GP Rennvoort
Magdalena Club Magdalena GP
Copperwood GP Magdalena Club
Copperwood Club Copperwood GP
Interstate Copperwood Club
Buffalo Hill Interstate
Lost Lagoons Buffalo Hill
Bullseye Speedway Lost Lagoons
Speedopolis Bullseye Speedway
Faenza Speedopolis
Siena Faenza
Thunder Point Siena
Tilksport GP Thunder Point
Tilksport Club Tilksport GP
Tilksport Club
Tilksport Rallycross Tilksport Rallycross

View File

@ -112,16 +112,33 @@ struct UiState {
debug_lap: Option<DebugLap>, debug_lap: Option<DebugLap>,
} }
#[derive(Default)]
struct UiData {
cars: Vec<String>,
tracks: Vec<String>,
}
fn split_lines(data: &str) -> Vec<String> {
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)] #[derive(Default)]
struct AppUi { struct AppUi {
state: SharedAppState, state: SharedAppState,
ui_state: UiState, ui_state: UiState,
data: UiData,
} }
impl AppUi { impl AppUi {
pub fn new(state: SharedAppState) -> Self { pub fn new(state: SharedAppState) -> Self {
Self { Self {
state, state,
data: UiData::load(),
..Default::default() ..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 { impl eframe::App for AppUi {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
@ -353,11 +382,11 @@ impl eframe::App for AppUi {
let len = state.past_races.len(); let len = state.past_races.len();
for (i, race) in state.past_races.iter_mut().enumerate() { for (i, race) in state.past_races.iter_mut().enumerate() {
ui.separator(); ui.separator();
ui.heading(format!("Race #{}", len - i)); ui.heading(format!("Race #{}: {}", len - i, race.name()));
show_race_state( show_race_state(
ui, ui,
&mut self.ui_state, &mut self.ui_state,
&format!("{}: {}", i, race.name()), &format!("race {}:", i),
race, race,
config.clone(), config.clone(),
learned.clone(), learned.clone(),
@ -367,10 +396,8 @@ impl eframe::App for AppUi {
img.show_max_size(ui, Vec2::new(600.0, 500.0)); img.show_max_size(ui, Vec2::new(600.0, 500.0));
} }
if !race.exported { if !race.exported {
ui.label("Car:"); show_combo_box(ui, "car-combo", "Car", &self.data.cars, &mut race.car);
ui.text_edit_singleline(&mut race.car); show_combo_box(ui, "track-combo", "Track", &self.data.tracks, &mut race.track);
ui.label("Track:");
ui.text_edit_singleline(&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() {

View File

@ -91,7 +91,7 @@ impl RaceState {
} }
pub fn fastest_lap(&self) -> Option<Duration> { pub fn fastest_lap(&self) -> Option<Duration> {
self.laps.iter().filter_map(|lap| lap.lap_time.clone()).max() self.laps.iter().filter_map(|lap| lap.lap_time).min()
} }
} }

View File

@ -2,4 +2,4 @@
- Penalties - Penalties
- Pit stops - Pit stops
- ComboBox for car/track - ComboBox for car/track
- GLobal best time not current best - [DONE] Global best time not current best