summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/cl_console.c16
-rw-r--r--src/client/cl_keys.c51
2 files changed, 52 insertions, 15 deletions
diff --git a/src/client/cl_console.c b/src/client/cl_console.c
index e832910e..3b4fc2c6 100644
--- a/src/client/cl_console.c
+++ b/src/client/cl_console.c
@@ -79,6 +79,16 @@ void Con_ToggleConsole_f (void) {
}
/*
+===================
+Con_ToggleMenu_f
+===================
+*/
+void Con_ToggleMenu_f( void ) {
+ CL_KeyEvent( K_ESCAPE, qtrue, Sys_Milliseconds() );
+ CL_KeyEvent( K_ESCAPE, qfalse, Sys_Milliseconds() );
+}
+
+/*
================
Con_Clear_f
================
@@ -262,6 +272,7 @@ void Con_Init (void) {
CL_LoadConsoleHistory( );
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
+ Cmd_AddCommand ("togglemenu", Con_ToggleMenu_f);
Cmd_AddCommand ("clear", Con_Clear_f);
Cmd_AddCommand ("condump", Con_Dump_f);
Cmd_SetCommandCompletionFunc( "condump", Cmd_CompleteTxtName );
@@ -275,10 +286,7 @@ Con_Shutdown
void Con_Shutdown(void)
{
Cmd_RemoveCommand("toggleconsole");
- Cmd_RemoveCommand("messagemode");
- Cmd_RemoveCommand("messagemode2");
- Cmd_RemoveCommand("messagemode3");
- Cmd_RemoveCommand("messagemode4");
+ Cmd_RemoveCommand("togglemenu");
Cmd_RemoveCommand("clear");
Cmd_RemoveCommand("condump");
}
diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c
index 8bd0b654..95858d40 100644
--- a/src/client/cl_keys.c
+++ b/src/client/cl_keys.c
@@ -1074,6 +1074,23 @@ void CL_InitKeyCommands( void ) {
/*
===================
+CL_BindUICommand
+
+Returns qtrue if bind command should be executed while user interface is shown
+===================
+*/
+static qboolean CL_BindUICommand( const char *cmd ) {
+ if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE )
+ return qfalse;
+
+ if ( !Q_stricmp( cmd, "togglemenu" ) )
+ return qtrue;
+
+ return qfalse;
+}
+
+/*
+===================
CL_ParseBinding
Execute the commands in the bind string
@@ -1082,11 +1099,20 @@ Execute the commands in the bind string
void CL_ParseBinding( int key, qboolean down, unsigned time )
{
char buf[ MAX_STRING_CHARS ], *p = buf, *end;
+ qboolean allCommands, allowUpCmds;
+ if( clc.state == CA_DISCONNECTED && Key_GetCatcher( ) == 0 )
+ return;
if( !keys[key].binding || !keys[key].binding[0] )
return;
Q_strncpyz( buf, keys[key].binding, sizeof( buf ) );
+ // run all bind commands if console, ui, etc aren't reading keys
+ allCommands = ( Key_GetCatcher( ) == 0 );
+
+ // allow button up commands if in game even if key catcher is set
+ allowUpCmds = ( clc.state != CA_DISCONNECTED );
+
while( 1 )
{
while( isspace( *p ) )
@@ -1099,16 +1125,20 @@ void CL_ParseBinding( int key, qboolean down, unsigned time )
// button commands add keynum and time as parameters
// so that multiple sources can be discriminated and
// subframe corrected
- char cmd[1024];
- Com_sprintf( cmd, sizeof( cmd ), "%c%s %d %d\n",
- ( down ) ? '+' : '-', p + 1, key, time );
- Cbuf_AddText( cmd );
+ if ( allCommands || ( allowUpCmds && !down ) ) {
+ char cmd[1024];
+ Com_sprintf( cmd, sizeof( cmd ), "%c%s %d %d\n",
+ ( down ) ? '+' : '-', p + 1, key, time );
+ Cbuf_AddText( cmd );
+ }
}
else if( down )
{
// normal commands only execute on key press
- Cbuf_AddText( p );
- Cbuf_AddText( "\n" );
+ if ( allCommands || CL_BindUICommand( p ) ) {
+ Cbuf_AddText( p );
+ Cbuf_AddText( "\n" );
+ }
}
if( !end )
break;
@@ -1194,10 +1224,10 @@ void CL_KeyDownEvent( int key, unsigned time )
}
} else if ( clc.state == CA_DISCONNECTED ) {
Console_Key( key );
- } else {
- // send the bound action
- CL_ParseBinding( key, qtrue, time );
}
+
+ // send the bound action
+ CL_ParseBinding( key, qtrue, time );
return;
}
@@ -1229,8 +1259,7 @@ void CL_KeyUpEvent( int key, unsigned time )
// console mode and menu mode, to keep the character from continuing
// an action started before a mode switch.
//
- if( clc.state != CA_DISCONNECTED )
- CL_ParseBinding( key, qfalse, time );
+ CL_ParseBinding( key, qfalse, time );
if ( Key_GetCatcher( ) & KEYCATCH_UI && uivm ) {
VM_Call( uivm, UI_KEY_EVENT, key, qfalse );