summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/cl_console.c130
-rw-r--r--source/cl_parse.c20
-rw-r--r--source/cl_public.h38
-rw-r--r--source/cl_scrn.c74
-rw-r--r--source/cmd.c4
-rw-r--r--source/com_local.h19
-rw-r--r--source/common.c84
-rw-r--r--source/gl_draw.c91
-rw-r--r--source/gl_local.h2
-rw-r--r--source/gl_state.c3
-rw-r--r--source/q_field.c1
-rw-r--r--source/q_shared.c217
-rw-r--r--source/q_shared.h74
-rw-r--r--source/sw_draw.c43
-rw-r--r--source/sys_public.h1
-rw-r--r--source/sys_unix.c123
-rw-r--r--source/ui_atoms.c6
-rw-r--r--source/ui_menu.c4
18 files changed, 329 insertions, 605 deletions
diff --git a/source/cl_console.c b/source/cl_console.c
index 655c0ff..0410a66 100644
--- a/source/cl_console.c
+++ b/source/cl_console.c
@@ -49,6 +49,8 @@ typedef struct console_s {
int current; // line where next message will be printed
int x; // offset in current line for next print
int display; // bottom of console displays this line
+ int color;
+ qboolean newline;
int linewidth; // characters across screen
int vidWidth, vidHeight;
@@ -201,7 +203,6 @@ static void Con_Dump_f( void ) {
int l;
char *line;
fileHandle_t f;
- char buffer[CON_LINEWIDTH];
char name[MAX_OSPATH];
size_t len;
@@ -232,9 +233,7 @@ static void Con_Dump_f( void ) {
// write the remaining lines
for( ; l <= con.current ; l++ ) {
line = con.text[l & CON_TOTALLINES_MASK];
- Q_ClearColorStr( buffer, line, sizeof( buffer ) );
-
- FS_FPrintf( f, "%s\n", buffer );
+ FS_FPrintf( f, "%s\n", line + 1 );
}
FS_FCloseFile( f );
@@ -337,7 +336,7 @@ static void Con_CheckResize( void ) {
con.linewidth = width > CON_LINEWIDTH ? CON_LINEWIDTH : width;
con.prompt.inputLine.visibleChars = con.linewidth;
- con.prompt.widthInChars = con.linewidth;
+ con.prompt.widthInChars = con.linewidth - 1; // account for color byte
con.chatPrompt.inputLine.visibleChars = con.linewidth;
}
@@ -416,6 +415,9 @@ void Con_Init( void ) {
scr_glconfig.vidHeight = 480;
con.linewidth = -1;
con.scale = 1;
+ con.color = COLOR_NONE;
+ con.text[0][0] = COLOR_NONE;
+ con.x = 1;
Con_CheckResize();
@@ -440,19 +442,28 @@ void Con_Shutdown( void ) {
Prompt_Clear( &con.prompt );
}
+static void Con_CarriageRet( void ) {
+ char *p;
+
+ p = con.text[con.current & CON_TOTALLINES_MASK];
+ memset( p, 0, sizeof( con.text[0] ) );
+
+ // add color from last line
+ con.x = 0;
+ p[con.x++] = con.color;
+}
+
/*
===============
Con_Linefeed
===============
*/
-void Con_Linefeed( void ) {
- con.x = 0;
-
+static void Con_Linefeed( void ) {
if( con.display == con.current )
con.display++;
con.current++;
- memset( con.text[con.current & CON_TOTALLINES_MASK], 0, sizeof( con.text[0] ) );
+ Con_CarriageRet();
if( con_scroll->integer & 2 ) {
con.display = con.current;
@@ -461,6 +472,10 @@ void Con_Linefeed( void ) {
}
}
+void Con_SetColor( color_index_t color ) {
+ con.color = color;
+}
+
/*
================
Con_Print
@@ -472,8 +487,6 @@ If no console is visible, the text will appear at the top of the game window
*/
void Con_Print( const char *txt ) {
int prevline;
- int color;
- static qboolean cr;
char *p;
int l;
@@ -482,67 +495,39 @@ void Con_Print( const char *txt ) {
prevline = con.current;
- color = 0;
while( *txt ) {
- // count word length
- l = 0;
- p = ( char * )txt;
- while( *p > 32 || *p == Q_COLOR_ESCAPE ) {
- if( Q_IsColorString( p ) ) {
- p += 2;
- } else {
- l++; p++;
- }
+ if( con.newline ) {
+ Con_Linefeed();
+ con.newline = qfalse;
}
- // word wrap
- p = con.text[con.current & CON_TOTALLINES_MASK];
- if( l < con.linewidth && ( Q_DrawStrlen( p ) + l > con.linewidth ) )
- con.x = 0;
+ // count word length
+ for( p = ( char * )txt; *p > 32; p++ )
+ ;
+ l = p - txt;
- if( cr ) {
- cr = qfalse;
- con.current--;
- }
-
- if( !con.x ) {
+ // word wrap
+ if( l < con.linewidth && con.x + l > con.linewidth ) {
Con_Linefeed();
-
- // add color from last line
- if( color ) {
- p = con.text[con.current & CON_TOTALLINES_MASK];
- p[con.x++] = Q_COLOR_ESCAPE;
- p[con.x++] = color;
- }
}
switch( *txt ) {
case '\r':
- cr = qtrue;
- case '\n':
- con.x = 0;
- //color = 0;
+ Con_CarriageRet();
break;
- case Q_COLOR_ESCAPE:
- if( !txt[1] ) {
- break;
- }
- txt++;
- color = *txt;
- p = con.text[con.current & CON_TOTALLINES_MASK];
- p[con.x++] = Q_COLOR_ESCAPE;
- p[con.x++] = color;
+ case '\n':
+ con.newline = qtrue;
break;
default: // display character and advance
+ if( con.x == con.linewidth ) {
+ Con_Linefeed();
+ }
p = con.text[con.current & CON_TOTALLINES_MASK];
p[con.x++] = *txt;
- if( Q_DrawStrlen( p ) > con.linewidth )
- con.x = 0;
break;
}
txt++;
-
}
// update time for transparent overlay
@@ -551,7 +536,6 @@ void Con_Print( const char *txt ) {
con.times[l & CON_TIMES_MASK] = cls.realtime;
}
}
-
}
/*
@@ -603,6 +587,30 @@ DRAWING
==============================================================================
*/
+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 ) {
+ case COLOR_ALT:
+ flags = UI_ALTCOLOR;
+ // fall through
+ case COLOR_NONE:
+ R_SetColor( DRAW_COLOR_CLEAR, NULL );
+ break;
+ default:
+ VectorCopy( colorTable[c & 7], color );
+ color[3] = alpha * 255;
+ R_SetColor( DRAW_COLOR_RGBA, color );
+ break;
+ }
+
+ return R_DrawString( CHAR_WIDTH, v, flags, con.linewidth - 1, p + 1,
+ con.charsetImage );
+}
+
#define CON_PRESTEP ( 10 + CHAR_HEIGHT * 2 )
/*
@@ -647,15 +655,11 @@ void Con_DrawNotify( void ) {
alpha = SCR_FadeAlpha( time, con_notifytime->value * 1000, 300 );
if( !alpha )
continue;
- text = con.text[i & CON_TOTALLINES_MASK];
-
if( v || i != con.current ) {
alpha = 1; // don't fade
}
- R_SetColor( DRAW_COLOR_ALPHA, ( byte * )&alpha );
- R_DrawString( CHAR_WIDTH, v, 0, con.linewidth, text,
- con.charsetImage );
+ Con_DrawLine( v, i, alpha );
v += CHAR_HEIGHT;
}
@@ -758,9 +762,7 @@ void Con_DrawSolidConsole( void ) {
if( con.current - row > CON_TOTALLINES - 1 )
break; // past scrollback wrap point
- text = con.text[row & CON_TOTALLINES_MASK];
-
- x = R_DrawString( CHAR_WIDTH, y, 0, con.linewidth, text, con.charsetImage );
+ x = Con_DrawLine( y, row, 1 );
if( i < 2 ) {
widths[i] = x;
}
@@ -768,6 +770,8 @@ void Con_DrawSolidConsole( void ) {
y -= CHAR_HEIGHT;
row--;
}
+
+ R_SetColor( DRAW_COLOR_CLEAR, NULL );
//ZOID
// draw the download bar
diff --git a/source/cl_parse.c b/source/cl_parse.c
index 0b21f95..8dd5a16 100644
--- a/source/cl_parse.c
+++ b/source/cl_parse.c
@@ -891,14 +891,16 @@ static void CL_ParseServerData( void ) {
CL_ClientCommand( va( "nextserver %i\n", cl.servercount ) );
} else {
// seperate the printfs so the server message can have a color
- Con_Printf( "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
- "\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
- "\36\36\36\36\36\36\37\n\n" );
- Con_Printf( S_COLOR_ALT "%s\n\n", levelname );
+ Con_Printf(
+ "\n\n"
+ "\35\36\36\36\36\36\36\36\36\36\36\36"
+ "\36\36\36\36\36\36\36\36\36\36\36\36"
+ "\36\36\36\36\36\36\36\36\36\36\36\37"
+ "\n\n" );
-#if USE_SYSCON
- Sys_Printf( "%s\n", levelname );
-#endif
+ Com_SetColor( COLOR_ALT );
+ Com_Printf( "%s\n", levelname );
+ Com_SetColor( COLOR_NONE );
// make sure clientNum is in range
if( cl.clientNum < 0 || cl.clientNum >= MAX_CLIENTS ) {
@@ -1221,7 +1223,9 @@ static void CL_ParsePrint( void ) {
string[len] = '\n';
}
- Com_Printf( S_COLOR_ALT "%s", string );
+ Com_SetColor( COLOR_ALT );
+ Com_Printf( "%s", string );
+ Com_SetColor( COLOR_NONE );
Con_SkipNotify( qfalse );
diff --git a/source/cl_public.h b/source/cl_public.h
index fe550fc..5d79bfc 100644
--- a/source/cl_public.h
+++ b/source/cl_public.h
@@ -68,6 +68,7 @@ qboolean CL_ForwardToServer( void );
// so when they are typed in at the console, they will need to be forwarded.
void Con_Init( void );
+void Con_SetColor( color_index_t color );
void Con_Print( const char *text );
void Con_Printf( const char *fmt, ... );
void Con_Close( void );
@@ -79,6 +80,43 @@ void SCR_EndLoadingPlaque( void );
void SCR_ModeChanged( void );
void SCR_UpdateScreen( void );
+#define colorBlack colorTable[COLOR_BLACK]
+#define colorRed colorTable[COLOR_RED]
+#define colorGreen colorTable[COLOR_GREEN]
+#define colorYellow colorTable[COLOR_YELLOW]
+#define colorBlue colorTable[COLOR_BLUE]
+#define colorCyan colorTable[COLOR_CYAN]
+#define colorMagenta colorTable[COLOR_MAGENTA]
+#define colorWhite colorTable[COLOR_WHITE]
+
+#define MAKERGB(v,r,g,b) ((v)[0]=(r),(v)[1]=(g),(v)[2]=(b))
+#define MAKERGBA(v,r,g,b,a) ((v)[0]=(r),(v)[1]=(g),(v)[2]=(b),(v)[3]=(a))
+
+#define SCREEN_WIDTH 640
+#define SCREEN_HEIGHT 480
+
+#define CHAR_WIDTH 8
+#define CHAR_HEIGHT 8
+
+#define UI_LEFT 0x00000001
+#define UI_RIGHT 0x00000002
+#define UI_CENTER (UI_LEFT|UI_RIGHT)
+#define UI_BOTTOM 0x00000004
+#define UI_TOP 0x00000008
+#define UI_MIDDLE (UI_BOTTOM|UI_TOP)
+#define UI_DROPSHADOW 0x00000010
+#define UI_ALTCOLOR 0x00000020
+#define UI_IGNORECOLOR 0x00000040
+#define UI_ALTESCAPES 0x00000080
+#define UI_AUTOWRAP 0x00000100
+#define UI_MULTILINE 0x00000200
+#define UI_DRAWCURSOR 0x00000400
+
+extern const color_t colorTable[8];
+extern const char colorNames[10][8];
+
+qboolean COM_ParseColor( const char *s, color_t color );
+
float V_CalcFov( float fov_x, float width, float height );
void IN_Frame( void );
diff --git a/source/cl_scrn.c b/source/cl_scrn.c
index b97a922..0319b17 100644
--- a/source/cl_scrn.c
+++ b/source/cl_scrn.c
@@ -90,6 +90,23 @@ static const char *const sb_nums[2][STAT_PICS] = {
"anum_6", "anum_7", "anum_8", "anum_9", "anum_minus" }
};
+const color_t colorTable[8] = {
+ { 0, 0, 0, 255 },
+ { 255, 0, 0, 255 },
+ { 0, 255, 0, 255 },
+ { 255, 255, 0, 255 },
+ { 0, 0, 255, 255 },
+ { 0, 255, 255, 255 },
+ { 255, 0, 255, 255 },
+ { 255, 255, 255, 255 }
+};
+
+const char colorNames[10][8] = {
+ "black", "red", "green", "yellow",
+ "blue", "cyan", "magenta", "white",
+ "alt", "none"
+};
+
/*
===============================================================================
@@ -109,12 +126,16 @@ SCR_DrawStringEx
int SCR_DrawStringEx( int x, int y, int flags, size_t maxlen,
const char *s, qhandle_t font )
{
- int w = Q_DrawStrlenTo( s, maxlen ) * CHAR_WIDTH;
-
+ size_t len = strlen( s );
+
+ if( len > maxlen ) {
+ len = maxlen;
+ }
+
if( ( flags & UI_CENTER ) == UI_CENTER ) {
- x -= w / 2;
+ x -= len * CHAR_WIDTH / 2;
} else if( flags & UI_RIGHT ) {
- x -= w;
+ x -= len * CHAR_WIDTH;
}
return R_DrawString( x, y, flags, maxlen, s, font );
@@ -177,6 +198,51 @@ float SCR_FadeAlpha( unsigned startTime, unsigned visTime, unsigned fadeTime ) {
return alpha;
}
+qboolean COM_ParseColor( const char *s, color_t color ) {
+ int i;
+ int c[8];
+
+ if( *s == '#' ) {
+ s++;
+ for( i = 0; s[i]; i++ ) {
+ c[i] = Q_charhex( s[i] );
+ if( c[i] == -1 ) {
+ return qfalse;
+ }
+ }
+ switch( i ) {
+ case 3:
+ color[0] = c[0] | ( c[0] << 4 );
+ color[1] = c[1] | ( c[1] << 4 );
+ color[2] = c[2] | ( c[2] << 4 );
+ color[3] = 255;
+ break;
+ case 6:
+ color[0] = c[1] | ( c[0] << 4 );
+ color[1] = c[3] | ( c[2] << 4 );
+ color[2] = c[5] | ( c[4] << 4 );
+ color[3] = 255;
+ break;
+ case 8:
+ color[0] = c[1] | ( c[0] << 4 );
+ color[1] = c[3] | ( c[2] << 4 );
+ color[2] = c[5] | ( c[4] << 4 );
+ color[3] = c[7] | ( c[6] << 4 );
+ break;
+ default:
+ return qfalse;
+ }
+ return qtrue;
+ } else {
+ for( i = 0; i < 8; i++ ) {
+ if( !strcmp( colorNames[i], s ) ) {
+ *( uint32_t * )color = *( uint32_t * )colorTable[i];
+ return qtrue;
+ }
+ }
+ return qfalse;
+ }
+}
/*
===============================================================================
diff --git a/source/cmd.c b/source/cmd.c
index 35c6ddf..c0b256a 100644
--- a/source/cmd.c
+++ b/source/cmd.c
@@ -1451,7 +1451,7 @@ static void Cmd_EchoEx_f( void ) {
src = Cmd_RawArgsFrom( cmd_optind );
dst = buffer;
while( *src ) {
- if( colors && src[0] == '^' && src[1] ) {
+ /*if( colors && src[0] == '^' && src[1] ) {
if( src[1] == '^' ) {
*dst++ = '^';
} else {
@@ -1460,7 +1460,7 @@ static void Cmd_EchoEx_f( void ) {
dst += 2;
}
src += 2;
- } else if( escapes && src[0] == '\\' && src[1] ) {
+ } else */if( escapes && src[0] == '\\' && src[1] ) {
switch( src[1] ) {
case 't':
*dst++ = '\t';
diff --git a/source/com_local.h b/source/com_local.h
index 6b2b4d5..eb44fbd 100644
--- a/source/com_local.h
+++ b/source/com_local.h
@@ -453,6 +453,20 @@ MISC
#define MAXPRINTMSG 4096
typedef enum {
+ COLOR_BLACK,
+ COLOR_RED,
+ COLOR_GREEN,
+ COLOR_YELLOW,
+ COLOR_BLUE,
+ COLOR_CYAN,
+ COLOR_MAGENTA,
+ COLOR_WHITE,
+
+ COLOR_ALT,
+ COLOR_NONE
+} color_index_t;
+
+typedef enum {
KILL_RESTART,
KILL_DISCONNECT,
KILL_DROP
@@ -482,15 +496,14 @@ typedef void (*rdflush_t)( int target, char *buffer, size_t len );
void Com_BeginRedirect (int target, char *buffer, size_t buffersize, rdflush_t flush);
void Com_EndRedirect (void);
-void Com_LevelPrint( comPrintType_t type, const char *str );
-void Com_LevelError( comErrorType_t code, const char *str ) q_noreturn;
-
#ifdef _WIN32
void Com_AbortFrame( void );
#endif
void Com_Quit( const char *reason, killtype_t type ) q_noreturn;
+void Com_SetColor( color_index_t color );
+
byte COM_BlockSequenceCRCByte (byte *base, size_t length, int sequence);
void Com_ProcessEvents( void );
diff --git a/source/common.c b/source/common.c
index bcd197f..50b3592 100644
--- a/source/common.c
+++ b/source/common.c
@@ -292,6 +292,20 @@ void Com_FlushLogs( void ) {
}
#endif
+void Com_SetColor( color_index_t color ) {
+ if( rd_target ) {
+ return;
+ }
+#if USE_CLIENT
+ // graphical console
+ Con_SetColor( color );
+#endif
+#if USE_SYSCON
+ // debugging console
+ Sys_SetConsoleColor( color );
+#endif
+}
+
/*
=============
Com_Printf
@@ -360,7 +374,7 @@ void Com_DPrintf( const char *fmt, ... ) {
Q_vsnprintf( msg, sizeof( msg ), fmt, argptr );
va_end( argptr );
- Com_Printf( S_COLOR_BLUE "%s", msg );
+ Com_Printf( "%s", msg );
}
/*
@@ -377,7 +391,7 @@ void Com_WPrintf( const char *fmt, ... ) {
Q_vsnprintf( msg, sizeof( msg ), fmt, argptr );
va_end( argptr );
- Com_Printf( S_COLOR_YELLOW "WARNING: %s", msg );
+ Com_Printf( "WARNING: %s", msg );
}
/*
@@ -394,10 +408,9 @@ void Com_EPrintf( const char *fmt, ... ) {
Q_vsnprintf( msg, sizeof( msg ), fmt, argptr );
va_end( argptr );
- Com_Printf( S_COLOR_RED "ERROR: %s", msg );
+ Com_Printf( "ERROR: %s", msg );
}
-
/*
=============
Com_Error
@@ -429,7 +442,7 @@ void Com_Error( comErrorType_t code, const char *fmt, ... ) {
Com_AbortRedirect();
if( code == ERR_DISCONNECT || code == ERR_SILENT ) {
- Com_Printf( S_COLOR_YELLOW "%s\n", com_errorMsg );
+ Com_Printf( "%s\n", com_errorMsg );
SV_Shutdown( va( "Server was killed: %s", com_errorMsg ),
KILL_DISCONNECT );
#if USE_CLIENT
@@ -448,9 +461,9 @@ void Com_Error( comErrorType_t code, const char *fmt, ... ) {
}
if( code == ERR_DROP ) {
- Com_Printf( S_COLOR_RED "********************\n"
- "ERROR: %s\n"
- "********************\n", com_errorMsg );
+ Com_Printf( "********************\n"
+ "ERROR: %s\n"
+ "********************\n", com_errorMsg );
SV_Shutdown( va( "Server crashed: %s\n", com_errorMsg ), KILL_DROP );
#if USE_CLIENT
CL_Disconnect( ERR_DROP, com_errorMsg );
@@ -486,37 +499,6 @@ void Com_AbortFrame( void ) {
#endif
/*
-===================
-Com_LevelPrint
-===================
-*/
-void Com_LevelPrint( comPrintType_t type, const char *str ) {
- switch( type ) {
- case PRINT_DEVELOPER:
- Com_DPrintf( "%s", str );
- break;
- case PRINT_WARNING:
- Com_WPrintf( "%s", str );
- break;
- case PRINT_ERROR:
- Com_EPrintf( "%s", str );
- break;
- default:
- Com_Printf( "%s", str );
- break;
- }
-}
-
-/*
-===================
-Com_LevelError
-===================
-*/
-void Com_LevelError( comErrorType_t code, const char *str ) {
- Com_Error( code, "%s", str );
-}
-
-/*
=============
Com_Quit
@@ -673,11 +655,11 @@ void Z_LeakTest( memtag_t tag ) {
}
if( numLeaks ) {
- Com_Printf( S_COLOR_YELLOW "************* Z_LeakTest *************\n"
- "%s leaked %"PRIz" bytes of memory (%"PRIz" object%s)\n"
- "**************************************\n",
- z_tagnames[tag < TAG_MAX ? tag : TAG_FREE],
- numBytes, numLeaks, numLeaks == 1 ? "" : "s" );
+ Com_Printf( "************* Z_LeakTest *************\n"
+ "%s leaked %"PRIz" bytes of memory (%"PRIz" object%s)\n"
+ "**************************************\n",
+ z_tagnames[tag < TAG_MAX ? tag : TAG_FREE],
+ numBytes, numLeaks, numLeaks == 1 ? "" : "s" );
}
}
@@ -1649,7 +1631,9 @@ void Qcommon_Init( int argc, char **argv ) {
#endif
// print version
- Com_Printf( S_COLOR_CYAN "%s\n", version );
+ Com_SetColor( COLOR_CYAN );
+ Com_Printf( "%s\n", version );
+ Com_SetColor( COLOR_NONE );
FS_Init();
@@ -1733,12 +1717,10 @@ void Qcommon_Init( int argc, char **argv ) {
}
Com_Printf( "====== " APPLICATION " initialized ======\n\n" );
- Com_Printf( S_COLOR_CYAN APPLICATION " " VERSION ", " __DATE__ "\n"
-#if USE_ZLIB
- S_COLOR_RESET "w/ zlib " ZLIB_VERSION "\n"
-#endif
- );
- Com_Printf( "http://q2pro.sf.net\n\n" );
+ Com_SetColor( COLOR_CYAN );
+ Com_Printf( APPLICATION " " VERSION ", " __DATE__ "\n" );
+ Com_SetColor( COLOR_NONE );
+ Com_Printf( "http://skuller.ath.cx/q2pro/\n\n" );
time( &com_startTime );
diff --git a/source/gl_draw.c b/source/gl_draw.c
index c0cfc12..d906239 100644
--- a/source/gl_draw.c
+++ b/source/gl_draw.c
@@ -83,19 +83,23 @@ void R_SetColor( int flags, const color_t color ) {
draw.flags &= ~DRAW_COLOR_MASK;
if( flags == DRAW_COLOR_CLEAR ) {
- *( uint32_t * )draw.color = *( uint32_t * )colorWhite;
+ FastColorCopy( colorWhite, draw.colors[0] );
+ FastColorCopy( colorWhite, draw.colors[1] );
return;
}
if( flags == DRAW_COLOR_ALPHA ) {
- draw.color[3] = *( float * )color * 255;
+ draw.colors[0][3] = *( float * )color * 255;
+ draw.colors[1][3] = *( float * )color * 255;
} else if( flags == DRAW_COLOR_INDEXED ) {
- *( uint32_t * )draw.color = d_8to24table[ *( uint32_t * )color & 255 ];
+ *( uint32_t * )draw.colors[0] = d_8to24table[ *( uint32_t * )color & 255 ];
} else {
if( flags & DRAW_COLOR_RGB ) {
- VectorCopy( color, draw.color );
+ VectorCopy( color, draw.colors[0] );
+ VectorCopy( colorWhite, draw.colors[1] );
}
if( flags & DRAW_COLOR_ALPHA ) {
- draw.color[3] = color[3];
+ draw.colors[0][3] = color[3];
+ draw.colors[1][3] = color[3];
}
}
@@ -196,21 +200,21 @@ void R_DrawStretchPicST( int x, int y, int w, int h, float s1, float t1,
float s2, float t2, qhandle_t pic )
{
/* TODO: scrap support */
- GL_StretchPic( x, y, w, h, s1, t1, s2, t2, draw.color, IMG_ForHandle( pic ) );
+ GL_StretchPic( x, y, w, h, s1, t1, s2, t2, draw.colors[0], IMG_ForHandle( pic ) );
}
void R_DrawStretchPic( int x, int y, int w, int h, qhandle_t pic ) {
image_t *image = IMG_ForHandle( pic );
GL_StretchPic( x, y, w, h, image->sl, image->tl, image->sh, image->th,
- draw.color, image );
+ draw.colors[0], image );
}
void R_DrawPic( int x, int y, qhandle_t pic ) {
image_t *image = IMG_ForHandle( pic );
GL_StretchPic( x, y, image->width, image->height,
- image->sl, image->tl, image->sh, image->th, draw.color, image );
+ image->sl, image->tl, image->sh, image->th, draw.colors[0], image );
}
#define DIV64 ( 1.0f / 64.0f )
@@ -232,65 +236,34 @@ void R_DrawFillEx( int x, int y, int w, int h, const color_t color ) {
void R_FadeScreen( void ) {
}
-void R_DrawChar( int x, int y, int flags, int ch, qhandle_t font ) {
+static inline void draw_char( int x, int y, int c, qboolean alt, image_t *image ) {
float s, t;
-
- ch &= 255;
- s = ( ch & 15 ) * 0.0625f;
- t = ( ch >> 4 ) * 0.0625f;
+
+ if( ( c & 127 ) == 32 ) {
+ return;
+ }
- GL_StretchPic( x, y, 8, 8, s, t, s + 0.0625f, t + 0.0625f,
- draw.color, IMG_ForHandle( font ) );
+ c |= alt << 7;
+ s = ( c & 15 ) * 0.0625f;
+ t = ( c >> 4 ) * 0.0625f;
+ GL_StretchPic( x, y, 8, 8, s, t, s + 0.0625f, t + 0.0625f, draw.colors[alt], image );
}
-int R_DrawString( int x, int y, int flags, size_t maxChars,
- const char *string, qhandle_t font )
-{
- byte c;
- float s, t;
- image_t *image;
- color_t colors[2];
- int mask, altmask = 0;
-
- image = IMG_ForHandle( font );
-
- if( flags & UI_ALTCOLOR ) {
- altmask |= 128;
- }
- mask = altmask;
-
- *( uint32_t * )colors[0] = *( uint32_t * )draw.color;
- *( uint32_t * )colors[1] = MakeColor( 255, 255, 255, draw.color[3] );
- while( maxChars-- && *string ) {
- if( Q_IsColorString( string ) ) {
- c = string[1];
- if( c == COLOR_ALT ) {
- mask |= 128;
- } else if( c == COLOR_RESET ) {
- *( uint32_t * )colors[0] = *( uint32_t * )draw.color;
- mask = altmask;
- } else {
- VectorCopy( colorTable[ ColorIndex( c ) ], colors[0] );
- mask = 0;
- }
- string += 2;
- continue;
- }
-
- c = *string++;
- if( ( c & 127 ) == 32 ) {
- x += 8;
- continue;
- }
+void R_DrawChar( int x, int y, int flags, int c, qhandle_t font ) {
+ qboolean alt = ( flags & UI_ALTCOLOR ) ? qtrue : qfalse;
+ draw_char( x, y, c & 255, alt, IMG_ForHandle( font ) );
+}
- c |= mask;
- s = ( c & 15 ) * 0.0625f;
- t = ( c >> 4 ) * 0.0625f;
+int R_DrawString( int x, int y, int flags, size_t maxlen, const char *s, qhandle_t font ) {
+ image_t *image = IMG_ForHandle( font );
+ qboolean alt = ( flags & UI_ALTCOLOR ) ? qtrue : qfalse;
- GL_StretchPic( x, y, 8, 8, s, t, s + 0.0625f, t + 0.0625f,
- colors[ ( c >> 7 ) & 1 ], image );
+ while( maxlen-- && *s ) {
+ byte c = *s++;
+ draw_char( x, y, c, alt, image );
x += 8;
}
+
return x;
}
diff --git a/source/gl_local.h b/source/gl_local.h
index 71f9e55..4f5983a 100644
--- a/source/gl_local.h
+++ b/source/gl_local.h
@@ -234,7 +234,7 @@ void GL_DisableOutlines( void );
*
*/
typedef struct {
- color_t color;
+ color_t colors[2]; // 0 - actual color, 1 - transparency (for text drawing)
int flags;
float scale;
} drawStatic_t;
diff --git a/source/gl_state.c b/source/gl_state.c
index 6410e3b..f8d6996 100644
--- a/source/gl_state.c
+++ b/source/gl_state.c
@@ -159,7 +159,8 @@ void GL_Setup2D( void ) {
qglOrtho( 0, gl_config.vidWidth, gl_config.vidHeight, 0, -1, 1 );
draw.scale = 1;
- *( uint32_t * )draw.color = *( uint32_t * )colorWhite;
+ FastColorCopy( colorWhite, draw.colors[0] );
+ FastColorCopy( colorWhite, draw.colors[1] );
if( draw.flags & DRAW_CLIP_MASK ) {
qglDisable( GL_SCISSOR_TEST );
diff --git a/source/q_field.c b/source/q_field.c
index bd92caf..f1e3361 100644
--- a/source/q_field.c
+++ b/source/q_field.c
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include "com_local.h"
+#include "cl_public.h"
#include "key_public.h"
#include "ref_public.h"
#include "vid_public.h"
diff --git a/source/q_shared.c b/source/q_shared.c
index 9c11c16..5a27132 100644
--- a/source/q_shared.c
+++ b/source/q_shared.c
@@ -23,27 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
vec3_t vec3_origin = { 0, 0, 0 };
-#if USE_CLIENT
-const color_t colorTable[8] = {
- { 0, 0, 0, 255 },
- { 255, 0, 0, 255 },
- { 0, 255, 0, 255 },
- { 255, 255, 0, 255 },
- { 0, 0, 255, 255 },
- { 0, 255, 255, 255 },
- { 255, 0, 255, 255 },
- { 255, 255, 255, 255 }
-};
-
-const char colorNames[10][8] = {
- "black", "red", "green", "yellow",
- "blue", "cyan", "magenta", "white",
- "alt", "none"
-};
-#endif // USE_CLIENT
-
-//============================================================================
-
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
{
float angle;
@@ -392,54 +371,6 @@ unsigned COM_ParseHex( const char *s ) {
return result;
}
-#if USE_CLIENT
-qboolean COM_ParseColor( const char *s, color_t color ) {
- int i;
- int c[8];
-
- if( *s == '#' ) {
- s++;
- for( i = 0; s[i]; i++ ) {
- c[i] = Q_charhex( s[i] );
- if( c[i] == -1 ) {
- return qfalse;
- }
- }
- switch( i ) {
- case 3:
- color[0] = c[0] | ( c[0] << 4 );
- color[1] = c[1] | ( c[1] << 4 );
- color[2] = c[2] | ( c[2] << 4 );
- color[3] = 255;
- break;
- case 6:
- color[0] = c[1] | ( c[0] << 4 );
- color[1] = c[3] | ( c[2] << 4 );
- color[2] = c[5] | ( c[4] << 4 );
- color[3] = 255;
- break;
- case 8:
- color[0] = c[1] | ( c[0] << 4 );
- color[1] = c[3] | ( c[2] << 4 );
- color[2] = c[5] | ( c[4] << 4 );
- color[3] = c[7] | ( c[6] << 4 );
- break;
- default:
- return qfalse;
- }
- return qtrue;
- } else {
- for( i = 0; i < 8; i++ ) {
- if( !strcmp( colorNames[i], s ) ) {
- *( uint32_t * )color = *( uint32_t * )colorTable[i];
- return qtrue;
- }
- }
- return qfalse;
- }
-}
-#endif // USE_CLIENT
-
/*
=================
SortStrcmp
@@ -526,87 +457,6 @@ unsigned Com_HashPath( const char *string, int hashSize ) {
/*
================
-Q_DrawStrlen
-================
-*/
-int Q_DrawStrlen( const char *string ) {
- int length;
-
- length = 0;
- while( *string ) {
- if( Q_IsColorString( string ) ) {
- string++;
- } else {
- length++;
- }
- string++;
- }
-
- return length;
-}
-
-/*
-================
-Q_DrawStrlenTo
-================
-*/
-int Q_DrawStrlenTo( const char *string, int maxChars ) {
- int length;
-
- if( maxChars < 1 ) {
- maxChars = MAX_STRING_CHARS;
- }
-
- length = 0;
- while( *string && maxChars-- ) {
- if( Q_IsColorString( string ) ) {
- string++;
- } else {
- length++;
- }
- string++;
- }
-
- return length;
-}
-
-/*
-================
-Q_ClearColorStr
-
-Removes color escape codes, high-bit and unprintable characters.
-Return number of characters written, not including the NULL character.
-================
-*/
-int Q_ClearColorStr( char *out, const char *in, int bufsize ) {
- char *p, *m;
- int c;
-
- if( bufsize < 1 ) {
- Com_Error( ERR_FATAL, "%s: bad bufsize: %d", __func__, bufsize );
- }
-
- p = out;
- m = out + bufsize - 1;
- while( *in && p < m ) {
- if( Q_IsColorString( in ) ) {
- in += 2;
- continue;
- }
- c = *in++;
- c &= 127;
- if( Q_isprint( c ) ) {
- *p++ = c;
- }
- }
-
- *p = 0;
-
- return p - out;
-}
-
-/*
-================
Q_ClearStr
Removes high-bit and unprintable characters.
@@ -736,73 +586,6 @@ char *Q_FormatString( const char *string ) {
return buffer;
}
-#if 0
-
-typedef enum {
- ESC_CHR = ( 1 << 0 ),
- ESC_CLR = ( 1 << 1 )
-} escape_t;
-
-/*
-================
-Q_UnescapeString
-================
-*/
-size_t Q_UnescapeString( char *out, const char *in, size_t bufsize, escape_t flags ) {
- char *dst, *last;
- int c;
-
- if( bufsize < 1 ) {
- Com_Error( ERR_FATAL, "%s: bad bufsize: %d", __func__, bufsize );
- }
-
- p = out;
- m = out + bufsize - 1;
- while( *in && p < m ) {
- c = *in++;
-
- if( ( flags & ESC_CHR ) && c == '\\' ) {
- c = *in++;
- switch( c ) {
- case 0:
- goto breakOut;
- case 't':
- c = '\t';
- break;
- case 'b':
- c = '\b';
- break;
- case 'r':
- c = '\r';
- break;
- case 'n':
- c = '\n';
- break;
- case '\\':
- c = '\\';
- break;
- case 'x':
- if( ( c = Q_charhex( in[0] ) ) == -1 ) {
- goto breakOut;
- }
- result = c | ( r << 4 );
- }
- break;
- default:
- break;
- }
-
- *p++ = c;
- }
- }
-
- *dst = 0;
-
- return buffer;
-
-}
-#endif
-
size_t Q_FormatFileSize( char *dest, size_t bytes, size_t size ) {
if( bytes >= 1000000 ) {
return Q_snprintf( dest, size, "%2.1fM", ( float )bytes / 1000000 );
diff --git a/source/q_shared.h b/source/q_shared.h
index 93175b4..fe07962 100644
--- a/source/q_shared.h
+++ b/source/q_shared.h
@@ -179,11 +179,6 @@ struct cplane_s;
extern vec3_t vec3_origin;
-#if USE_CLIENT
-extern const color_t colorTable[8];
-extern const char colorNames[10][8];
-#endif
-
typedef struct vrect_s {
int x, y, width, height;
} vrect_t;
@@ -271,6 +266,8 @@ static inline float Q_fabs( float f ) {
#define Vector4Negate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2],(b)[3]=-(a)[3])
#define Vector4Set(v, a, b, c, d) ((v)[0]=(a),(v)[1]=(b),(v)[2]=(c),(v)[3]=(d))
+#define FastColorCopy(a,b) (*(uint32_t*)(b)=*(uint32_t*)(a))
+
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
vec_t VectorNormalize (vec3_t v); // returns vector length
vec_t VectorNormalize2 (vec3_t v, vec3_t out);
@@ -331,75 +328,9 @@ static inline int rand_byte( void ) {
#define Q_SetBit( data, bit ) ( (data)[(bit) >> 3] |= ( 1 << ( (bit) & 7 ) ) )
#define Q_ClearBit( data, bit ) ( (data)[(bit) >> 3] &= ~( 1 << ( (bit) & 7 ) ) )
-/* use escape character server will never send */
-#define Q_COLOR_ESCAPE '\x7F'
-#define Q_COLOR_ESCAPE_STRING "\x7F"
-#define Q_IsColorString(p) ( *(p) == Q_COLOR_ESCAPE && *( (p) + 1 ) )
-
-#define COLOR_BLACK '0'
-#define COLOR_RED '1'
-#define COLOR_GREEN '2'
-#define COLOR_YELLOW '3'
-#define COLOR_BLUE '4'
-#define COLOR_CYAN '5'
-#define COLOR_MAGENTA '6'
-#define COLOR_WHITE '7'
-#define ColorIndex(c) ( ( (c) - '0' ) & 7 )
-
-#define COLOR_ALT '8'
-#define COLOR_RESET '9'
-
-#define S_COLOR_BLACK Q_COLOR_ESCAPE_STRING "0"
-#define S_COLOR_RED Q_COLOR_ESCAPE_STRING "1"
-#define S_COLOR_GREEN Q_COLOR_ESCAPE_STRING "2"
-#define S_COLOR_YELLOW Q_COLOR_ESCAPE_STRING "3"
-#define S_COLOR_BLUE Q_COLOR_ESCAPE_STRING "4"
-#define S_COLOR_CYAN Q_COLOR_ESCAPE_STRING "5"
-#define S_COLOR_MAGENTA Q_COLOR_ESCAPE_STRING "6"
-#define S_COLOR_WHITE Q_COLOR_ESCAPE_STRING "7"
-
-#define S_COLOR_ALT Q_COLOR_ESCAPE_STRING "8"
-#define S_COLOR_RESET Q_COLOR_ESCAPE_STRING "9"
-
-#define colorBlack colorTable[ColorIndex(COLOR_BLACK)]
-#define colorRed colorTable[ColorIndex(COLOR_RED)]
-#define colorGreen colorTable[ColorIndex(COLOR_GREEN)]
-#define colorYellow colorTable[ColorIndex(COLOR_YELLOW)]
-#define colorBlue colorTable[ColorIndex(COLOR_BLUE)]
-#define colorCyan colorTable[ColorIndex(COLOR_CYAN)]
-#define colorMagenta colorTable[ColorIndex(COLOR_MAGENTA)]
-#define colorWhite colorTable[ColorIndex(COLOR_WHITE)]
-
-#define MAKERGB(v,r,g,b) ((v)[0]=(r),(v)[1]=(g),(v)[2]=(b))
-#define MAKERGBA(v,r,g,b,a) ((v)[0]=(r),(v)[1]=(g),(v)[2]=(b),(v)[3]=(a))
-
-#define SCREEN_WIDTH 640
-#define SCREEN_HEIGHT 480
-
-#define UI_LEFT 0x00000001
-#define UI_RIGHT 0x00000002
-#define UI_CENTER (UI_LEFT|UI_RIGHT)
-#define UI_BOTTOM 0x00000004
-#define UI_TOP 0x00000008
-#define UI_MIDDLE (UI_BOTTOM|UI_TOP)
-#define UI_DROPSHADOW 0x00000010
-#define UI_ALTCOLOR 0x00000020
-#define UI_IGNORECOLOR 0x00000040
-#define UI_ALTESCAPES 0x00000080
-#define UI_AUTOWRAP 0x00000100
-#define UI_MULTILINE 0x00000200
-#define UI_DRAWCURSOR 0x00000400
-
-#define CHAR_WIDTH 8
-#define CHAR_HEIGHT 8
-
-int Q_DrawStrlen( const char *string );
-int Q_DrawStrlenTo( const char *string, int maxChars );
qboolean Q_IsWhiteSpace( const char *string );
char *Q_FormatString( const char *string );
-char *Q_UnescapeString( const char *string );
size_t Q_FormatFileSize( char *dest, size_t bytes, size_t size );
-int Q_ClearColorStr( char *out, const char *in, int bufsize );
int Q_ClearStr( char *out, const char *in, int bufsize );
int Q_HighlightStr( char *out, const char *in, int bufsize );
@@ -541,7 +472,6 @@ size_t Q_snprintf( char *dest, size_t size, const char *fmt, ... ) q_printf( 3,
size_t Q_scnprintf( char *dest, size_t size, const char *fmt, ... ) q_printf( 3, 4 );
unsigned COM_ParseHex( const char *string );
-qboolean COM_ParseColor( const char *s, color_t color );
char *va( const char *format, ... ) q_printf( 1, 2 );
diff --git a/source/sw_draw.c b/source/sw_draw.c
index d7d2311..eabdbd3 100644
--- a/source/sw_draw.c
+++ b/source/sw_draw.c
@@ -566,7 +566,8 @@ int R_DrawString( int x, int y, int flags, size_t maxChars,
image_t *image;
byte c, *data;
int xx, yy;
- int color, mask;
+ int color;
+ qboolean alt;
if( !font ) {
return x;
@@ -576,48 +577,20 @@ int R_DrawString( int x, int y, int flags, size_t maxChars,
return x;
}
- mask = 0;
- if( flags & UI_ALTCOLOR ) {
- mask |= 128;
- }
-
+ alt = ( flags & UI_ALTCOLOR ) ? qtrue : qfalse;
color = draw.colorIndex;
- while( *string ) {
- if( Q_IsColorString( string ) ) {
- string++;
- c = *string++;
- if( c == COLOR_ALT ) {
- mask |= 128;
- } else if( c == COLOR_RESET ) {
- color = draw.colorIndex;
- mask = 0;
- if( flags & UI_ALTCOLOR ) {
- mask |= 128;
- }
- } else if( !( flags & UI_IGNORECOLOR ) ) {
- color = colorIndices[ ColorIndex( c ) ];
- }
- continue;
- }
-
- if( !maxChars-- ) {
- break;
- }
-
- if( !( c = *string++ ) ) {
- break;
- }
-
- c |= mask;
-
+ while( maxChars-- && *string ) {
+ c = *string++;
if( ( c & 127 ) == 32 ) {
- x += 8; /* optimized case */
+ x += 8;
continue;
}
+ c |= alt << 7;
xx = ( c & 15 ) << 3;
yy = ( c >> 4 ) << 3;
+
data = image->pixels[0] + yy * image->width + xx;
if( color != -1 && !( c & 128 ) ) {
R_DrawFixedDataAsMask( x, y, 8, 8, image->width, data, color );
diff --git a/source/sys_public.h b/source/sys_public.h
index 4cf713e..7e7a984 100644
--- a/source/sys_public.h
+++ b/source/sys_public.h
@@ -45,6 +45,7 @@ void Sys_AddDefaultConfig( void );
void Sys_RunConsole( void );
void Sys_ConsoleOutput( const char *string );
void Sys_SetConsoleTitle( const char *title );
+void Sys_SetConsoleColor( color_index_t color );
void Sys_Printf( const char *fmt, ... ) q_printf( 1, 2 );
#endif
diff --git a/source/sys_unix.c b/source/sys_unix.c
index fbb56df..72d5406 100644
--- a/source/sys_unix.c
+++ b/source/sys_unix.c
@@ -152,91 +152,50 @@ static void tty_shutdown_input( void ) {
}
}
-static const char color_to_ansi[8] = {
- '0', '1', '2', '3', '4', '6', '5', '7' };
-
-static void tty_write_output( const char *text ) {
- char buffer[MAXPRINTMSG];
- char *p = buffer, *m = buffer + sizeof( buffer );
- int c, color = 0;
-
- while( *text ) {
- if( Q_IsColorString( text ) ) {
- color = text[1];
- text += 2;
- if( p + 5 > m ) {
- break;
- }
- p[0] = '\033';
- p[1] = '[';
- if( color == COLOR_RESET ) {
- p[2] = '0';
- p[3] = 'm';
- p += 4;
- } else if( color == COLOR_ALT ) {
- p[2] = '3';
- p[3] = '2';
- p[4] = 'm';
- p += 5;
- } else {
- p[2] = '3';
- p[3] = color_to_ansi[ ColorIndex( color ) ];
- p[4] = 'm';
- p += 5;
- }
- continue;
- }
- if( p + 1 > m ) {
- break;
- }
- c = *text++;
- if( c & 128 ) {
- c &= 127;
- if( c < 32 ) {
- continue;
- }
- }
- *p++ = c;
- }
+void Sys_SetConsoleColor( color_index_t color ) {
+ static const char color_to_ansi[8] =
+ { '0', '1', '2', '3', '4', '6', '5', '7' };
+ char buf[5];
+ size_t len;
- if( color ) {
- if( p + 4 > m ) {
- p = m - 4;
- }
- p[0] = '\033';
- p[1] = '[';
- p[2] = '0';
- p[3] = 'm';
- p += 4;
+ buf[0] = '\033';
+ buf[1] = '[';
+ switch( color ) {
+ case COLOR_NONE:
+ buf[2] = '0';
+ buf[3] = 'm';
+ len = 4;
+ break;
+ case COLOR_ALT:
+ buf[2] = '3';
+ buf[3] = '2';
+ buf[4] = 'm';
+ len = 5;
+ break;
+ default:
+ buf[2] = '3';
+ buf[3] = color_to_ansi[color];
+ buf[4] = 'm';
+ len = 5;
+ break;
}
- write( 1, buffer, p - buffer );
+ write( 1, buf, len );
}
-static void simple_write_output( const char *text ) {
- char buffer[MAXPRINTMSG];
- char *p = buffer, *m = buffer + sizeof( buffer );
- int c;
+static void tty_write_output( const char *text ) {
+ char buf[MAXPRINTMSG];
+ size_t len;
- while( *text ) {
- if( Q_IsColorString( text ) ) {
- text += 2;
- continue;
- }
- if( p + 1 > m ) {
+ for( len = 0; len < MAXPRINTMSG; len++ ) {
+ int c = *text++;
+ if( !c ) {
break;
}
- c = *text++;
- if( c & 128 ) {
- c &= 127;
- if( c < 32 ) {
- continue;
- }
- }
- *p++ = c;
+ buf[len] = Q_charascii( c );
}
- write( 1, buffer, p - buffer );
+ write( 1, buf, len );
}
/*
@@ -250,13 +209,12 @@ void Sys_ConsoleOutput( const char *text ) {
}
if( !tty_enabled ) {
- simple_write_output( text );
- return;
+ tty_write_output( text );
+ } else {
+ tty_hide_input();
+ tty_write_output( text );
+ tty_show_input();
}
-
- tty_hide_input();
- tty_write_output( text );
- tty_show_input();
}
void Sys_SetConsoleTitle( const char *title ) {
@@ -333,16 +291,13 @@ static void tty_parse_input( const char *text ) {
}
if( key == '\t' ) {
- //Con_Print(va("before=%d (%s)\n",tty_prompt.inputLine.cursorPos,tty_prompt.inputLine.text) );
tty_hide_input();
Prompt_CompleteCommand( &tty_prompt, qfalse );
f->cursorPos = strlen( f->text ); // FIXME
tty_show_input();
- //Con_Print(va("after=%d (%s)\n",tty_prompt.inputLine.cursorPos,tty_prompt.inputLine.text) );
continue;
}
- //Com_Printf( "%s\n",Q_FormatString(text));
if( *text ) {
key = *text++;
if( key == '[' || key == 'O' ) {
diff --git a/source/ui_atoms.c b/source/ui_atoms.c
index ab1ba1a..fb421ee 100644
--- a/source/ui_atoms.c
+++ b/source/ui_atoms.c
@@ -325,9 +325,9 @@ void UI_DrawString( int x, int y, const color_t color, int flags, const char *st
}
if( ( flags & UI_CENTER ) == UI_CENTER ) {
- x -= Q_DrawStrlen( string ) * 8 / 2;
+ x -= strlen( string ) * 8 / 2;
} else if( flags & UI_RIGHT ) {
- x -= Q_DrawStrlen( string ) * 8;
+ x -= strlen( string ) * 8;
}
R_DrawString( x, y, flags, MAX_STRING_CHARS, string, uis.fontHandle );
@@ -342,7 +342,7 @@ void UI_DrawChar( int x, int y, int flags, int ch ) {
void UI_StringDimensions( vrect_t *rc, int flags, const char *string ) {
rc->height = 8;
- rc->width = 8 * Q_DrawStrlen( string );
+ rc->width = 8 * strlen( string );
if( ( flags & UI_CENTER ) == UI_CENTER ) {
rc->x -= rc->width / 2;
diff --git a/source/ui_menu.c b/source/ui_menu.c
index 1b9cc32..3bc3c4b 100644
--- a/source/ui_menu.c
+++ b/source/ui_menu.c
@@ -150,7 +150,7 @@ static void Keybind_Init( menuKeybind_t *k ) {
k->generic.uiFlags | UI_RIGHT, k->generic.name );
k->generic.rect.width += ( RCOLUMN_OFFSET - LCOLUMN_OFFSET ) +
- Q_DrawStrlen( k->binding ) * CHAR_WIDTH;
+ strlen( k->binding ) * CHAR_WIDTH;
}
/*
@@ -442,7 +442,7 @@ void SpinControl_Init( menuSpinControl_t *s ) {
s->numItems = 0;
n = s->itemnames;
while( *n ) {
- length = Q_DrawStrlen( *n );
+ length = strlen( *n );
if( maxLength < length ) {
maxLength = length;