mirror of
https://codeberg.org/schrottkatze/mgd2-tram-championships.git
synced 2025-07-01 17:27:38 +00:00
mode DebugEvent
into its own file
This commit is contained in:
parent
fcc4ebeba8
commit
f2fc8f41da
2 changed files with 59 additions and 52 deletions
55
src/debug.rs
55
src/debug.rs
|
@ -9,6 +9,9 @@ use console::{ConsoleLog, exec_script};
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
|
|
||||||
mod console;
|
mod console;
|
||||||
|
mod debug_event;
|
||||||
|
|
||||||
|
pub use debug_event::DebugEvent;
|
||||||
|
|
||||||
/// Debug system set.
|
/// Debug system set.
|
||||||
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -34,58 +37,6 @@ pub fn plugin(app: &mut App) {
|
||||||
.add_plugins(console::plugin);
|
.add_plugins(console::plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Event, Debug, Subcommand, PartialEq, Eq)]
|
|
||||||
enum DebugEvent {
|
|
||||||
/// Close the debug console.
|
|
||||||
#[command(name = "close", aliases = ["close-console"])]
|
|
||||||
CloseDebugConsole,
|
|
||||||
|
|
||||||
/// Output a string to the console.
|
|
||||||
///
|
|
||||||
/// Needed for logging in startup scripts, since the console isn't initialized yet.
|
|
||||||
#[command(name = "echo", aliases = ["print", "print-to-console"])]
|
|
||||||
PrintToConsole {
|
|
||||||
/// Print as error.
|
|
||||||
#[arg(short, long)]
|
|
||||||
error: bool,
|
|
||||||
/// The text to be printed in the console.
|
|
||||||
text: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Log as INFO or ERROR to stdout.
|
|
||||||
Log {
|
|
||||||
/// Log as error.
|
|
||||||
#[arg(short, long)]
|
|
||||||
error: bool,
|
|
||||||
/// The text to be logged.
|
|
||||||
text: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// Start the game
|
|
||||||
StartGame,
|
|
||||||
|
|
||||||
/// Run a tx file (the games debug scripting lang :3)
|
|
||||||
#[command(name = "run")]
|
|
||||||
RunFile { file: PathBuf },
|
|
||||||
|
|
||||||
/// Enable debug mode.
|
|
||||||
/// Will cause the game to behave differently (mostly, not do things by default it otherwise would.)
|
|
||||||
///
|
|
||||||
/// Do note while all of this is part of the debug tooling, debug mode just gives the debug tools more controls of the game.
|
|
||||||
///
|
|
||||||
/// Read: In debug mode, a lot of features of the normal game aren't enabled, and might have to be turned on explicitly.
|
|
||||||
/// This is to allow for easier testing. The console etc. will still stay available regardless, just might complain that debug mode isn't enabled on some commands.
|
|
||||||
///
|
|
||||||
/// For best results, enable debug mode before starting the game.
|
|
||||||
///
|
|
||||||
/// Debug mode cannot be disabled. Just restart the game lmao.
|
|
||||||
///
|
|
||||||
/// Current debug mode behaviour:
|
|
||||||
/// - Nothing
|
|
||||||
#[command(name = "enable-debug", aliases = ["debug-enable"])]
|
|
||||||
EnableDebugMode,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn start_game(
|
fn start_game(
|
||||||
mut dbg_reader: EventReader<DebugEvent>,
|
mut dbg_reader: EventReader<DebugEvent>,
|
||||||
mut log: ResMut<ConsoleLog>,
|
mut log: ResMut<ConsoleLog>,
|
||||||
|
|
56
src/debug/debug_event.rs
Normal file
56
src/debug/debug_event.rs
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use bevy::prelude::*;
|
||||||
|
use clap::Subcommand;
|
||||||
|
|
||||||
|
#[derive(Event, Debug, Subcommand, PartialEq, Eq)]
|
||||||
|
pub enum DebugEvent {
|
||||||
|
/// Close the debug console.
|
||||||
|
#[command(name = "close", aliases = ["close-console"])]
|
||||||
|
CloseDebugConsole,
|
||||||
|
|
||||||
|
/// Output a string to the console.
|
||||||
|
///
|
||||||
|
/// Needed for logging in startup scripts, since the console isn't initialized yet.
|
||||||
|
#[command(name = "echo", aliases = ["print", "print-to-console"])]
|
||||||
|
PrintToConsole {
|
||||||
|
/// Print as error.
|
||||||
|
#[arg(short, long)]
|
||||||
|
error: bool,
|
||||||
|
/// The text to be printed in the console.
|
||||||
|
text: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Log as INFO or ERROR to stdout.
|
||||||
|
Log {
|
||||||
|
/// Log as error.
|
||||||
|
#[arg(short, long)]
|
||||||
|
error: bool,
|
||||||
|
/// The text to be logged.
|
||||||
|
text: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Start the game
|
||||||
|
StartGame,
|
||||||
|
|
||||||
|
/// Run a tx file (the games debug scripting lang :3)
|
||||||
|
#[command(name = "run")]
|
||||||
|
RunFile { file: PathBuf },
|
||||||
|
|
||||||
|
/// Enable debug mode.
|
||||||
|
/// Will cause the game to behave differently (mostly, not do things by default it otherwise would.)
|
||||||
|
///
|
||||||
|
/// Do note while all of this is part of the debug tooling, debug mode just gives the debug tools more controls of the game.
|
||||||
|
///
|
||||||
|
/// Read: In debug mode, a lot of features of the normal game aren't enabled, and might have to be turned on explicitly.
|
||||||
|
/// This is to allow for easier testing. The console etc. will still stay available regardless, just might complain that debug mode isn't enabled on some commands.
|
||||||
|
///
|
||||||
|
/// For best results, enable debug mode before starting the game.
|
||||||
|
///
|
||||||
|
/// Debug mode cannot be disabled. Just restart the game lmao.
|
||||||
|
///
|
||||||
|
/// Current debug mode behaviour:
|
||||||
|
/// - Nothing
|
||||||
|
#[command(name = "enable-debug", aliases = ["debug-enable"])]
|
||||||
|
EnableDebugMode,
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue