From b626472f1047969bcf0380cacb4e645d05d330a0 Mon Sep 17 00:00:00 2001 From: dawnDus <96957561+dawndus@users.noreply.github.com> Date: Tue, 19 Apr 2022 18:50:04 -0400 Subject: [PATCH] Debug mode config toggle --- src/framework/backend_sdl2.rs | 1 - src/settings.rs | 9 ++++++++- src/shared_game_state.rs | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/framework/backend_sdl2.rs b/src/framework/backend_sdl2.rs index f291b8e..e3bac9b 100644 --- a/src/framework/backend_sdl2.rs +++ b/src/framework/backend_sdl2.rs @@ -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) diff --git a/src/settings.rs b/src/settings.rs index c472752..fd7f38d 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -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, } } } diff --git a/src/shared_game_state.rs b/src/shared_game_state.rs index 4e80359..c5b932a 100644 --- a/src/shared_game_state.rs +++ b/src/shared_game_state.rs @@ -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,