2019-06-22 22:26:52 +03:00
|
|
|
mod abtest;
|
2019-10-31 06:44:27 +03:00
|
|
|
mod challenges;
|
2020-02-03 22:14:17 +03:00
|
|
|
mod colors;
|
2019-04-29 02:29:19 +03:00
|
|
|
mod common;
|
2019-06-22 19:48:42 +03:00
|
|
|
mod debug;
|
2019-06-22 21:03:37 +03:00
|
|
|
mod edit;
|
2019-04-24 01:08:36 +03:00
|
|
|
mod game;
|
2019-04-29 19:56:01 +03:00
|
|
|
mod helpers;
|
2019-11-24 18:21:23 +03:00
|
|
|
mod managed;
|
2019-06-22 23:01:42 +03:00
|
|
|
mod mission;
|
2019-12-12 02:04:32 +03:00
|
|
|
mod obj_actions;
|
2019-12-03 21:39:16 +03:00
|
|
|
mod options;
|
2019-11-24 18:21:21 +03:00
|
|
|
mod pregame;
|
2018-08-10 23:28:34 +03:00
|
|
|
mod render;
|
2019-04-25 19:41:19 +03:00
|
|
|
mod sandbox;
|
2018-08-10 23:28:34 +03:00
|
|
|
mod ui;
|
|
|
|
|
2019-09-19 03:29:34 +03:00
|
|
|
use crate::ui::Flags;
|
|
|
|
use abstutil::CmdArgs;
|
|
|
|
use sim::SimFlags;
|
2018-03-13 18:04:21 +03:00
|
|
|
|
|
|
|
fn main() {
|
2019-09-19 03:29:34 +03:00
|
|
|
let mut args = CmdArgs::new();
|
2019-11-01 23:33:02 +03:00
|
|
|
|
|
|
|
if args.enabled("--prebake") {
|
2020-02-16 22:45:23 +03:00
|
|
|
challenges::prebake_all();
|
2019-11-01 23:33:02 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-19 03:29:34 +03:00
|
|
|
let mut flags = Flags {
|
|
|
|
sim_flags: SimFlags::from_args(&mut args),
|
|
|
|
kml: args.optional("--kml"),
|
|
|
|
draw_lane_markings: !args.enabled("--dont_draw_lane_markings"),
|
2019-09-19 20:42:16 +03:00
|
|
|
num_agents: args.optional_parse("--num_agents", |s| s.parse()),
|
2019-09-19 03:29:34 +03:00
|
|
|
};
|
2019-12-04 01:36:51 +03:00
|
|
|
let mut opts = options::Options::default();
|
|
|
|
if args.enabled("--dev") {
|
|
|
|
opts.dev = true;
|
2019-09-19 03:29:34 +03:00
|
|
|
flags.sim_flags.rng_seed = Some(42);
|
|
|
|
}
|
2020-02-16 03:44:06 +03:00
|
|
|
|
|
|
|
// No random in wasm
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
{
|
|
|
|
flags.sim_flags.rng_seed = Some(42);
|
|
|
|
}
|
|
|
|
|
2019-12-17 22:05:07 +03:00
|
|
|
if let Some(x) = args.optional("--color_scheme") {
|
|
|
|
opts.color_scheme = Some(format!("../data/system/{}", x));
|
|
|
|
}
|
2020-02-07 22:51:41 +03:00
|
|
|
let mut settings = ezgui::Settings::new("A/B Street", "../data/system/fonts");
|
2019-10-07 19:45:53 +03:00
|
|
|
if args.enabled("--enable_profiler") {
|
|
|
|
settings.enable_profiling();
|
|
|
|
}
|
2020-01-12 20:35:38 +03:00
|
|
|
if args.enabled("--dump_raw_events") {
|
|
|
|
settings.dump_raw_events();
|
|
|
|
}
|
2019-10-07 20:39:09 +03:00
|
|
|
if let Some(n) = args.optional_parse("--font_size", |s| s.parse::<usize>()) {
|
|
|
|
settings.default_font_size(n);
|
|
|
|
}
|
2019-12-27 03:53:44 +03:00
|
|
|
|
2020-02-18 03:43:37 +03:00
|
|
|
let mut mode = None;
|
2019-12-27 03:53:44 +03:00
|
|
|
if let Some(x) = args.optional("--challenge") {
|
|
|
|
let mut aliases = Vec::new();
|
2020-01-31 00:55:48 +03:00
|
|
|
'OUTER: for (_, stages) in challenges::all_challenges(true) {
|
2019-12-27 03:53:44 +03:00
|
|
|
for challenge in stages {
|
|
|
|
if challenge.alias == x {
|
2020-02-18 03:43:37 +03:00
|
|
|
flags.sim_flags.load = challenge.gameplay.map_path();
|
|
|
|
mode = Some(challenge.gameplay);
|
2019-12-27 03:53:44 +03:00
|
|
|
break 'OUTER;
|
|
|
|
} else {
|
|
|
|
aliases.push(challenge.alias);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-18 03:43:37 +03:00
|
|
|
if mode.is_none() {
|
2019-12-27 03:53:44 +03:00
|
|
|
panic!(
|
|
|
|
"Don't know --challenge={}. Choices: {}",
|
|
|
|
x,
|
|
|
|
aliases.join(", ")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-02-25 01:29:10 +03:00
|
|
|
// TODO Stage only, not part
|
2020-02-03 21:21:13 +03:00
|
|
|
if let Some(n) = args.optional_parse("--tutorial", |s| s.parse::<usize>()) {
|
2020-02-25 01:29:10 +03:00
|
|
|
mode = Some(sandbox::GameplayMode::Tutorial(
|
|
|
|
sandbox::TutorialPointer::new(n - 1, 0),
|
|
|
|
));
|
2020-02-03 21:21:13 +03:00
|
|
|
}
|
2019-12-27 03:53:44 +03:00
|
|
|
|
2019-09-19 03:29:34 +03:00
|
|
|
args.done();
|
|
|
|
|
2019-12-27 03:53:44 +03:00
|
|
|
ezgui::run(settings, |ctx| game::Game::new(flags, opts, mode, ctx));
|
2019-04-22 03:18:09 +03:00
|
|
|
}
|