mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
move dev flag into options
This commit is contained in:
parent
d47be1e175
commit
10e44dd0b8
@ -31,6 +31,7 @@ impl Clone for Box<dyn Cloneable> {
|
||||
}
|
||||
|
||||
impl Cloneable for () {}
|
||||
impl Cloneable for bool {}
|
||||
impl Cloneable for usize {}
|
||||
impl Cloneable for f64 {}
|
||||
impl Cloneable for String {}
|
||||
|
@ -57,7 +57,7 @@ impl CommonState {
|
||||
self.location_tools.event(ctx);
|
||||
|
||||
if ctx.input.new_was_pressed(lctrl(Key::S).unwrap()) {
|
||||
ui.primary.current_flags.dev = !ui.primary.current_flags.dev;
|
||||
ui.opts.dev = !ui.opts.dev;
|
||||
}
|
||||
|
||||
if self.location_tools.action("warp") {
|
||||
|
@ -17,11 +17,11 @@ pub struct Game {
|
||||
}
|
||||
|
||||
impl Game {
|
||||
pub fn new(flags: Flags, ctx: &mut EventCtx) -> Game {
|
||||
let title = !flags.dev
|
||||
pub fn new(flags: Flags, opts: Options, ctx: &mut EventCtx) -> Game {
|
||||
let title = !opts.dev
|
||||
&& !flags.sim_flags.load.contains("data/player/save")
|
||||
&& !flags.sim_flags.load.contains("data/system/scenarios");
|
||||
let mut ui = UI::new(flags, Options::default(), ctx, title);
|
||||
let mut ui = UI::new(flags, opts, ctx, title);
|
||||
let states: Vec<Box<dyn State>> = if title {
|
||||
vec![Box::new(TitleScreen::new(ctx, &ui))]
|
||||
} else {
|
||||
@ -111,7 +111,7 @@ impl GUI for Game {
|
||||
}
|
||||
state.draw(g, &self.ui);
|
||||
|
||||
if self.ui.primary.current_flags.dev {
|
||||
if self.ui.opts.dev {
|
||||
g.draw_blocking_text(
|
||||
&Text::from(Line("DEV")).bg(Color::RED),
|
||||
(HorizontalAlignment::Right, VerticalAlignment::Bottom),
|
||||
|
@ -33,9 +33,10 @@ fn main() {
|
||||
draw_lane_markings: !args.enabled("--dont_draw_lane_markings"),
|
||||
num_agents: args.optional_parse("--num_agents", |s| s.parse()),
|
||||
textures: args.enabled("--textures"),
|
||||
dev: args.enabled("--dev"),
|
||||
};
|
||||
if flags.dev {
|
||||
let mut opts = options::Options::default();
|
||||
if args.enabled("--dev") {
|
||||
opts.dev = true;
|
||||
flags.sim_flags.rng_seed = Some(42);
|
||||
}
|
||||
let mut settings = ezgui::Settings::new("A/B Street", (1800.0, 800.0));
|
||||
@ -47,5 +48,5 @@ fn main() {
|
||||
}
|
||||
args.done();
|
||||
|
||||
ezgui::run(settings, |ctx| game::Game::new(flags, ctx));
|
||||
ezgui::run(settings, |ctx| game::Game::new(flags, opts, ctx));
|
||||
}
|
||||
|
@ -2,11 +2,11 @@ use crate::game::{State, Transition, WizardState};
|
||||
use ezgui::Choice;
|
||||
|
||||
// TODO SimOptions stuff too
|
||||
// TODO Move dev mode here
|
||||
#[derive(Clone)]
|
||||
pub struct Options {
|
||||
pub traffic_signal_style: TrafficSignalStyle,
|
||||
pub color_scheme: String,
|
||||
pub dev: bool,
|
||||
}
|
||||
|
||||
impl Options {
|
||||
@ -14,6 +14,7 @@ impl Options {
|
||||
Options {
|
||||
traffic_signal_style: TrafficSignalStyle::GroupArrows,
|
||||
color_scheme: "../data/system/color_scheme.json".to_string(),
|
||||
dev: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -54,6 +55,9 @@ pub fn open_panel() -> Box<dyn State> {
|
||||
Choice::new("night mode", "../data/system/night_colors.json".to_string()),
|
||||
]
|
||||
})?;
|
||||
let (_, dev) = wizard.choose("Enable developer mode?", || {
|
||||
vec![Choice::new("yes", true), Choice::new("no", false)]
|
||||
})?;
|
||||
|
||||
if ui.opts.color_scheme != color_scheme {
|
||||
wizard.acknowledge("Changing color scheme", || {
|
||||
@ -65,6 +69,8 @@ pub fn open_panel() -> Box<dyn State> {
|
||||
})?;
|
||||
}
|
||||
|
||||
ui.opts.dev = dev;
|
||||
|
||||
if ui.opts.traffic_signal_style != traffic_signal_style {
|
||||
ui.opts.traffic_signal_style = traffic_signal_style;
|
||||
println!("Rerendering traffic signals...");
|
||||
|
@ -127,7 +127,7 @@ pub fn main_menu(ctx: &EventCtx, ui: &UI) -> Box<dyn State> {
|
||||
),
|
||||
],
|
||||
));
|
||||
if ui.primary.current_flags.dev {
|
||||
if ui.opts.dev {
|
||||
col.push(ManagedWidget::Row(
|
||||
LayoutStyle::Centered,
|
||||
vec![
|
||||
|
@ -41,7 +41,7 @@ pub struct SandboxMode {
|
||||
impl SandboxMode {
|
||||
pub fn new(ctx: &mut EventCtx, ui: &mut UI, mode: GameplayMode) -> SandboxMode {
|
||||
SandboxMode {
|
||||
speed: speed::SpeedControls::new(ctx, ui.primary.current_flags.dev),
|
||||
speed: speed::SpeedControls::new(ctx, ui.opts.dev),
|
||||
general_tools: MenuUnderButton::new(
|
||||
"assets/ui/hamburger.png",
|
||||
"General",
|
||||
|
@ -485,7 +485,6 @@ pub struct Flags {
|
||||
// included.
|
||||
pub num_agents: Option<usize>,
|
||||
pub textures: bool,
|
||||
pub dev: bool,
|
||||
}
|
||||
|
||||
// All of the state that's bound to a specific map+edit has to live here.
|
||||
|
Loading…
Reference in New Issue
Block a user