mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-03 12:03:30 +03:00
make it easy to dump raw events for debugging on windows/mac [rebuild]
This commit is contained in:
parent
de1c481c93
commit
ec1e3f435b
@ -182,6 +182,7 @@ pub struct Settings {
|
||||
profiling_enabled: bool,
|
||||
default_font_size: usize,
|
||||
override_hidpi_factor: Option<f64>,
|
||||
dump_raw_events: bool,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
@ -191,6 +192,7 @@ impl Settings {
|
||||
profiling_enabled: false,
|
||||
default_font_size: 30,
|
||||
override_hidpi_factor: None,
|
||||
dump_raw_events: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,6 +201,11 @@ impl Settings {
|
||||
self.profiling_enabled = true;
|
||||
}
|
||||
|
||||
pub fn dump_raw_events(&mut self) {
|
||||
assert!(!self.dump_raw_events);
|
||||
self.dump_raw_events = true;
|
||||
}
|
||||
|
||||
pub fn default_font_size(&mut self, size: usize) {
|
||||
self.default_font_size = size;
|
||||
}
|
||||
@ -309,6 +316,7 @@ pub fn run<G: GUI, F: FnOnce(&mut EventCtx) -> G>(settings: Settings, make_gui:
|
||||
program,
|
||||
prerender,
|
||||
settings.profiling_enabled,
|
||||
settings.dump_raw_events,
|
||||
);
|
||||
}
|
||||
|
||||
@ -318,6 +326,7 @@ fn loop_forever<G: GUI>(
|
||||
program: glium::Program,
|
||||
prerender: Prerender,
|
||||
profiling_enabled: bool,
|
||||
dump_raw_events: bool,
|
||||
) {
|
||||
if profiling_enabled {
|
||||
#[cfg(feature = "profiler")]
|
||||
@ -348,6 +357,9 @@ fn loop_forever<G: GUI>(
|
||||
state.gui.before_quit(&state.canvas);
|
||||
process::exit(0);
|
||||
}
|
||||
if dump_raw_events {
|
||||
println!("Event: {:?}", event);
|
||||
}
|
||||
if let Some(ev) = Event::from_glutin_event(event, state.canvas.hidpi_factor) {
|
||||
new_events.push(ev);
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ fn main() {
|
||||
if args.enabled("--enable_profiler") {
|
||||
settings.enable_profiling();
|
||||
}
|
||||
if args.enabled("--dump_raw_events") {
|
||||
settings.dump_raw_events();
|
||||
}
|
||||
if let Some(n) = args.optional_parse("--font_size", |s| s.parse::<usize>()) {
|
||||
settings.default_font_size(n);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user