mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-22 14:52:07 +03:00
Remove map_gui's dependency on sim! This cuts build times for the LTN
tool, among other benefits
This commit is contained in:
parent
5b52725bd4
commit
f8cac65d83
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2330,7 +2330,6 @@ dependencies = [
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sim",
|
||||
"structopt",
|
||||
"synthpop",
|
||||
"wasm-bindgen",
|
||||
@ -2454,7 +2453,6 @@ dependencies = [
|
||||
"regex",
|
||||
"rfd",
|
||||
"serde",
|
||||
"sim",
|
||||
"structopt",
|
||||
"subprocess",
|
||||
"synthpop",
|
||||
|
@ -497,10 +497,6 @@ impl map_gui::AppLike for App {
|
||||
&self.primary.map
|
||||
}
|
||||
#[inline]
|
||||
fn sim(&self) -> &Sim {
|
||||
&self.primary.sim
|
||||
}
|
||||
#[inline]
|
||||
fn cs(&self) -> &ColorScheme {
|
||||
&self.cs
|
||||
}
|
||||
@ -564,6 +560,14 @@ impl map_gui::AppLike for App {
|
||||
&mut self.primary,
|
||||
)
|
||||
}
|
||||
|
||||
fn sim_time(&self) -> Time {
|
||||
self.primary.sim.time()
|
||||
}
|
||||
|
||||
fn current_stage_and_remaining_time(&self, id: IntersectionID) -> (usize, Duration) {
|
||||
self.primary.sim.current_stage_and_remaining_time(id)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ShowLayers {
|
||||
|
@ -5,7 +5,7 @@ use geom::{Circle, Distance, Time};
|
||||
use map_gui::colors::ColorSchemeChoice;
|
||||
use map_gui::load::MapLoader;
|
||||
use map_gui::options::OptionsPanel;
|
||||
use map_gui::tools::{Minimap, TurnExplorer};
|
||||
use map_gui::tools::Minimap;
|
||||
use map_gui::AppLike;
|
||||
use sim::Analytics;
|
||||
use synthpop::Scenario;
|
||||
@ -36,6 +36,7 @@ mod minimap;
|
||||
mod misc_tools;
|
||||
mod speed;
|
||||
mod time_warp;
|
||||
mod turn_explorer;
|
||||
|
||||
pub struct SandboxMode {
|
||||
gameplay: Box<dyn gameplay::GameplayState>,
|
||||
@ -379,7 +380,7 @@ impl ContextualActions for Actions {
|
||||
Transition::Push(TrafficRecorder::new_state(ctx, btreeset! {i}))
|
||||
}
|
||||
(ID::Lane(l), "explore turns from this lane") => {
|
||||
Transition::Push(TurnExplorer::new_state(ctx, app, l))
|
||||
Transition::Push(turn_explorer::TurnExplorer::new_state(ctx, app, l))
|
||||
}
|
||||
(ID::Lane(l), "edit lane") => Transition::Multi(vec![
|
||||
Transition::Push(EditMode::new_state(ctx, app, self.gameplay.clone())),
|
||||
|
@ -1,13 +1,14 @@
|
||||
use geom::{ArrowCap, Distance};
|
||||
use map_gui::render::{DrawOptions, BIG_ARROW_THICKNESS};
|
||||
use map_gui::AppLike;
|
||||
use map_model::{LaneID, PathConstraints, TurnType};
|
||||
use widgetry::tools::ColorLegend;
|
||||
use widgetry::{
|
||||
Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome,
|
||||
Panel, State, Text, TextExt, Transition, VerticalAlignment, Widget,
|
||||
Panel, State, Text, TextExt, VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
use crate::render::{DrawOptions, BIG_ARROW_THICKNESS};
|
||||
use crate::AppLike;
|
||||
use crate::app::{App, Transition};
|
||||
|
||||
/// A tool to explore all of the turns from a single lane.
|
||||
pub struct TurnExplorer {
|
||||
@ -18,11 +19,7 @@ pub struct TurnExplorer {
|
||||
}
|
||||
|
||||
impl TurnExplorer {
|
||||
pub fn new_state<A: AppLike + 'static>(
|
||||
ctx: &mut EventCtx,
|
||||
app: &A,
|
||||
l: LaneID,
|
||||
) -> Box<dyn State<A>> {
|
||||
pub fn new_state(ctx: &mut EventCtx, app: &App, l: LaneID) -> Box<dyn State<App>> {
|
||||
Box::new(TurnExplorer {
|
||||
l,
|
||||
idx: 0,
|
||||
@ -31,8 +28,8 @@ impl TurnExplorer {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: AppLike + 'static> State<A> for TurnExplorer {
|
||||
fn event(&mut self, ctx: &mut EventCtx, app: &mut A) -> Transition<A> {
|
||||
impl State<App> for TurnExplorer {
|
||||
fn event(&mut self, ctx: &mut EventCtx, app: &mut App) -> Transition {
|
||||
ctx.canvas_movement();
|
||||
|
||||
if let Outcome::Clicked(x) = self.panel.event(ctx) {
|
||||
@ -59,7 +56,7 @@ impl<A: AppLike + 'static> State<A> for TurnExplorer {
|
||||
DrawBaselayer::Custom
|
||||
}
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, app: &A) {
|
||||
fn draw(&self, g: &mut GfxCtx, app: &App) {
|
||||
let mut opts = DrawOptions::new();
|
||||
{
|
||||
let l = app.map().get_l(self.l);
|
||||
@ -107,7 +104,7 @@ impl<A: AppLike + 'static> State<A> for TurnExplorer {
|
||||
}
|
||||
|
||||
impl TurnExplorer {
|
||||
fn make_panel<A: AppLike>(ctx: &mut EventCtx, app: &A, l: LaneID, idx: usize) -> Panel {
|
||||
fn make_panel(ctx: &mut EventCtx, app: &App, l: LaneID, idx: usize) -> Panel {
|
||||
let turns = app.map().get_turns_from_lane(l);
|
||||
|
||||
let mut col = vec![Widget::row(vec![
|
||||
@ -179,7 +176,8 @@ impl TurnExplorer {
|
||||
} else {
|
||||
let (lt, lc, slow_lane) = turns[idx - 1].penalty(PathConstraints::Car, app.map());
|
||||
let (vehicles, bike) = app
|
||||
.sim()
|
||||
.primary
|
||||
.sim
|
||||
.target_lane_penalty(app.map().get_l(turns[idx - 1].id.dst));
|
||||
col.push(
|
||||
format!(
|
@ -34,7 +34,6 @@ rand_xorshift = { workspace = true }
|
||||
regex = "1.5.5"
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
sim = { path = "../../sim" }
|
||||
osm2streets = { git = "https://github.com/a-b-street/osm2streets" }
|
||||
synthpop = { path = "../../synthpop" }
|
||||
wasm-bindgen = { workspace = true, optional = true }
|
||||
|
@ -124,10 +124,6 @@ impl AppLike for App {
|
||||
&self.per_map.map
|
||||
}
|
||||
#[inline]
|
||||
fn sim(&self) -> &sim::Sim {
|
||||
unreachable!()
|
||||
}
|
||||
#[inline]
|
||||
fn cs(&self) -> &ColorScheme {
|
||||
&self.cs
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use abstutil::{prettyprint_usize, Counter};
|
||||
use geom::ArrowCap;
|
||||
use map_gui::options::OptionsPanel;
|
||||
use map_gui::render::{DrawOptions, BIG_ARROW_THICKNESS};
|
||||
use map_gui::tools::{CityPicker, Minimap, MinimapControls, Navigator, TurnExplorer};
|
||||
use map_gui::tools::{CityPicker, Minimap, MinimapControls, Navigator};
|
||||
use map_gui::{SimpleApp, ID};
|
||||
use widgetry::tools::{open_browser, PopupMsg, URLManager};
|
||||
use widgetry::{
|
||||
@ -240,7 +240,7 @@ impl State<App> for Viewer {
|
||||
if let Some(ID::Lane(l)) = app.current_selection {
|
||||
for turn in app.map.get_turns_from_lane(l) {
|
||||
batch.push(
|
||||
TurnExplorer::color_turn_type(turn.turn_type),
|
||||
Color::RED,
|
||||
turn.geom
|
||||
.make_arrow(BIG_ARROW_THICKNESS, ArrowCap::Triangle),
|
||||
);
|
||||
|
@ -31,7 +31,6 @@ map_model = { path = "../map_model" }
|
||||
regex = "1.5.5"
|
||||
rfd = "0.8.0"
|
||||
serde = { workspace = true }
|
||||
sim = { path = "../sim" }
|
||||
synthpop = { path = "../synthpop" }
|
||||
structopt = { workspace = true }
|
||||
subprocess = { git = "https://github.com/hniksic/rust-subprocess", optional = true }
|
||||
|
@ -14,7 +14,6 @@ use geom::{Duration, Pt2D, Time};
|
||||
use map_model::{
|
||||
AreaID, BuildingID, IntersectionID, LaneID, Map, ParkingLotID, RoadID, TransitStopID,
|
||||
};
|
||||
use sim::Sim;
|
||||
use widgetry::{EventCtx, GfxCtx, State};
|
||||
|
||||
pub use self::simple_app::{SimpleApp, SimpleAppArgs};
|
||||
@ -35,7 +34,6 @@ pub mod tools;
|
||||
/// `SimpleApp` for an example implementation.
|
||||
pub trait AppLike {
|
||||
fn map(&self) -> ⤅
|
||||
fn sim(&self) -> &Sim;
|
||||
fn cs(&self) -> &ColorScheme;
|
||||
fn mut_cs(&mut self) -> &mut ColorScheme;
|
||||
fn draw_map(&self) -> &DrawMap;
|
||||
@ -55,14 +53,10 @@ pub trait AppLike {
|
||||
where
|
||||
Self: Sized;
|
||||
|
||||
// These two are needed to render traffic signals. Splitting them from sim() allows
|
||||
// applications that don't run a traffic sim to work.
|
||||
fn sim_time(&self) -> Time {
|
||||
self.sim().time()
|
||||
}
|
||||
fn current_stage_and_remaining_time(&self, id: IntersectionID) -> (usize, Duration) {
|
||||
self.sim().current_stage_and_remaining_time(id)
|
||||
}
|
||||
// These two are needed to render traffic signals. They only make sense when there is a
|
||||
// simulation
|
||||
fn sim_time(&self) -> Time;
|
||||
fn current_stage_and_remaining_time(&self, id: IntersectionID) -> (usize, Duration);
|
||||
|
||||
/// Change the color scheme. Idempotent. Return true if there was a change.
|
||||
fn change_color_scheme(&mut self, ctx: &mut EventCtx, cs: ColorSchemeChoice) -> bool {
|
||||
|
@ -4,7 +4,6 @@ use abstio::MapName;
|
||||
use abstutil::Timer;
|
||||
use geom::{Circle, Distance, Duration, Pt2D, Time};
|
||||
use map_model::{IntersectionID, Map};
|
||||
use sim::Sim;
|
||||
use widgetry::tools::URLManager;
|
||||
use widgetry::{Canvas, EventCtx, GfxCtx, Settings, SharedAppState, State, Transition, Warper};
|
||||
|
||||
@ -274,10 +273,6 @@ impl<T: 'static> AppLike for SimpleApp<T> {
|
||||
&self.map
|
||||
}
|
||||
#[inline]
|
||||
fn sim(&self) -> &Sim {
|
||||
unreachable!()
|
||||
}
|
||||
#[inline]
|
||||
fn cs(&self) -> &ColorScheme {
|
||||
&self.cs
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ pub use self::navigate::Navigator;
|
||||
pub use self::polygon::EditPolygon;
|
||||
pub use self::title_screen::{Executable, TitleScreen};
|
||||
pub use self::trip_files::{TripManagement, TripManagementState};
|
||||
pub use self::turn_explorer::TurnExplorer;
|
||||
pub use self::ui::{
|
||||
checkbox_per_mode, cmp_count, cmp_dist, cmp_duration, color_for_mode, percentage_bar,
|
||||
FilePicker,
|
||||
@ -49,7 +48,6 @@ mod navigate;
|
||||
mod polygon;
|
||||
mod title_screen;
|
||||
mod trip_files;
|
||||
mod turn_explorer;
|
||||
mod ui;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod updater;
|
||||
|
Loading…
Reference in New Issue
Block a user