FS2_Open
Open source remastering of the Freespace 2 engine
|
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new features. More...
#include "debugconsole/consoleparse.h"
#include "globalincs/pstypes.h"
#include "globalincs/vmallocator.h"
Go to the source code of this file.
Classes | |
class | debug_command |
Class to aggregate a debug command with its name (as shown in the console) and short help. More... | |
class | is_dcmd |
Predicate class used to search for a dcmd by name. More... | |
Macros | |
#define | DC_MAX_COMMANDS 300 |
#define | DCF(function_name, help_text) |
The potent DCF macro, used to define new debug commands for the console. More... | |
#define | DCF_BOOL(function_name, bool_variable) |
#define | DCF_BOOL2(function_name, bool_variable, short_help, long_help) |
#define | DCF_FLOAT(function_name, float_variable, short_help) |
#define | DCF_FLOAT2(function_name, float_variable, lower_bounds, upper_bounds, short_help) |
#define | DCF_INT(function_name, int_variable, short_help) |
#define | DCF_INT2(function_name, int_variable, lower_bounds, upper_bounds, short_help) |
Functions | |
bool | dc_pause_output (void) |
Pauses the output of a command and allows user to scroll through the output history. More... | |
void | dc_printf (const char *format,...) |
Prints the given char string to the debug console. More... | |
void | debug_console (void(*func)(void)=NULL) |
Opens and processes the debug console. (Blocking call) More... | |
Variables | |
bool | Dc_debug_on |
Flag used to print console and command debugging strings. More... | |
int | dc_commands_size |
uint | lastline |
SCP_string | dc_command_str |
Is progressively culled from the left as commands, arguments are parsed in DCF's. More... | |
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new features.
Of key interest is Volition's DCF macro, which adds the function argument to the available command list in the debug console. These functions may be defined in the .cpp file that they are related to, but it is recommended that they be in their own .cpp if they have multiple sub-arguments (ex: Git has its sub-arguments delimited by a pair of -'s, or –)
Definition in file console.h.
#define DCF | ( | function_name, | |
help_text | |||
) |
The potent DCF macro, used to define new debug commands for the console.
function_name[in] | The name of the function, as shown in the debug console |
help_txt[in] | The short-help text, as shown as listed from the 'help' command |
Each DCF is responsible for getting data from the debug console's command line. The parsing functions for the command line have been set up to have similar syntax and usage as the parselo commands. (see consoleparse.h) Most, if not all, argument and subcommand strings should be parsed by the dc_optional_string functions. Usage example: DCF(toggle_it, "description") { if (dc_optional_string_either("help", "--help")) { dc_printf("Usage: sample. Toggles This_var on/off\n");
} else if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) { dc_printf("This_var is %s\n", (This_var ? "ON" : "OFF"));
} else { This_var = !This_var;
} }
In the console, the command would be listed as 'toggle_it', and dcf_help would display it as: toggle_it - Usage: sample. Toggles This_var on/off. Note: The only allowed function type is a void fn( void )
#define DCF_BOOL | ( | function_name, | |
bool_variable | |||
) |
#define DCF_BOOL2 | ( | function_name, | |
bool_variable, | |||
short_help, | |||
long_help | |||
) |
#define DCF_FLOAT | ( | function_name, | |
float_variable, | |||
short_help | |||
) |
#define DCF_FLOAT2 | ( | function_name, | |
float_variable, | |||
lower_bounds, | |||
upper_bounds, | |||
short_help | |||
) |
#define DCF_INT | ( | function_name, | |
int_variable, | |||
short_help | |||
) |
#define DCF_INT2 | ( | function_name, | |
int_variable, | |||
lower_bounds, | |||
upper_bounds, | |||
short_help | |||
) |
bool dc_pause_output | ( | void | ) |
Pauses the output of a command and allows user to scroll through the output history.
Returns true if user has pressed Esc, returns false otherwise. Use this in your function to (safely?) break out of the loop it's presumably in.
Definition at line 306 of file console.cpp.
void dc_printf | ( | const char * | format, |
... | |||
) |
Prints the given char string to the debug console.
See the doc for std::printf() for formating and more details
Definition at line 358 of file console.cpp.
Opens and processes the debug console. (Blocking call)
TODO: Make this a non-blocking call so that the game can still run while the debug console is open.
Definition at line 495 of file console.cpp.
SCP_string dc_command_str |
Is progressively culled from the left as commands, arguments are parsed in DCF's.
The entered command line, arguments and all.
Definition at line 27 of file console.cpp.
int dc_commands_size |
Definition at line 28 of file consolecmds.cpp.
bool Dc_debug_on |
Flag used to print console and command debugging strings.
Definition at line 24 of file console.cpp.
uint lastline |
Definition at line 32 of file console.cpp.