engine: client: fix taking console color from colors.lst

This commit is contained in:
Alibek Omarov 2024-01-25 04:22:20 +03:00
parent 7c82766a5c
commit 47bc50b8c6
3 changed files with 19 additions and 5 deletions

View File

@ -1092,6 +1092,11 @@ static int pfnDelete( const char *path )
return FS_Delete( path ); return FS_Delete( path );
} }
static void GAME_EXPORT pfnCon_DefaultColor( int r, int g, int b )
{
Con_DefaultColor( r, g, b, true );
}
// engine callbacks // engine callbacks
static ui_enginefuncs_t gEngfuncs = static ui_enginefuncs_t gEngfuncs =
{ {
@ -1131,7 +1136,7 @@ static ui_enginefuncs_t gEngfuncs =
UI_DrawConsoleString, UI_DrawConsoleString,
UI_DrawSetTextColor, UI_DrawSetTextColor,
Con_DrawStringLen, Con_DrawStringLen,
Con_DefaultColor, pfnCon_DefaultColor,
pfnGetPlayerModel, pfnGetPlayerModel,
pfnSetPlayerModel, pfnSetPlayerModel,
pfnClearScene, pfnClearScene,

View File

@ -1072,7 +1072,7 @@ int Con_UtfProcessChar( int in );
int Con_UtfProcessCharForce( int in ); int Con_UtfProcessCharForce( int in );
int Con_UtfMoveLeft( char *str, int pos ); int Con_UtfMoveLeft( char *str, int pos );
int Con_UtfMoveRight( char *str, int pos, int length ); int Con_UtfMoveRight( char *str, int pos, int length );
void Con_DefaultColor( int r, int g, int b ); void Con_DefaultColor( int r, int g, int b, qboolean gameui );
void Con_InvalidateFonts( void ); void Con_InvalidateFonts( void );
cl_font_t *Con_GetCurFont( void ); cl_font_t *Con_GetCurFont( void );
cl_font_t *Con_GetFont( int num ); cl_font_t *Con_GetFont( int num );

View File

@ -175,10 +175,10 @@ static void Con_SetColor( void )
switch( num ) switch( num )
{ {
case 1: case 1:
Con_DefaultColor( r, r, r ); Con_DefaultColor( r, r, r, false );
break; break;
case 3: case 3:
Con_DefaultColor( r, g, b ); Con_DefaultColor( r, g, b, false );
break; break;
default: default:
Cvar_DirectSet( &con_color, con_color.def_string ); Cvar_DirectSet( &con_color, con_color.def_string );
@ -2310,11 +2310,20 @@ Con_DefaultColor
called from MainUI called from MainUI
========= =========
*/ */
void GAME_EXPORT Con_DefaultColor( int r, int g, int b ) void Con_DefaultColor( int r, int g, int b, qboolean gameui )
{ {
r = bound( 0, r, 255 ); r = bound( 0, r, 255 );
g = bound( 0, g, 255 ); g = bound( 0, g, 255 );
b = bound( 0, b, 255 ); b = bound( 0, b, 255 );
// gameui wants to override console color... check if it's not default
if( gameui && ( g_color_table[7][0] != r || g_color_table[7][1] != g || g_color_table[7][2] != b ))
{
// yes, different from default orange, disable con_color
SetBits( con_color.flags, FCVAR_READ_ONLY );
ClearBits( con_color.flags, FCVAR_CHANGED );
}
MakeRGBA( g_color_table[7], r, g, b, 255 ); MakeRGBA( g_color_table[7], r, g, b, 255 );
} }