mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 12:12:00 +03:00
toggle dev mode at runtime
This commit is contained in:
parent
a8aa8f526d
commit
e1496acf70
@ -77,7 +77,8 @@ One-time setup:
|
||||
traces and run more slowly. You can do `cargo run --release` to build in
|
||||
optimized release mode; compilation will be slower, but the executable much
|
||||
faster.
|
||||
- To add some extra debug modes to the game, `cargo run -- --dev`
|
||||
- To add some extra debug modes to the game, `cargo run -- --dev` or press
|
||||
Control+S to toggle in-game
|
||||
- All code is automatically formatted using
|
||||
https://github.com/rust-lang/rustfmt; please run `cargo fmt` before sending a
|
||||
PR.
|
||||
|
@ -176,7 +176,7 @@ impl UserInput {
|
||||
false
|
||||
}
|
||||
|
||||
pub(crate) fn new_was_pressed(&mut self, multikey: MultiKey) -> bool {
|
||||
pub fn new_was_pressed(&mut self, multikey: MultiKey) -> bool {
|
||||
if self.context_menu_active() {
|
||||
return false;
|
||||
}
|
||||
|
@ -80,6 +80,11 @@ impl Text {
|
||||
txt
|
||||
}
|
||||
|
||||
pub fn bg(mut self, color: Color) -> Text {
|
||||
self.bg_color = Some(color);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn no_bg(mut self) -> Text {
|
||||
self.bg_color = None;
|
||||
self
|
||||
|
@ -27,7 +27,7 @@ use crate::helpers::ID;
|
||||
use crate::render::DrawOptions;
|
||||
use crate::ui::UI;
|
||||
use ezgui::{
|
||||
hotkey, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, MenuUnderButton, Text,
|
||||
hotkey, lctrl, Color, EventCtx, GfxCtx, HorizontalAlignment, Key, Line, MenuUnderButton, Text,
|
||||
VerticalAlignment,
|
||||
};
|
||||
use std::collections::BTreeSet;
|
||||
@ -58,6 +58,10 @@ impl CommonState {
|
||||
pub fn event(&mut self, ctx: &mut EventCtx, ui: &mut UI) -> Option<Transition> {
|
||||
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;
|
||||
}
|
||||
|
||||
if self.location_tools.action("warp") {
|
||||
return Some(Transition::Push(warp::EnteringWarp::new()));
|
||||
}
|
||||
|
@ -2,7 +2,10 @@ use crate::pregame::{main_menu, TitleScreen};
|
||||
use crate::render::DrawOptions;
|
||||
use crate::sandbox::{GameplayMode, SandboxMode};
|
||||
use crate::ui::{Flags, ShowEverything, UI};
|
||||
use ezgui::{Canvas, EventCtx, EventLoopMode, GfxCtx, Wizard, GUI};
|
||||
use ezgui::{
|
||||
Canvas, Color, EventCtx, EventLoopMode, GfxCtx, HorizontalAlignment, Line, Text,
|
||||
VerticalAlignment, Wizard, GUI,
|
||||
};
|
||||
|
||||
// This is the top-level of the GUI logic. This module should just manage interactions between the
|
||||
// top-level game states.
|
||||
@ -107,6 +110,13 @@ impl GUI for Game {
|
||||
}
|
||||
state.draw(g, &self.ui);
|
||||
|
||||
if self.ui.primary.current_flags.dev {
|
||||
g.draw_blocking_text(
|
||||
&Text::from(Line("DEV")).bg(Color::RED),
|
||||
(HorizontalAlignment::Right, VerticalAlignment::Bottom),
|
||||
);
|
||||
}
|
||||
|
||||
/*println!(
|
||||
"{} uploads, {} draw calls",
|
||||
g.get_num_uploads(),
|
||||
|
Loading…
Reference in New Issue
Block a user