mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 02:33:54 +03:00
Add a checkbox for mixing in background traffic to the actdev scenarios. No effect on the scenario yet... #539
This commit is contained in:
parent
6cacaf1c8a
commit
0ee22ad58e
@ -105,7 +105,11 @@ pub fn main() {
|
||||
// Parking data in the actdev maps is nonexistent, so many people have convoluted walking
|
||||
// routes just to fetch their car. Just disable parking entirely.
|
||||
flags.sim_flags.opts.infinite_parking = true;
|
||||
mode = Some(sandbox::GameplayMode::Actdev(name, "base".to_string()));
|
||||
mode = Some(sandbox::GameplayMode::Actdev(
|
||||
name,
|
||||
"base".to_string(),
|
||||
false,
|
||||
));
|
||||
}
|
||||
|
||||
args.done();
|
||||
@ -277,7 +281,7 @@ fn finish_app_setup(
|
||||
let states: Vec<Box<dyn State<App>>> = if title {
|
||||
vec![Box::new(TitleScreen::new(ctx, app))]
|
||||
} else if let Some(mode) = maybe_mode {
|
||||
if let GameplayMode::Actdev(_, _) = mode {
|
||||
if let GameplayMode::Actdev(_, _, _) = mode {
|
||||
vec![SandboxMode::async_new(
|
||||
app,
|
||||
mode,
|
||||
|
@ -5,7 +5,7 @@ use map_gui::tools::{grey_out_map, nice_map_name, open_browser, PopupMsg};
|
||||
use sim::{AgentType, PersonID, TripID};
|
||||
use widgetry::{
|
||||
lctrl, ControlState, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, Outcome, Panel,
|
||||
SimpleState, Text, TextExt, VerticalAlignment, Widget,
|
||||
SimpleState, Text, TextExt, Toggle, VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -20,14 +20,20 @@ use crate::sandbox::{Actions, SandboxControls, SandboxMode, SpeedSetting};
|
||||
pub struct Actdev {
|
||||
top_center: Panel,
|
||||
scenario_name: String,
|
||||
bg_traffic: bool,
|
||||
once: bool,
|
||||
}
|
||||
|
||||
impl Actdev {
|
||||
pub fn new(ctx: &mut EventCtx, scenario_name: String) -> Box<dyn GameplayState> {
|
||||
pub fn new(
|
||||
ctx: &mut EventCtx,
|
||||
scenario_name: String,
|
||||
bg_traffic: bool,
|
||||
) -> Box<dyn GameplayState> {
|
||||
Box::new(Actdev {
|
||||
top_center: Panel::empty(ctx),
|
||||
scenario_name,
|
||||
bg_traffic,
|
||||
once: true,
|
||||
})
|
||||
}
|
||||
@ -63,6 +69,7 @@ impl GameplayState for Actdev {
|
||||
GameplayMode::Actdev(
|
||||
app.primary.map.get_name().clone(),
|
||||
scenario.to_string(),
|
||||
self.bg_traffic,
|
||||
),
|
||||
jump_to_time_upon_startup(Duration::hours(8)),
|
||||
)));
|
||||
@ -73,6 +80,7 @@ impl GameplayState for Actdev {
|
||||
GameplayMode::Actdev(
|
||||
app.primary.map.get_name().clone(),
|
||||
self.scenario_name.clone(),
|
||||
self.bg_traffic,
|
||||
),
|
||||
))),
|
||||
"about A/B Street" => {
|
||||
@ -133,6 +141,18 @@ impl GameplayState for Actdev {
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
Outcome::Changed => {
|
||||
// Background traffic was toggled
|
||||
return Some(Transition::Replace(SandboxMode::async_new(
|
||||
app,
|
||||
GameplayMode::Actdev(
|
||||
app.primary.map.get_name().clone(),
|
||||
self.scenario_name.clone(),
|
||||
!self.bg_traffic,
|
||||
),
|
||||
jump_to_time_upon_startup(Duration::hours(8)),
|
||||
)));
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -192,6 +212,8 @@ impl GameplayState for Actdev {
|
||||
.btn_plain
|
||||
.icon_text("system/assets/meters/bike.svg", "Cycling activity")
|
||||
.build_def(ctx),
|
||||
// TODO Layout pending.
|
||||
Toggle::checkbox(ctx, "background traffic", None, self.bg_traffic),
|
||||
]),
|
||||
]);
|
||||
|
||||
|
@ -38,8 +38,8 @@ pub enum GameplayMode {
|
||||
PlayScenario(MapName, String, Vec<ScenarioModifier>),
|
||||
FixTrafficSignals,
|
||||
OptimizeCommute(OrigPersonID, Duration),
|
||||
// Map name, scenario name
|
||||
Actdev(MapName, String),
|
||||
// Map name, scenario name, background traffic
|
||||
Actdev(MapName, String, bool),
|
||||
|
||||
// current
|
||||
Tutorial(TutorialPointer),
|
||||
@ -104,7 +104,7 @@ impl GameplayMode {
|
||||
GameplayMode::FixTrafficSignals => MapName::seattle("downtown"),
|
||||
GameplayMode::OptimizeCommute(_, _) => MapName::seattle("montlake"),
|
||||
GameplayMode::Tutorial(_) => MapName::seattle("montlake"),
|
||||
GameplayMode::Actdev(ref name, _) => name.clone(),
|
||||
GameplayMode::Actdev(ref name, _, _) => name.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,8 @@ impl GameplayMode {
|
||||
None => LoadScenario::Nothing,
|
||||
};
|
||||
}
|
||||
GameplayMode::Actdev(_, ref scenario) => scenario.to_string(),
|
||||
// TODO We'll need to load two files... and cache both?
|
||||
GameplayMode::Actdev(_, ref scenario, _) => scenario.to_string(),
|
||||
GameplayMode::FixTrafficSignals | GameplayMode::OptimizeCommute(_, _) => {
|
||||
"weekday".to_string()
|
||||
}
|
||||
@ -220,7 +221,9 @@ impl GameplayMode {
|
||||
commute::OptimizeCommute::new(ctx, app, *p, *goal)
|
||||
}
|
||||
GameplayMode::Tutorial(current) => Tutorial::make_gameplay(ctx, app, *current),
|
||||
GameplayMode::Actdev(_, ref scenario) => actdev::Actdev::new(ctx, scenario.clone()),
|
||||
GameplayMode::Actdev(_, ref scenario, bg_traffic) => {
|
||||
actdev::Actdev::new(ctx, scenario.clone(), *bg_traffic)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user