diff --git a/game/src/abtest/mod.rs b/game/src/abtest/mod.rs index 926f95df36..8ec15269f6 100644 --- a/game/src/abtest/mod.rs +++ b/game/src/abtest/mod.rs @@ -72,8 +72,8 @@ impl State for ABTestMode { diff.lines.len() ))); } - let (percent, unfinished, by_mode) = ui.primary.sim.num_trips(); - txt.add(Line(format!("Percent of trips completed: {}", percent))); + let (finished, unfinished, by_mode) = ui.primary.sim.num_trips(); + txt.add(Line(format!("Finished trips: {}", finished))); txt.add(Line(format!("Unfinished trips: {}", unfinished))); txt.add(Line(format!( "Peds {}, Bikes {}, Cars {}, Buses {}", diff --git a/game/src/sandbox/mod.rs b/game/src/sandbox/mod.rs index 81bf90dc5f..31fa432d3c 100644 --- a/game/src/sandbox/mod.rs +++ b/game/src/sandbox/mod.rs @@ -15,12 +15,12 @@ use crate::pregame::main_menu; use crate::ui::{ShowEverything, UI}; use abstutil::Timer; use ezgui::{ - hotkey, lctrl, Choice, Color, Composite, DrawBoth, EventCtx, EventLoopMode, GeomBatch, GfxCtx, - HorizontalAlignment, JustDraw, Key, Line, ManagedWidget, ScreenPt, Text, VerticalAlignment, + hotkey, lctrl, Choice, Color, Composite, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, + Key, Line, ManagedWidget, Text, VerticalAlignment, }; pub use gameplay::spawner::spawn_agents_around; pub use gameplay::GameplayMode; -use geom::{Polygon, Time}; +use geom::Time; use map_model::MapEdits; use sim::TripMode; pub use speed::{SpeedControls, TimePanel}; @@ -289,7 +289,7 @@ struct AgentMeter { impl AgentMeter { fn new(ctx: &mut EventCtx, ui: &UI) -> AgentMeter { - let (percent, unfinished, by_mode) = ui.primary.sim.num_trips(); + let (finished, unfinished, by_mode) = ui.primary.sim.num_trips(); let composite = Composite::new( ManagedWidget::col(vec![ @@ -305,25 +305,10 @@ impl AgentMeter { ]) .centered(), { - // TODO Manaully tuned. :\ - let width = 350.0; - let height = 30.0; - - let txt = Text::from( - Line(format!("Unfinished trips: {}", unfinished)).fg(Color::BLACK), - ); - let mut batch = - GeomBatch::from(vec![(Color::WHITE, Polygon::rectangle(width, height))]); - if percent != 0.0 { - batch.push(Color::YELLOW, Polygon::rectangle(percent * width, height)); - } - - ManagedWidget::just_draw(JustDraw::wrap(DrawBoth::new( - ctx, - batch, - vec![(txt, ScreenPt::new(0.0, 0.0))], - ))) - .margin(10) + let mut txt = Text::new(); + txt.add(Line(format!("Finished trips: {}", finished))); + txt.add(Line(format!("Unfinished trips: {}", unfinished))); + ManagedWidget::draw_text(ctx, txt) }, // TODO The SVG button uses clip and doesn't seem to work crate::managed::Composite::text_button( diff --git a/sim/src/sim.rs b/sim/src/sim.rs index aa82db5fa7..7d43225432 100644 --- a/sim/src/sim.rs +++ b/sim/src/sim.rs @@ -660,11 +660,11 @@ impl Sim { let dt_real = Duration::realtime_elapsed(last_print); if dt_real >= Duration::seconds(1.0) { - let (percent, unfinished, _) = self.num_trips(); + let (finished, unfinished, _) = self.num_trips(); println!( - "{}: {}% trips complete, {} unfinished, speed = {:.2}x, {}", + "{}: {} trips finished, {} unfinished, speed = {:.2}x, {}", self.time(), - percent * 100.0, + finished, unfinished, (self.time() - last_sim_time) / dt_real, self.scheduler.describe_stats() @@ -816,12 +816,12 @@ impl Sim { self.time == Time::START_OF_DAY && self.is_done() } - // (percent of trips complete, number of unfinished trips, number of active by mode) + // (number of finished trips, number of unfinished trips, number of active by mode) // prettyprinted - pub fn num_trips(&self) -> (f64, String, BTreeMap) { - let (percent, unfinished, by_mode) = self.trips.num_trips(); + pub fn num_trips(&self) -> (String, String, BTreeMap) { + let (finished, unfinished, by_mode) = self.trips.num_trips(); ( - percent, + abstutil::prettyprint_usize(finished), abstutil::prettyprint_usize(unfinished), by_mode .into_iter() diff --git a/sim/src/trips.rs b/sim/src/trips.rs index b6bbb98cb8..fa51f61e97 100644 --- a/sim/src/trips.rs +++ b/sim/src/trips.rs @@ -492,8 +492,8 @@ impl TripManager { } } - // (percent of trips completed, unfinished trips, active trips by the trip's current mode) - pub fn num_trips(&self) -> (f64, usize, BTreeMap) { + // (finished trips, unfinished trips, active trips by the trip's current mode) + pub fn num_trips(&self) -> (usize, usize, BTreeMap) { let mut cnt = Counter::new(); for a in self.active_trip_mode.keys() { cnt.inc(TripMode::from_agent(*a)); @@ -502,13 +502,11 @@ impl TripManager { .into_iter() .map(|k| (k, cnt.get(k))) .collect(); - let percent = if self.trips.len() == 0 { - 0.0 - } else { - 1.0 - ((self.unfinished_trips as f64) / (self.trips.len() as f64)) - }; - - (percent, self.unfinished_trips, per_mode) + ( + self.trips.len() - self.unfinished_trips, + self.unfinished_trips, + per_mode, + ) } pub fn is_done(&self) -> bool {