mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-05-24 07:51:11 +00:00
process debug keys in game scene and add quick save shortcut
This commit is contained in:
parent
f1b3c680c9
commit
b1b3b131e2
|
@ -276,7 +276,9 @@ impl BackendEventLoop for SDL2EventLoop {
|
||||||
Event::KeyDown { scancode: Some(scancode), repeat, keymod, .. } => {
|
Event::KeyDown { scancode: Some(scancode), repeat, keymod, .. } => {
|
||||||
if let Some(drs_scan) = conv_scancode(scancode) {
|
if let Some(drs_scan) = conv_scancode(scancode) {
|
||||||
if !repeat {
|
if !repeat {
|
||||||
state.process_debug_keys(ctx, drs_scan);
|
if let Some(scene) = &mut game.scene {
|
||||||
|
scene.process_debug_keys(state, ctx, drs_scan);
|
||||||
|
}
|
||||||
|
|
||||||
if keymod.intersects(keyboard::Mod::RALTMOD | keyboard::Mod::LALTMOD)
|
if keymod.intersects(keyboard::Mod::RALTMOD | keyboard::Mod::LALTMOD)
|
||||||
&& drs_scan == ScanCode::Return
|
&& drs_scan == ScanCode::Return
|
||||||
|
|
|
@ -154,6 +154,7 @@ impl LiveDebugger {
|
||||||
if state.textscript_vm.state == TextScriptExecutionState::Ended {
|
if state.textscript_vm.state == TextScriptExecutionState::Ended {
|
||||||
if ui.button("Save") {
|
if ui.button("Save") {
|
||||||
let _ = state.save_game(game_scene, ctx);
|
let _ = state.save_game(game_scene, ctx);
|
||||||
|
state.sound_manager.play_sfx(18);
|
||||||
}
|
}
|
||||||
} else if ui.button("Busy") {
|
} else if ui.button("Busy") {
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,9 @@ impl LiveDebugger {
|
||||||
if ui.button("Hotkey List") {
|
if ui.button("Hotkey List") {
|
||||||
self.hotkey_list_visible = !self.hotkey_list_visible;
|
self.hotkey_list_visible = !self.hotkey_list_visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.checkbox("noclip", &mut state.settings.noclip);
|
ui.checkbox("noclip", &mut state.settings.noclip);
|
||||||
|
ui.same_line();
|
||||||
ui.checkbox("more rust", &mut state.more_rust);
|
ui.checkbox("more rust", &mut state.more_rust);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -402,7 +405,7 @@ impl LiveDebugger {
|
||||||
if self.hotkey_list_visible {
|
if self.hotkey_list_visible {
|
||||||
Window::new("Hotkeys")
|
Window::new("Hotkeys")
|
||||||
.position([400.0, 5.0], Condition::FirstUseEver)
|
.position([400.0, 5.0], Condition::FirstUseEver)
|
||||||
.size([300.0, 240.0], Condition::FirstUseEver)
|
.size([300.0, 280.0], Condition::FirstUseEver)
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
.build(ui, || {
|
.build(ui, || {
|
||||||
let key = vec![
|
let key = vec![
|
||||||
|
@ -418,6 +421,7 @@ impl LiveDebugger {
|
||||||
"F11 > Toggle FPS Counter",
|
"F11 > Toggle FPS Counter",
|
||||||
"F12 > Toggle Debugger",
|
"F12 > Toggle Debugger",
|
||||||
"Ctrl + F3 > Reload Sound Manager",
|
"Ctrl + F3 > Reload Sound Manager",
|
||||||
|
"Ctrl + S > Quick Save",
|
||||||
];
|
];
|
||||||
for hotkeys in key.iter() {
|
for hotkeys in key.iter() {
|
||||||
match hotkeys {
|
match hotkeys {
|
||||||
|
|
|
@ -30,6 +30,7 @@ use crate::framework::backend::SpriteBatchCommand;
|
||||||
use crate::framework::context::Context;
|
use crate::framework::context::Context;
|
||||||
use crate::framework::error::GameResult;
|
use crate::framework::error::GameResult;
|
||||||
use crate::framework::graphics::{draw_rect, BlendMode, FilterMode};
|
use crate::framework::graphics::{draw_rect, BlendMode, FilterMode};
|
||||||
|
use crate::framework::keyboard::ScanCode;
|
||||||
use crate::framework::ui::Components;
|
use crate::framework::ui::Components;
|
||||||
use crate::framework::{filesystem, gamepad, graphics};
|
use crate::framework::{filesystem, gamepad, graphics};
|
||||||
use crate::input::touch_controls::TouchControlType;
|
use crate::input::touch_controls::TouchControlType;
|
||||||
|
@ -2320,4 +2321,46 @@ impl Scene for GameScene {
|
||||||
components.live_debugger.run_ingame(self, state, ctx, ui)?;
|
components.live_debugger.run_ingame(self, state, ctx, ui)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn process_debug_keys(&mut self, state: &mut SharedGameState, ctx: &mut Context, key_code: ScanCode) -> GameResult {
|
||||||
|
if key_code == ScanCode::F3 && ctx.keyboard_context.active_mods().ctrl() {
|
||||||
|
let _ = state.sound_manager.reload();
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if key_code == ScanCode::S && ctx.keyboard_context.active_mods().ctrl() {
|
||||||
|
let _ = state.save_game(self, ctx);
|
||||||
|
state.sound_manager.play_sfx(18);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
if !state.settings.debug_mode {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
match key_code {
|
||||||
|
ScanCode::F3 => state.settings.god_mode = !state.settings.god_mode,
|
||||||
|
ScanCode::F4 => state.settings.infinite_booster = !state.settings.infinite_booster,
|
||||||
|
ScanCode::F5 => state.settings.subpixel_coords = !state.settings.subpixel_coords,
|
||||||
|
ScanCode::F6 => state.settings.motion_interpolation = !state.settings.motion_interpolation,
|
||||||
|
ScanCode::F7 => state.set_speed(1.0),
|
||||||
|
ScanCode::F8 => {
|
||||||
|
if state.settings.speed > 0.2 {
|
||||||
|
state.set_speed(state.settings.speed - 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ScanCode::F9 => {
|
||||||
|
if state.settings.speed < 3.0 {
|
||||||
|
state.set_speed(state.settings.speed + 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ScanCode::F10 => state.settings.debug_outlines = !state.settings.debug_outlines,
|
||||||
|
ScanCode::F11 => state.settings.fps_counter = !state.settings.fps_counter,
|
||||||
|
ScanCode::F12 => state.debugger = !state.debugger,
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::framework::context::Context;
|
use crate::framework::context::Context;
|
||||||
use crate::framework::error::GameResult;
|
use crate::framework::error::GameResult;
|
||||||
|
use crate::framework::keyboard::ScanCode;
|
||||||
use crate::framework::ui::Components;
|
use crate::framework::ui::Components;
|
||||||
use crate::shared_game_state::SharedGameState;
|
use crate::shared_game_state::SharedGameState;
|
||||||
|
|
||||||
|
@ -44,6 +45,15 @@ pub trait Scene: downcast::Any {
|
||||||
) -> GameResult {
|
) -> GameResult {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn process_debug_keys(
|
||||||
|
&mut self,
|
||||||
|
_state: &mut SharedGameState,
|
||||||
|
_ctx: &mut Context,
|
||||||
|
_key_code: ScanCode,
|
||||||
|
) -> GameResult {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
downcast::impl_downcast!(dyn Scene);
|
downcast::impl_downcast!(dyn Scene);
|
||||||
|
|
|
@ -13,7 +13,6 @@ use crate::framework::backend::BackendTexture;
|
||||||
use crate::framework::context::Context;
|
use crate::framework::context::Context;
|
||||||
use crate::framework::error::GameResult;
|
use crate::framework::error::GameResult;
|
||||||
use crate::framework::graphics::{create_texture_mutable, set_render_target};
|
use crate::framework::graphics::{create_texture_mutable, set_render_target};
|
||||||
use crate::framework::keyboard::ScanCode;
|
|
||||||
use crate::framework::vfs::OpenOptions;
|
use crate::framework::vfs::OpenOptions;
|
||||||
use crate::framework::{filesystem, graphics};
|
use crate::framework::{filesystem, graphics};
|
||||||
#[cfg(feature = "hooks")]
|
#[cfg(feature = "hooks")]
|
||||||
|
@ -489,40 +488,6 @@ impl SharedGameState {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_debug_keys(&mut self, ctx: &mut Context, key_code: ScanCode) {
|
|
||||||
if key_code == ScanCode::F3 && ctx.keyboard_context.active_mods().ctrl() {
|
|
||||||
let _ = self.sound_manager.reload();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
|
||||||
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,
|
|
||||||
ScanCode::F5 => self.settings.subpixel_coords = !self.settings.subpixel_coords,
|
|
||||||
ScanCode::F6 => self.settings.motion_interpolation = !self.settings.motion_interpolation,
|
|
||||||
ScanCode::F7 => self.set_speed(1.0),
|
|
||||||
ScanCode::F8 => {
|
|
||||||
if self.settings.speed > 0.2 {
|
|
||||||
self.set_speed(self.settings.speed - 0.1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ScanCode::F9 => {
|
|
||||||
if self.settings.speed < 3.0 {
|
|
||||||
self.set_speed(self.settings.speed + 0.1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ScanCode::F10 => self.settings.debug_outlines = !self.settings.debug_outlines,
|
|
||||||
ScanCode::F11 => self.settings.fps_counter = !self.settings.fps_counter,
|
|
||||||
ScanCode::F12 => self.debugger = !self.debugger,
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn reload_resources(&mut self, ctx: &mut Context) -> GameResult {
|
pub fn reload_resources(&mut self, ctx: &mut Context) -> GameResult {
|
||||||
self.constants.rebuild_path_list(self.mod_path.clone(), self.season, &self.settings);
|
self.constants.rebuild_path_list(self.mod_path.clone(), self.season, &self.settings);
|
||||||
if !self.constants.is_demo {
|
if !self.constants.is_demo {
|
||||||
|
|
Loading…
Reference in a new issue