Debug mode config toggle

This commit is contained in:
dawnDus 2022-04-19 18:50:04 -04:00
parent 0c97d554ae
commit b626472f10
No known key found for this signature in database
GPG Key ID: 972AABDE81848F21
3 changed files with 12 additions and 2 deletions

View File

@ -256,7 +256,6 @@ impl BackendEventLoop for SDL2EventLoop {
Event::KeyDown { scancode: Some(scancode), repeat, keymod, .. } => {
if let Some(drs_scan) = conv_scancode(scancode) {
if !repeat {
#[cfg(debug_assertions)]
state.process_debug_keys(drs_scan);
if keymod.intersects(keyboard::Mod::RALTMOD | keyboard::Mod::LALTMOD)

View File

@ -50,6 +50,7 @@ pub struct Settings {
pub locale: Language,
#[serde(default = "default_vsync")]
pub vsync_mode: VSyncMode,
pub debug_mode: bool,
}
fn default_true() -> bool {
@ -58,7 +59,7 @@ fn default_true() -> bool {
#[inline(always)]
fn current_version() -> u32 {
8
9
}
#[inline(always)]
@ -138,6 +139,11 @@ impl Settings {
self.vsync_mode = default_vsync();
}
if self.version == 8 {
self.version = 9;
self.debug_mode = false;
}
if self.version != initial_version {
log::info!("Upgraded configuration file from version {} to {}.", initial_version, self.version);
}
@ -190,6 +196,7 @@ impl Default for Settings {
fps_counter: false,
locale: Language::English,
vsync_mode: VSyncMode::VSync,
debug_mode: false,
}
}
}

View File

@ -404,6 +404,10 @@ impl SharedGameState {
}
pub fn process_debug_keys(&mut self, key_code: ScanCode) {
if !self.settings.debug_mode {
return;
}
match key_code {
ScanCode::F3 => self.settings.god_mode = !self.settings.god_mode,
ScanCode::F4 => self.settings.infinite_booster = !self.settings.infinite_booster,