abstreet/game/src/main.rs

86 lines
2.3 KiB
Rust
Raw Normal View History

2019-06-22 22:26:52 +03:00
mod abtest;
mod challenges;
2020-02-03 22:14:17 +03:00
mod colors;
mod common;
2019-06-22 19:48:42 +03:00
mod debug;
2019-06-22 21:03:37 +03:00
mod edit;
mod game;
mod helpers;
mod managed;
2019-06-22 23:01:42 +03:00
mod mission;
mod obj_actions;
mod options;
mod pregame;
mod render;
mod sandbox;
mod ui;
2019-09-19 03:29:34 +03:00
use crate::ui::Flags;
use abstutil::CmdArgs;
use sim::SimFlags;
fn main() {
2019-09-19 03:29:34 +03:00
let mut args = CmdArgs::new();
// TODO Lift this out of the game crate entirely.
if args.enabled("--prebake") {
challenges::prebake();
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);
}
if let Some(x) = args.optional("--color_scheme") {
opts.color_scheme = Some(format!("../data/system/{}", x));
}
let mut settings = ezgui::Settings::new("A/B Street", "../data/system/fonts");
if args.enabled("--enable_profiler") {
settings.enable_profiling();
}
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);
}
let mut mode = sandbox::GameplayMode::Freeform;
if let Some(x) = args.optional("--challenge") {
let mut aliases = Vec::new();
'OUTER: for (_, stages) in challenges::all_challenges(true) {
for challenge in stages {
if challenge.alias == x {
mode = challenge.gameplay;
flags.sim_flags.load = challenge.map_path;
break 'OUTER;
} else {
aliases.push(challenge.alias);
}
}
}
if mode == sandbox::GameplayMode::Freeform {
panic!(
"Don't know --challenge={}. Choices: {}",
x,
aliases.join(", ")
);
}
}
if let Some(n) = args.optional_parse("--tutorial", |s| s.parse::<usize>()) {
mode = sandbox::GameplayMode::Tutorial(n - 1);
}
2019-09-19 03:29:34 +03:00
args.done();
ezgui::run(settings, |ctx| game::Game::new(flags, opts, mode, ctx));
}