add combo boxes for export
This commit is contained in:
parent
35415d2724
commit
9923b95deb
|
@ -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": {}
|
||||
}
|
|
@ -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
|
||||
|
|
|
|
@ -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
|
|
@ -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
|
39
src/main.rs
39
src/main.rs
|
@ -112,16 +112,33 @@ struct UiState {
|
|||
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)]
|
||||
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() {
|
||||
|
|
|
@ -91,7 +91,7 @@ impl RaceState {
|
|||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
- Penalties
|
||||
- Pit stops
|
||||
- ComboBox for car/track
|
||||
- GLobal best time not current best
|
||||
- [DONE] Global best time not current best
|
Loading…
Reference in New Issue