@@ -17,9 +17,9 @@ use map_model::{Map, MapEdits};
1717use sim:: Sim ;
1818use synthpop:: Scenario ;
1919use widgetry:: tools:: { FutureLoader , PopupMsg , URLManager } ;
20- use widgetry:: { EventCtx , Settings , State , Transition } ;
20+ use widgetry:: { EventCtx , GfxCtx , Settings , State } ;
2121
22- use crate :: app:: { App , Flags , PerMap } ;
22+ use crate :: app:: { App , Flags , PerMap , Transition } ;
2323use crate :: common:: jump_to_time_upon_startup;
2424use crate :: id:: ID ;
2525use crate :: pregame:: TitleScreen ;
@@ -111,6 +111,12 @@ struct Args {
111111 /// Start on a particular tutorial stage
112112 #[ structopt( long) ]
113113 tutorial : Option < usize > ,
114+ /// Start with a specific layer enabled. Example: steep_streets
115+ #[ structopt( long) ]
116+ layer : Option < String > ,
117+ /// Start with a specific info panel open. Example: b42 for building 42
118+ #[ structopt( long) ]
119+ info : Option < String > ,
114120 /// Start in ActDev mode for a particular site name.
115121 #[ structopt( long) ]
116122 actdev : Option < String > ,
@@ -131,6 +137,8 @@ struct Setup {
131137 start_time : Option < Duration > ,
132138 diff_map : Option < String > ,
133139 mode : Mode ,
140+ start_with_layer : Option < String > ,
141+ start_with_info_panel : Option < String > ,
134142}
135143
136144// TODO Switch to explicit enum subcommands, each of which includes precisely the set of common
@@ -175,6 +183,8 @@ fn run(mut settings: Settings) {
175183 center_camera : args. cam ,
176184 start_time : args. start_time ,
177185 diff_map : args. diff_map ,
186+ start_with_layer : args. layer ,
187+ start_with_info_panel : args. info ,
178188 mode : if args. tutorial_intro {
179189 Mode :: TutorialIntro
180190 } else if args. challenges {
@@ -513,6 +523,35 @@ fn finish_app_setup(
513523 return vec ! [ TitleScreen :: new_state( ctx, app) ] ;
514524 }
515525
526+ // Handle layer parameter before creating the state
527+ if let Some ( layer_name) = setup. start_with_layer {
528+ match layer_name. as_str ( ) {
529+ "steep_streets" => {
530+ app. primary . layer = Some ( Box :: new ( layer:: elevation:: SteepStreets :: new ( ctx, app) ) ) ;
531+ }
532+ "elevation" => {
533+ app. primary . layer = Some ( Box :: new ( layer:: elevation:: ElevationContours :: new ( ctx, app) ) ) ;
534+ }
535+ "map_edits" => {
536+ app. primary . layer = Some ( Box :: new ( layer:: map:: Static :: edits ( ctx, app) ) ) ;
537+ }
538+ "no_sidewalks" => {
539+ app. primary . layer = Some ( Box :: new ( layer:: map:: Static :: no_sidewalks ( ctx, app) ) ) ;
540+ }
541+ "parking_occupancy" => {
542+ // Parking occupancy layer - skipping for now as it needs more parameters
543+ warn ! ( "parking_occupancy layer not implemented in URL parameters yet" ) ;
544+ }
545+ "transit_network" => {
546+ // Transit network layer - showing all routes, buses, and trains by default
547+ app. primary . layer = Some ( Box :: new ( layer:: transit:: TransitNetwork :: new ( ctx, app, true , true , true ) ) ) ;
548+ }
549+ _ => {
550+ warn ! ( "Unknown layer: {}" , layer_name) ;
551+ }
552+ }
553+ }
554+
516555 let state = if let Some ( ss) = savestate {
517556 app. primary . sim = ss;
518557 SandboxMode :: start_from_savestate ( app)
@@ -581,7 +620,33 @@ fn finish_app_setup(
581620 }
582621 }
583622 } ;
584- vec ! [ TitleScreen :: new_state( ctx, app) , state]
623+
624+ let mut states = vec ! [ TitleScreen :: new_state( ctx, app) , state] ;
625+
626+ // Handle info panel parameter - needs to be done after the state is created
627+ if let Some ( info_id) = setup. start_with_info_panel {
628+ states. push ( Box :: new ( InitialInfoPanel { info_id } ) ) ;
629+ }
630+
631+ states
632+ }
633+
634+ struct InitialInfoPanel {
635+ info_id : String ,
636+ }
637+
638+ impl State < App > for InitialInfoPanel {
639+ fn event ( & mut self , ctx : & mut EventCtx , app : & mut App ) -> Transition {
640+ match crate :: common:: inner_warp_to_id ( ctx, app, & self . info_id ) {
641+ Some ( t) => t,
642+ None => {
643+ warn ! ( "Invalid info ID: {}" , self . info_id) ;
644+ Transition :: Pop
645+ }
646+ }
647+ }
648+
649+ fn draw ( & self , _: & mut GfxCtx , _: & App ) { }
585650}
586651
587652#[ cfg( target_arch = "wasm32" ) ]
0 commit comments