Browse Source

engine: client: font: fix consecutive newlines skipped, add flag to reset color after a newline

pull/2/head
Alibek Omarov 2 years ago
parent
commit
6eae3471cf
  1. 5
      engine/client/cl_font.c
  2. 10
      engine/client/cl_scrn.c
  3. 1
      engine/client/client.h

5
engine/client/cl_font.c

@ -213,6 +213,10 @@ int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *fon @@ -213,6 +213,10 @@ int CL_DrawString( float x, float y, const char *s, rgba_t color, cl_font_t *fon
draw_len = 0;
y += font->charHeight;
}
if( FBitSet( flags, FONT_DRAW_RESETCOLORONLF ))
Vector4Copy( color, current_color );
continue;
}
if( IsColorString( s ))
@ -275,6 +279,7 @@ void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height, @@ -275,6 +279,7 @@ void CL_DrawStringLen( cl_font_t *font, const char *s, int *width, int *height,
if( height )
*height += font->charHeight;
}
continue;
}
if( IsColorString( s ))

10
engine/client/cl_scrn.c

@ -150,8 +150,7 @@ same as r_speeds but for network channel @@ -150,8 +150,7 @@ same as r_speeds but for network channel
void SCR_NetSpeeds( void )
{
static char msg[MAX_SYSPATH];
int x, y, height;
char *p, *start, *end;
int x, y;
float time = cl.mtime[0];
static int min_svfps = 100;
static int max_svfps = 0;
@ -201,7 +200,7 @@ void SCR_NetSpeeds( void ) @@ -201,7 +200,7 @@ void SCR_NetSpeeds( void )
y = 384;
MakeRGBA( color, 255, 255, 255, 255 );
CL_DrawString( x, y, msg, color, font, 0 );
CL_DrawString( x, y, msg, color, font, FONT_DRAW_RESETCOLORONLF );
}
/*
@ -218,8 +217,7 @@ void SCR_RSpeeds( void ) @@ -218,8 +217,7 @@ void SCR_RSpeeds( void )
if( ref.dllFuncs.R_SpeedsMessage( msg, sizeof( msg )))
{
int x, y, height;
char *p, *start, *end;
int x, y;
rgba_t color;
cl_font_t *font = Con_GetCurFont();
@ -227,7 +225,7 @@ void SCR_RSpeeds( void ) @@ -227,7 +225,7 @@ void SCR_RSpeeds( void )
y = 64;
MakeRGBA( color, 255, 255, 255, 255 );
CL_DrawString( x, y, msg, color, font, 0 );
CL_DrawString( x, y, msg, color, font, FONT_DRAW_RESETCOLORONLF );
}
}

1
engine/client/client.h

@ -326,6 +326,7 @@ typedef struct @@ -326,6 +326,7 @@ typedef struct
#define FONT_DRAW_FORCECOL BIT( 2 ) // ignore colorcodes
#define FONT_DRAW_NORENDERMODE BIT( 3 ) // ignore font's default rendermode
#define FONT_DRAW_NOLF BIT( 4 ) // ignore \n
#define FONT_DRAW_RESETCOLORONLF BIT( 5 ) // yet another flag to simulate consecutive Con_DrawString calls...
typedef struct
{

Loading…
Cancel
Save