summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2007-10-02 21:29:25 +0000
committerTim Angus <tim@ngus.net>2007-10-02 21:29:25 +0000
commitdd0dd03f6f94a15b8764973e4c893526d8cfd722 (patch)
tree4a3989e08a16d58e6b4f9fda7380e20ba05b8a28 /src/client
parente6513f95705560250f00f1ccc0707e01e318192f (diff)
* Merge of ioq3-r1189
+ Fix bug that prevented key up events getting to cgame/ui when not in game + Use Key_[GS]etCatcher everywhere to set keycatcher + Clear all key states when the catcher changes * Slim down client userinfo somewhat * Remove some redundant client autocomplete commands * Actually make use of "menuStack" in the UI module + No longer close all menus when exiting one, instead reverting to the next one on the stack + Cleanup the menu activation functions a little * Truncate text in list columns if it exceeds the column width * Remove maxChars field from columns member of ITEM_TYPE_LISTBOX * Revert r992 due to more general and less buggy/hacky fix from ioq3
Diffstat (limited to 'src/client')
-rw-r--r--src/client/cl_cgame.c5
-rw-r--r--src/client/cl_console.c30
-rw-r--r--src/client/cl_input.c8
-rw-r--r--src/client/cl_keys.c51
-rw-r--r--src/client/cl_main.c33
-rw-r--r--src/client/cl_scrn.c2
-rw-r--r--src/client/cl_ui.c5
-rw-r--r--src/client/client.h3
8 files changed, 63 insertions, 74 deletions
diff --git a/src/client/cl_cgame.c b/src/client/cl_cgame.c
index 40714a56..84b58d74 100644
--- a/src/client/cl_cgame.c
+++ b/src/client/cl_cgame.c
@@ -385,7 +385,7 @@ CL_ShutdonwCGame
====================
*/
void CL_ShutdownCGame( void ) {
- cls.keyCatchers &= ~KEYCATCH_CGAME;
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CGAME );
cls.cgameStarted = qfalse;
if ( !cgvm ) {
return;
@@ -619,7 +619,8 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
case CG_KEY_GETCATCHER:
return Key_GetCatcher();
case CG_KEY_SETCATCHER:
- Key_SetCatcher( args[1] );
+ // Don't allow the cgame module to close the console
+ Key_SetCatcher( args[1] | ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) );
return 0;
case CG_KEY_GETKEY:
return Key_GetKey( VMA(1) );
diff --git a/src/client/cl_console.c b/src/client/cl_console.c
index 9d2d8e7c..d740696d 100644
--- a/src/client/cl_console.c
+++ b/src/client/cl_console.c
@@ -70,14 +70,14 @@ Con_ToggleConsole_f
*/
void Con_ToggleConsole_f (void) {
// Can't toggle the console when it's the only thing available
- if ( cls.state == CA_DISCONNECTED && cls.keyCatchers == KEYCATCH_CONSOLE ) {
+ if ( cls.state == CA_DISCONNECTED && Key_GetCatcher( ) == KEYCATCH_CONSOLE ) {
return;
}
Field_Clear( &g_consoleField );
g_consoleField.widthInChars = g_console_field_width;
- cls.keyCatchers ^= KEYCATCH_CONSOLE;
+ Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_CONSOLE );
}
/*
@@ -91,7 +91,7 @@ void Con_MessageMode_f (void) {
Field_Clear( &chatField );
chatField.widthInChars = 30;
- cls.keyCatchers ^= KEYCATCH_MESSAGE;
+ Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE );
}
/*
@@ -104,7 +104,7 @@ void Con_MessageMode2_f (void) {
chat_team = qtrue;
Field_Clear( &chatField );
chatField.widthInChars = 25;
- cls.keyCatchers ^= KEYCATCH_MESSAGE;
+ Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE );
}
/*
@@ -121,7 +121,7 @@ void Con_MessageMode3_f (void) {
chat_team = qfalse;
Field_Clear( &chatField );
chatField.widthInChars = 30;
- cls.keyCatchers ^= KEYCATCH_MESSAGE;
+ Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE );
}
/*
@@ -138,7 +138,7 @@ void Con_MessageMode4_f (void) {
chat_team = qfalse;
Field_Clear( &chatField );
chatField.widthInChars = 30;
- cls.keyCatchers ^= KEYCATCH_MESSAGE;
+ Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE );
}
/*
@@ -377,7 +377,7 @@ void CL_ConsolePrint( char *txt ) {
con.initialized = qtrue;
}
- if( !skipnotify && !( cls.keyCatchers & KEYCATCH_CONSOLE ) ) {
+ if( !skipnotify && !( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) {
Cmd_SaveCmdContext( );
// feed the text to cgame
@@ -453,7 +453,7 @@ Draw the editline after a ] prompt
void Con_DrawInput (void) {
int y;
- if ( cls.state != CA_DISCONNECTED && !(cls.keyCatchers & KEYCATCH_CONSOLE ) ) {
+ if ( cls.state != CA_DISCONNECTED && !(Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) {
return;
}
@@ -594,7 +594,7 @@ void Con_DrawConsole( void ) {
// if disconnected, render console full screen
if ( cls.state == CA_DISCONNECTED ) {
- if ( !( cls.keyCatchers & (KEYCATCH_UI | KEYCATCH_CGAME)) ) {
+ if ( !( Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME)) ) {
Con_DrawSolidConsole( 1.0 );
return;
}
@@ -604,11 +604,11 @@ void Con_DrawConsole( void ) {
Con_DrawSolidConsole( con.displayFrac );
}
- if( cls.keyCatchers & ( KEYCATCH_UI | KEYCATCH_CGAME ) )
+ if( Key_GetCatcher( ) & ( KEYCATCH_UI | KEYCATCH_CGAME ) )
return;
// draw the chat line
- if( cls.keyCatchers & KEYCATCH_MESSAGE )
+ if( Key_GetCatcher( ) & KEYCATCH_MESSAGE )
{
int skip;
@@ -638,12 +638,8 @@ Scroll it up or down
==================
*/
void Con_RunConsole (void) {
- // Don't allow any key states at all when keycatching
- if ( cls.keyCatchers != 0 )
- Key_ClearStates( );
-
// decide on the destination height of the console
- if ( cls.keyCatchers & KEYCATCH_CONSOLE )
+ if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE )
con.finalFrac = 0.5; // half screen
else
con.finalFrac = 0; // none visible
@@ -697,7 +693,7 @@ void Con_Close( void ) {
return;
}
Field_Clear( &g_consoleField );
- cls.keyCatchers &= ~KEYCATCH_CONSOLE;
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CONSOLE );
con.finalFrac = 0; // none visible
con.displayFrac = 0;
}
diff --git a/src/client/cl_input.c b/src/client/cl_input.c
index 6faec21c..e5c87f14 100644
--- a/src/client/cl_input.c
+++ b/src/client/cl_input.c
@@ -352,9 +352,9 @@ CL_MouseEvent
=================
*/
void CL_MouseEvent( int dx, int dy, int time ) {
- if ( cls.keyCatchers & KEYCATCH_UI ) {
+ if ( Key_GetCatcher( ) & KEYCATCH_UI ) {
VM_Call( uivm, UI_MOUSE_EVENT, dx, dy );
- } else if (cls.keyCatchers & KEYCATCH_CGAME) {
+ } else if (Key_GetCatcher( ) & KEYCATCH_CGAME) {
VM_Call (cgvm, CG_MOUSE_EVENT, dx, dy);
} else {
cl.mouseDx[cl.mouseIndex] += dx;
@@ -488,13 +488,13 @@ void CL_CmdButtons( usercmd_t *cmd ) {
in_buttons[i].wasPressed = qfalse;
}
- if ( cls.keyCatchers ) {
+ if ( Key_GetCatcher( ) ) {
cmd->buttons |= BUTTON_TALK;
}
// allow the game to know if any key at all is
// currently pressed, even if it isn't bound to anything
- if ( anykeydown && !cls.keyCatchers ) {
+ if ( anykeydown && Key_GetCatcher( ) == 0 ) {
cmd->buttons |= BUTTON_ANY;
}
}
diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c
index e6e8261c..b23247bd 100644
--- a/src/client/cl_keys.c
+++ b/src/client/cl_keys.c
@@ -721,7 +721,7 @@ void Message_Key( int key ) {
if (key == K_ESCAPE) {
- cls.keyCatchers &= ~KEYCATCH_MESSAGE;
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_MESSAGE );
Field_Clear( &chatField );
return;
}
@@ -743,7 +743,7 @@ void Message_Key( int key ) {
CL_AddReliableCommand( buffer );
}
- cls.keyCatchers &= ~KEYCATCH_MESSAGE;
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_MESSAGE );
Field_Clear( &chatField );
return;
}
@@ -1174,7 +1174,8 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
// keys can still be used for bound actions
- if ( down && ( key < 128 || key == K_MOUSE1 ) && ( clc.demoplaying || cls.state == CA_CINEMATIC ) && !cls.keyCatchers) {
+ if ( down && ( key < 128 || key == K_MOUSE1 ) &&
+ ( clc.demoplaying || cls.state == CA_CINEMATIC ) && Key_GetCatcher( ) == 0 ) {
if (Cvar_VariableValue ("com_cameraMode") == 0) {
Cvar_Set ("nextdemo","");
@@ -1185,20 +1186,20 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
// escape is always handled special
if ( key == K_ESCAPE && down ) {
- if ( cls.keyCatchers & KEYCATCH_MESSAGE ) {
+ if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) {
// clear message mode
Message_Key( key );
return;
}
// escape always gets out of CGAME stuff
- if (cls.keyCatchers & KEYCATCH_CGAME) {
- cls.keyCatchers &= ~KEYCATCH_CGAME;
+ if (Key_GetCatcher( ) & KEYCATCH_CGAME) {
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CGAME );
VM_Call (cgvm, CG_EVENT_HANDLING, CGAME_EVENT_NONE);
return;
}
- if ( !( cls.keyCatchers & KEYCATCH_UI ) ) {
+ if ( !( Key_GetCatcher( ) & KEYCATCH_UI ) ) {
if ( cls.state == CA_ACTIVE && !clc.demoplaying ) {
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_INGAME );
}
@@ -1225,12 +1226,12 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
kb = keys[key].binding;
CL_AddKeyUpCommands( key, kb, time );
+ }
- if ( cls.keyCatchers & KEYCATCH_UI && uivm ) {
- VM_Call( uivm, UI_KEY_EVENT, key, down );
- } else if ( cls.keyCatchers & KEYCATCH_CGAME && cgvm ) {
- VM_Call( cgvm, CG_KEY_EVENT, key, down );
- }
+ if ( Key_GetCatcher( ) & KEYCATCH_UI && uivm ) {
+ VM_Call( uivm, UI_KEY_EVENT, key, down );
+ } else if ( Key_GetCatcher( ) & KEYCATCH_CGAME && cgvm ) {
+ VM_Call( cgvm, CG_KEY_EVENT, key, down );
}
return;
@@ -1238,17 +1239,17 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
// distribute the key down event to the apropriate handler
- if ( cls.keyCatchers & KEYCATCH_CONSOLE ) {
+ if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) {
Console_Key( key );
- } else if ( cls.keyCatchers & KEYCATCH_UI ) {
+ } else if ( Key_GetCatcher( ) & KEYCATCH_UI ) {
if ( uivm ) {
VM_Call( uivm, UI_KEY_EVENT, key, down );
}
- } else if ( cls.keyCatchers & KEYCATCH_CGAME ) {
+ } else if ( Key_GetCatcher( ) & KEYCATCH_CGAME ) {
if ( cgvm ) {
VM_Call( cgvm, CG_KEY_EVENT, key, down );
}
- } else if ( cls.keyCatchers & KEYCATCH_MESSAGE ) {
+ } else if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) {
Message_Key( key );
} else if ( cls.state == CA_DISCONNECTED ) {
Console_Key( key );
@@ -1316,15 +1317,15 @@ void CL_CharEvent( int key ) {
}
// distribute the key down event to the apropriate handler
- if ( cls.keyCatchers & KEYCATCH_CONSOLE )
+ if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE )
{
Field_CharEvent( &g_consoleField, key );
}
- else if ( cls.keyCatchers & KEYCATCH_UI )
+ else if ( Key_GetCatcher( ) & KEYCATCH_UI )
{
VM_Call( uivm, UI_KEY_EVENT, key | K_CHAR_FLAG, qtrue );
}
- else if ( cls.keyCatchers & KEYCATCH_MESSAGE )
+ else if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE )
{
Field_CharEvent( &chatField, key );
}
@@ -1382,22 +1383,28 @@ void Key_GetBindingBuf( int keynum, char *buf, int buflen ) {
}
}
+static int keyCatchers = 0;
+
/*
====================
Key_GetCatcher
====================
*/
int Key_GetCatcher( void ) {
- return cls.keyCatchers;
+ return keyCatchers;
}
/*
====================
-Ket_SetCatcher
+Key_SetCatcher
====================
*/
void Key_SetCatcher( int catcher ) {
- cls.keyCatchers = catcher;
+ // If the catcher state is changing, clear all key states
+ if( catcher != keyCatchers )
+ Key_ClearStates( );
+
+ keyCatchers = catcher;
}
// This must not exceed MAX_CMD_LINE
diff --git a/src/client/cl_main.c b/src/client/cl_main.c
index fc73ad47..413a0948 100644
--- a/src/client/cl_main.c
+++ b/src/client/cl_main.c
@@ -653,7 +653,7 @@ Closing the main menu will restart the demo loop
void CL_StartDemoLoop( void ) {
// start the demo loop again
Cbuf_AddText ("d1\n");
- cls.keyCatchers = 0;
+ Key_SetCatcher( 0 );
}
/*
@@ -798,7 +798,7 @@ memory on the hunk from cgame, ui, and renderer
void CL_MapLoading( void ) {
if ( com_dedicated->integer ) {
cls.state = CA_DISCONNECTED;
- cls.keyCatchers = KEYCATCH_CONSOLE;
+ Key_SetCatcher( KEYCATCH_CONSOLE );
return;
}
@@ -807,7 +807,7 @@ void CL_MapLoading( void ) {
}
Con_Close();
- cls.keyCatchers = 0;
+ Key_SetCatcher( 0 );
// if we are already connected to the local host, stay connected
if ( cls.state >= CA_CONNECTED && !Q_stricmp( cls.servername, "localhost" ) ) {
@@ -821,7 +821,7 @@ void CL_MapLoading( void ) {
CL_Disconnect( qtrue );
Q_strncpyz( cls.servername, "localhost", sizeof(cls.servername) );
cls.state = CA_CHALLENGING; // so the connect screen is drawn
- cls.keyCatchers = 0;
+ Key_SetCatcher( 0 );
SCR_UpdateScreen();
clc.connectTime = -RETRANSMIT_TIMEOUT;
NET_StringToAdr( cls.servername, &clc.serverAddress);
@@ -1169,7 +1169,7 @@ void CL_Connect_f( void ) {
cls.state = CA_CONNECTING;
}
- cls.keyCatchers = 0;
+ Key_SetCatcher( 0 );
clc.connectTime = -99999; // CL_CheckForResend() will fire immediately
clc.connectPacketCount = 0;
@@ -2181,7 +2181,7 @@ void CL_Frame ( int msec ) {
}
#endif
- if ( cls.state == CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_UI )
+ if ( cls.state == CA_DISCONNECTED && !( Key_GetCatcher( ) & KEYCATCH_UI )
&& !com_sv_running->integer ) {
// if disconnected, bring up the menu
S_StopAllSounds();
@@ -2598,8 +2598,6 @@ CL_Init
====================
*/
void CL_Init( void ) {
- const char *playerName;
-
Com_Printf( "----- Client Initialization -----\n" );
Con_Init ();
@@ -2691,32 +2689,16 @@ void CL_Init( void ) {
cl_guidServerUniq = Cvar_Get ("cl_guidServerUniq", "1", CVAR_ARCHIVE);
// userinfo
- playerName = getenv( "USER" ); // Unixy stuff
- if( playerName == NULL )
- {
- playerName = getenv( "USERNAME" ); // Windows
- if( playerName == NULL )
- {
- playerName = "Newbie"; // Default
- }
- }
- Cvar_Get ("name", playerName, CVAR_USERINFO | CVAR_ARCHIVE );
+ Cvar_Get ("name", Sys_GetCurrentUser( ), CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("snaps", "20", CVAR_USERINFO | CVAR_ARCHIVE );
- Cvar_Get ("model", "sarge", CVAR_USERINFO | CVAR_ARCHIVE );
- Cvar_Get ("headmodel", "sarge", CVAR_USERINFO | CVAR_ARCHIVE );
- Cvar_Get ("team_model", "james", CVAR_USERINFO | CVAR_ARCHIVE );
- Cvar_Get ("team_headmodel", "*james", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("color1", "4", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("color2", "5", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("handicap", "100", CVAR_USERINFO | CVAR_ARCHIVE );
- Cvar_Get ("teamtask", "0", CVAR_USERINFO );
Cvar_Get ("sex", "male", CVAR_USERINFO | CVAR_ARCHIVE );
- Cvar_Get ("cl_anonymous", "0", CVAR_USERINFO | CVAR_ARCHIVE );
Cvar_Get ("password", "", CVAR_USERINFO);
- Cvar_Get ("cg_predictItems", "1", CVAR_USERINFO | CVAR_ARCHIVE );
// cgame might not be initialized before menu is used
@@ -2820,6 +2802,7 @@ void CL_Shutdown( void ) {
recursive = qfalse;
Com_Memset( &cls, 0, sizeof( cls ) );
+ Key_SetCatcher( 0 );
Com_Printf( "-----------------------\n" );
diff --git a/src/client/cl_scrn.c b/src/client/cl_scrn.c
index f5c6cb9b..25217072 100644
--- a/src/client/cl_scrn.c
+++ b/src/client/cl_scrn.c
@@ -467,7 +467,7 @@ void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
}
// the menu draws next
- if ( cls.keyCatchers & KEYCATCH_UI && uivm ) {
+ if ( Key_GetCatcher( ) & KEYCATCH_UI && uivm ) {
VM_Call( uivm, UI_REFRESH, cls.realtime );
}
diff --git a/src/client/cl_ui.c b/src/client/cl_ui.c
index 6a4bb16f..8aa4550f 100644
--- a/src/client/cl_ui.c
+++ b/src/client/cl_ui.c
@@ -853,7 +853,8 @@ intptr_t CL_UISystemCalls( intptr_t *args ) {
return Key_GetCatcher();
case UI_KEY_SETCATCHER:
- Key_SetCatcher( args[1] );
+ // Don't allow the ui module to close the console
+ Key_SetCatcher( args[1] | ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) );
return 0;
case UI_GETCLIPBOARDDATA:
@@ -1032,7 +1033,7 @@ CL_ShutdownUI
====================
*/
void CL_ShutdownUI( void ) {
- cls.keyCatchers &= ~KEYCATCH_UI;
+ Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_UI );
cls.uiStarted = qfalse;
if ( !uivm ) {
return;
diff --git a/src/client/client.h b/src/client/client.h
index 12d13f9c..5e68edff 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -270,7 +270,6 @@ typedef struct {
typedef struct {
connstate_t state; // connection status
- int keyCatchers; // bit flags
qboolean cddialog; // bring up the cd needed dialog next frame
@@ -444,6 +443,8 @@ void CL_VerifyCode( void );
float CL_KeyState (kbutton_t *key);
char *Key_KeynumToString (int keynum);
+int Key_GetCatcher( void );
+void Key_SetCatcher( int catcher );
//
// cl_parse.c