diff options
author | Tim Angus <tim@ngus.net> | 2007-10-02 21:29:25 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2007-10-02 21:29:25 +0000 |
commit | dd0dd03f6f94a15b8764973e4c893526d8cfd722 (patch) | |
tree | 4a3989e08a16d58e6b4f9fda7380e20ba05b8a28 /src | |
parent | e6513f95705560250f00f1ccc0707e01e318192f (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')
-rw-r--r-- | src/cgame/cg_consolecmds.c | 8 | ||||
-rw-r--r-- | src/cgame/cg_draw.c | 2 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 15 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 12 | ||||
-rw-r--r-- | src/cgame/cg_players.c | 74 | ||||
-rw-r--r-- | src/cgame/cg_tutorial.c | 1 | ||||
-rw-r--r-- | src/client/cl_cgame.c | 5 | ||||
-rw-r--r-- | src/client/cl_console.c | 30 | ||||
-rw-r--r-- | src/client/cl_input.c | 8 | ||||
-rw-r--r-- | src/client/cl_keys.c | 51 | ||||
-rw-r--r-- | src/client/cl_main.c | 33 | ||||
-rw-r--r-- | src/client/cl_scrn.c | 2 | ||||
-rw-r--r-- | src/client/cl_ui.c | 5 | ||||
-rw-r--r-- | src/client/client.h | 3 | ||||
-rw-r--r-- | src/game/g_client.c | 27 | ||||
-rw-r--r-- | src/game/g_local.h | 1 | ||||
-rw-r--r-- | src/qcommon/qcommon.h | 4 | ||||
-rw-r--r-- | src/sdl/sdl_gamma.c | 28 | ||||
-rw-r--r-- | src/sdl/sdl_glimp.c | 2 | ||||
-rw-r--r-- | src/sdl/sdl_input.c | 4 | ||||
-rw-r--r-- | src/sys/sys_main.c | 2 | ||||
-rw-r--r-- | src/ui/ui_main.c | 6 | ||||
-rw-r--r-- | src/ui/ui_shared.c | 135 | ||||
-rw-r--r-- | src/ui/ui_shared.h | 3 |
24 files changed, 175 insertions, 286 deletions
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c index 3dc7ef4d..65177875 100644 --- a/src/cgame/cg_consolecmds.c +++ b/src/cgame/cg_consolecmds.c @@ -282,13 +282,6 @@ void CG_InitConsoleCommands( void ) trap_AddCommand( "say" ); trap_AddCommand( "say_team" ); trap_AddCommand( "tell" ); - trap_AddCommand( "vsay" ); - trap_AddCommand( "vsay_team" ); - trap_AddCommand( "vtell" ); - trap_AddCommand( "vtaunt" ); - trap_AddCommand( "vosay" ); - trap_AddCommand( "vosay_team" ); - trap_AddCommand( "votell" ); trap_AddCommand( "give" ); trap_AddCommand( "god" ); trap_AddCommand( "notarget" ); @@ -303,7 +296,6 @@ void CG_InitConsoleCommands( void ) trap_AddCommand( "callteamvote" ); trap_AddCommand( "teamvote" ); trap_AddCommand( "stats" ); - trap_AddCommand( "teamtask" ); trap_AddCommand( "class" ); trap_AddCommand( "build" ); trap_AddCommand( "buy" ); diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 774b10c4..a5d458cf 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -2802,7 +2802,7 @@ CG_ShowTeamMenus */ void CG_ShowTeamMenu( void ) { - Menus_OpenByName( "teamMenu" ); + Menus_ActivateByName( "teamMenu" ); } /* diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 4952eef4..2ed268e7 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -79,10 +79,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define TEAM_OVERLAY_MAXNAME_WIDTH 12 #define TEAM_OVERLAY_MAXLOCATION_WIDTH 16 -#define DEFAULT_MODEL "sarge" -#define DEFAULT_TEAM_MODEL "sarge" -#define DEFAULT_TEAM_HEAD "sarge" - typedef enum { FOOTSTEP_NORMAL, @@ -708,8 +704,6 @@ typedef struct char name[ MAX_QPATH ]; pTeam_t team; - int botSkill; // 0 = not bot, 1-5 = bot - vec3_t color1; vec3_t color2; @@ -720,10 +714,6 @@ typedef struct int curWeapon; int handicap; - int wins, losses; // in tourney mode - - int teamTask; // task in teamplay (offence/defence) - qboolean teamLeader; // true when this is a team leader int medkitUsageTime; int invulnerabilityStartTime; @@ -736,8 +726,6 @@ typedef struct // gameplay char modelName[ MAX_QPATH ]; char skinName[ MAX_QPATH ]; - char headModelName[ MAX_QPATH ]; - char headSkinName[ MAX_QPATH ]; qboolean newAnims; // true if using the new mission pack animations qboolean fixedlegs; // true if legs yaw is always the same as torso yaw @@ -1461,7 +1449,6 @@ extern vmCvar_t cg_forceModel; extern vmCvar_t cg_buildScript; extern vmCvar_t cg_paused; extern vmCvar_t cg_blood; -extern vmCvar_t cg_predictItems; extern vmCvar_t cg_deferPlayers; extern vmCvar_t cg_drawFriend; extern vmCvar_t cg_teamChatsOnly; @@ -1471,7 +1458,6 @@ extern vmCvar_t cg_scorePlum; extern vmCvar_t cg_smoothClients; extern vmCvar_t pmove_fixed; extern vmCvar_t pmove_msec; -//extern vmCvar_t cg_pmove_fixed; extern vmCvar_t cg_cameraOrbit; extern vmCvar_t cg_cameraOrbitDelay; extern vmCvar_t cg_timescaleFadeEnd; @@ -1486,7 +1472,6 @@ extern vmCvar_t cg_oldRail; extern vmCvar_t cg_oldRocket; extern vmCvar_t cg_oldPlasma; extern vmCvar_t cg_trueLightning; -extern vmCvar_t cg_creepRes; extern vmCvar_t cg_drawSurfNormal; extern vmCvar_t cg_drawBBOX; extern vmCvar_t cg_debugAlloc; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 3f20ce20..9bc39014 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -170,7 +170,6 @@ vmCvar_t cg_buildScript; vmCvar_t cg_forceModel; vmCvar_t cg_paused; vmCvar_t cg_blood; -vmCvar_t cg_predictItems; vmCvar_t cg_deferPlayers; vmCvar_t cg_drawTeamOverlay; vmCvar_t cg_teamOverlayUserinfo; @@ -182,7 +181,6 @@ vmCvar_t cg_hudFiles; vmCvar_t cg_scorePlum; vmCvar_t cg_smoothClients; vmCvar_t pmove_fixed; -//vmCvar_t cg_pmove_fixed; vmCvar_t pmove_msec; vmCvar_t cg_pmove_msec; vmCvar_t cg_cameraMode; @@ -199,7 +197,6 @@ vmCvar_t cg_oldRail; vmCvar_t cg_oldRocket; vmCvar_t cg_oldPlasma; vmCvar_t cg_trueLightning; -vmCvar_t cg_creepRes; vmCvar_t cg_drawSurfNormal; vmCvar_t cg_drawBBOX; vmCvar_t cg_debugAlloc; @@ -306,7 +303,6 @@ static cvarTable_t cvarTable[ ] = { &cg_thirdPersonAngle, "cg_thirdPersonAngle", "0", CVAR_CHEAT }, { &cg_thirdPerson, "cg_thirdPerson", "0", CVAR_CHEAT }, { &cg_forceModel, "cg_forceModel", "0", CVAR_ARCHIVE }, - { &cg_predictItems, "cg_predictItems", "1", CVAR_ARCHIVE }, { &cg_deferPlayers, "cg_deferPlayers", "1", CVAR_ARCHIVE }, { &cg_drawTeamOverlay, "cg_drawTeamOverlay", "0", CVAR_ARCHIVE }, { &cg_teamOverlayUserinfo, "teamoverlay", "0", CVAR_ROM | CVAR_USERINFO }, @@ -315,7 +311,6 @@ static cvarTable_t cvarTable[ ] = { &cg_teamChatsOnly, "cg_teamChatsOnly", "0", CVAR_ARCHIVE }, { &cg_noVoiceChats, "cg_noVoiceChats", "0", CVAR_ARCHIVE }, { &cg_noVoiceText, "cg_noVoiceText", "0", CVAR_ARCHIVE }, - { &cg_creepRes, "cg_creepRes", "16", CVAR_ARCHIVE }, { &cg_drawSurfNormal, "cg_drawSurfNormal", "0", CVAR_CHEAT }, { &cg_drawBBOX, "cg_drawBBOX", "0", CVAR_CHEAT }, { &cg_debugAlloc, "cg_debugAlloc", "0", 0 }, @@ -366,7 +361,6 @@ static cvarTable_t cvarTable[ ] = { &cg_timescaleFadeEnd, "cg_timescaleFadeEnd", "1", 0}, { &cg_timescaleFadeSpeed, "cg_timescaleFadeSpeed", "0", 0}, { &cg_timescale, "timescale", "1", 0}, - { &cg_scorePlum, "cg_scorePlums", "1", CVAR_USERINFO | CVAR_ARCHIVE}, { &cg_smoothClients, "cg_smoothClients", "0", CVAR_USERINFO | CVAR_ARCHIVE}, { &cg_cameraMode, "com_cameraMode", "0", CVAR_CHEAT}, @@ -380,7 +374,6 @@ static cvarTable_t cvarTable[ ] = { &cg_oldRocket, "cg_oldRocket", "1", CVAR_ARCHIVE}, { &cg_oldPlasma, "cg_oldPlasma", "1", CVAR_ARCHIVE}, { &cg_trueLightning, "cg_trueLightning", "0.0", CVAR_ARCHIVE} -// { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE } }; static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); @@ -409,11 +402,6 @@ void CG_RegisterCvars( void ) trap_Cvar_VariableStringBuffer( "sv_running", var, sizeof( var ) ); cgs.localServer = atoi( var ); forceModelModificationCount = cg_forceModel.modificationCount; - - trap_Cvar_Register( NULL, "model", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE ); - trap_Cvar_Register( NULL, "headmodel", DEFAULT_MODEL, CVAR_USERINFO | CVAR_ARCHIVE ); - trap_Cvar_Register( NULL, "team_model", DEFAULT_TEAM_MODEL, CVAR_USERINFO | CVAR_ARCHIVE ); - trap_Cvar_Register( NULL, "team_headmodel", DEFAULT_TEAM_HEAD, CVAR_USERINFO | CVAR_ARCHIVE ); } diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index f0800fa5..ad517800 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -484,15 +484,6 @@ static qboolean CG_RegisterClientModelname( clientInfo_t *ci, const char *modelN return qfalse; } - //FIXME: skins do not load without icon present. do we want icons anyway? -/* Com_sprintf( filename, sizeof( filename ), "models/players/%s/icon_%s.tga", modelName, skinName ); - ci->modelIcon = trap_R_RegisterShaderNoMip( filename ); - if( !ci->modelIcon ) - { - Com_Printf( "Failed to load icon file: %s\n", filename ); - return qfalse; - }*/ - return qtrue; } @@ -535,24 +526,16 @@ Load it now, taking the disk hits */ static void CG_LoadClientInfo( clientInfo_t *ci ) { - const char *dir, *fallback; + const char *dir; int i; const char *s; int clientNum; if( !CG_RegisterClientModelname( ci, ci->modelName, ci->skinName ) ) - { - if( cg_buildScript.integer ) - CG_Error( "CG_RegisterClientModelname( %s, %s ) failed", ci->modelName, ci->skinName ); - - // fall back - if( !CG_RegisterClientModelname( ci, DEFAULT_MODEL, "default" ) ) - CG_Error( "DEFAULT_MODEL (%s) failed to register", DEFAULT_MODEL ); - } + CG_Error( "CG_RegisterClientModelname( %s, %s ) failed", ci->modelName, ci->skinName ); // sounds dir = ci->modelName; - fallback = DEFAULT_MODEL; for( i = 0; i < MAX_CUSTOM_SOUNDS; i++ ) { @@ -578,15 +561,11 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) s = cg_customSoundNames[ 0 ]; //death1 ci->sounds[ i ] = trap_S_RegisterSound( va( "sound/player/%s/%s", dir, s + 1 ), qfalse ); - if( !ci->sounds[ i ] ) - ci->sounds[ i ] = trap_S_RegisterSound( va( "sound/player/%s/%s", fallback, s + 1 ), qfalse ); } } else { ci->sounds[ i ] = trap_S_RegisterSound( va( "sound/player/%s/%s", dir, s + 1 ), qfalse ); - if( !ci->sounds[ i ] ) - ci->sounds[ i ] = trap_S_RegisterSound( va( "sound/player/%s/%s", fallback, s + 1 ), qfalse ); } } @@ -728,19 +707,12 @@ void CG_PrecacheClientInfo( pClass_t class, char *model, char *skin ) // model Q_strncpyz( newInfo.modelName, model, sizeof( newInfo.modelName ) ); - Q_strncpyz( newInfo.headModelName, model, sizeof( newInfo.headModelName ) ); - // modelName didn not include a skin name + // modelName did not include a skin name if( !skin ) - { Q_strncpyz( newInfo.skinName, "default", sizeof( newInfo.skinName ) ); - Q_strncpyz( newInfo.headSkinName, "default", sizeof( newInfo.headSkinName ) ); - } else - { Q_strncpyz( newInfo.skinName, skin, sizeof( newInfo.skinName ) ); - Q_strncpyz( newInfo.headSkinName, skin, sizeof( newInfo.headSkinName ) ); - } newInfo.infoValid = qtrue; @@ -786,34 +758,14 @@ void CG_NewClientInfo( int clientNum ) v = Info_ValueForKey( configstring, "c2" ); CG_ColorFromString( v, newInfo.color2 ); - // bot skill - v = Info_ValueForKey( configstring, "skill" ); - newInfo.botSkill = atoi( v ); - // handicap v = Info_ValueForKey( configstring, "hc" ); newInfo.handicap = atoi( v ); - // wins - v = Info_ValueForKey( configstring, "w" ); - newInfo.wins = atoi( v ); - - // losses - v = Info_ValueForKey( configstring, "l" ); - newInfo.losses = atoi( v ); - // team v = Info_ValueForKey( configstring, "t" ); newInfo.team = atoi( v ); - // team task - v = Info_ValueForKey( configstring, "tt" ); - newInfo.teamTask = atoi( v ); - - // team leader - v = Info_ValueForKey( configstring, "tl" ); - newInfo.teamLeader = atoi( v ); - // model v = Info_ValueForKey( configstring, "model" ); Q_strncpyz( newInfo.modelName, v, sizeof( newInfo.modelName ) ); @@ -832,26 +784,6 @@ void CG_NewClientInfo( int clientNum ) *slash = 0; } - //CG_Printf( "NCI: %s\n", v ); - - // head model - v = Info_ValueForKey( configstring, "hmodel" ); - Q_strncpyz( newInfo.headModelName, v, sizeof( newInfo.headModelName ) ); - - slash = strchr( newInfo.headModelName, '/' ); - - if( !slash ) - { - // modelName didn not include a skin name - Q_strncpyz( newInfo.headSkinName, "default", sizeof( newInfo.headSkinName ) ); - } - else - { - Q_strncpyz( newInfo.headSkinName, slash + 1, sizeof( newInfo.headSkinName ) ); - // truncate modelName - *slash = 0; - } - // replace whatever was there with the new one newInfo.infoValid = qtrue; *ci = newInfo; diff --git a/src/cgame/cg_tutorial.c b/src/cgame/cg_tutorial.c index 9997abcd..21242a75 100644 --- a/src/cgame/cg_tutorial.c +++ b/src/cgame/cg_tutorial.c @@ -646,6 +646,7 @@ const char *CG_TutorialText( void ) break; case PCL_HUMAN: + case PCL_HUMAN_BSUIT: CG_HumanText( text, ps ); break; 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 diff --git a/src/game/g_client.c b/src/game/g_client.c index bed2fefd..66ba3b6f 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -944,7 +944,7 @@ if desired. void ClientUserinfoChanged( int clientNum ) { gentity_t *ent; - int teamTask, teamLeader, health; + int health; char *s; char model[ MAX_QPATH ]; char buffer[ MAX_QPATH ]; @@ -974,14 +974,6 @@ void ClientUserinfoChanged( int clientNum ) if( !strcmp( s, "localhost" ) ) client->pers.localClient = qtrue; - // check the item prediction - s = Info_ValueForKey( userinfo, "cg_predictItems" ); - - if( !atoi( s ) ) - client->pers.predictItemPickup = qfalse; - else - client->pers.predictItemPickup = qtrue; - // set name Q_strncpyz( oldname, client->pers.netname, sizeof( oldname ) ); s = Info_ValueForKey( userinfo, "name" ); @@ -1118,16 +1110,11 @@ void ClientUserinfoChanged( int clientNum ) // teamInfo s = Info_ValueForKey( userinfo, "teamoverlay" ); - if( ! *s || atoi( s ) != 0 ) + if( !*s || atoi( s ) != 0 ) client->pers.teamInfo = qtrue; else client->pers.teamInfo = qfalse; - // team task (0 = none, 1 = offence, 2 = defence) - teamTask = atoi( Info_ValueForKey( userinfo, "teamtask" ) ); - // team Leader (1 = leader, 0 is normal player) - teamLeader = client->sess.teamLeader; - // colors strcpy( c1, Info_ValueForKey( userinfo, "color1" ) ); strcpy( c2, Info_ValueForKey( userinfo, "color2" ) ); @@ -1141,12 +1128,10 @@ void ClientUserinfoChanged( int clientNum ) // print scoreboards, display models, and play custom sounds Com_sprintf( userinfo, sizeof( userinfo ), - "n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\c1\\%s\\c2\\%s\\" - "hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\" - "tl\\%d\\ig\\%16s", - client->pers.netname, team, model, model, c1, c2, - client->pers.maxHealth, client->sess.wins, client->sess.losses, teamTask, - teamLeader, BG_ClientListString( &client->sess.ignoreList ) ); + "n\\%s\\t\\%i\\model\\%s\\c1\\%s\\c2\\%s\\" + "hc\\%i\\ig\\%16s", + client->pers.netname, team, model, c1, c2, + client->pers.maxHealth, BG_ClientListString( &client->sess.ignoreList ) ); trap_SetConfigstring( CS_PLAYERS + clientNum, userinfo ); diff --git a/src/game/g_local.h b/src/game/g_local.h index 643757aa..54600578 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -322,7 +322,6 @@ typedef struct usercmd_t cmd; // we would lose angles if not persistant qboolean localClient; // true if "ip" info key is "localhost" qboolean initialSpawn; // the first spawn should be at a cool location - qboolean predictItemPickup; // based on cg_predictItems userinfo qboolean pmoveFixed; // char netname[ MAX_NETNAME ]; int maxHealth; // for handicapping diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index 7e6c40cd..59332068 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -683,10 +683,12 @@ MISC // vsnprintf is ISO/IEC 9899:1999 // abstracting this to make it portable -#ifdef WIN32 +#ifdef _WIN32 #define Q_vsnprintf _vsnprintf +#define Q_snprintf _snprintf #else #define Q_vsnprintf vsnprintf +#define Q_snprintf snprintf #endif // returned by Sys_GetProcessorFeatures diff --git a/src/sdl/sdl_gamma.c b/src/sdl/sdl_gamma.c index 70e00b25..0b63b85a 100644 --- a/src/sdl/sdl_gamma.c +++ b/src/sdl/sdl_gamma.c @@ -48,23 +48,25 @@ void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned #include <windows.h> // Win2K and newer put this odd restriction on gamma ramps... - OSVERSIONINFO vinfo; - - vinfo.dwOSVersionInfoSize = sizeof( vinfo ); - GetVersionEx( &vinfo ); - if( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) { - Com_DPrintf( "performing gamma clamp.\n" ); - for( j = 0 ; j < 3 ; j++ ) + OSVERSIONINFO vinfo; + + vinfo.dwOSVersionInfoSize = sizeof( vinfo ); + GetVersionEx( &vinfo ); + if( vinfo.dwMajorVersion >= 5 && vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT ) { - for( i = 0 ; i < 128 ; i++ ) + Com_DPrintf( "performing gamma clamp.\n" ); + for( j = 0 ; j < 3 ; j++ ) { - if( table[ j ] [ i] > ( ( 128 + i ) << 8 ) ) - table[ j ][ i ] = ( 128 + i ) << 8; - } + for( i = 0 ; i < 128 ; i++ ) + { + if( table[ j ] [ i] > ( ( 128 + i ) << 8 ) ) + table[ j ][ i ] = ( 128 + i ) << 8; + } - if( table[ j ] [127 ] > 254 << 8 ) - table[ j ][ 127 ] = 254 << 8; + if( table[ j ] [127 ] > 254 << 8 ) + table[ j ][ 127 ] = 254 << 8; + } } } #endif diff --git a/src/sdl/sdl_glimp.c b/src/sdl/sdl_glimp.c index a980b0ed..1f5c3434 100644 --- a/src/sdl/sdl_glimp.c +++ b/src/sdl/sdl_glimp.c @@ -115,6 +115,7 @@ static int GLimp_SetMode( int mode, qboolean fullscreen ) int tcolorbits, tdepthbits, tstencilbits; int i = 0; SDL_Surface *vidscreen = NULL; + Uint32 flags = SDL_OPENGL; ri.Printf( PRINT_ALL, "Initializing OpenGL display\n"); @@ -127,7 +128,6 @@ static int GLimp_SetMode( int mode, qboolean fullscreen ) } ri.Printf( PRINT_ALL, " %d %d\n", glConfig.vidWidth, glConfig.vidHeight); - Uint32 flags = SDL_OPENGL; if (fullscreen) { flags |= SDL_FULLSCREEN; diff --git a/src/sdl/sdl_input.c b/src/sdl/sdl_input.c index 6ad660bc..1e2ca988 100644 --- a/src/sdl/sdl_input.c +++ b/src/sdl/sdl_input.c @@ -651,7 +651,7 @@ static void IN_ProcessEvents( void ) if( !SDL_WasInit( SDL_INIT_VIDEO ) ) return; - if( cls.keyCatchers == 0 && keyRepeatEnabled ) + if( Key_GetCatcher( ) == 0 && keyRepeatEnabled ) { SDL_EnableKeyRepeat( 0, 0 ); keyRepeatEnabled = qfalse; @@ -730,7 +730,7 @@ void IN_Frame (void) IN_JoyMove( ); // Release the mouse if the console if down and we're windowed - if( ( cls.keyCatchers & KEYCATCH_CONSOLE ) && !r_fullscreen->integer ) + if( ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) && !r_fullscreen->integer ) IN_DeactivateMouse( ); else IN_ActivateMouse( ); diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c index b235c6c0..3f3bd7d5 100644 --- a/src/sys/sys_main.c +++ b/src/sys/sys_main.c @@ -463,7 +463,7 @@ void *Sys_LoadDll( const char *name, char *fqpath , assert( name ); getcwd(curpath, sizeof(curpath)); - snprintf (fname, sizeof(fname), "%s" ARCH_STRING DLL_EXT, name); + Q_snprintf (fname, sizeof(fname), "%s" ARCH_STRING DLL_EXT, name); // TODO: use fs_searchpaths from files.c pwdpath = Sys_Cwd(); diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index 0af801a0..768008f6 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -1612,7 +1612,7 @@ static const char *UI_AIFromName(const char *name) { return uiInfo.aliasList[j].ai; } } - return "James"; + return ""; } static qboolean updateOpponentModel = qtrue; @@ -3926,7 +3926,7 @@ static void UI_RunMenuScript(char **args) { UI_BuildServerDisplayList(qtrue); } else { Menus_CloseByName("joinserver"); - Menus_OpenByName("main"); + Menus_ActivateByName("main"); } } else if (Q_stricmp(name, "StopRefresh") == 0) { UI_StopServerRefresh(); @@ -6092,7 +6092,7 @@ static cvarTable_t cvarTable[] = { { &ui_captureLimit, "ui_captureLimit", "5", 0}, { &ui_smallFont, "ui_smallFont", "0.2", CVAR_ARCHIVE}, { &ui_bigFont, "ui_bigFont", "0.5", CVAR_ARCHIVE}, - { &ui_findPlayer, "ui_findPlayer", "Sarge", CVAR_ARCHIVE}, + { &ui_findPlayer, "ui_findPlayer", "", CVAR_ARCHIVE}, { &ui_Q3Model, "ui_q3model", "0", CVAR_ARCHIVE}, { &ui_hudFiles, "cg_hudFiles", "ui/hud.txt", CVAR_ARCHIVE}, { &ui_recordSPDemo, "ui_recordSPDemo", "0", CVAR_ARCHIVE}, diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c index 0bb5b748..0a8a3c25 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -1014,17 +1014,6 @@ menuDef_t *Menus_FindByName(const char *p) { return NULL; } -void Menus_ShowByName(const char *p) { - menuDef_t *menu = Menus_FindByName(p); - if (menu) { - Menus_Activate(menu); - } -} - -void Menus_OpenByName(const char *p) { - Menus_ActivateByName(p); -} - static void Menu_RunCloseScript(menuDef_t *menu) { if (menu && menu->window.flags & WINDOW_VISIBLE && menu->onClose) { itemDef_t item; @@ -1033,20 +1022,29 @@ static void Menu_RunCloseScript(menuDef_t *menu) { } } -void Menus_CloseByName(const char *p) { - menuDef_t *menu = Menus_FindByName(p); +static void Menus_Close( menuDef_t *menu ) +{ if (menu != NULL) { Menu_RunCloseScript(menu); menu->window.flags &= ~(WINDOW_VISIBLE | WINDOW_HASFOCUS); + + openMenuCount--; + if( openMenuCount > 0 ) + Menus_Activate( menuStack[ openMenuCount - 1 ] ); } } +void Menus_CloseByName(const char *p) { + Menus_Close( Menus_FindByName(p) ); +} + void Menus_CloseAll( void ) { int i; for (i = 0; i < menuCount; i++) { - Menu_RunCloseScript(&Menus[i]); - Menus[i].window.flags &= ~(WINDOW_HASFOCUS | WINDOW_VISIBLE); + Menus_Close(&Menus[i]); } + + openMenuCount = 0; } @@ -1083,7 +1081,7 @@ void Script_FadeOut(itemDef_t *item, char **args) { void Script_Open(itemDef_t *item, char **args) { const char *name; if (String_Parse(args, &name)) { - Menus_OpenByName(name); + Menus_ActivateByName(name); } } @@ -1096,9 +1094,9 @@ void Script_ConditionalOpen(itemDef_t *item, char **args) { if ( String_Parse(args, &cvar) && String_Parse(args, &name1) && String_Parse(args, &name2) ) { val = DC->getCVarValue( cvar ); if ( val == 0.f ) { - Menus_OpenByName(name2); + Menus_ActivateByName(name2); } else { - Menus_OpenByName(name1); + Menus_ActivateByName(name1); } } } @@ -2549,21 +2547,47 @@ static void Display_CloseCinematics( void ) { } } -void Menus_Activate(menuDef_t *menu) { +void Menus_Activate( menuDef_t *menu ) +{ + int i; + qboolean onTopOfMenuStack = qfalse; + + if( openMenuCount > 0 && menuStack[ openMenuCount - 1 ] == menu ) + onTopOfMenuStack = qtrue; + menu->window.flags |= (WINDOW_HASFOCUS | WINDOW_VISIBLE); - if (menu->onOpen) { - itemDef_t item; - item.parent = menu; - Item_RunScript(&item, menu->onOpen); - } - if (menu->soundName && *menu->soundName) { -// DC->stopBackgroundTrack(); // you don't want to do this since it will reset s_rawend - DC->startBackgroundTrack(menu->soundName, menu->soundName); - } + // If being opened for the first time + if( !onTopOfMenuStack ) + { + if( menu->onOpen ) + { + itemDef_t item; + item.parent = menu; + Item_RunScript( &item, menu->onOpen ); + } + + if( menu->soundName && *menu->soundName ) + DC->startBackgroundTrack(menu->soundName, menu->soundName); - Display_CloseCinematics(); + Display_CloseCinematics( ); + Menu_HandleMouseMove( menu, DC->cursorx, DC->cursory ); // force the item under the cursor to focus + + for( i = 0; i < menu->itemCount; i++ ) // reset selection in listboxes when opened + { + if( menu->items[ i ]->type == ITEM_TYPE_LISTBOX ) + { + listBoxDef_t *listPtr = (listBoxDef_t*)menu->items[ i ]->typeData; + menu->items[ i ]->cursorPos = 0; + listPtr->startPos = 0; + DC->feederSelection( menu->items[ i ]->special, 0 ); + } + } + + if( openMenuCount < MAX_OPEN_MENUS ) + menuStack[ openMenuCount++ ] = menu; + } } int Display_VisibleMenuCount( void ) { @@ -2584,14 +2608,12 @@ void Menus_HandleOOBClick(menuDef_t *menu, int key, qboolean down) { // the cursor is within any of them.. if not close them otherwise activate them and pass the // key on.. force a mouse move to activate focus and script stuff if (down && menu->window.flags & WINDOW_OOB_CLICK) { - Menu_RunCloseScript(menu); - menu->window.flags &= ~(WINDOW_HASFOCUS | WINDOW_VISIBLE); + Menus_Close( menu ); } for (i = 0; i < menuCount; i++) { if (Menu_OverActiveItem(&Menus[i], DC->cursorx, DC->cursory)) { - Menu_RunCloseScript(menu); - menu->window.flags &= ~(WINDOW_HASFOCUS | WINDOW_VISIBLE); + Menus_Close( menu ); Menus_Activate(&Menus[i]); Menu_HandleMouseMove(&Menus[i], DC->cursorx, DC->cursory); Menu_HandleKey(&Menus[i], key, down); @@ -3968,14 +3990,14 @@ void Item_ListBox_Paint(itemDef_t *item) { x = item->window.rect.x + 1; y = item->window.rect.y + 1; for (i = listPtr->startPos; i < count; i++) { - const char *text; + char text[ MAX_STRING_CHARS ]; // always draw at least one // which may overdraw the box if it is too small for the element if (listPtr->numColumns > 0) { int j; for (j = 0; j < listPtr->numColumns; j++) { - text = DC->feederItemText(item->special, i, j, &optionalImage); + Q_strncpyz( text, DC->feederItemText(item->special, i, j, &optionalImage), sizeof( text ) ); if (optionalImage >= 0) { DC->drawHandlePic(x + 4 + listPtr->columnInfo[j].pos, y - 1 + listPtr->elementHeight / 2, listPtr->columnInfo[j].width, listPtr->columnInfo[j].width, optionalImage); } else if (text) { @@ -3983,6 +4005,13 @@ void Item_ListBox_Paint(itemDef_t *item) { tw = DC->textWidth( text, item->textscale, 0 ); + // Shorten the string if it's too long + while( tw > listPtr->columnInfo[ j ].width ) + { + text[ strlen( text ) - 1 ] = '\0'; + tw = DC->textWidth( text, item->textscale, 0 ); + } + switch( listPtr->columnInfo[ j ].align ) { case ITEM_ALIGN_LEFT: @@ -4003,11 +4032,11 @@ void Item_ListBox_Paint(itemDef_t *item) { DC->drawText( x + 4 + listPtr->columnInfo[j].pos + alignOffset, y + listPtr->elementHeight, item->textscale, item->window.foreColor, text, 0, - listPtr->columnInfo[j].maxChars, item->textStyle ); + 0, item->textStyle ); } } } else { - text = DC->feederItemText(item->special, i, 0, &optionalImage); + Q_strncpyz( text, DC->feederItemText(item->special, i, 0, &optionalImage), sizeof( text ) ); if (optionalImage >= 0) { //DC->drawHandlePic(x + 4 + listPtr->elementHeight, y, listPtr->columnInfo[j].width, listPtr->columnInfo[j].width, optionalImage); } else if (text) { @@ -4366,35 +4395,25 @@ qboolean Menus_AnyFullScreenVisible( void ) { } menuDef_t *Menus_ActivateByName(const char *p) { - int i, j; + int i; menuDef_t *m = NULL; - menuDef_t *focus = Menu_GetFocused(); + // Activate one menu for (i = 0; i < menuCount; i++) { if (Q_stricmp(Menus[i].window.name, p) == 0) { m = &Menus[i]; Menus_Activate(m); - Menu_HandleMouseMove( m, DC->cursorx, DC->cursory ); // force the item under the cursor to focus - - for( j = 0; j < m->itemCount; j++ ) // reset selection in listboxes when opened - { - if( m->items[ j ]->type == ITEM_TYPE_LISTBOX ) - { - listBoxDef_t *listPtr = (listBoxDef_t*)m->items[ j ]->typeData; - m->items[ j ]->cursorPos = 0; - listPtr->startPos = 0; - DC->feederSelection( m->items[ j ]->special, 0 ); - } - } + break; + } + } - if (openMenuCount < MAX_OPEN_MENUS && focus != NULL) { - menuStack[openMenuCount++] = focus; - } - } else { + // Defocus the others + for (i = 0; i < menuCount; i++) { + if (Q_stricmp(Menus[i].window.name, p) != 0) { Menus[i].window.flags &= ~WINDOW_HASFOCUS; } } - Display_CloseCinematics(); + return m; } @@ -4861,16 +4880,14 @@ qboolean ItemParse_columns( itemDef_t *item, int handle ) { } listPtr->numColumns = num; for (i = 0; i < num; i++) { - int pos, width, maxChars, align; + int pos, width, align; if( PC_Int_Parse( handle, &pos ) && PC_Int_Parse( handle, &width ) && - PC_Int_Parse( handle, &maxChars ) && PC_Int_Parse( handle, &align ) ) { listPtr->columnInfo[i].pos = pos; listPtr->columnInfo[i].width = width; - listPtr->columnInfo[i].maxChars = maxChars; listPtr->columnInfo[i].align = align; } else { return qfalse; diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h index 81d629b5..2fd396d0 100644 --- a/src/ui/ui_shared.h +++ b/src/ui/ui_shared.h @@ -170,7 +170,6 @@ typedef struct { typedef struct columnInfo_s { int pos; int width; - int maxChars; int align; } columnInfo_t; @@ -420,9 +419,7 @@ void *Display_CaptureItem(int x, int y); qboolean Display_MouseMove(void *p, int x, int y); int Display_CursorType(int x, int y); qboolean Display_KeyBindPending( void ); -void Menus_OpenByName(const char *p); menuDef_t *Menus_FindByName(const char *p); -void Menus_ShowByName(const char *p); void Menus_CloseByName(const char *p); void Display_HandleKey(int key, qboolean down, int x, int y); void LerpColor(vec4_t a, vec4_t b, vec4_t c, float t); |