1#![allow(clippy::too_many_arguments, clippy::type_complexity)]
5#![allow(clippy::new_without_default)]
6
7#[macro_use]
8extern crate anyhow;
9#[macro_use]
10extern crate log;
11
12use abstutil::Timer;
13use geom::{Duration, Pt2D, Time};
14use map_model::{
15 AreaID, BuildingID, IntersectionID, LaneID, Map, ParkingLotID, RoadID, TransitStopID,
16};
17use widgetry::{EventCtx, GfxCtx, State};
18
19pub use self::simple_app::{SimpleApp, SimpleAppArgs};
20use crate::render::DrawOptions;
21use colors::{ColorScheme, ColorSchemeChoice};
22use options::Options;
23use render::DrawMap;
24
25pub mod colors;
26pub mod load;
27pub mod options;
28pub mod render;
29mod simple_app;
30pub mod tools;
31
32pub trait AppLike {
36 fn map(&self) -> ⤅
37 fn cs(&self) -> &ColorScheme;
38 fn mut_cs(&mut self) -> &mut ColorScheme;
39 fn draw_map(&self) -> &DrawMap;
40 fn mut_draw_map(&mut self) -> &mut DrawMap;
41 fn opts(&self) -> &Options;
42 fn mut_opts(&mut self) -> &mut Options;
43 fn map_switched(&mut self, ctx: &mut EventCtx, map: Map, timer: &mut Timer);
44 fn draw_with_opts(&self, g: &mut GfxCtx, opts: DrawOptions);
45 fn make_warper(
47 &mut self,
48 ctx: &EventCtx,
49 pt: Pt2D,
50 target_cam_zoom: Option<f64>,
51 id: Option<ID>,
52 ) -> Box<dyn State<Self>>
53 where
54 Self: Sized;
55
56 fn sim_time(&self) -> Time;
59 fn current_stage_and_remaining_time(&self, id: IntersectionID) -> (usize, Duration);
60
61 fn change_color_scheme(&mut self, ctx: &mut EventCtx, cs: ColorSchemeChoice) -> bool {
63 if self.opts().color_scheme == cs {
64 return false;
65 }
66 self.mut_opts().color_scheme = cs;
67 *self.mut_cs() = ColorScheme::new(ctx, self.opts().color_scheme);
68
69 ctx.loading_screen("rerendering map colors", |ctx, timer| {
70 *self.mut_draw_map() = DrawMap::new(ctx, self.map(), self.opts(), self.cs(), timer);
71 });
72
73 true
74 }
75}
76
77#[derive(Clone, Hash, PartialEq, Eq, Debug, PartialOrd, Ord)]
78pub enum ID {
79 Road(RoadID),
80 Lane(LaneID),
81 Intersection(IntersectionID),
82 Building(BuildingID),
83 ParkingLot(ParkingLotID),
84 TransitStop(TransitStopID),
85 Area(AreaID),
86}