summaryrefslogtreecommitdiff
path: root/src/cl_console.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cl_console.c')
-rw-r--r--src/cl_console.c706
1 files changed, 373 insertions, 333 deletions
diff --git a/src/cl_console.c b/src/cl_console.c
index d91572b..175fde8 100644
--- a/src/cl_console.c
+++ b/src/cl_console.c
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@@ -23,10 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "prompt.h"
#define CON_TIMES 16
-#define CON_TIMES_MASK ( CON_TIMES - 1 )
+#define CON_TIMES_MASK (CON_TIMES - 1)
#define CON_TOTALLINES 1024 // total lines in console scrollback
-#define CON_TOTALLINES_MASK ( CON_TOTALLINES - 1 )
+#define CON_TOTALLINES_MASK (CON_TOTALLINES - 1)
#define CON_LINEWIDTH 100 // fixed width, do not need more
@@ -58,7 +58,7 @@ typedef struct console_s {
float scale;
unsigned times[CON_TIMES]; // cls.realtime time the line was generated
- // for transparent notify lines
+ // for transparent notify lines
qboolean skipNotify;
qhandle_t backImage;
@@ -97,7 +97,8 @@ static cvar_t *con_history;
Con_SkipNotify
================
*/
-void Con_SkipNotify( qboolean skip ) {
+void Con_SkipNotify(qboolean skip)
+{
con.skipNotify = skip;
}
@@ -106,10 +107,11 @@ void Con_SkipNotify( qboolean skip ) {
Con_ClearTyping
================
*/
-void Con_ClearTyping( void ) {
+void Con_ClearTyping(void)
+{
// clear any typing
- IF_Clear( &con.prompt.inputLine );
- Prompt_ClearState( &con.prompt );
+ IF_Clear(&con.prompt.inputLine);
+ Prompt_ClearState(&con.prompt);
}
/*
@@ -120,15 +122,16 @@ Instantly removes the console. Unless `force' is true, does not remove the conso
if user has typed something into it since the last call to Con_Popup.
================
*/
-void Con_Close( qboolean force ) {
- if( con.mode && !force ) {
+void Con_Close(qboolean force)
+{
+ if (con.mode && !force) {
return;
}
Con_ClearTyping();
Con_ClearNotify_f();
- Key_SetDest( cls.key_dest & ~KEY_CONSOLE );
+ Key_SetDest(cls.key_dest & ~KEY_CONSOLE);
con.destHeight = con.currentHeight = 0;
con.mode = CON_DEFAULT;
@@ -142,12 +145,13 @@ Con_Popup
Drop to connection screen.
================
*/
-void Con_Popup( void ) {
- if( con.mode == CON_DEFAULT ) {
+void Con_Popup(void)
+{
+ if (con.mode == CON_DEFAULT) {
con.mode = CON_POPUP;
}
- Key_SetDest( cls.key_dest | KEY_CONSOLE );
+ Key_SetDest(cls.key_dest | KEY_CONSOLE);
Con_RunConsole();
}
@@ -158,40 +162,44 @@ Con_ToggleConsole_f
Toggles console up/down animation.
================
*/
-static void toggle_console( consoleMode_t mode, chatMode_t chat ) {
+static void toggle_console(consoleMode_t mode, chatMode_t chat)
+{
SCR_EndLoadingPlaque(); // get rid of loading plaque
Con_ClearTyping();
Con_ClearNotify_f();
- if( cls.key_dest & KEY_CONSOLE ) {
- Key_SetDest( cls.key_dest & ~KEY_CONSOLE );
+ if (cls.key_dest & KEY_CONSOLE) {
+ Key_SetDest(cls.key_dest & ~KEY_CONSOLE);
con.mode = CON_DEFAULT;
con.chat = CHAT_NONE;
return;
}
- if( mode == CON_CHAT && ( cls.state != ca_active || cls.demo.playback ) ) {
- Com_Printf( "You must be in a level to chat.\n" );
+ if (mode == CON_CHAT && (cls.state != ca_active || cls.demo.playback)) {
+ Com_Printf("You must be in a level to chat.\n");
return;
}
// toggling console discards chat message
- Key_SetDest( ( cls.key_dest | KEY_CONSOLE ) & ~KEY_MESSAGE );
+ Key_SetDest((cls.key_dest | KEY_CONSOLE) & ~KEY_MESSAGE);
con.mode = mode;
con.chat = chat;
}
-void Con_ToggleConsole_f( void ) {
- toggle_console( CON_DEFAULT, CHAT_NONE );
+void Con_ToggleConsole_f(void)
+{
+ toggle_console(CON_DEFAULT, CHAT_NONE);
}
-static void Con_ToggleChat_f( void ) {
- toggle_console( CON_CHAT, CHAT_DEFAULT );
+static void Con_ToggleChat_f(void)
+{
+ toggle_console(CON_CHAT, CHAT_DEFAULT);
}
-static void Con_ToggleChat2_f( void ) {
- toggle_console( CON_CHAT, CHAT_TEAM );
+static void Con_ToggleChat2_f(void)
+{
+ toggle_console(CON_CHAT, CHAT_TEAM);
}
/*
@@ -199,14 +207,16 @@ static void Con_ToggleChat2_f( void ) {
Con_Clear_f
================
*/
-static void Con_Clear_f( void ) {
- memset( con.text, 0, sizeof( con.text ) );
+static void Con_Clear_f(void)
+{
+ memset(con.text, 0, sizeof(con.text));
con.display = con.current;
}
-static void Con_Dump_c( genctx_t *ctx, int argnum ) {
- if( argnum == 1 ) {
- FS_File_g( "condumps", ".txt", FS_SEARCH_STRIPEXT, ctx );
+static void Con_Dump_c(genctx_t *ctx, int argnum)
+{
+ if (argnum == 1) {
+ FS_File_g("condumps", ".txt", FS_SEARCH_STRIPEXT, ctx);
}
}
@@ -217,51 +227,53 @@ Con_Dump_f
Save the console contents out to a file
================
*/
-static void Con_Dump_f( void ) {
+static void Con_Dump_f(void)
+{
int l;
char *line;
qhandle_t f;
char name[MAX_OSPATH];
- if( Cmd_Argc() != 2 ) {
- Com_Printf( "Usage: %s <filename>\n", Cmd_Argv( 0 ) );
+ if (Cmd_Argc() != 2) {
+ Com_Printf("Usage: %s <filename>\n", Cmd_Argv(0));
return;
}
- f = FS_EasyOpenFile( name, sizeof( name ), FS_MODE_WRITE | FS_FLAG_TEXT,
- "condumps/", Cmd_Argv( 1 ), ".txt" );
- if( !f ) {
+ f = FS_EasyOpenFile(name, sizeof(name), FS_MODE_WRITE | FS_FLAG_TEXT,
+ "condumps/", Cmd_Argv(1), ".txt");
+ if (!f) {
return;
}
// skip empty lines
- for( l = con.current - CON_TOTALLINES + 1 ; l <= con.current ; l++ ) {
- if( con.text[l & CON_TOTALLINES_MASK][0] ) {
+ for (l = con.current - CON_TOTALLINES + 1; l <= con.current; l++) {
+ if (con.text[l & CON_TOTALLINES_MASK][0]) {
break;
}
}
// write the remaining lines
- for( ; l <= con.current ; l++ ) {
+ for (; l <= con.current; l++) {
line = con.text[l & CON_TOTALLINES_MASK];
- FS_FPrintf( f, "%s\n", line + 1 );
+ FS_FPrintf(f, "%s\n", line + 1);
}
- FS_FCloseFile( f );
+ FS_FCloseFile(f);
- Com_Printf( "Dumped console text to %s.\n", name );
+ Com_Printf("Dumped console text to %s.\n", name);
}
-
+
/*
================
Con_ClearNotify_f
================
*/
-void Con_ClearNotify_f( void ) {
+void Con_ClearNotify_f(void)
+{
int i;
-
- for( i = 0; i < CON_TIMES; i++ )
+
+ for (i = 0; i < CON_TIMES; i++)
con.times[i] = 0;
}
@@ -270,25 +282,28 @@ void Con_ClearNotify_f( void ) {
Con_MessageMode_f
================
*/
-static void start_message_mode( chatMode_t mode ) {
- if( cls.state != ca_active || cls.demo.playback ) {
- Com_Printf( "You must be in a level to chat.\n" );
+static void start_message_mode(chatMode_t mode)
+{
+ if (cls.state != ca_active || cls.demo.playback) {
+ Com_Printf("You must be in a level to chat.\n");
return;
}
- Con_Close( qtrue );
+ Con_Close(qtrue);
con.chat = mode;
- IF_Replace( &con.chatPrompt.inputLine, Cmd_RawArgs() );
- Key_SetDest( cls.key_dest | KEY_MESSAGE );
+ IF_Replace(&con.chatPrompt.inputLine, Cmd_RawArgs());
+ Key_SetDest(cls.key_dest | KEY_MESSAGE);
}
-static void Con_MessageMode_f( void ) {
- start_message_mode( CHAT_DEFAULT );
+static void Con_MessageMode_f(void)
+{
+ start_message_mode(CHAT_DEFAULT);
}
-static void Con_MessageMode2_f( void ) {
- start_message_mode( CHAT_TEAM );
+static void Con_MessageMode2_f(void)
+{
+ start_message_mode(CHAT_TEAM);
}
/*
@@ -296,40 +311,42 @@ static void Con_MessageMode2_f( void ) {
Con_RemoteMode_f
================
*/
-static void Con_RemoteMode_f( void ) {
+static void Con_RemoteMode_f(void)
+{
netadr_t adr;
char *s;
- if( Cmd_Argc() != 3 ) {
- Com_Printf( "Usage: %s <address> <password>\n", Cmd_Argv( 0 ) );
+ if (Cmd_Argc() != 3) {
+ Com_Printf("Usage: %s <address> <password>\n", Cmd_Argv(0));
return;
}
- s = Cmd_Argv( 1 );
- if( !NET_StringToAdr( s, &adr, PORT_SERVER ) ) {
- Com_Printf( "Bad address: %s\n", s );
+ s = Cmd_Argv(1);
+ if (!NET_StringToAdr(s, &adr, PORT_SERVER)) {
+ Com_Printf("Bad address: %s\n", s);
return;
}
- s = Cmd_Argv( 2 );
+ s = Cmd_Argv(2);
- if( !( cls.key_dest & KEY_CONSOLE ) ) {
- toggle_console( CON_REMOTE, CHAT_NONE );
+ if (!(cls.key_dest & KEY_CONSOLE)) {
+ toggle_console(CON_REMOTE, CHAT_NONE);
} else {
con.mode = CON_REMOTE;
con.chat = CHAT_NONE;
}
con.remoteAddress = adr;
- if( con.remotePassword ) {
- Z_Free( con.remotePassword );
+ if (con.remotePassword) {
+ Z_Free(con.remotePassword);
}
- con.remotePassword = Z_CopyString( s );
+ con.remotePassword = Z_CopyString(s);
}
-static void CL_RemoteMode_c( genctx_t *ctx, int argnum ) {
- if( argnum == 1 ) {
- Com_Address_g( ctx );
+static void CL_RemoteMode_c(genctx_t *ctx, int argnum)
+{
+ if (argnum == 1) {
+ Com_Address_g(ctx);
}
}
@@ -340,15 +357,16 @@ Con_CheckResize
If the line width has changed, reformat the buffer.
================
*/
-static void Con_CheckResize( void ) {
+static void Con_CheckResize(void)
+{
int width;
con.vidWidth = r_config.width * con.scale;
con.vidHeight = r_config.height * con.scale;
- width = ( con.vidWidth / CHAR_WIDTH ) - 2;
+ width = (con.vidWidth / CHAR_WIDTH) - 2;
- if( width == con.linewidth )
+ if (width == con.linewidth)
return;
con.linewidth = width > CON_LINEWIDTH ? CON_LINEWIDTH : width;
@@ -364,19 +382,21 @@ Con_CheckTop
Make sure at least one line is visible if console is backscrolled.
================
*/
-static void Con_CheckTop( void ) {
+static void Con_CheckTop(void)
+{
int top = con.current - CON_TOTALLINES + 1;
- if( top < 1 ) {
+ if (top < 1) {
top = 1;
}
- if( con.display < top ) {
+ if (con.display < top) {
con.display = top;
}
}
-static void con_param_changed( cvar_t *self ) {
- if( con.initialized && cls.ref_initialized ) {
+static void con_param_changed(cvar_t *self)
+{
+ if (con.initialized && cls.ref_initialized) {
Con_RegisterMedia();
}
}
@@ -400,30 +420,31 @@ static const cmdreg_t c_console[] = {
Con_Init
================
*/
-void Con_Init( void ) {
- memset( &con, 0, sizeof( con ) );
+void Con_Init(void)
+{
+ memset(&con, 0, sizeof(con));
//
// register our commands
//
- Cmd_Register( c_console );
-
- con_notifytime = Cvar_Get( "con_notifytime", "3", 0 );
- con_notifylines = Cvar_Get( "con_notifylines", "4", 0 );
- con_clock = Cvar_Get( "con_clock", "0", 0 );
- con_height = Cvar_Get( "con_height", "0.5", 0 );
- con_speed = Cvar_Get( "scr_conspeed", "3", 0 );
- con_alpha = Cvar_Get( "con_alpha", "1", 0 );
- con_scale = Cvar_Get( "con_scale", "1", 0 );
- con_font = Cvar_Get( "con_font", "conchars", 0 );
+ Cmd_Register(c_console);
+
+ con_notifytime = Cvar_Get("con_notifytime", "3", 0);
+ con_notifylines = Cvar_Get("con_notifylines", "4", 0);
+ con_clock = Cvar_Get("con_clock", "0", 0);
+ con_height = Cvar_Get("con_height", "0.5", 0);
+ con_speed = Cvar_Get("scr_conspeed", "3", 0);
+ con_alpha = Cvar_Get("con_alpha", "1", 0);
+ con_scale = Cvar_Get("con_scale", "1", 0);
+ con_font = Cvar_Get("con_font", "conchars", 0);
con_font->changed = con_param_changed;
- con_background = Cvar_Get( "con_background", "conback", 0 );
+ con_background = Cvar_Get("con_background", "conback", 0);
con_background->changed = con_param_changed;
- con_scroll = Cvar_Get( "con_scroll", "0", 0 );
- con_history = Cvar_Get( "con_history", "0", 0 );
+ con_scroll = Cvar_Get("con_scroll", "0", 0);
+ con_history = Cvar_Get("con_history", "0", 0);
- IF_Init( &con.prompt.inputLine, 0, MAX_FIELD_TEXT - 1 );
- IF_Init( &con.chatPrompt.inputLine, 0, MAX_FIELD_TEXT - 1 );
+ IF_Init(&con.prompt.inputLine, 0, MAX_FIELD_TEXT - 1);
+ IF_Init(&con.chatPrompt.inputLine, 0, MAX_FIELD_TEXT - 1);
con.prompt.printf = Con_Printf;
@@ -441,9 +462,10 @@ void Con_Init( void ) {
con.initialized = qtrue;
}
-void Con_PostInit( void ) {
- if( con_history->integer > 0 ) {
- Prompt_LoadHistory( &con.prompt, COM_HISTORYFILE_NAME );
+void Con_PostInit(void)
+{
+ if (con_history->integer > 0) {
+ Prompt_LoadHistory(&con.prompt, COM_HISTORYFILE_NAME);
}
}
@@ -452,44 +474,48 @@ void Con_PostInit( void ) {
Con_Shutdown
================
*/
-void Con_Shutdown( void ) {
- if( con_history->integer > 0 ) {
- Prompt_SaveHistory( &con.prompt, COM_HISTORYFILE_NAME, con_history->integer );
+void Con_Shutdown(void)
+{
+ if (con_history->integer > 0) {
+ Prompt_SaveHistory(&con.prompt, COM_HISTORYFILE_NAME, con_history->integer);
}
- Prompt_Clear( &con.prompt );
+ Prompt_Clear(&con.prompt);
}
-static void Con_CarriageRet( void ) {
+static void Con_CarriageRet(void)
+{
char *p;
p = con.text[con.current & CON_TOTALLINES_MASK];
- memset( p, 0, sizeof( con.text[0] ) );
+ memset(p, 0, sizeof(con.text[0]));
// add color from last line
con.x = 0;
p[con.x++] = con.color;
// update time for transparent overlay
- if( !con.skipNotify ) {
+ if (!con.skipNotify) {
con.times[con.current & CON_TIMES_MASK] = cls.realtime;
}
}
-static void Con_Linefeed( void ) {
- if( con.display == con.current )
+static void Con_Linefeed(void)
+{
+ if (con.display == con.current)
con.display++;
con.current++;
Con_CarriageRet();
- if( con_scroll->integer & 2 ) {
+ if (con_scroll->integer & 2) {
con.display = con.current;
} else {
Con_CheckTop();
}
}
-void Con_SetColor( color_index_t color ) {
+void Con_SetColor(color_index_t color)
+{
con.color = color;
}
@@ -502,16 +528,17 @@ All console printing must go through this in order to be displayed on screen
If no console is visible, the text will appear at the top of the game window
================
*/
-void Con_Print( const char *txt ) {
+void Con_Print(const char *txt)
+{
char *p;
int l;
- if( !con.initialized )
+ if (!con.initialized)
return;
- while( *txt ) {
- if( con.newline ) {
- if( con.newline == '\n' ) {
+ while (*txt) {
+ if (con.newline) {
+ if (con.newline == '\n') {
Con_Linefeed();
} else {
Con_CarriageRet();
@@ -519,23 +546,23 @@ void Con_Print( const char *txt ) {
con.newline = 0;
}
- // count word length
- for( p = ( char * )txt; *p > 32; p++ )
+ // count word length
+ for (p = (char *)txt; *p > 32; p++)
;
l = p - txt;
- // word wrap
- if( l < con.linewidth && con.x + l > con.linewidth ) {
+ // word wrap
+ if (l < con.linewidth && con.x + l > con.linewidth) {
Con_Linefeed();
}
- switch( *txt ) {
+ switch (*txt) {
case '\r':
case '\n':
con.newline = *txt;
break;
default: // display character and advance
- if( con.x == con.linewidth ) {
+ if (con.x == con.linewidth) {
Con_Linefeed();
}
p = con.text[con.current & CON_TOTALLINES_MASK];
@@ -555,15 +582,16 @@ Print text to graphical console only,
bypassing system console and logfiles
================
*/
-void Con_Printf( const char *fmt, ... ) {
+void Con_Printf(const char *fmt, ...)
+{
va_list argptr;
char msg[MAXPRINTMSG];
- va_start( argptr, fmt );
- Q_vsnprintf( msg, sizeof( msg ), fmt, argptr );
- va_end( argptr );
+ va_start(argptr, fmt);
+ Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
+ va_end(argptr);
- Con_Print( msg );
+ Con_Print(msg);
}
/*
@@ -571,30 +599,31 @@ void Con_Printf( const char *fmt, ... ) {
Con_RegisterMedia
================
*/
-void Con_RegisterMedia( void ) {
+void Con_RegisterMedia(void)
+{
qerror_t ret;
- ret = _R_RegisterFont( con_font->string, &con.charsetImage );
- if( !con.charsetImage ) {
- if( strcmp( con_font->string, "conchars" ) ) {
- Com_WPrintf( "Couldn't load console font: %s\n", Q_ErrorString( ret ) );
- Cvar_Reset( con_font );
- ret = _R_RegisterFont( "conchars", &con.charsetImage );
+ ret = _R_RegisterFont(con_font->string, &con.charsetImage);
+ if (!con.charsetImage) {
+ if (strcmp(con_font->string, "conchars")) {
+ Com_WPrintf("Couldn't load console font: %s\n", Q_ErrorString(ret));
+ Cvar_Reset(con_font);
+ ret = _R_RegisterFont("conchars", &con.charsetImage);
}
- if( !con.charsetImage ) {
- Com_Error( ERR_FATAL, "Couldn't load pics/conchars.pcx: %s", Q_ErrorString( ret ) );
+ if (!con.charsetImage) {
+ Com_Error(ERR_FATAL, "Couldn't load pics/conchars.pcx: %s", Q_ErrorString(ret));
}
}
- ret = _R_RegisterPic( con_background->string, &con.backImage );
- if( !con.backImage ) {
- if( strcmp( con_background->string, "conback" ) ) {
- Com_WPrintf( "Couldn't load console background: %s\n", Q_ErrorString( ret ) );
- Cvar_Reset( con_background );
- ret = _R_RegisterPic( "conback", &con.backImage );
+ ret = _R_RegisterPic(con_background->string, &con.backImage);
+ if (!con.backImage) {
+ if (strcmp(con_background->string, "conback")) {
+ Com_WPrintf("Couldn't load console background: %s\n", Q_ErrorString(ret));
+ Cvar_Reset(con_background);
+ ret = _R_RegisterPic("conback", &con.backImage);
}
- if( !con.charsetImage ) {
- Com_EPrintf( "Couldn't load pics/conback.pcx: %s\n", Q_ErrorString( ret ) );
+ if (!con.charsetImage) {
+ Com_EPrintf("Couldn't load pics/conback.pcx: %s\n", Q_ErrorString(ret));
}
}
}
@@ -607,36 +636,37 @@ DRAWING
==============================================================================
*/
-static int Con_DrawLine( int v, int line, float alpha ) {
+static int Con_DrawLine(int v, int line, float alpha)
+{
char *p = con.text[line & CON_TOTALLINES_MASK];
color_index_t c = *p;
color_t color;
int flags = 0;
- switch( c ) {
+ switch (c) {
case COLOR_ALT:
flags = UI_ALTCOLOR;
// fall through
case COLOR_NONE:
R_ClearColor();
- if( alpha != 1 ) {
- R_SetAlpha( alpha );
+ if (alpha != 1) {
+ R_SetAlpha(alpha);
}
break;
default:
color.u32 = colorTable[c & 7];
- if( alpha != 1 ) {
+ if (alpha != 1) {
color.u8[3] = alpha * 255;
}
- R_SetColor( color.u32 );
+ R_SetColor(color.u32);
break;
}
- return R_DrawString( CHAR_WIDTH, v, flags, con.linewidth - 1, p + 1,
- con.charsetImage );
+ return R_DrawString(CHAR_WIDTH, v, flags, con.linewidth - 1, p + 1,
+ con.charsetImage);
}
-#define CON_PRESTEP ( 10 + CHAR_HEIGHT * 2 )
+#define CON_PRESTEP (10 + CHAR_HEIGHT * 2)
/*
================
@@ -645,7 +675,8 @@ Con_DrawNotify
Draws the last few lines of output transparently over the game top
================
*/
-static void Con_DrawNotify( void ) {
+static void Con_DrawNotify(void)
+{
int v;
char *text;
int i, j;
@@ -654,45 +685,45 @@ static void Con_DrawNotify( void ) {
float alpha;
// only draw notify in game
- if( cls.state != ca_active ) {
- return;
+ if (cls.state != ca_active) {
+ return;
}
- if( cls.key_dest & ( KEY_MENU|KEY_CONSOLE ) ) {
+ if (cls.key_dest & (KEY_MENU | KEY_CONSOLE)) {
return;
}
- if( con.currentHeight ) {
+ if (con.currentHeight) {
return;
}
j = con_notifylines->integer;
- if( j > CON_TIMES ) {
+ if (j > CON_TIMES) {
j = CON_TIMES;
}
v = 0;
- for( i = con.current - j + 1; i <= con.current; i++ ) {
- if( i < 0 )
+ for (i = con.current - j + 1; i <= con.current; i++) {
+ if (i < 0)
continue;
time = con.times[i & CON_TIMES_MASK];
- if( time == 0 )
+ if (time == 0)
continue;
// alpha fade the last string left on screen
- alpha = SCR_FadeAlpha( time, con_notifytime->value * 1000, 300 );
- if( !alpha )
+ alpha = SCR_FadeAlpha(time, con_notifytime->value * 1000, 300);
+ if (!alpha)
continue;
- if( v || i != con.current ) {
+ if (v || i != con.current) {
alpha = 1; // don't fade
}
- Con_DrawLine( v, i, alpha );
+ Con_DrawLine(v, i, alpha);
v += CHAR_HEIGHT;
}
R_ClearColor();
- if( cls.key_dest & KEY_MESSAGE ) {
- if( con.chat == CHAT_TEAM ) {
+ if (cls.key_dest & KEY_MESSAGE) {
+ if (con.chat == CHAT_TEAM) {
text = "say_team:";
skip = 11;
} else {
@@ -700,11 +731,11 @@ static void Con_DrawNotify( void ) {
skip = 5;
}
- R_DrawString( CHAR_WIDTH, v, 0, MAX_STRING_CHARS, text,
- con.charsetImage );
+ R_DrawString(CHAR_WIDTH, v, 0, MAX_STRING_CHARS, text,
+ con.charsetImage);
con.chatPrompt.inputLine.visibleChars = con.linewidth - skip + 1;
- IF_Draw( &con.chatPrompt.inputLine, skip * CHAR_WIDTH, v,
- UI_DRAWCURSOR, con.charsetImage );
+ IF_Draw(&con.chatPrompt.inputLine, skip * CHAR_WIDTH, v,
+ UI_DRAWCURSOR, con.charsetImage);
}
}
@@ -715,7 +746,8 @@ Con_DrawSolidConsole
Draws the console with the solid background
================
*/
-static void Con_DrawSolidConsole( void ) {
+static void Con_DrawSolidConsole(void)
+{
int i, x, y;
int rows;
char *text;
@@ -727,35 +759,34 @@ static void Con_DrawSolidConsole( void ) {
int widths[2];
vislines = con.vidHeight * con.currentHeight;
- if( vislines <= 0 )
+ if (vislines <= 0)
return;
- if( vislines > con.vidHeight )
+ if (vislines > con.vidHeight)
vislines = con.vidHeight;
// setup transparency
- if( cls.state == ca_active &&
+ if (cls.state == ca_active &&
con_alpha->value &&
- ( cls.key_dest & KEY_MENU ) == 0 )
- {
- alpha = 0.5f + 0.5f * ( con.currentHeight / con_height->value );
- R_SetAlpha( alpha * Cvar_ClampValue( con_alpha, 0, 1 ) );
+ (cls.key_dest & KEY_MENU) == 0) {
+ alpha = 0.5f + 0.5f * (con.currentHeight / con_height->value);
+ R_SetAlpha(alpha * Cvar_ClampValue(con_alpha, 0, 1));
}
clip.left = 0;
clip.top = 0;
clip.right = 0;
clip.bottom = 0;
- R_SetClipRect( DRAW_CLIP_TOP, &clip );
+ R_SetClipRect(DRAW_CLIP_TOP, &clip);
// draw the background
- if( cls.state != ca_active || ( cls.key_dest & KEY_MENU ) || con_alpha->value ) {
- R_DrawStretchPic( 0, vislines - con.vidHeight,
- con.vidWidth, con.vidHeight, con.backImage );
+ if (cls.state != ca_active || (cls.key_dest & KEY_MENU) || con_alpha->value) {
+ R_DrawStretchPic(0, vislines - con.vidHeight,
+ con.vidWidth, con.vidHeight, con.backImage);
}
#if 0
- if( cls.state > ca_disconnected && cls.state < ca_active ) {
- R_DrawFill( 0, vislines, con.vidWidth, con.vidHeight - vislines, 0 );
+ if (cls.state > ca_disconnected && cls.state < ca_active) {
+ R_DrawFill(0, vislines, con.vidWidth, con.vidHeight - vislines, 0);
}
#endif
@@ -764,12 +795,12 @@ static void Con_DrawSolidConsole( void ) {
rows = y / CHAR_HEIGHT + 1; // rows of text to draw
// draw arrows to show the buffer is backscrolled
- if( con.display != con.current ) {
- R_SetColor( U32_RED );
- for( i = 1; i < con.linewidth / 2; i += 4 ) {
- R_DrawChar( i * CHAR_WIDTH, y, 0, '^', con.charsetImage );
+ if (con.display != con.current) {
+ R_SetColor(U32_RED);
+ for (i = 1; i < con.linewidth / 2; i += 4) {
+ R_DrawChar(i * CHAR_WIDTH, y, 0, '^', con.charsetImage);
}
-
+
y -= CHAR_HEIGHT;
rows--;
}
@@ -778,52 +809,52 @@ static void Con_DrawSolidConsole( void ) {
R_ClearColor();
row = con.display;
widths[0] = widths[1] = 0;
- for( i = 0; i < rows; i++ ) {
- if( row < 0 )
+ for (i = 0; i < rows; i++) {
+ if (row < 0)
break;
- if( con.current - row > CON_TOTALLINES - 1 )
+ if (con.current - row > CON_TOTALLINES - 1)
break; // past scrollback wrap point
-
- x = Con_DrawLine( y, row, 1 );
- if( i < 2 ) {
+
+ x = Con_DrawLine(y, row, 1);
+ if (i < 2) {
widths[i] = x;
}
y -= CHAR_HEIGHT;
row--;
}
-
+
R_ClearColor();
//ZOID
// draw the download bar
// figure out width
- if( cls.download.current ) {
+ if (cls.download.current) {
int n, j;
- if( ( text = strrchr( cls.download.current->path, '/' ) ) != NULL )
+ if ((text = strrchr(cls.download.current->path, '/')) != NULL)
text++;
else
text = cls.download.current->path;
- x = con.linewidth - ( ( con.linewidth * 7 ) / 40 );
- y = x - strlen( text ) - 8;
+ x = con.linewidth - ((con.linewidth * 7) / 40);
+ y = x - strlen(text) - 8;
i = con.linewidth / 3;
- if ( strlen( text ) > i ) {
+ if (strlen(text) > i) {
y = x - i - 11;
- strncpy( buffer, text, i );
+ strncpy(buffer, text, i);
buffer[i] = 0;
- strcat( buffer, "..." );
+ strcat(buffer, "...");
} else {
- strcpy( buffer, text );
+ strcpy(buffer, text);
}
- strcat( buffer, ": " );
- i = strlen( buffer );
+ strcat(buffer, ": ");
+ i = strlen(buffer);
buffer[i++] = '\x80';
// where's the dot go?
- n = y * cls.download.percent / 100;
- for ( j = 0; j < y; j++ ) {
- if ( j == n ) {
+ n = y * cls.download.percent / 100;
+ for (j = 0; j < y; j++) {
+ if (j == n) {
buffer[i++] = '\x83';
} else {
buffer[i++] = '\x81';
@@ -832,21 +863,21 @@ static void Con_DrawSolidConsole( void ) {
buffer[i++] = '\x82';
buffer[i] = 0;
- sprintf( buffer + i, " %02d%%", cls.download.percent );
+ sprintf(buffer + i, " %02d%%", cls.download.percent);
// draw it
y = vislines - 10;
- R_DrawString( CHAR_WIDTH, y, 0, CON_LINEWIDTH, buffer, con.charsetImage );
+ R_DrawString(CHAR_WIDTH, y, 0, CON_LINEWIDTH, buffer, con.charsetImage);
}
//ZOID
// draw the input prompt, user text, and cursor if desired
x = 0;
- if( cls.key_dest & KEY_CONSOLE ) {
+ if (cls.key_dest & KEY_CONSOLE) {
y = vislines - CON_PRESTEP + CHAR_HEIGHT;
// draw command prompt
- switch( con.mode ) {
+ switch (con.mode) {
case CON_CHAT:
i = '&';
break;
@@ -857,46 +888,46 @@ static void Con_DrawSolidConsole( void ) {
i = 17;
break;
}
- R_SetColor( U32_YELLOW );
- R_DrawChar( CHAR_WIDTH, y, 0, i, con.charsetImage );
+ R_SetColor(U32_YELLOW);
+ R_DrawChar(CHAR_WIDTH, y, 0, i, con.charsetImage);
R_ClearColor();
// draw input line
- x = IF_Draw( &con.prompt.inputLine, 2 * CHAR_WIDTH, y,
- UI_DRAWCURSOR, con.charsetImage );
+ x = IF_Draw(&con.prompt.inputLine, 2 * CHAR_WIDTH, y,
+ UI_DRAWCURSOR, con.charsetImage);
}
#define APP_VERSION APPLICATION " " VERSION
-#define VER_WIDTH ( ( int )( sizeof( APP_VERSION ) + 1 ) * CHAR_WIDTH )
+#define VER_WIDTH ((int)(sizeof(APP_VERSION) + 1) * CHAR_WIDTH)
y = vislines - CON_PRESTEP + CHAR_HEIGHT;
row = 0;
// shift version upwards to prevent overdraw
- if( x > con.vidWidth - VER_WIDTH ) {
+ if (x > con.vidWidth - VER_WIDTH) {
y -= CHAR_HEIGHT;
row++;
}
- R_SetColor( U32_CYAN );
+ R_SetColor(U32_CYAN);
// draw clock
- if( con_clock->integer ) {
- x = Com_Time_m( buffer, sizeof( buffer ) ) * CHAR_WIDTH;
- if( widths[row] + x + CHAR_WIDTH <= con.vidWidth ) {
- R_DrawString( con.vidWidth - CHAR_WIDTH - x, y - CHAR_HEIGHT,
- UI_RIGHT, MAX_STRING_CHARS, buffer, con.charsetImage );
+ if (con_clock->integer) {
+ x = Com_Time_m(buffer, sizeof(buffer)) * CHAR_WIDTH;
+ if (widths[row] + x + CHAR_WIDTH <= con.vidWidth) {
+ R_DrawString(con.vidWidth - CHAR_WIDTH - x, y - CHAR_HEIGHT,
+ UI_RIGHT, MAX_STRING_CHARS, buffer, con.charsetImage);
}
}
// draw version
- if( !row || widths[0] + VER_WIDTH <= con.vidWidth ) {
- SCR_DrawStringEx( con.vidWidth - CHAR_WIDTH, y, UI_RIGHT,
- MAX_STRING_CHARS, APP_VERSION, con.charsetImage );
+ if (!row || widths[0] + VER_WIDTH <= con.vidWidth) {
+ SCR_DrawStringEx(con.vidWidth - CHAR_WIDTH, y, UI_RIGHT,
+ MAX_STRING_CHARS, APP_VERSION, con.charsetImage);
}
// restore rendering parameters
R_ClearColor();
- R_SetClipRect( DRAW_CLIP_DISABLED, NULL );
+ R_SetClipRect(DRAW_CLIP_DISABLED, NULL);
}
//=============================================================================
@@ -908,19 +939,20 @@ Con_RunConsole
Scroll it up or down
==================
*/
-void Con_RunConsole( void ) {
- if( cls.disable_screen ) {
+void Con_RunConsole(void)
+{
+ if (cls.disable_screen) {
con.destHeight = con.currentHeight = 0;
return;
}
- if( !( cls.key_dest & KEY_MENU ) ) {
- if( cls.state == ca_disconnected ) {
+ if (!(cls.key_dest & KEY_MENU)) {
+ if (cls.state == ca_disconnected) {
// draw fullscreen console
con.destHeight = con.currentHeight = 1;
return;
}
- if( cls.state > ca_disconnected && cls.state < ca_active ) {
+ if (cls.state > ca_disconnected && cls.state < ca_active) {
// draw half-screen console
con.destHeight = con.currentHeight = 0.5f;
return;
@@ -928,20 +960,20 @@ void Con_RunConsole( void ) {
}
// decide on the height of the console
- if( cls.key_dest & KEY_CONSOLE ) {
- con.destHeight = Cvar_ClampValue( con_height, 0.1f, 1 );
+ if (cls.key_dest & KEY_CONSOLE) {
+ con.destHeight = Cvar_ClampValue(con_height, 0.1f, 1);
} else {
con.destHeight = 0; // none visible
}
- if( con.currentHeight > con.destHeight ) {
+ if (con.currentHeight > con.destHeight) {
con.currentHeight -= con_speed->value * cls.frametime;
- if( con.currentHeight < con.destHeight ) {
+ if (con.currentHeight < con.destHeight) {
con.currentHeight = con.destHeight;
}
- } else if( con.currentHeight < con.destHeight ) {
+ } else if (con.currentHeight < con.destHeight) {
con.currentHeight += con_speed->value * cls.frametime;
- if( con.currentHeight > con.destHeight ) {
+ if (con.currentHeight > con.destHeight) {
con.currentHeight = con.destHeight;
}
}
@@ -952,17 +984,18 @@ void Con_RunConsole( void ) {
SCR_DrawConsole
==================
*/
-void Con_DrawConsole( void ) {
- Cvar_ClampValue( con_scale, 1, 9 );
+void Con_DrawConsole(void)
+{
+ Cvar_ClampValue(con_scale, 1, 9);
con.scale = 1.0f / con_scale->value;
- R_SetScale( &con.scale );
+ R_SetScale(&con.scale);
Con_CheckResize();
Con_DrawSolidConsole();
- Con_DrawNotify();
+ Con_DrawNotify();
- R_SetScale( NULL );
+ R_SetScale(NULL);
}
@@ -974,81 +1007,85 @@ void Con_DrawConsole( void ) {
==============================================================================
*/
-static void Con_Say( char *msg ) {
- CL_ClientCommand( va( "say%s \"%s\"", con.chat == CHAT_TEAM ? "_team" : "", msg ) );
+static void Con_Say(char *msg)
+{
+ CL_ClientCommand(va("say%s \"%s\"", con.chat == CHAT_TEAM ? "_team" : "", msg));
}
// don't close console after connecting
-static void Con_InteractiveMode( void ) {
- if( !con.mode ) {
+static void Con_InteractiveMode(void)
+{
+ if (!con.mode) {
con.mode = CON_DEFAULT;
}
}
-static void Con_Action( void ) {
- char *cmd = Prompt_Action( &con.prompt );
+static void Con_Action(void)
+{
+ char *cmd = Prompt_Action(&con.prompt);
Con_InteractiveMode();
-
- if( !cmd ) {
- Con_Printf( "]\n" );
+
+ if (!cmd) {
+ Con_Printf("]\n");
return;
}
-
+
// backslash text are commands, else chat
- if( cmd[0] == '\\' || cmd[0] == '/' ) {
- Cbuf_AddText( &cmd_buffer, cmd + 1 ); // skip slash
- Cbuf_AddText( &cmd_buffer, "\n" );
+ if (cmd[0] == '\\' || cmd[0] == '/') {
+ Cbuf_AddText(&cmd_buffer, cmd + 1); // skip slash
+ Cbuf_AddText(&cmd_buffer, "\n");
} else {
- if( con.mode == CON_REMOTE ) {
- CL_SendRcon( &con.remoteAddress, con.remotePassword, cmd );
- } else if( cls.state == ca_active && con.mode == CON_CHAT ) {
- Con_Say( cmd );
+ if (con.mode == CON_REMOTE) {
+ CL_SendRcon(&con.remoteAddress, con.remotePassword, cmd);
+ } else if (cls.state == ca_active && con.mode == CON_CHAT) {
+ Con_Say(cmd);
} else {
- Cbuf_AddText( &cmd_buffer, cmd );
- Cbuf_AddText( &cmd_buffer, "\n" );
+ Cbuf_AddText(&cmd_buffer, cmd);
+ Cbuf_AddText(&cmd_buffer, "\n");
}
}
- Con_Printf( "]%s\n", cmd );
+ Con_Printf("]%s\n", cmd);
- if( cls.state == ca_disconnected ) {
- SCR_UpdateScreen (); // force an update, because the command
- // may take some time
+ if (cls.state == ca_disconnected) {
+ // force an update, because the command may take some time
+ SCR_UpdateScreen();
}
}
-static void Con_Paste( void ) {
+static void Con_Paste(void)
+{
char *cbd, *s;
Con_InteractiveMode();
- if( ( cbd = VID_GetClipboardData() ) == NULL ) {
+ if ((cbd = VID_GetClipboardData()) == NULL) {
return;
}
s = cbd;
- while( *s ) {
+ while (*s) {
int c = *s++;
- switch( c ) {
+ switch (c) {
case '\n':
- if( *s ) {
+ if (*s) {
Con_Action();
}
break;
case '\r':
case '\t':
- IF_CharEvent( &con.prompt.inputLine, ' ' );
+ IF_CharEvent(&con.prompt.inputLine, ' ');
break;
default:
- if( Q_isprint( c ) ) {
- IF_CharEvent( &con.prompt.inputLine, c );
+ if (Q_isprint(c)) {
+ IF_CharEvent(&con.prompt.inputLine, c);
}
break;
}
}
- Z_Free( cbd );
+ Z_Free(cbd);
}
/*
@@ -1058,56 +1095,56 @@ Key_Console
Interactive line editing and console scrollback
====================
*/
-void Key_Console( int key ) {
- if( key == 'l' && Key_IsDown( K_CTRL ) ) {
+void Key_Console(int key)
+{
+ if (key == 'l' && Key_IsDown(K_CTRL)) {
Con_Clear_f();
return;
}
- if( key == 'd' && Key_IsDown( K_CTRL ) ) {
+ if (key == 'd' && Key_IsDown(K_CTRL)) {
con.mode = CON_DEFAULT;
return;
}
- if( key == K_ENTER || key == K_KP_ENTER ) {
+ if (key == K_ENTER || key == K_KP_ENTER) {
Con_Action();
goto scroll;
}
- if( ( key == 'v' && Key_IsDown( K_CTRL ) ) ||
- ( key == K_INS && Key_IsDown( K_SHIFT ) ) || key == K_MOUSE3 )
- {
+ if ((key == 'v' && Key_IsDown(K_CTRL)) ||
+ (key == K_INS && Key_IsDown(K_SHIFT)) || key == K_MOUSE3) {
Con_Paste();
goto scroll;
}
- if( key == K_TAB ) {
- Prompt_CompleteCommand( &con.prompt, qtrue );
+ if (key == K_TAB) {
+ Prompt_CompleteCommand(&con.prompt, qtrue);
goto scroll;
}
- if( key == 'r' && Key_IsDown( K_CTRL ) ) {
- Prompt_CompleteHistory( &con.prompt, qfalse );
+ if (key == 'r' && Key_IsDown(K_CTRL)) {
+ Prompt_CompleteHistory(&con.prompt, qfalse);
goto scroll;
}
- if( key == 's' && Key_IsDown( K_CTRL ) ) {
- Prompt_CompleteHistory( &con.prompt, qtrue );
+ if (key == 's' && Key_IsDown(K_CTRL)) {
+ Prompt_CompleteHistory(&con.prompt, qtrue);
goto scroll;
}
- if( key == K_UPARROW || ( key == 'p' && Key_IsDown( K_CTRL ) ) ) {
- Prompt_HistoryUp( &con.prompt );
+ if (key == K_UPARROW || (key == 'p' && Key_IsDown(K_CTRL))) {
+ Prompt_HistoryUp(&con.prompt);
goto scroll;
}
- if( key == K_DOWNARROW || ( key == 'n' && Key_IsDown( K_CTRL ) ) ) {
- Prompt_HistoryDown( &con.prompt );
+ if (key == K_DOWNARROW || (key == 'n' && Key_IsDown(K_CTRL))) {
+ Prompt_HistoryDown(&con.prompt);
goto scroll;
}
- if( key == K_PGUP || key == K_MWHEELUP ) {
- if( Key_IsDown( K_CTRL ) ) {
+ if (key == K_PGUP || key == K_MWHEELUP) {
+ if (Key_IsDown(K_CTRL)) {
con.display -= 6;
} else {
con.display -= 2;
@@ -1116,42 +1153,43 @@ void Key_Console( int key ) {
return;
}
- if( key == K_PGDN || key == K_MWHEELDOWN ) {
- if( Key_IsDown( K_CTRL ) ) {
+ if (key == K_PGDN || key == K_MWHEELDOWN) {
+ if (Key_IsDown(K_CTRL)) {
con.display += 6;
} else {
con.display += 2;
}
- if( con.display > con.current ) {
+ if (con.display > con.current) {
con.display = con.current;
}
return;
}
- if( key == K_HOME && Key_IsDown( K_CTRL ) ) {
+ if (key == K_HOME && Key_IsDown(K_CTRL)) {
con.display = 1;
Con_CheckTop();
return;
}
- if( key == K_END && Key_IsDown( K_CTRL ) ) {
+ if (key == K_END && Key_IsDown(K_CTRL)) {
con.display = con.current;
return;
}
- if( IF_KeyEvent( &con.prompt.inputLine, key ) ) {
- Prompt_ClearState( &con.prompt );
+ if (IF_KeyEvent(&con.prompt.inputLine, key)) {
+ Prompt_ClearState(&con.prompt);
Con_InteractiveMode();
}
-scroll:
- if( con_scroll->integer & 1 ) {
+scroll:
+ if (con_scroll->integer & 1) {
con.display = con.current;
}
}
-void Char_Console( int key ) {
- if( IF_CharEvent( &con.prompt.inputLine, key ) ) {
+void Char_Console(int key)
+{
+ if (IF_CharEvent(&con.prompt.inputLine, key)) {
Con_InteractiveMode();
}
}
@@ -1161,55 +1199,57 @@ void Char_Console( int key ) {
Key_Message
====================
*/
-void Key_Message( int key ) {
- if( key == 'l' && Key_IsDown( K_CTRL ) ) {
- IF_Clear( &con.chatPrompt.inputLine );
+void Key_Message(int key)
+{
+ if (key == 'l' && Key_IsDown(K_CTRL)) {
+ IF_Clear(&con.chatPrompt.inputLine);
return;
}
- if( key == K_ENTER || key == K_KP_ENTER ) {
- char *cmd = Prompt_Action( &con.chatPrompt );
-
- if( cmd ) {
- Con_Say( cmd );
+ if (key == K_ENTER || key == K_KP_ENTER) {
+ char *cmd = Prompt_Action(&con.chatPrompt);
+
+ if (cmd) {
+ Con_Say(cmd);
}
- Key_SetDest( cls.key_dest & ~KEY_MESSAGE );
+ Key_SetDest(cls.key_dest & ~KEY_MESSAGE);
return;
}
- if( key == K_ESCAPE ) {
- Key_SetDest( cls.key_dest & ~KEY_MESSAGE );
- IF_Clear( &con.chatPrompt.inputLine );
+ if (key == K_ESCAPE) {
+ Key_SetDest(cls.key_dest & ~KEY_MESSAGE);
+ IF_Clear(&con.chatPrompt.inputLine);
return;
}
- if( key == 'r' && Key_IsDown( K_CTRL ) ) {
- Prompt_CompleteHistory( &con.chatPrompt, qfalse );
+ if (key == 'r' && Key_IsDown(K_CTRL)) {
+ Prompt_CompleteHistory(&con.chatPrompt, qfalse);
return;
}
- if( key == 's' && Key_IsDown( K_CTRL ) ) {
- Prompt_CompleteHistory( &con.chatPrompt, qtrue );
+ if (key == 's' && Key_IsDown(K_CTRL)) {
+ Prompt_CompleteHistory(&con.chatPrompt, qtrue);
return;
}
- if( key == K_UPARROW || ( key == 'p' && Key_IsDown( K_CTRL ) ) ) {
- Prompt_HistoryUp( &con.chatPrompt );
+ if (key == K_UPARROW || (key == 'p' && Key_IsDown(K_CTRL))) {
+ Prompt_HistoryUp(&con.chatPrompt);
return;
}
- if( key == K_DOWNARROW || ( key == 'n' && Key_IsDown( K_CTRL ) ) ) {
- Prompt_HistoryDown( &con.chatPrompt );
+ if (key == K_DOWNARROW || (key == 'n' && Key_IsDown(K_CTRL))) {
+ Prompt_HistoryDown(&con.chatPrompt);
return;
}
- if( IF_KeyEvent( &con.chatPrompt.inputLine, key ) ) {
- Prompt_ClearState( &con.chatPrompt );
+ if (IF_KeyEvent(&con.chatPrompt.inputLine, key)) {
+ Prompt_ClearState(&con.chatPrompt);
}
}
-void Char_Message( int key ) {
- IF_CharEvent( &con.chatPrompt.inputLine, key );
+void Char_Message(int key)
+{
+ IF_CharEvent(&con.chatPrompt.inputLine, key);
}