mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: add con_showcompletion feature from FTEQW
This commit is contained in:
@@ -33,6 +33,7 @@ static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number
|
|||||||
static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
||||||
static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in menu or screenshots, doesn't affect console" );
|
static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in menu or screenshots, doesn't affect console" );
|
||||||
static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" );
|
static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" );
|
||||||
|
static CVAR_DEFINE_AUTO( con_showcompletion, "1", FCVAR_ARCHIVE, "perform simplified autocompletion while typing" );
|
||||||
|
|
||||||
static int g_codepage = 0;
|
static int g_codepage = 0;
|
||||||
|
|
||||||
@@ -130,6 +131,7 @@ typedef struct
|
|||||||
|
|
||||||
// console input
|
// console input
|
||||||
field_t input;
|
field_t input;
|
||||||
|
field_t input_completion;
|
||||||
|
|
||||||
// chatfiled
|
// chatfiled
|
||||||
field_t chat;
|
field_t chat;
|
||||||
@@ -786,6 +788,7 @@ void Con_Init( void )
|
|||||||
Cvar_RegisterVariable( &con_color );
|
Cvar_RegisterVariable( &con_color );
|
||||||
Cvar_RegisterVariable( &scr_drawversion );
|
Cvar_RegisterVariable( &scr_drawversion );
|
||||||
Cvar_RegisterVariable( &con_oldfont );
|
Cvar_RegisterVariable( &con_oldfont );
|
||||||
|
Cvar_RegisterVariable( &con_showcompletion );
|
||||||
|
|
||||||
// init the console buffer
|
// init the console buffer
|
||||||
con.bufsize = CON_TEXTSIZE;
|
con.bufsize = CON_TEXTSIZE;
|
||||||
@@ -1261,36 +1264,34 @@ static void Field_CharEvent( field_t *edit, int ch )
|
|||||||
Field_DrawInputLine
|
Field_DrawInputLine
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
static void Field_DrawInputLine( int x, int y, const field_t *edit )
|
static int Field_DrawInputLine( int x, int y, const field_t *edit, byte alpha, qboolean cursor )
|
||||||
{
|
{
|
||||||
int curPos;
|
int curPos;
|
||||||
char str[MAX_SYSPATH];
|
char str[MAX_SYSPATH];
|
||||||
const byte *colorDefault = g_color_table[ColorIndex( COLOR_DEFAULT )];
|
rgba_t colorDefault;
|
||||||
const int prestep = bound( 0, edit->scroll, sizeof( edit->buffer ) - 1 );
|
const int prestep = bound( 0, edit->scroll, sizeof( edit->buffer ) - 1 );
|
||||||
const int drawLen = bound( 0, edit->widthInChars, sizeof( str ));
|
const int drawLen = bound( 0, edit->widthInChars, sizeof( str ));
|
||||||
const int cursorCharPos = bound( 0, edit->cursor - prestep, sizeof( str ));
|
const int cursorCharPos = bound( 0, edit->cursor - prestep, sizeof( str ));
|
||||||
|
|
||||||
str[0] = 0;
|
memcpy( colorDefault, g_color_table[ColorIndex( COLOR_DEFAULT )], 3 * sizeof( colorDefault[0] ));
|
||||||
|
colorDefault[3] = alpha;
|
||||||
|
|
||||||
Q_strncpy( str, edit->buffer + prestep, drawLen );
|
Q_strncpy( str, edit->buffer + prestep, drawLen );
|
||||||
|
|
||||||
// draw it
|
// draw it
|
||||||
CL_DrawString( x, y, str, colorDefault, con.curFont, FONT_DRAW_UTF8 );
|
CL_DrawString( x, y, str, colorDefault, con.curFont, FONT_DRAW_UTF8 );
|
||||||
|
|
||||||
// draw the cursor
|
|
||||||
if((int)( host.realtime * 4 ) & 1 ) return; // off blink
|
|
||||||
|
|
||||||
// calc cursor position
|
// calc cursor position
|
||||||
str[cursorCharPos] = 0;
|
str[cursorCharPos] = 0;
|
||||||
CL_DrawStringLen( con.curFont, str, &curPos, NULL, FONT_DRAW_UTF8 );
|
CL_DrawStringLen( con.curFont, str, &curPos, NULL, FONT_DRAW_UTF8 );
|
||||||
|
|
||||||
if( host.key_overstrike )
|
// draw the cursor
|
||||||
{
|
if( !cursor || (int)( host.realtime * 4 ) & 1 )
|
||||||
CL_DrawCharacter( x + curPos, y, '|', colorDefault, con.curFont, 0 );
|
return curPos; // off blink
|
||||||
}
|
|
||||||
else
|
CL_DrawCharacter( x + curPos, y, host.key_overstrike ? '|' : '_', colorDefault, con.curFont, 0 );
|
||||||
{
|
|
||||||
CL_DrawCharacter( x + curPos, y, '_', colorDefault, con.curFont, 0 );
|
return curPos;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1479,6 +1480,17 @@ CONSOLE LINE EDITING
|
|||||||
|
|
||||||
=============================================================================
|
=============================================================================
|
||||||
*/
|
*/
|
||||||
|
static void Con_InputCompletion( void )
|
||||||
|
{
|
||||||
|
if( !con_showcompletion.value )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// keep a copy of console input
|
||||||
|
con.input_completion = con.input;
|
||||||
|
|
||||||
|
Con_CompleteCommand( &con.input_completion, false );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
Key_Console
|
Key_Console
|
||||||
@@ -1526,6 +1538,7 @@ void Key_Console( int key )
|
|||||||
Con_ClearField( &con.input );
|
Con_ClearField( &con.input );
|
||||||
con.input.widthInChars = con.linewidth;
|
con.input.widthInChars = con.linewidth;
|
||||||
Con_Bottom();
|
Con_Bottom();
|
||||||
|
Con_ClearField( &con.input_completion );
|
||||||
|
|
||||||
if( cls.state == ca_disconnected )
|
if( cls.state == ca_disconnected )
|
||||||
{
|
{
|
||||||
@@ -1538,8 +1551,9 @@ void Key_Console( int key )
|
|||||||
// command completion
|
// command completion
|
||||||
if( key == K_TAB || key == K_L2_BUTTON )
|
if( key == K_TAB || key == K_L2_BUTTON )
|
||||||
{
|
{
|
||||||
Con_CompleteCommand( &con.input );
|
Con_CompleteCommand( &con.input, true );
|
||||||
Con_Bottom();
|
Con_Bottom();
|
||||||
|
Con_ClearField( &con.input_completion );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1547,12 +1561,14 @@ void Key_Console( int key )
|
|||||||
if(( key == K_MWHEELUP && Key_IsDown( K_SHIFT )) || ( key == K_UPARROW ) || (( Q_tolower(key) == 'p' ) && Key_IsDown( K_CTRL )))
|
if(( key == K_MWHEELUP && Key_IsDown( K_SHIFT )) || ( key == K_UPARROW ) || (( Q_tolower(key) == 'p' ) && Key_IsDown( K_CTRL )))
|
||||||
{
|
{
|
||||||
Con_HistoryUp( &con.history, &con.input );
|
Con_HistoryUp( &con.history, &con.input );
|
||||||
|
Con_InputCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(( key == K_MWHEELDOWN && Key_IsDown( K_SHIFT )) || ( key == K_DOWNARROW ) || (( Q_tolower(key) == 'n' ) && Key_IsDown( K_CTRL )))
|
if(( key == K_MWHEELDOWN && Key_IsDown( K_SHIFT )) || ( key == K_DOWNARROW ) || (( Q_tolower(key) == 'n' ) && Key_IsDown( K_CTRL )))
|
||||||
{
|
{
|
||||||
Con_HistoryDown( &con.history, &con.input );
|
Con_HistoryDown( &con.history, &con.input );
|
||||||
|
Con_InputCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1608,6 +1624,7 @@ void Key_Console( int key )
|
|||||||
|
|
||||||
// pass to the normal editline routine
|
// pass to the normal editline routine
|
||||||
Field_KeyDownEvent( &con.input, key );
|
Field_KeyDownEvent( &con.input, key );
|
||||||
|
Con_InputCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1663,7 +1680,7 @@ The input line scrolls horizontally if typing goes beyond the right edge
|
|||||||
*/
|
*/
|
||||||
static void Con_DrawInput( int lines )
|
static void Con_DrawInput( int lines )
|
||||||
{
|
{
|
||||||
int y;
|
int x, y;
|
||||||
|
|
||||||
// don't draw anything (always draw if not active)
|
// don't draw anything (always draw if not active)
|
||||||
if( cls.key_dest != key_console || !con.curFont )
|
if( cls.key_dest != key_console || !con.curFont )
|
||||||
@@ -1671,7 +1688,26 @@ static void Con_DrawInput( int lines )
|
|||||||
|
|
||||||
y = lines - ( con.curFont->charHeight * 2 );
|
y = lines - ( con.curFont->charHeight * 2 );
|
||||||
CL_DrawCharacter( con.curFont->charWidths[' '], y, ']', g_color_table[7], con.curFont, 0 );
|
CL_DrawCharacter( con.curFont->charWidths[' '], y, ']', g_color_table[7], con.curFont, 0 );
|
||||||
Field_DrawInputLine( con.curFont->charWidths[' ']*2, y, &con.input );
|
x = Field_DrawInputLine( con.curFont->charWidths[' ']*2, y, &con.input, 255, true );
|
||||||
|
|
||||||
|
// HACKHACK: avoid rendering issues when scroll != 0
|
||||||
|
if( con_showcompletion.value && con.input.scroll == 0 )
|
||||||
|
{
|
||||||
|
int len = Q_strlen( con.input.buffer );
|
||||||
|
|
||||||
|
if( FBitSet( con_showcompletion.flags, FCVAR_CHANGED ))
|
||||||
|
{
|
||||||
|
Con_InputCompletion();
|
||||||
|
ClearBits( con_showcompletion.flags, FCVAR_CHANGED );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Con_CompleteCommand destroys the buffer. Need to figure out how to make it append only
|
||||||
|
if( con.input_completion.buffer > len && !Q_strncmp( con.input.buffer, con.input_completion.buffer, len ))
|
||||||
|
{
|
||||||
|
con.input_completion.scroll = len;
|
||||||
|
Field_DrawInputLine( con.curFont->charWidths[' ']*2 + x, y, &con.input_completion, 128, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1803,7 +1839,7 @@ static void Con_DrawNotify( void )
|
|||||||
Con_DrawStringLen( buf, &len, NULL );
|
Con_DrawStringLen( buf, &len, NULL );
|
||||||
Con_DrawString( x, y, buf, g_color_table[7] );
|
Con_DrawString( x, y, buf, g_color_table[7] );
|
||||||
|
|
||||||
Field_DrawInputLine( x + len, y, &con.chat );
|
Field_DrawInputLine( x + len, y, &con.chat, 255, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
|
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
|
||||||
@@ -2150,6 +2186,7 @@ void Con_CharEvent( int key )
|
|||||||
if( cls.key_dest == key_console )
|
if( cls.key_dest == key_console )
|
||||||
{
|
{
|
||||||
Field_CharEvent( &con.input, key );
|
Field_CharEvent( &con.input, key );
|
||||||
|
Con_InputCompletion();
|
||||||
}
|
}
|
||||||
else if( cls.key_dest == key_message )
|
else if( cls.key_dest == key_message )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -473,7 +473,7 @@ static inline int Cmd_AddCommandWithFlags( const char *cmd_name, xcommand_t func
|
|||||||
void Cmd_RemoveCommand( const char *cmd_name );
|
void Cmd_RemoveCommand( const char *cmd_name );
|
||||||
cmd_t *Cmd_Exists( const char *cmd_name );
|
cmd_t *Cmd_Exists( const char *cmd_name );
|
||||||
void Cmd_LookupCmds( void *buffer, void *ptr, setpair_t callback );
|
void Cmd_LookupCmds( void *buffer, void *ptr, setpair_t callback );
|
||||||
int Cmd_ListMaps( search_t *t , char *lastmapname, size_t len );
|
int Cmd_ListMaps( search_t *t , char *lastmapname, size_t len, qboolean silent );
|
||||||
void Cmd_TokenizeString( const char *text );
|
void Cmd_TokenizeString( const char *text );
|
||||||
void Cmd_ExecuteString( const char *text );
|
void Cmd_ExecuteString( const char *text );
|
||||||
void Cmd_ForwardToServer( void );
|
void Cmd_ForwardToServer( void );
|
||||||
@@ -680,7 +680,7 @@ void pfnResetTutorMessageDecayData( void );
|
|||||||
//
|
//
|
||||||
// con_utils.c
|
// con_utils.c
|
||||||
//
|
//
|
||||||
void Con_CompleteCommand( field_t *field );
|
void Con_CompleteCommand( field_t *field, qboolean print_suggestions );
|
||||||
void Cmd_AutoComplete( char *complete_string );
|
void Cmd_AutoComplete( char *complete_string );
|
||||||
void Cmd_AutoCompleteClear( void );
|
void Cmd_AutoCompleteClear( void );
|
||||||
void Host_InitializeConfig( file_t *f, const char *config, const char *description );
|
void Host_InitializeConfig( file_t *f, const char *config, const char *description );
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ typedef struct autocomplete_list_s
|
|||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
int arg; // argument number to handle
|
int arg; // argument number to handle
|
||||||
qboolean (*func)( const char *s, char *name, int length );
|
qboolean (*func)( const char *s, char *name, int length, qboolean print_suggestions );
|
||||||
} autocomplete_list_t;
|
} autocomplete_list_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -53,7 +53,7 @@ Cmd_ListMaps
|
|||||||
|
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len )
|
int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len, qboolean silent )
|
||||||
{
|
{
|
||||||
file_t *f;
|
file_t *f;
|
||||||
int i, nummaps;
|
int i, nummaps;
|
||||||
@@ -86,7 +86,7 @@ int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len )
|
|||||||
filelen = FS_Read( f, buf, sizeof( buf ));
|
filelen = FS_Read( f, buf, sizeof( buf ));
|
||||||
|
|
||||||
// check all the lumps and some other errors
|
// check all the lumps and some other errors
|
||||||
if( !Mod_TestBmodelLumps( f, t->filenames[i], buf, filelen, true, &entities ))
|
if( !Mod_TestBmodelLumps( f, t->filenames[i], buf, filelen, silent, &entities ))
|
||||||
{
|
{
|
||||||
FS_Close( f );
|
FS_Close( f );
|
||||||
continue;
|
continue;
|
||||||
@@ -168,7 +168,8 @@ int Cmd_ListMaps( search_t *t, char *lastmapname, size_t len )
|
|||||||
default: Q_strncpy( version_description, "??", sizeof( version_description )); break;
|
default: Q_strncpy( version_description, "??", sizeof( version_description )); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "%16s (%s) ^3%s^7 ^2%s %s^7\n", mapname, version_description, message, compiler, generator );
|
if( !silent )
|
||||||
|
Con_Printf( "%16s (%s) ^3%s^7 ^2%s %s^7\n", mapname, version_description, message, compiler, generator );
|
||||||
nummaps++;
|
nummaps++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +186,7 @@ Cmd_GetMapList
|
|||||||
Prints or complete map filename
|
Prints or complete map filename
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetMapList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
search_t *t;
|
search_t *t;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -199,9 +200,10 @@ static qboolean Cmd_GetMapList( const char *s, char *completedname, int length )
|
|||||||
Q_strncpy( completedname, matchbuf, length );
|
Q_strncpy( completedname, matchbuf, length );
|
||||||
if( t->numfilenames == 1 ) return true;
|
if( t->numfilenames == 1 ) return true;
|
||||||
|
|
||||||
nummaps = Cmd_ListMaps( t, matchbuf, sizeof( matchbuf ));
|
nummaps = Cmd_ListMaps( t, matchbuf, sizeof( matchbuf ), !print_suggestions );
|
||||||
|
|
||||||
Con_Printf( "\n^3 %d maps found.\n", nummaps );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %d maps found.\n", nummaps );
|
||||||
|
|
||||||
Mem_Free( t );
|
Mem_Free( t );
|
||||||
|
|
||||||
@@ -221,7 +223,7 @@ Cmd_GetDemoList
|
|||||||
Prints or complete demo filename
|
Prints or complete demo filename
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetDemoList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetDemoList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
search_t *t;
|
search_t *t;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -242,11 +244,14 @@ static qboolean Cmd_GetDemoList( const char *s, char *completedname, int length
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
|
||||||
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
numdems++;
|
numdems++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i demos found.\n", numdems );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i demos found.\n", numdems );
|
||||||
Mem_Free( t );
|
Mem_Free( t );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
@@ -268,7 +273,7 @@ Cmd_GetMovieList
|
|||||||
Prints or complete movie filename
|
Prints or complete movie filename
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetMovieList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetMovieList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
search_t *t;
|
search_t *t;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -288,11 +293,13 @@ static qboolean Cmd_GetMovieList( const char *s, char *completedname, int length
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
nummovies++;
|
nummovies++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i movies found.\n", nummovies );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i movies found.\n", nummovies );
|
||||||
Mem_Free( t );
|
Mem_Free( t );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
@@ -315,7 +322,7 @@ Cmd_GetMusicList
|
|||||||
Prints or complete background track filename
|
Prints or complete background track filename
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetMusicList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetMusicList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
search_t *t;
|
search_t *t;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -337,11 +344,13 @@ static qboolean Cmd_GetMusicList( const char *s, char *completedname, int length
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
numtracks++;
|
numtracks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i soundtracks found.\n", numtracks );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i soundtracks found.\n", numtracks );
|
||||||
Mem_Free(t);
|
Mem_Free(t);
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
@@ -363,7 +372,7 @@ Cmd_GetSavesList
|
|||||||
Prints or complete savegame filename
|
Prints or complete savegame filename
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetSavesList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetSavesList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
search_t *t;
|
search_t *t;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -383,11 +392,13 @@ static qboolean Cmd_GetSavesList( const char *s, char *completedname, int length
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
numsaves++;
|
numsaves++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i saves found.\n", numsaves );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i saves found.\n", numsaves );
|
||||||
Mem_Free( t );
|
Mem_Free( t );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
@@ -410,7 +421,7 @@ Cmd_GetConfigList
|
|||||||
Prints or complete .cfg filename
|
Prints or complete .cfg filename
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetConfigList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetConfigList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
search_t *t;
|
search_t *t;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -430,11 +441,13 @@ static qboolean Cmd_GetConfigList( const char *s, char *completedname, int lengt
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
numconfigs++;
|
numconfigs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i configs found.\n", numconfigs );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i configs found.\n", numconfigs );
|
||||||
Mem_Free( t );
|
Mem_Free( t );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
@@ -457,7 +470,7 @@ Cmd_GetSoundList
|
|||||||
Prints or complete sound filename
|
Prints or complete sound filename
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
search_t *t;
|
search_t *t;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -481,11 +494,13 @@ static qboolean Cmd_GetSoundList( const char *s, char *completedname, int length
|
|||||||
|
|
||||||
Q_strncpy( matchbuf, t->filenames[i] + sizeof( DEFAULT_SOUNDPATH ) - 1, sizeof( matchbuf ));
|
Q_strncpy( matchbuf, t->filenames[i] + sizeof( DEFAULT_SOUNDPATH ) - 1, sizeof( matchbuf ));
|
||||||
COM_StripExtension( matchbuf );
|
COM_StripExtension( matchbuf );
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
numsounds++;
|
numsounds++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i sounds found.\n", numsounds );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i sounds found.\n", numsounds );
|
||||||
Mem_Free( t );
|
Mem_Free( t );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
@@ -508,7 +523,7 @@ Cmd_GetItemsList
|
|||||||
Prints or complete item classname (weapons only)
|
Prints or complete item classname (weapons only)
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetItemsList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetItemsList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
#if !XASH_DEDICATED
|
#if !XASH_DEDICATED
|
||||||
search_t *t;
|
search_t *t;
|
||||||
@@ -530,11 +545,13 @@ static qboolean Cmd_GetItemsList( const char *s, char *completedname, int length
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
numitems++;
|
numitems++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i items found.\n", numitems );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i items found.\n", numitems );
|
||||||
Mem_Free( t );
|
Mem_Free( t );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
@@ -558,7 +575,7 @@ Cmd_GetKeysList
|
|||||||
Autocomplete for bind command
|
Autocomplete for bind command
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetKeysList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetKeysList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
#if !XASH_DEDICATED
|
#if !XASH_DEDICATED
|
||||||
size_t i, numkeys;
|
size_t i, numkeys;
|
||||||
@@ -586,10 +603,12 @@ static qboolean Cmd_GetKeysList( const char *s, char *completedname, int length
|
|||||||
for( i = 0; i < numkeys; i++ )
|
for( i = 0; i < numkeys; i++ )
|
||||||
{
|
{
|
||||||
Q_strncpy( matchbuf, keys[i], sizeof( matchbuf ));
|
Q_strncpy( matchbuf, keys[i], sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %zu keys found.\n", numkeys );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %zu keys found.\n", numkeys );
|
||||||
|
|
||||||
if( completedname && length )
|
if( completedname && length )
|
||||||
{
|
{
|
||||||
@@ -648,7 +667,7 @@ Cmd_GetCommandsList
|
|||||||
Autocomplete for bind command
|
Autocomplete for bind command
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetCommandsAndCvarsList( const char *s, char *completedname, int length, qboolean cmds, qboolean cvars, qboolean toggle )
|
static qboolean Cmd_GetCommandsAndCvarsList( const char *s, char *completedname, int length, qboolean cmds, qboolean cvars, qboolean toggle, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -686,10 +705,12 @@ static qboolean Cmd_GetCommandsAndCvarsList( const char *s, char *completedname,
|
|||||||
for( i = 0; i < list.matchCount; i++ )
|
for( i = 0; i < list.matchCount; i++ )
|
||||||
{
|
{
|
||||||
Q_strncpy( matchbuf, list.cmds[i], sizeof( matchbuf ));
|
Q_strncpy( matchbuf, list.cmds[i], sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i %s found.\n", list.matchCount, cmds ? "commands" : "variables" );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i %s found.\n", list.matchCount, cmds ? "commands" : "variables" );
|
||||||
|
|
||||||
if( completedname && length )
|
if( completedname && length )
|
||||||
{
|
{
|
||||||
@@ -718,9 +739,9 @@ Cmd_GetCommandsList
|
|||||||
Autocomplete for bind command
|
Autocomplete for bind command
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetCommandsList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetCommandsList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
return Cmd_GetCommandsAndCvarsList( s, completedname, length, true, true, false );
|
return Cmd_GetCommandsAndCvarsList( s, completedname, length, true, true, false, print_suggestions );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -730,10 +751,10 @@ Cmd_GetCvarList
|
|||||||
Autocomplete for bind command
|
Autocomplete for bind command
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetCvarsList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetCvarsList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
qboolean toggle = !Q_stricmp( Cmd_Argv( 0 ), "toggle" );
|
qboolean toggle = !Q_stricmp( Cmd_Argv( 0 ), "toggle" );
|
||||||
return Cmd_GetCommandsAndCvarsList( s, completedname, length, false, true, toggle );
|
return Cmd_GetCommandsAndCvarsList( s, completedname, length, false, true, toggle, print_suggestions );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -743,7 +764,7 @@ Cmd_GetCustomList
|
|||||||
Prints or complete .HPK filenames
|
Prints or complete .HPK filenames
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetCustomList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetCustomList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
search_t *t;
|
search_t *t;
|
||||||
string matchbuf;
|
string matchbuf;
|
||||||
@@ -763,11 +784,13 @@ static qboolean Cmd_GetCustomList( const char *s, char *completedname, int lengt
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
COM_FileBase( t->filenames[i], matchbuf, sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
numitems++;
|
numitems++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i items found.\n", numitems );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i items found.\n", numitems );
|
||||||
Mem_Free( t );
|
Mem_Free( t );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
@@ -789,7 +812,7 @@ Cmd_GetGameList
|
|||||||
Prints or complete gamedir name
|
Prints or complete gamedir name
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
int i, numgamedirs;
|
int i, numgamedirs;
|
||||||
string gamedirs[MAX_MODS];
|
string gamedirs[MAX_MODS];
|
||||||
@@ -814,10 +837,12 @@ static qboolean Cmd_GetGamesList( const char *s, char *completedname, int length
|
|||||||
for( i = 0; i < numgamedirs; i++ )
|
for( i = 0; i < numgamedirs; i++ )
|
||||||
{
|
{
|
||||||
Q_strncpy( matchbuf, gamedirs[i], sizeof( matchbuf ));
|
Q_strncpy( matchbuf, gamedirs[i], sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i games found.\n", numgamedirs );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i games found.\n", numgamedirs );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
if( completedname && length )
|
if( completedname && length )
|
||||||
@@ -838,7 +863,7 @@ Cmd_GetCDList
|
|||||||
Prints or complete CD command name
|
Prints or complete CD command name
|
||||||
=====================================
|
=====================================
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
|
static qboolean Cmd_GetCDList( const char *s, char *completedname, int length, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
int i, numcdcommands;
|
int i, numcdcommands;
|
||||||
string cdcommands[8];
|
string cdcommands[8];
|
||||||
@@ -875,10 +900,12 @@ static qboolean Cmd_GetCDList( const char *s, char *completedname, int length )
|
|||||||
for( i = 0; i < numcdcommands; i++ )
|
for( i = 0; i < numcdcommands; i++ )
|
||||||
{
|
{
|
||||||
Q_strncpy( matchbuf, cdcommands[i], sizeof( matchbuf ));
|
Q_strncpy( matchbuf, cdcommands[i], sizeof( matchbuf ));
|
||||||
Con_Printf( "%16s\n", matchbuf );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "%16s\n", matchbuf );
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf( "\n^3 %i commands found.\n", numcdcommands );
|
if( print_suggestions )
|
||||||
|
Con_Printf( "\n^3 %i commands found.\n", numcdcommands );
|
||||||
|
|
||||||
// cut shortestMatch to the amount common with s
|
// cut shortestMatch to the amount common with s
|
||||||
if( completedname && length )
|
if( completedname && length )
|
||||||
@@ -1116,14 +1143,14 @@ Autocomplete filename
|
|||||||
for various cmds
|
for various cmds
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
static qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize )
|
static qboolean Cmd_AutocompleteName( const char *source, int arg, char *buffer, size_t bufsize, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for( i = 0; i < ARRAYSIZE( cmd_list ); i++ )
|
for( i = 0; i < ARRAYSIZE( cmd_list ); i++ )
|
||||||
{
|
{
|
||||||
if( cmd_list[i].arg == arg && Cmd_CheckName( cmd_list[i].name ))
|
if( cmd_list[i].arg == arg && Cmd_CheckName( cmd_list[i].name ))
|
||||||
return cmd_list[i].func( source, buffer, bufsize );
|
return cmd_list[i].func( source, buffer, bufsize, print_suggestions );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -1202,7 +1229,7 @@ Con_CompleteCommand
|
|||||||
perform Tab expansion
|
perform Tab expansion
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void Con_CompleteCommand( field_t *field )
|
void Con_CompleteCommand( field_t *field, qboolean print_suggestions )
|
||||||
{
|
{
|
||||||
field_t temp;
|
field_t temp;
|
||||||
string filename;
|
string filename;
|
||||||
@@ -1249,7 +1276,7 @@ void Con_CompleteCommand( field_t *field )
|
|||||||
temp = *con.completionField;
|
temp = *con.completionField;
|
||||||
|
|
||||||
// autocomplete second arg
|
// autocomplete second arg
|
||||||
if( (Cmd_Argc() >= 2) || ((Cmd_Argc() == 1) && nextcmd) )
|
if(( Cmd_Argc() >= 2 ) || ( Cmd_Argc() == 1 && nextcmd ))
|
||||||
{
|
{
|
||||||
con.completionBuffer = Cmd_Argv( Cmd_Argc() - 1 );
|
con.completionBuffer = Cmd_Argv( Cmd_Argc() - 1 );
|
||||||
|
|
||||||
@@ -1260,7 +1287,7 @@ void Con_CompleteCommand( field_t *field )
|
|||||||
if( !COM_CheckStringEmpty( con.completionBuffer ) )
|
if( !COM_CheckStringEmpty( con.completionBuffer ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( Cmd_AutocompleteName( con.completionBuffer, Cmd_Argc() - 1, filename, sizeof( filename ) ) )
|
if( Cmd_AutocompleteName( con.completionBuffer, Cmd_Argc() - 1, filename, sizeof( filename ), print_suggestions ))
|
||||||
{
|
{
|
||||||
con.completionField->buffer[0] = 0;
|
con.completionField->buffer[0] = 0;
|
||||||
|
|
||||||
@@ -1311,11 +1338,14 @@ void Con_CompleteCommand( field_t *field )
|
|||||||
con.completionField->cursor = Q_strlen( con.completionField->buffer );
|
con.completionField->cursor = Q_strlen( con.completionField->buffer );
|
||||||
Con_ConcatRemaining( temp.buffer, con.completionString );
|
Con_ConcatRemaining( temp.buffer, con.completionString );
|
||||||
|
|
||||||
Con_Printf( "]%s\n", con.completionField->buffer );
|
|
||||||
|
|
||||||
// run through again, printing matches
|
// run through again, printing matches
|
||||||
Cmd_LookupCmds( NULL, NULL, (setpair_t)Con_PrintCmdMatches );
|
if( print_suggestions )
|
||||||
Cvar_LookupVars( 0, NULL, NULL, (setpair_t)Con_PrintCvarMatches );
|
{
|
||||||
|
Con_Printf( "]%s\n", con.completionField->buffer );
|
||||||
|
|
||||||
|
Cmd_LookupCmds( NULL, NULL, (setpair_t)Con_PrintCmdMatches );
|
||||||
|
Cvar_LookupVars( 0, NULL, NULL, (setpair_t)Con_PrintCvarMatches );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1337,7 +1367,7 @@ void Cmd_AutoComplete( char *complete_string )
|
|||||||
Q_strncpy( input.buffer, complete_string, sizeof( input.buffer ) );
|
Q_strncpy( input.buffer, complete_string, sizeof( input.buffer ) );
|
||||||
input.cursor = input.scroll = 0;
|
input.cursor = input.scroll = 0;
|
||||||
|
|
||||||
Con_CompleteCommand( &input );
|
Con_CompleteCommand( &input, true );
|
||||||
|
|
||||||
// setup output
|
// setup output
|
||||||
if( input.buffer[0] == '\\' || input.buffer[0] == '/' )
|
if( input.buffer[0] == '\\' || input.buffer[0] == '/' )
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ static void SV_Maps_f( void )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nummaps = Cmd_ListMaps( mapList, NULL, 0 );
|
nummaps = Cmd_ListMaps( mapList, NULL, 0, false );
|
||||||
|
|
||||||
Mem_Free( mapList );
|
Mem_Free( mapList );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user