mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
greying out choices in scoreboard that have no trips
This commit is contained in:
parent
c8e3e9ce4b
commit
97361317ed
@ -28,6 +28,7 @@ pub struct Menu<T: Clone> {
|
||||
icon_selected: bool,
|
||||
}
|
||||
|
||||
// TODO Maybe reuse the public Choice from wizard
|
||||
struct Choice<T: Clone> {
|
||||
hotkey: Option<MultiKey>,
|
||||
label: String,
|
||||
|
@ -409,9 +409,8 @@ impl<T: Clone> Choice<T> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn inactive(mut self) -> Choice<T> {
|
||||
assert!(self.active);
|
||||
self.active = false;
|
||||
pub fn active(mut self, active: bool) -> Choice<T> {
|
||||
self.active = active;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use ezgui::{
|
||||
use geom::Duration;
|
||||
use itertools::Itertools;
|
||||
use sim::{FinishedTrips, TripID, TripMode};
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
pub struct Scoreboard {
|
||||
menu: ModalMenu,
|
||||
@ -119,11 +119,22 @@ fn browse_trips(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Tra
|
||||
let mut wizard = wiz.wrap(ctx);
|
||||
let mode = wizard
|
||||
.choose("Browse which trips?", || {
|
||||
let trips = CompareTrips::new(
|
||||
ui.primary.sim.get_finished_trips(),
|
||||
ui.secondary.as_ref().unwrap().sim.get_finished_trips(),
|
||||
);
|
||||
let modes = trips
|
||||
.finished_trips
|
||||
.iter()
|
||||
.map(|(_, m, _, _)| *m)
|
||||
.collect::<BTreeSet<TripMode>>();
|
||||
|
||||
vec![
|
||||
Choice::new("walk", TripMode::Walk),
|
||||
Choice::new("bike", TripMode::Bike),
|
||||
Choice::new("transit", TripMode::Transit),
|
||||
Choice::new("drive", TripMode::Drive),
|
||||
Choice::new("walk", TripMode::Walk).active(modes.contains(&TripMode::Walk)),
|
||||
Choice::new("bike", TripMode::Bike).active(modes.contains(&TripMode::Bike)),
|
||||
Choice::new("transit", TripMode::Transit)
|
||||
.active(modes.contains(&TripMode::Transit)),
|
||||
Choice::new("drive", TripMode::Drive).active(modes.contains(&TripMode::Drive)),
|
||||
]
|
||||
})?
|
||||
.1;
|
||||
|
@ -8,6 +8,7 @@ use ezgui::{
|
||||
use geom::{Duration, DurationHistogram};
|
||||
use itertools::Itertools;
|
||||
use sim::{TripID, TripMode};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
pub struct Scoreboard {
|
||||
menu: ModalMenu,
|
||||
@ -74,11 +75,18 @@ impl State for Scoreboard {
|
||||
fn browse_trips(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Transition> {
|
||||
let mut wizard = wiz.wrap(ctx);
|
||||
let (_, mode) = wizard.choose("Browse which trips?", || {
|
||||
let trips = ui.primary.sim.get_finished_trips();
|
||||
let modes = trips
|
||||
.finished_trips
|
||||
.iter()
|
||||
.map(|(_, m, _)| *m)
|
||||
.collect::<BTreeSet<TripMode>>();
|
||||
|
||||
vec![
|
||||
Choice::new("walk", TripMode::Walk),
|
||||
Choice::new("bike", TripMode::Bike),
|
||||
Choice::new("transit", TripMode::Transit),
|
||||
Choice::new("drive", TripMode::Drive),
|
||||
Choice::new("walk", TripMode::Walk).active(modes.contains(&TripMode::Walk)),
|
||||
Choice::new("bike", TripMode::Bike).active(modes.contains(&TripMode::Bike)),
|
||||
Choice::new("transit", TripMode::Transit).active(modes.contains(&TripMode::Transit)),
|
||||
Choice::new("drive", TripMode::Drive).active(modes.contains(&TripMode::Drive)),
|
||||
]
|
||||
})?;
|
||||
wizard.choose("Examine which trip?", || {
|
||||
|
Loading…
Reference in New Issue
Block a user