Move game/helpers into game/common. And fix github rustdoc workflow

This commit is contained in:
Dustin Carlino 2020-11-23 23:39:55 -08:00
parent 5e952f9012
commit 16b561a408
49 changed files with 207 additions and 229 deletions

View File

@ -37,7 +37,7 @@ jobs:
run: | run: |
cargo doc --no-deps --workspace --exclude widgetry --document-private-items cargo doc --no-deps --workspace --exclude widgetry --document-private-items
cd widgetry cd widgetry
cargo doc --no-deps --document-private-items cargo doc --no-deps --document-private-items --features native-backend
cd .. cd ..
mv target/doc book/book/rustdoc mv target/doc book/book/rustdoc

View File

@ -9,6 +9,7 @@ use geom::{Bounds, Circle, Distance, Duration, Pt2D, Time};
use map_gui::colors::ColorScheme; use map_gui::colors::ColorScheme;
use map_gui::options::Options; use map_gui::options::Options;
use map_gui::render::{unzoomed_agent_radius, AgentCache, DrawMap, DrawOptions, Renderable}; use map_gui::render::{unzoomed_agent_radius, AgentCache, DrawMap, DrawOptions, Renderable};
use map_gui::ID;
use map_model::{IntersectionID, Map, Traversable}; use map_model::{IntersectionID, Map, Traversable};
use sim::{AgentID, Analytics, Scenario, Sim, SimCallback, SimFlags}; use sim::{AgentID, Analytics, Scenario, Sim, SimCallback, SimFlags};
use widgetry::{Canvas, EventCtx, GfxCtx, Prerender, SharedAppState, State}; use widgetry::{Canvas, EventCtx, GfxCtx, Prerender, SharedAppState, State};
@ -16,7 +17,6 @@ use widgetry::{Canvas, EventCtx, GfxCtx, Prerender, SharedAppState, State};
use crate::challenges::HighScore; use crate::challenges::HighScore;
use crate::common::Warping; use crate::common::Warping;
use crate::edit::apply_map_edits; use crate::edit::apply_map_edits;
use crate::helpers::ID;
use crate::layer::Layer; use crate::layer::Layer;
use crate::sandbox::{GameplayMode, TutorialState}; use crate::sandbox::{GameplayMode, TutorialState};

View File

@ -1,19 +1,19 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use geom::Polygon; use geom::{Duration, Polygon};
pub use map_gui::tools::{ColorDiscrete, ColorLegend, ColorNetwork, DivergingScale}; use map_gui::ID;
use map_model::{IntersectionID, Map, RoadID};
use sim::{AgentType, TripMode, TripPhaseType};
use widgetry::{ use widgetry::{
lctrl, Btn, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Panel, lctrl, Btn, Checkbox, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
ScreenDims, ScreenPt, ScreenRectangle, Text, VerticalAlignment, Widget, Panel, ScreenDims, ScreenPt, ScreenRectangle, Text, TextSpan, VerticalAlignment, Widget,
}; };
pub use self::minimap::Minimap; pub use self::minimap::Minimap;
pub use self::warp::Warping; pub use self::warp::Warping;
use crate::app::App; use crate::app::App;
use crate::app::Transition; use crate::app::Transition;
use crate::helpers::{list_names, ID}; use crate::info::{ContextualActions, InfoPanel, Tab};
use crate::info::InfoPanel;
pub use crate::info::{ContextualActions, Tab};
mod minimap; mod minimap;
mod warp; mod warp;
@ -296,3 +296,117 @@ pub fn tool_panel(ctx: &mut EventCtx) -> Panel {
.aligned(HorizontalAlignment::Left, VerticalAlignment::BottomAboveOSD) .aligned(HorizontalAlignment::Left, VerticalAlignment::BottomAboveOSD)
.build(ctx) .build(ctx)
} }
pub fn list_names<F: Fn(TextSpan) -> TextSpan>(txt: &mut Text, styler: F, names: BTreeSet<String>) {
let len = names.len();
for (idx, n) in names.into_iter().enumerate() {
if idx != 0 {
if idx == len - 1 {
if len == 2 {
txt.append(Line(" and "));
} else {
txt.append(Line(", and "));
}
} else {
txt.append(Line(", "));
}
}
txt.append(styler(Line(n)));
}
}
// Shorter is better
pub fn cmp_duration_shorter(app: &App, after: Duration, before: Duration) -> Vec<TextSpan> {
if after.epsilon_eq(before) {
vec![Line("same")]
} else if after < before {
vec![
Line((before - after).to_string(&app.opts.units)).fg(Color::GREEN),
Line(" faster"),
]
} else if after > before {
vec![
Line((after - before).to_string(&app.opts.units)).fg(Color::RED),
Line(" slower"),
]
} else {
unreachable!()
}
}
pub fn color_for_mode(app: &App, m: TripMode) -> Color {
match m {
TripMode::Walk => app.cs.unzoomed_pedestrian,
TripMode::Bike => app.cs.unzoomed_bike,
TripMode::Transit => app.cs.unzoomed_bus,
TripMode::Drive => app.cs.unzoomed_car,
}
}
pub fn color_for_agent_type(app: &App, a: AgentType) -> Color {
match a {
AgentType::Pedestrian => app.cs.unzoomed_pedestrian,
AgentType::Bike => app.cs.unzoomed_bike,
AgentType::Bus | AgentType::Train => app.cs.unzoomed_bus,
AgentType::TransitRider => app.cs.bus_trip,
AgentType::Car => app.cs.unzoomed_car,
}
}
pub fn color_for_trip_phase(app: &App, tpt: TripPhaseType) -> Color {
match tpt {
TripPhaseType::Driving => app.cs.unzoomed_car,
TripPhaseType::Walking => app.cs.unzoomed_pedestrian,
TripPhaseType::Biking => app.cs.bike_trip,
TripPhaseType::Parking => app.cs.parking_trip,
TripPhaseType::WaitingForBus(_, _) => app.cs.bus_layer,
TripPhaseType::RidingBus(_, _, _) => app.cs.bus_trip,
TripPhaseType::Cancelled | TripPhaseType::Finished => unreachable!(),
TripPhaseType::DelayedStart => Color::YELLOW,
}
}
// TODO Well, there goes the nice consolidation of stuff in BtnBuilder. :\
pub fn hotkey_btn<I: Into<String>>(ctx: &EventCtx, app: &App, label: I, key: Key) -> Widget {
let label = label.into();
let mut txt = Text::new();
txt.append(key.txt(ctx));
txt.append(Line(format!(" - {}", label)));
Btn::text_bg(label, txt, app.cs.section_bg, app.cs.hovering).build_def(ctx, key)
}
pub fn intersections_from_roads(roads: &BTreeSet<RoadID>, map: &Map) -> BTreeSet<IntersectionID> {
let mut results = BTreeSet::new();
for r in roads {
let r = map.get_r(*r);
for i in vec![r.src_i, r.dst_i] {
if results.contains(&i) {
continue;
}
if map.get_i(i).roads.iter().all(|r| roads.contains(r)) {
results.insert(i);
}
}
}
results
}
pub fn checkbox_per_mode(
ctx: &mut EventCtx,
app: &App,
current_state: &BTreeSet<TripMode>,
) -> Widget {
let mut filters = Vec::new();
for m in TripMode::all() {
filters.push(
Checkbox::colored(
ctx,
m.ongoing_verb(),
color_for_mode(app, m),
current_state.contains(&m),
)
.margin_right(24),
);
}
Widget::custom_row(filters)
}

View File

@ -1,7 +1,8 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use geom::Pt2D; use geom::Pt2D;
use map_gui::tools::PopupMsg; use map_gui::tools::{grey_out_map, PopupMsg};
use map_gui::ID;
use map_model::{AreaID, BuildingID, BusRouteID, IntersectionID, LaneID, ParkingLotID, RoadID}; use map_model::{AreaID, BuildingID, BusRouteID, IntersectionID, LaneID, ParkingLotID, RoadID};
use sim::{PedestrianID, PersonID, TripID}; use sim::{PedestrianID, PersonID, TripID};
use widgetry::{ use widgetry::{
@ -9,9 +10,7 @@ use widgetry::{
}; };
use crate::app::{App, PerMap, Transition}; use crate::app::{App, PerMap, Transition};
use crate::common::Tab; use crate::info::{OpenTrip, Tab};
use crate::helpers::{grey_out_map, ID};
use crate::info::OpenTrip;
use crate::sandbox::SandboxMode; use crate::sandbox::SandboxMode;
const WARP_TO_CAM_ZOOM: f64 = 10.0; const WARP_TO_CAM_ZOOM: f64 = 10.0;

View File

@ -1,3 +1,4 @@
use map_gui::tools::grey_out_map;
use widgetry::{ use widgetry::{
hotkeys, Btn, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, hotkeys, Btn, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel,
RewriteColor, State, Text, Widget, RewriteColor, State, Text, Widget,
@ -5,7 +6,6 @@ use widgetry::{
use crate::app::App; use crate::app::App;
use crate::app::Transition; use crate::app::Transition;
use crate::helpers::grey_out_map;
pub struct CutsceneBuilder { pub struct CutsceneBuilder {
name: String, name: String,

View File

@ -1,5 +1,6 @@
use std::collections::HashSet; use std::collections::HashSet;
use map_gui::tools::ColorDiscrete;
use map_model::{connectivity, LaneID, Map, PathConstraints}; use map_model::{connectivity, LaneID, Map, PathConstraints};
use widgetry::{ use widgetry::{
Btn, Choice, Color, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Line, Outcome, Panel, Btn, Choice, Color, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Line, Outcome, Panel,
@ -8,7 +9,6 @@ use widgetry::{
use crate::app::App; use crate::app::App;
use crate::app::Transition; use crate::app::Transition;
use crate::common::ColorDiscrete;
pub struct Floodfiller { pub struct Floodfiller {
panel: Panel, panel: Panel,

View File

@ -6,6 +6,7 @@ use map_gui::load::MapLoader;
use map_gui::options::OptionsPanel; use map_gui::options::OptionsPanel;
use map_gui::render::{calculate_corners, DrawOptions}; use map_gui::render::{calculate_corners, DrawOptions};
use map_gui::tools::{ChooseSomething, PopupMsg, PromptInput}; use map_gui::tools::{ChooseSomething, PopupMsg, PromptInput};
use map_gui::ID;
use map_model::{osm, ControlTrafficSignal, NORMAL_LANE_THICKNESS}; use map_model::{osm, ControlTrafficSignal, NORMAL_LANE_THICKNESS};
use sim::{AgentID, Sim}; use sim::{AgentID, Sim};
use widgetry::{ use widgetry::{
@ -15,8 +16,8 @@ use widgetry::{
}; };
use crate::app::{App, ShowLayers, ShowObject, Transition}; use crate::app::{App, ShowLayers, ShowObject, Transition};
use crate::common::{tool_panel, CommonState, ContextualActions}; use crate::common::{tool_panel, CommonState};
use crate::helpers::ID; use crate::info::ContextualActions;
use crate::sandbox::GameplayMode; use crate::sandbox::GameplayMode;
mod blocked_by; mod blocked_by;

View File

@ -1,9 +1,9 @@
use map_gui::ID;
use map_model::{Map, PathConstraints}; use map_model::{Map, PathConstraints};
use sim::{AgentID, Sim}; use sim::{AgentID, Sim};
use widgetry::{GfxCtx, Key, Line, Text}; use widgetry::{GfxCtx, Key, Line, Text};
use crate::app::App; use crate::app::App;
use crate::helpers::ID;
pub struct ObjectDebugger; pub struct ObjectDebugger;

View File

@ -1,4 +1,6 @@
use abstutil::Counter; use abstutil::Counter;
use map_gui::tools::{ColorLegend, ColorNetwork};
use map_gui::ID;
use map_model::{IntersectionID, PathStep, RoadID, Traversable}; use map_model::{IntersectionID, PathStep, RoadID, Traversable};
use widgetry::{ use widgetry::{
Btn, Color, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Line, Outcome, Panel, State, Text, Btn, Color, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Line, Outcome, Panel, State, Text,
@ -7,8 +9,7 @@ use widgetry::{
use crate::app::App; use crate::app::App;
use crate::app::Transition; use crate::app::Transition;
use crate::common::{ColorLegend, ColorNetwork, CommonState}; use crate::common::CommonState;
use crate::helpers::ID;
/// A state to count the number of trips that will cross different roads. /// A state to count the number of trips that will cross different roads.
pub struct PathCounter { pub struct PathCounter {

View File

@ -1,15 +1,14 @@
use abstutil::{prettyprint_usize, Counter}; use abstutil::{prettyprint_usize, Counter};
use collisions::{CollisionDataset, Severity}; use collisions::{CollisionDataset, Severity};
use geom::{Circle, Distance, Duration, FindClosest, Polygon, Time}; use geom::{Circle, Distance, Duration, FindClosest, Polygon, Time};
use map_gui::tools::ColorNetwork;
use map_gui::ID;
use widgetry::{ use widgetry::{
Btn, Checkbox, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Btn, Checkbox, Choice, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line,
Outcome, Panel, Slider, State, Text, TextExt, VerticalAlignment, Widget, Outcome, Panel, Slider, State, Text, TextExt, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition;
use crate::common::ColorNetwork;
use crate::helpers::ID;
pub struct CollisionsViewer { pub struct CollisionsViewer {
data: CollisionDataset, data: CollisionDataset,

View File

@ -1,5 +1,6 @@
use abstutil::Counter; use abstutil::Counter;
use map_gui::tools::{make_heatmap, HeatmapOptions}; use map_gui::tools::{amenity_type, make_heatmap, HeatmapOptions};
use map_gui::ID;
use map_model::BuildingID; use map_model::BuildingID;
use sim::{Scenario, TripEndpoint}; use sim::{Scenario, TripEndpoint};
use widgetry::{ use widgetry::{
@ -7,9 +8,7 @@ use widgetry::{
Outcome, Panel, State, Text, VerticalAlignment, Widget, Outcome, Panel, State, Text, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition;
use crate::helpers::{amenity_type, ID};
pub struct PopularDestinations { pub struct PopularDestinations {
per_bldg: Counter<BuildingID>, per_bldg: Counter<BuildingID>,

View File

@ -3,14 +3,13 @@
use abstutil::Timer; use abstutil::Timer;
use geom::{LonLat, Percent}; use geom::{LonLat, Percent};
use map_gui::tools::{ChooseSomething, CityPicker}; use map_gui::tools::{nice_map_name, ChooseSomething, CityPicker};
use widgetry::{ use widgetry::{
lctrl, Btn, Choice, DrawBaselayer, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, lctrl, Btn, Choice, DrawBaselayer, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome,
Panel, State, TextExt, VerticalAlignment, Widget, Panel, State, TextExt, VerticalAlignment, Widget,
}; };
use crate::app::{App, Transition}; use crate::app::{App, Transition};
use crate::helpers::nice_map_name;
mod collisions; mod collisions;
mod destinations; mod destinations;

View File

@ -1,13 +1,13 @@
use abstutil::prettyprint_usize; use abstutil::prettyprint_usize;
use map_gui::tools::ColorDiscrete;
use sim::Scenario; use sim::Scenario;
use widgetry::{ use widgetry::{
Btn, Color, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State, Btn, Color, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State,
Text, VerticalAlignment, Widget, Text, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition; use crate::common::CommonState;
use crate::common::{ColorDiscrete, CommonState};
use crate::devtools::destinations::PopularDestinations; use crate::devtools::destinations::PopularDestinations;
pub struct ScenarioManager { pub struct ScenarioManager {

View File

@ -1,4 +1,5 @@
use map_gui::render::Renderable; use map_gui::render::Renderable;
use map_gui::ID;
use map_model::{EditCmd, LaneID, LaneType, Map}; use map_model::{EditCmd, LaneID, LaneType, Map};
use widgetry::{ use widgetry::{
Btn, Choice, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State, Btn, Choice, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, State,
@ -12,7 +13,6 @@ use crate::edit::zones::ZoneEditor;
use crate::edit::{ use crate::edit::{
apply_map_edits, can_edit_lane, maybe_edit_intersection, speed_limit_choices, try_change_lt, apply_map_edits, can_edit_lane, maybe_edit_intersection, speed_limit_choices, try_change_lt,
}; };
use crate::helpers::ID;
use crate::sandbox::GameplayMode; use crate::sandbox::GameplayMode;
pub struct LaneEditor { pub struct LaneEditor {

View File

@ -6,7 +6,8 @@ use abstutil::{prettyprint_usize, Timer};
use geom::Speed; use geom::Speed;
use map_gui::options::OptionsPanel; use map_gui::options::OptionsPanel;
use map_gui::render::DrawMap; use map_gui::render::DrawMap;
use map_gui::tools::{ChooseSomething, PopupMsg}; use map_gui::tools::{grey_out_map, ChooseSomething, ColorLegend, PopupMsg};
use map_gui::ID;
use map_model::{EditCmd, IntersectionID, LaneID, LaneType, MapEdits}; use map_model::{EditCmd, IntersectionID, LaneID, LaneType, MapEdits};
use widgetry::{ use widgetry::{
lctrl, Btn, Choice, Color, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Menu, lctrl, Btn, Choice, Color, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Menu,
@ -20,9 +21,8 @@ pub use self::stop_signs::StopSignEditor;
pub use self::traffic_signals::TrafficSignalEditor; pub use self::traffic_signals::TrafficSignalEditor;
pub use self::validate::{check_blackholes, check_sidewalk_connectivity, try_change_lt}; pub use self::validate::{check_blackholes, check_sidewalk_connectivity, try_change_lt};
use crate::app::{App, Transition}; use crate::app::{App, Transition};
use crate::common::{tool_panel, ColorLegend, CommonState, Warping}; use crate::common::{tool_panel, CommonState, Warping};
use crate::debug::DebugMode; use crate::debug::DebugMode;
use crate::helpers::{grey_out_map, ID};
use crate::sandbox::{GameplayMode, SandboxMode, TimeWarpScreen}; use crate::sandbox::{GameplayMode, SandboxMode, TimeWarpScreen};
mod bulk; mod bulk;

View File

@ -1,11 +1,11 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use map_gui::ID;
use map_model::{IntersectionID, RoadID}; use map_model::{IntersectionID, RoadID};
use widgetry::{Btn, Color, Drawable, EventCtx, GeomBatch, GfxCtx, Key, RewriteColor, Widget}; use widgetry::{Btn, Color, Drawable, EventCtx, GeomBatch, GfxCtx, Key, RewriteColor, Widget};
use crate::app::App; use crate::app::App;
use crate::common::CommonState; use crate::common::{intersections_from_roads, CommonState};
use crate::helpers::{intersections_from_roads, ID};
pub struct RoadSelector { pub struct RoadSelector {
pub roads: BTreeSet<RoadID>, pub roads: BTreeSet<RoadID>,

View File

@ -3,6 +3,7 @@ use std::collections::BTreeSet;
use maplit::btreeset; use maplit::btreeset;
use geom::{Distance, Duration}; use geom::{Distance, Duration};
use map_gui::ID;
use map_model::IntersectionID; use map_model::IntersectionID;
use sim::Scenario; use sim::Scenario;
use widgetry::{ use widgetry::{
@ -10,11 +11,9 @@ use widgetry::{
RewriteColor, Spinner, State, Text, TextExt, VerticalAlignment, Widget, RewriteColor, Spinner, State, Text, TextExt, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition;
use crate::common::CommonState; use crate::common::CommonState;
use crate::edit::traffic_signals::fade_irrelevant; use crate::edit::traffic_signals::fade_irrelevant;
use crate::helpers::ID;
pub struct ShowAbsolute { pub struct ShowAbsolute {
members: BTreeSet<IntersectionID>, members: BTreeSet<IntersectionID>,

View File

@ -1,5 +1,6 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use map_gui::ID;
use map_model::IntersectionID; use map_model::IntersectionID;
use widgetry::{ use widgetry::{
hotkeys, Btn, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome, hotkeys, Btn, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome,
@ -10,7 +11,6 @@ use crate::app::App;
use crate::app::Transition; use crate::app::Transition;
use crate::common::CommonState; use crate::common::CommonState;
use crate::edit::TrafficSignalEditor; use crate::edit::TrafficSignalEditor;
use crate::helpers::ID;
use crate::sandbox::gameplay::GameplayMode; use crate::sandbox::gameplay::GameplayMode;
pub struct SignalPicker { pub struct SignalPicker {

View File

@ -1,12 +1,11 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use abstutil::Timer; use abstutil::Timer;
use map_gui::tools::PopupMsg; use map_gui::tools::{ColorDiscrete, PopupMsg};
use map_model::{connectivity, EditCmd, LaneID, LaneType, Map, PathConstraints}; use map_model::{connectivity, EditCmd, LaneID, LaneType, Map, PathConstraints};
use widgetry::{Color, EventCtx, State}; use widgetry::{Color, EventCtx, State};
use crate::app::App; use crate::app::App;
use crate::common::ColorDiscrete;
// All of these take a candidate EditCmd to do, then see if it's valid. If they return None, it's // All of these take a candidate EditCmd to do, then see if it's valid. If they return None, it's
// fine. They always leave the map in the original state without the new EditCmd. // fine. They always leave the map in the original state without the new EditCmd.

View File

@ -3,6 +3,7 @@ use std::collections::BTreeSet;
use enumset::EnumSet; use enumset::EnumSet;
use maplit::btreeset; use maplit::btreeset;
use map_gui::tools::ColorDiscrete;
use map_model::{AccessRestrictions, PathConstraints, RoadID}; use map_model::{AccessRestrictions, PathConstraints, RoadID};
use sim::TripMode; use sim::TripMode;
use widgetry::{ use widgetry::{
@ -10,13 +11,10 @@ use widgetry::{
Spinner, State, Text, TextExt, VerticalAlignment, Widget, Spinner, State, Text, TextExt, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition; use crate::common::{checkbox_per_mode, intersections_from_roads, CommonState};
use crate::common::ColorDiscrete;
use crate::common::CommonState;
use crate::edit::apply_map_edits; use crate::edit::apply_map_edits;
use crate::edit::select::RoadSelector; use crate::edit::select::RoadSelector;
use crate::helpers::{checkbox_per_mode, intersections_from_roads};
pub struct ZoneEditor { pub struct ZoneEditor {
panel: Panel, panel: Panel,

View File

@ -1,124 +0,0 @@
use std::collections::BTreeSet;
use geom::Duration;
pub use map_gui::tools::{amenity_type, grey_out_map, nice_map_name, open_browser};
pub use map_gui::ID;
use map_model::{IntersectionID, Map, RoadID};
use sim::{AgentType, TripMode, TripPhaseType};
use widgetry::{Btn, Checkbox, Color, EventCtx, Key, Line, Text, TextSpan, Widget};
use crate::app::App;
pub fn list_names<F: Fn(TextSpan) -> TextSpan>(txt: &mut Text, styler: F, names: BTreeSet<String>) {
let len = names.len();
for (idx, n) in names.into_iter().enumerate() {
if idx != 0 {
if idx == len - 1 {
if len == 2 {
txt.append(Line(" and "));
} else {
txt.append(Line(", and "));
}
} else {
txt.append(Line(", "));
}
}
txt.append(styler(Line(n)));
}
}
// Shorter is better
pub fn cmp_duration_shorter(app: &App, after: Duration, before: Duration) -> Vec<TextSpan> {
if after.epsilon_eq(before) {
vec![Line("same")]
} else if after < before {
vec![
Line((before - after).to_string(&app.opts.units)).fg(Color::GREEN),
Line(" faster"),
]
} else if after > before {
vec![
Line((after - before).to_string(&app.opts.units)).fg(Color::RED),
Line(" slower"),
]
} else {
unreachable!()
}
}
pub fn color_for_mode(app: &App, m: TripMode) -> Color {
match m {
TripMode::Walk => app.cs.unzoomed_pedestrian,
TripMode::Bike => app.cs.unzoomed_bike,
TripMode::Transit => app.cs.unzoomed_bus,
TripMode::Drive => app.cs.unzoomed_car,
}
}
pub fn color_for_agent_type(app: &App, a: AgentType) -> Color {
match a {
AgentType::Pedestrian => app.cs.unzoomed_pedestrian,
AgentType::Bike => app.cs.unzoomed_bike,
AgentType::Bus | AgentType::Train => app.cs.unzoomed_bus,
AgentType::TransitRider => app.cs.bus_trip,
AgentType::Car => app.cs.unzoomed_car,
}
}
pub fn color_for_trip_phase(app: &App, tpt: TripPhaseType) -> Color {
match tpt {
TripPhaseType::Driving => app.cs.unzoomed_car,
TripPhaseType::Walking => app.cs.unzoomed_pedestrian,
TripPhaseType::Biking => app.cs.bike_trip,
TripPhaseType::Parking => app.cs.parking_trip,
TripPhaseType::WaitingForBus(_, _) => app.cs.bus_layer,
TripPhaseType::RidingBus(_, _, _) => app.cs.bus_trip,
TripPhaseType::Cancelled | TripPhaseType::Finished => unreachable!(),
TripPhaseType::DelayedStart => Color::YELLOW,
}
}
// TODO Well, there goes the nice consolidation of stuff in BtnBuilder. :\
pub fn hotkey_btn<I: Into<String>>(ctx: &EventCtx, app: &App, label: I, key: Key) -> Widget {
let label = label.into();
let mut txt = Text::new();
txt.append(key.txt(ctx));
txt.append(Line(format!(" - {}", label)));
Btn::text_bg(label, txt, app.cs.section_bg, app.cs.hovering).build_def(ctx, key)
}
pub fn intersections_from_roads(roads: &BTreeSet<RoadID>, map: &Map) -> BTreeSet<IntersectionID> {
let mut results = BTreeSet::new();
for r in roads {
let r = map.get_r(*r);
for i in vec![r.src_i, r.dst_i] {
if results.contains(&i) {
continue;
}
if map.get_i(i).roads.iter().all(|r| roads.contains(r)) {
results.insert(i);
}
}
}
results
}
pub fn checkbox_per_mode(
ctx: &mut EventCtx,
app: &App,
current_state: &BTreeSet<TripMode>,
) -> Widget {
let mut filters = Vec::new();
for m in TripMode::all() {
filters.push(
Checkbox::colored(
ctx,
m.ongoing_verb(),
color_for_mode(app, m),
current_state.contains(&m),
)
.margin_right(24),
);
}
Widget::custom_row(filters)
}

View File

@ -1,12 +1,12 @@
use abstutil::{prettyprint_usize, Counter}; use abstutil::{prettyprint_usize, Counter};
use geom::{Circle, Distance, Time}; use geom::{Circle, Distance, Time};
use map_gui::tools::ColorNetwork;
use map_gui::ID;
use map_model::{BusRoute, BusRouteID, BusStopID, PathStep}; use map_model::{BusRoute, BusRouteID, BusStopID, PathStep};
use sim::{AgentID, CarID}; use sim::{AgentID, CarID};
use widgetry::{Btn, Color, EventCtx, Key, Line, RewriteColor, Text, TextExt, Widget}; use widgetry::{Btn, Color, EventCtx, Key, Line, RewriteColor, Text, TextExt, Widget};
use crate::app::App; use crate::app::App;
use crate::common::ColorNetwork;
use crate::helpers::ID;
use crate::info::{header_btns, make_tabs, Details, Tab}; use crate::info::{header_btns, make_tabs, Details, Tab};
pub fn stop(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusStopID) -> Vec<Widget> { pub fn stop(ctx: &mut EventCtx, app: &App, details: &mut Details, id: BusStopID) -> Vec<Widget> {

View File

@ -12,7 +12,7 @@ use widgetry::{
}; };
use crate::app::App; use crate::app::App;
use crate::helpers::color_for_agent_type; use crate::common::color_for_agent_type;
use crate::info::{header_btns, make_tabs, throughput, DataOptions, Details, Tab}; use crate::info::{header_btns, make_tabs, throughput, DataOptions, Details, Tab};
pub fn info(ctx: &EventCtx, app: &App, details: &mut Details, id: IntersectionID) -> Vec<Widget> { pub fn info(ctx: &EventCtx, app: &App, details: &mut Details, id: IntersectionID) -> Vec<Widget> {

View File

@ -3,6 +3,8 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
pub use trip::OpenTrip; pub use trip::OpenTrip;
use geom::{Circle, Distance, Time}; use geom::{Circle, Distance, Time};
use map_gui::tools::open_browser;
use map_gui::ID;
use map_model::{AreaID, BuildingID, BusRouteID, BusStopID, IntersectionID, LaneID, ParkingLotID}; use map_model::{AreaID, BuildingID, BusRouteID, BusStopID, IntersectionID, LaneID, ParkingLotID};
use sim::{ use sim::{
AgentID, AgentType, Analytics, CarID, ParkingSpot, PedestrianID, PersonID, PersonState, TripID, AgentID, AgentType, Analytics, CarID, ParkingSpot, PedestrianID, PersonID, PersonState, TripID,
@ -13,12 +15,10 @@ use widgetry::{
LinePlot, Outcome, Panel, PlotOptions, Series, TextExt, VerticalAlignment, Widget, LinePlot, Outcome, Panel, PlotOptions, Series, TextExt, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition; use crate::common::{color_for_agent_type, hotkey_btn, Warping};
use crate::common::Warping;
use crate::debug::path_counter::PathCounter; use crate::debug::path_counter::PathCounter;
use crate::edit::{EditMode, RouteEditor}; use crate::edit::{EditMode, RouteEditor};
use crate::helpers::{color_for_agent_type, hotkey_btn, open_browser, ID};
use crate::sandbox::{dashboards, GameplayMode, SandboxMode, TimeWarpScreen}; use crate::sandbox::{dashboards, GameplayMode, SandboxMode, TimeWarpScreen};
mod building; mod building;

View File

@ -3,6 +3,7 @@ use std::collections::BTreeMap;
use maplit::btreemap; use maplit::btreemap;
use geom::{Distance, Duration, Percent, Polygon, Pt2D, Time}; use geom::{Distance, Duration, Percent, Polygon, Pt2D, Time};
use map_gui::ID;
use map_model::{Map, Path, PathStep}; use map_model::{Map, Path, PathStep};
use sim::{AgentID, PersonID, TripEndpoint, TripID, TripPhase, TripPhaseType}; use sim::{AgentID, PersonID, TripEndpoint, TripID, TripPhase, TripPhaseType};
use widgetry::{ use widgetry::{
@ -11,7 +12,7 @@ use widgetry::{
}; };
use crate::app::App; use crate::app::App;
use crate::helpers::{color_for_trip_phase, ID}; use crate::common::color_for_trip_phase;
use crate::info::{make_table, Details, Tab}; use crate::info::{make_table, Details, Tab};
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,11 +1,11 @@
use geom::{ArrowCap, Distance, PolyLine}; use geom::{ArrowCap, Distance, PolyLine};
use map_gui::tools::{ColorLegend, ColorNetwork};
use widgetry::{ use widgetry::{
Btn, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Panel, Text, Btn, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Line, Panel, Text,
TextExt, VerticalAlignment, Widget, TextExt, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::App;
use crate::common::{ColorLegend, ColorNetwork};
use crate::layer::{Layer, LayerOutcome}; use crate::layer::{Layer, LayerOutcome};
pub struct Elevation { pub struct Elevation {

View File

@ -1,5 +1,7 @@
use abstutil::{prettyprint_usize, Counter}; use abstutil::{prettyprint_usize, Counter};
use geom::{Distance, Time}; use geom::{Distance, Time};
use map_gui::tools::{amenity_type, ColorDiscrete, ColorLegend, ColorNetwork};
use map_gui::ID;
use map_model::{LaneType, PathConstraints}; use map_model::{LaneType, PathConstraints};
use sim::AgentType; use sim::AgentType;
use widgetry::{ use widgetry::{
@ -8,8 +10,6 @@ use widgetry::{
}; };
use crate::app::App; use crate::app::App;
use crate::common::{ColorDiscrete, ColorLegend, ColorNetwork};
use crate::helpers::{amenity_type, ID};
use crate::layer::{Layer, LayerOutcome}; use crate::layer::{Layer, LayerOutcome};
pub struct BikeNetwork { pub struct BikeNetwork {

View File

@ -1,11 +1,10 @@
use map_gui::tools::HeatmapOptions; use map_gui::tools::{grey_out_map, HeatmapOptions};
use widgetry::{ use widgetry::{
Btn, DrawBaselayer, EventCtx, GfxCtx, Key, Line, Outcome, Panel, State, TextExt, Widget, Btn, DrawBaselayer, EventCtx, GfxCtx, Key, Line, Outcome, Panel, State, TextExt, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition; use crate::common::hotkey_btn;
use crate::helpers::{grey_out_map, hotkey_btn};
use crate::sandbox::dashboards; use crate::sandbox::dashboards;
mod elevation; mod elevation;

View File

@ -3,6 +3,7 @@ use std::collections::BTreeSet;
use abstutil::{prettyprint_usize, Counter, Parallelism}; use abstutil::{prettyprint_usize, Counter, Parallelism};
use geom::{Circle, Distance, Duration, Pt2D, Time}; use geom::{Circle, Distance, Duration, Pt2D, Time};
use map_gui::render::unzoomed_agent_radius; use map_gui::render::unzoomed_agent_radius;
use map_gui::tools::{ColorLegend, ColorNetwork};
use map_model::{ use map_model::{
BuildingID, Map, OffstreetParking, ParkingLotID, PathConstraints, PathRequest, RoadID, BuildingID, Map, OffstreetParking, ParkingLotID, PathConstraints, PathRequest, RoadID,
}; };
@ -13,7 +14,6 @@ use widgetry::{
}; };
use crate::app::App; use crate::app::App;
use crate::common::{ColorLegend, ColorNetwork};
use crate::layer::{Layer, LayerOutcome}; use crate::layer::{Layer, LayerOutcome};
pub struct Occupancy { pub struct Occupancy {

View File

@ -5,6 +5,8 @@ use maplit::btreeset;
use abstutil::{prettyprint_usize, Counter}; use abstutil::{prettyprint_usize, Counter};
use geom::{Circle, Distance, Duration, Polygon, Pt2D, Time}; use geom::{Circle, Distance, Duration, Polygon, Pt2D, Time};
use map_gui::render::unzoomed_agent_radius; use map_gui::render::unzoomed_agent_radius;
use map_gui::tools::{ColorLegend, ColorNetwork, DivergingScale};
use map_gui::ID;
use map_model::{IntersectionID, Map, Traversable}; use map_model::{IntersectionID, Map, Traversable};
use sim::VehicleType; use sim::VehicleType;
use widgetry::{ use widgetry::{
@ -13,8 +15,6 @@ use widgetry::{
}; };
use crate::app::App; use crate::app::App;
use crate::common::{ColorLegend, ColorNetwork, DivergingScale};
use crate::helpers::ID;
use crate::layer::{Layer, LayerOutcome}; use crate::layer::{Layer, LayerOutcome};
pub struct Backpressure { pub struct Backpressure {

View File

@ -1,3 +1,4 @@
use map_gui::tools::ColorDiscrete;
use map_model::{PathConstraints, PathStep}; use map_model::{PathConstraints, PathStep};
use widgetry::{ use widgetry::{
Btn, Checkbox, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Outcome, Panel, TextExt, Btn, Checkbox, Drawable, EventCtx, GfxCtx, HorizontalAlignment, Outcome, Panel, TextExt,
@ -5,7 +6,6 @@ use widgetry::{
}; };
use crate::app::App; use crate::app::App;
use crate::common::ColorDiscrete;
use crate::layer::{Layer, LayerOutcome}; use crate::layer::{Layer, LayerOutcome};
pub struct TransitNetwork { pub struct TransitNetwork {

View File

@ -17,7 +17,6 @@ mod cutscene;
mod debug; mod debug;
mod devtools; mod devtools;
mod edit; mod edit;
mod helpers;
mod info; mod info;
mod layer; mod layer;
mod pregame; mod pregame;

View File

@ -7,7 +7,7 @@ use rand_xorshift::XorShiftRng;
use abstutil::Timer; use abstutil::Timer;
use geom::{Duration, Line, Percent, Pt2D, Speed}; use geom::{Duration, Line, Percent, Pt2D, Speed};
use map_gui::load::MapLoader; use map_gui::load::MapLoader;
use map_gui::tools::PopupMsg; use map_gui::tools::{open_browser, PopupMsg};
use map_model::PermanentMapEdits; use map_model::PermanentMapEdits;
use sim::{AlertHandler, ScenarioGenerator, Sim, SimOptions}; use sim::{AlertHandler, ScenarioGenerator, Sim, SimOptions};
use widgetry::{ use widgetry::{
@ -19,7 +19,6 @@ use crate::app::{App, Transition};
use crate::challenges::ChallengesPicker; use crate::challenges::ChallengesPicker;
use crate::devtools::DevToolsMode; use crate::devtools::DevToolsMode;
use crate::edit::apply_map_edits; use crate::edit::apply_map_edits;
use crate::helpers::open_browser;
use crate::sandbox::gameplay::Tutorial; use crate::sandbox::gameplay::Tutorial;
use crate::sandbox::{GameplayMode, SandboxMode}; use crate::sandbox::{GameplayMode, SandboxMode};

View File

@ -4,6 +4,7 @@ use maplit::hashset;
use abstutil::{prettyprint_usize, Counter, MultiMap}; use abstutil::{prettyprint_usize, Counter, MultiMap};
use geom::{Distance, PolyLine, Polygon, Time}; use geom::{Distance, PolyLine, Polygon, Time};
use map_gui::tools::ColorLegend;
use map_model::{osm, BuildingID, BuildingType, IntersectionID, LaneID, Map, RoadID, TurnType}; use map_model::{osm, BuildingID, BuildingType, IntersectionID, LaneID, Map, RoadID, TurnType};
use sim::{TripEndpoint, TripInfo, TripMode}; use sim::{TripEndpoint, TripInfo, TripMode};
use widgetry::{ use widgetry::{
@ -11,10 +12,8 @@ use widgetry::{
Outcome, Panel, RewriteColor, Slider, State, Text, TextExt, VerticalAlignment, Widget, Outcome, Panel, RewriteColor, Slider, State, Text, TextExt, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition; use crate::common::{checkbox_per_mode, CommonState};
use crate::common::{ColorLegend, CommonState};
use crate::helpers::checkbox_per_mode;
pub struct CommuterPatterns { pub struct CommuterPatterns {
bldg_to_block: HashMap<BuildingID, BlockID>, bldg_to_block: HashMap<BuildingID, BlockID>,

View File

@ -5,9 +5,8 @@ use widgetry::{
State, State,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition; use crate::common::color_for_trip_phase;
use crate::helpers::color_for_trip_phase;
use crate::info::{OpenTrip, Tab}; use crate::info::{OpenTrip, Tab};
use crate::sandbox::dashboards::table::Table; use crate::sandbox::dashboards::table::Table;
use crate::sandbox::dashboards::trip_table; use crate::sandbox::dashboards::trip_table;

View File

@ -6,9 +6,8 @@ use widgetry::{
PlotOptions, Series, State, TextExt, Widget, PlotOptions, Series, State, TextExt, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition; use crate::info::Tab;
use crate::common::Tab;
use crate::sandbox::dashboards::DashTab; use crate::sandbox::dashboards::DashTab;
use crate::sandbox::SandboxMode; use crate::sandbox::SandboxMode;

View File

@ -12,7 +12,7 @@ use widgetry::{
}; };
use crate::app::{App, Transition}; use crate::app::{App, Transition};
use crate::helpers::color_for_mode; use crate::common::color_for_mode;
use crate::sandbox::dashboards::DashTab; use crate::sandbox::dashboards::DashTab;
pub struct TripSummaries { pub struct TripSummaries {

View File

@ -3,6 +3,7 @@ use std::collections::HashMap;
use abstutil::{prettyprint_usize, Counter, Parallelism, Timer}; use abstutil::{prettyprint_usize, Counter, Parallelism, Timer};
use geom::{ArrowCap, Distance, Duration, Polygon, Time}; use geom::{ArrowCap, Distance, Duration, Polygon, Time};
use map_gui::render::DrawOptions; use map_gui::render::DrawOptions;
use map_gui::ID;
use map_model::{ControlTrafficSignal, IntersectionID, MovementID, PathStep, TurnType}; use map_model::{ControlTrafficSignal, IntersectionID, MovementID, PathStep, TurnType};
use sim::TripEndpoint; use sim::TripEndpoint;
use widgetry::{ use widgetry::{
@ -10,10 +11,8 @@ use widgetry::{
Line, Outcome, Panel, Spinner, State, Text, TextExt, VerticalAlignment, Widget, Line, Outcome, Panel, Spinner, State, Text, TextExt, VerticalAlignment, Widget,
}; };
use crate::app::Transition; use crate::app::{App, ShowEverything, Transition};
use crate::app::{App, ShowEverything};
use crate::common::CommonState; use crate::common::CommonState;
use crate::helpers::ID;
pub struct TrafficSignalDemand { pub struct TrafficSignalDemand {
panel: Panel, panel: Panel,

View File

@ -6,7 +6,7 @@ use sim::{TripEndpoint, TripID, TripMode};
use widgetry::{Btn, Checkbox, EventCtx, Filler, Line, Panel, State, Text, Widget}; use widgetry::{Btn, Checkbox, EventCtx, Filler, Line, Panel, State, Text, Widget};
use crate::app::App; use crate::app::App;
use crate::helpers::{checkbox_per_mode, cmp_duration_shorter, color_for_mode}; use crate::common::{checkbox_per_mode, cmp_duration_shorter, color_for_mode};
use crate::sandbox::dashboards::generic_trip_table::GenericTripTable; use crate::sandbox::dashboards::generic_trip_table::GenericTripTable;
use crate::sandbox::dashboards::table::{Col, Filter, Table}; use crate::sandbox::dashboards::table::{Col, Filter, Table};
use crate::sandbox::dashboards::DashTab; use crate::sandbox::dashboards::DashTab;

View File

@ -10,10 +10,10 @@ use widgetry::{
use crate::app::App; use crate::app::App;
use crate::app::Transition; use crate::app::Transition;
use crate::challenges::{Challenge, HighScore}; use crate::challenges::{Challenge, HighScore};
use crate::common::Tab; use crate::common::cmp_duration_shorter;
use crate::cutscene::{CutsceneBuilder, FYI}; use crate::cutscene::{CutsceneBuilder, FYI};
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::helpers::cmp_duration_shorter; use crate::info::Tab;
use crate::sandbox::gameplay::{challenge_header, FinalScore, GameplayMode, GameplayState}; use crate::sandbox::gameplay::{challenge_header, FinalScore, GameplayMode, GameplayState};
use crate::sandbox::{Actions, SandboxControls}; use crate::sandbox::{Actions, SandboxControls};

View File

@ -1,4 +1,5 @@
use geom::{Duration, Time}; use geom::{Duration, Time};
use map_gui::ID;
use map_model::IntersectionID; use map_model::IntersectionID;
use widgetry::{ use widgetry::{
Btn, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, RewriteColor, Btn, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, RewriteColor,
@ -11,7 +12,6 @@ use crate::challenges::HighScore;
use crate::common::Warping; use crate::common::Warping;
use crate::cutscene::{CutsceneBuilder, FYI}; use crate::cutscene::{CutsceneBuilder, FYI};
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::helpers::ID;
use crate::sandbox::gameplay::{challenge_header, FinalScore, GameplayMode, GameplayState}; use crate::sandbox::gameplay::{challenge_header, FinalScore, GameplayMode, GameplayState};
use crate::sandbox::{Actions, SandboxControls, SandboxMode}; use crate::sandbox::{Actions, SandboxControls, SandboxMode};

View File

@ -3,7 +3,8 @@ use rand::Rng;
use abstutil::Timer; use abstutil::Timer;
use geom::{Distance, Polygon}; use geom::{Distance, Polygon};
use map_gui::tools::{ChooseSomething, CityPicker, PopupMsg, PromptInput}; use map_gui::tools::{nice_map_name, ChooseSomething, CityPicker, PopupMsg, PromptInput};
use map_gui::ID;
use map_model::{BuildingID, IntersectionID, Position, NORMAL_LANE_THICKNESS}; use map_model::{BuildingID, IntersectionID, Position, NORMAL_LANE_THICKNESS};
use sim::{IndividTrip, PersonSpec, Scenario, TripEndpoint, TripMode, TripPurpose}; use sim::{IndividTrip, PersonSpec, Scenario, TripEndpoint, TripMode, TripPurpose};
use widgetry::{ use widgetry::{
@ -14,7 +15,6 @@ use widgetry::{
use crate::app::{App, Transition}; use crate::app::{App, Transition};
use crate::common::CommonState; use crate::common::CommonState;
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::helpers::{nice_map_name, ID};
use crate::sandbox::gameplay::{GameplayMode, GameplayState}; use crate::sandbox::gameplay::{GameplayMode, GameplayState};
use crate::sandbox::{Actions, SandboxControls, SandboxMode}; use crate::sandbox::{Actions, SandboxControls, SandboxMode};

View File

@ -2,7 +2,7 @@ use std::collections::BTreeSet;
use maplit::btreeset; use maplit::btreeset;
use map_gui::tools::{ChooseSomething, CityPicker, PopupMsg}; use map_gui::tools::{grey_out_map, nice_map_name, ChooseSomething, CityPicker, PopupMsg};
use sim::{ScenarioModifier, TripMode}; use sim::{ScenarioModifier, TripMode};
use widgetry::{ use widgetry::{
lctrl, Btn, Choice, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel, lctrl, Btn, Choice, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel,
@ -10,8 +10,8 @@ use widgetry::{
}; };
use crate::app::{App, Transition}; use crate::app::{App, Transition};
use crate::common::checkbox_per_mode;
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::helpers::{checkbox_per_mode, grey_out_map, nice_map_name};
use crate::sandbox::gameplay::freeform::make_change_traffic; use crate::sandbox::gameplay::freeform::make_change_traffic;
use crate::sandbox::gameplay::{GameplayMode, GameplayState}; use crate::sandbox::gameplay::{GameplayMode, GameplayState};
use crate::sandbox::{Actions, SandboxControls, SandboxMode}; use crate::sandbox::{Actions, SandboxControls, SandboxMode};

View File

@ -2,7 +2,8 @@ use std::collections::BTreeSet;
use abstutil::Timer; use abstutil::Timer;
use geom::{ArrowCap, Distance, Duration, PolyLine, Pt2D, Time}; use geom::{ArrowCap, Distance, Duration, PolyLine, Pt2D, Time};
use map_gui::tools::PopupMsg; use map_gui::tools::{grey_out_map, PopupMsg};
use map_gui::ID;
use map_model::raw::OriginalRoad; use map_model::raw::OriginalRoad;
use map_model::{osm, BuildingID, Map, Position}; use map_model::{osm, BuildingID, Map, Position};
use sim::{ use sim::{
@ -18,7 +19,6 @@ use crate::app::{App, Transition};
use crate::common::{tool_panel, Minimap, Warping}; use crate::common::{tool_panel, Minimap, Warping};
use crate::cutscene::CutsceneBuilder; use crate::cutscene::CutsceneBuilder;
use crate::edit::EditMode; use crate::edit::EditMode;
use crate::helpers::{grey_out_map, ID};
use crate::sandbox::gameplay::{GameplayMode, GameplayState}; use crate::sandbox::gameplay::{GameplayMode, GameplayState};
use crate::sandbox::{ use crate::sandbox::{
maybe_exit_sandbox, spawn_agents_around, Actions, AgentMeter, SandboxControls, SandboxMode, maybe_exit_sandbox, spawn_agents_around, Actions, AgentMeter, SandboxControls, SandboxMode,

View File

@ -1,6 +1,7 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use geom::{Distance, Time}; use geom::{Distance, Time};
use map_gui::ID;
use map_model::IntersectionID; use map_model::IntersectionID;
use sim::AgentID; use sim::AgentID;
use widgetry::{ use widgetry::{
@ -8,10 +9,8 @@ use widgetry::{
Panel, State, VerticalAlignment, Widget, Panel, State, VerticalAlignment, Widget,
}; };
use crate::app::App; use crate::app::{App, Transition};
use crate::app::Transition;
use crate::common::CommonState; use crate::common::CommonState;
use crate::helpers::ID;
/// Draws a preview of the path for the agent under the mouse cursor. /// Draws a preview of the path for the agent under the mouse cursor.
pub struct RoutePreview { pub struct RoutePreview {

View File

@ -8,6 +8,7 @@ use geom::{Circle, Distance, Pt2D, Time};
use map_gui::load::{FileLoader, MapLoader}; use map_gui::load::{FileLoader, MapLoader};
use map_gui::tools::{ChooseSomething, PopupMsg, TurnExplorer}; use map_gui::tools::{ChooseSomething, PopupMsg, TurnExplorer};
use map_gui::AppLike; use map_gui::AppLike;
use map_gui::ID;
use sim::{Analytics, Scenario}; use sim::{Analytics, Scenario};
use widgetry::{ use widgetry::{
lctrl, Btn, Choice, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, lctrl, Btn, Choice, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line,
@ -16,12 +17,12 @@ use widgetry::{
use self::misc_tools::{RoutePreview, TrafficRecorder}; use self::misc_tools::{RoutePreview, TrafficRecorder};
use crate::app::{App, Transition}; use crate::app::{App, Transition};
use crate::common::{tool_panel, CommonState, ContextualActions, Minimap}; use crate::common::{tool_panel, CommonState, Minimap};
use crate::debug::DebugMode; use crate::debug::DebugMode;
use crate::edit::{ use crate::edit::{
can_edit_lane, EditMode, LaneEditor, SaveEdits, StopSignEditor, TrafficSignalEditor, can_edit_lane, EditMode, LaneEditor, SaveEdits, StopSignEditor, TrafficSignalEditor,
}; };
use crate::helpers::ID; use crate::info::ContextualActions;
use crate::layer::PickLayer; use crate::layer::PickLayer;
use crate::pregame::MainMenu; use crate::pregame::MainMenu;
use map_gui::colors::ColorSchemeChoice; use map_gui::colors::ColorSchemeChoice;

View File

@ -1,5 +1,6 @@
use geom::{Duration, Polygon, Time}; use geom::{Duration, Polygon, Time};
use map_gui::tools::PopupMsg; use map_gui::tools::PopupMsg;
use map_gui::ID;
use sim::AlertLocation; use sim::AlertLocation;
use widgetry::{ use widgetry::{
Btn, Choice, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Btn, Choice, Color, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome,
@ -8,7 +9,6 @@ use widgetry::{
use crate::app::{App, Transition}; use crate::app::{App, Transition};
use crate::common::Warping; use crate::common::Warping;
use crate::helpers::ID;
use crate::sandbox::time_warp::JumpToTime; use crate::sandbox::time_warp::JumpToTime;
use crate::sandbox::{GameplayMode, SandboxMode, TimeWarpScreen}; use crate::sandbox::{GameplayMode, SandboxMode, TimeWarpScreen};

View File

@ -3,7 +3,8 @@ use instant::Instant;
use abstutil::prettyprint_usize; use abstutil::prettyprint_usize;
use geom::{Duration, Polygon, Pt2D, Ring, Time}; use geom::{Duration, Polygon, Pt2D, Ring, Time};
use map_gui::render::DrawOptions; use map_gui::render::DrawOptions;
use map_gui::tools::PopupMsg; use map_gui::tools::{grey_out_map, PopupMsg};
use map_gui::ID;
use widgetry::{ use widgetry::{
Btn, Checkbox, Choice, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Btn, Checkbox, Choice, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome,
Panel, Slider, State, Text, UpdateType, Widget, Panel, Slider, State, Text, UpdateType, Widget,
@ -11,7 +12,6 @@ use widgetry::{
use crate::app::{App, FindDelayedIntersections, ShowEverything, Transition}; use crate::app::{App, FindDelayedIntersections, ShowEverything, Transition};
use crate::common::Warping; use crate::common::Warping;
use crate::helpers::{grey_out_map, ID};
use crate::sandbox::{GameplayMode, SandboxMode}; use crate::sandbox::{GameplayMode, SandboxMode};
// TODO Text entry would be great // TODO Text entry would be great

View File

@ -3,6 +3,7 @@ use std::collections::BTreeSet;
use geom::ArrowCap; use geom::ArrowCap;
use map_gui::render::{DrawOptions, BIG_ARROW_THICKNESS}; use map_gui::render::{DrawOptions, BIG_ARROW_THICKNESS};
use map_gui::tools::PopupMsg; use map_gui::tools::PopupMsg;
use map_gui::ID;
use map_model::{IntersectionCluster, IntersectionID, PathConstraints}; use map_model::{IntersectionCluster, IntersectionID, PathConstraints};
use widgetry::{ use widgetry::{
Btn, Checkbox, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx, Btn, Checkbox, Color, DrawBaselayer, Drawable, EventCtx, GeomBatch, GfxCtx,
@ -13,7 +14,6 @@ use widgetry::{
use crate::app::{App, ShowEverything, Transition}; use crate::app::{App, ShowEverything, Transition};
use crate::common::CommonState; use crate::common::CommonState;
use crate::edit::ClusterTrafficSignalEditor; use crate::edit::ClusterTrafficSignalEditor;
use crate::helpers::ID;
pub struct UberTurnPicker { pub struct UberTurnPicker {
members: BTreeSet<IntersectionID>, members: BTreeSet<IntersectionID>,