mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-30 08:44:31 +00:00
engine: client: move console cvars to static allocation
This commit is contained in:
parent
f19ed1c1c2
commit
3918bcd71c
@ -1904,7 +1904,7 @@ drawing string like a console string
|
|||||||
*/
|
*/
|
||||||
int GAME_EXPORT pfnDrawConsoleString( int x, int y, char *string )
|
int GAME_EXPORT pfnDrawConsoleString( int x, int y, char *string )
|
||||||
{
|
{
|
||||||
cl_font_t *font = Con_GetFont( con_fontsize->value );
|
cl_font_t *font = Con_GetFont( con_fontsize.value );
|
||||||
rgba_t color;
|
rgba_t color;
|
||||||
Vector4Copy( clgame.ds.textColor, color );
|
Vector4Copy( clgame.ds.textColor, color );
|
||||||
Vector4Set( clgame.ds.textColor, 255, 255, 255, 255 );
|
Vector4Set( clgame.ds.textColor, 255, 255, 255, 255 );
|
||||||
@ -1937,7 +1937,7 @@ compute string length in screen pixels
|
|||||||
*/
|
*/
|
||||||
void GAME_EXPORT pfnDrawConsoleStringLen( const char *pText, int *length, int *height )
|
void GAME_EXPORT pfnDrawConsoleStringLen( const char *pText, int *length, int *height )
|
||||||
{
|
{
|
||||||
cl_font_t *font = Con_GetFont( con_fontsize->value );
|
cl_font_t *font = Con_GetFont( con_fontsize.value );
|
||||||
|
|
||||||
if( height ) *height = font->charHeight;
|
if( height ) *height = font->charHeight;
|
||||||
CL_DrawStringLen( font, pText, length, NULL, FONT_DRAW_UTF8 | FONT_DRAW_HUD );
|
CL_DrawStringLen( font, pText, length, NULL, FONT_DRAW_UTF8 | FONT_DRAW_HUD );
|
||||||
|
@ -1031,7 +1031,7 @@ void CL_RunLightStyles( void );
|
|||||||
//
|
//
|
||||||
// console.c
|
// console.c
|
||||||
//
|
//
|
||||||
extern convar_t *con_fontsize;
|
extern convar_t con_fontsize;
|
||||||
int Con_Visible( void );
|
int Con_Visible( void );
|
||||||
qboolean Con_FixedFont( void );
|
qboolean Con_FixedFont( void );
|
||||||
void Con_VidInit( void );
|
void Con_VidInit( void );
|
||||||
|
@ -22,13 +22,14 @@ GNU General Public License for more details.
|
|||||||
#include "wadfile.h"
|
#include "wadfile.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
convar_t *con_notifytime;
|
static CVAR_DEFINE_AUTO( scr_conspeed, "600", FCVAR_ARCHIVE, "console moving speed" );
|
||||||
convar_t *scr_conspeed;
|
static CVAR_DEFINE_AUTO( con_notifytime, "3", FCVAR_ARCHIVE, "notify time to live" );
|
||||||
convar_t *con_fontsize;
|
CVAR_DEFINE_AUTO( con_fontsize, "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" );
|
||||||
convar_t *con_charset;
|
static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" );
|
||||||
convar_t *con_fontscale;
|
static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" );
|
||||||
convar_t *con_fontnum;
|
static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
|
||||||
convar_t *con_color;
|
static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
||||||
|
|
||||||
|
|
||||||
static int g_codepage = 0;
|
static int g_codepage = 0;
|
||||||
static qboolean g_utf8 = false;
|
static qboolean g_utf8 = false;
|
||||||
@ -162,14 +163,13 @@ Con_SetColor
|
|||||||
*/
|
*/
|
||||||
static void Con_SetColor( void )
|
static void Con_SetColor( void )
|
||||||
{
|
{
|
||||||
vec3_t color;
|
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
if( !FBitSet( con_color->flags, FCVAR_CHANGED ))
|
if( !FBitSet( con_color.flags, FCVAR_CHANGED ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
num = sscanf( con_color->string, "%i %i %i", &r, &g, &b );
|
num = sscanf( con_color.string, "%i %i %i", &r, &g, &b );
|
||||||
|
|
||||||
switch( num )
|
switch( num )
|
||||||
{
|
{
|
||||||
@ -180,11 +180,11 @@ static void Con_SetColor( void )
|
|||||||
Con_DefaultColor( r, g, b );
|
Con_DefaultColor( r, g, b );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Cvar_DirectSet( con_color, con_color->def_string );
|
Cvar_DirectSet( &con_color, con_color.def_string );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearBits( con_color->flags, FCVAR_CHANGED );
|
ClearBits( con_color.flags, FCVAR_CHANGED );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -538,7 +538,7 @@ INTERNAL RESOURCE
|
|||||||
static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
|
static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
|
||||||
{
|
{
|
||||||
qboolean success = false;
|
qboolean success = false;
|
||||||
float scale = con_fontscale->value;
|
float scale = con_fontscale.value;
|
||||||
|
|
||||||
if( font->valid )
|
if( font->valid )
|
||||||
return; // already loaded
|
return; // already loaded
|
||||||
@ -593,8 +593,8 @@ static void Con_LoadConchars( void )
|
|||||||
Con_LoadConsoleFont( i, con.chars + i );
|
Con_LoadConsoleFont( i, con.chars + i );
|
||||||
|
|
||||||
// select properly fontsize
|
// select properly fontsize
|
||||||
if( con_fontnum->value >= 0 && con_fontnum->value <= CON_NUMFONTS - 1 )
|
if( con_fontnum.value >= 0 && con_fontnum.value <= CON_NUMFONTS - 1 )
|
||||||
fontSize = con_fontnum->value;
|
fontSize = con_fontnum.value;
|
||||||
else if( refState.width <= 640 )
|
else if( refState.width <= 640 )
|
||||||
fontSize = 0;
|
fontSize = 0;
|
||||||
else if( refState.width >= 1280 )
|
else if( refState.width >= 1280 )
|
||||||
@ -830,19 +830,17 @@ Con_Init
|
|||||||
*/
|
*/
|
||||||
void Con_Init( void )
|
void Con_Init( void )
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if( host.type == HOST_DEDICATED )
|
if( host.type == HOST_DEDICATED )
|
||||||
return; // dedicated server already have console
|
return; // dedicated server already have console
|
||||||
|
|
||||||
// must be init before startup video subsystem
|
// must be init before startup video subsystem
|
||||||
scr_conspeed = Cvar_Get( "scr_conspeed", "600", FCVAR_ARCHIVE, "console moving speed" );
|
Cvar_RegisterVariable( &scr_conspeed );
|
||||||
con_notifytime = Cvar_Get( "con_notifytime", "3", FCVAR_ARCHIVE, "notify time to live" );
|
Cvar_RegisterVariable( &con_notifytime );
|
||||||
con_fontsize = Cvar_Get( "con_fontsize", "1", FCVAR_ARCHIVE, "console font number (0, 1 or 2)" );
|
Cvar_RegisterVariable( &con_fontsize );
|
||||||
con_charset = Cvar_Get( "con_charset", "cp1251", FCVAR_ARCHIVE, "console font charset (only cp1251 supported now)" );
|
Cvar_RegisterVariable( &con_charset );
|
||||||
con_fontscale = Cvar_Get( "con_fontscale", "1.0", FCVAR_ARCHIVE, "scale font texture" );
|
Cvar_RegisterVariable( &con_fontscale );
|
||||||
con_fontnum = Cvar_Get( "con_fontnum", "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
|
Cvar_RegisterVariable( &con_fontnum );
|
||||||
con_color = Cvar_Get( "con_color", "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
Cvar_RegisterVariable( &con_color );
|
||||||
|
|
||||||
// init the console buffer
|
// init the console buffer
|
||||||
con.bufsize = CON_TEXTSIZE;
|
con.bufsize = CON_TEXTSIZE;
|
||||||
@ -1799,7 +1797,7 @@ void Con_DrawNotify( void )
|
|||||||
{
|
{
|
||||||
con_lineinfo_t *l = &CON_LINES( i );
|
con_lineinfo_t *l = &CON_LINES( i );
|
||||||
|
|
||||||
if( l->addtime < ( time - con_notifytime->value ))
|
if( l->addtime < ( time - con_notifytime.value ))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Con_DrawString( x, y, l->start, g_color_table[7] );
|
Con_DrawString( x, y, l->start, g_color_table[7] );
|
||||||
@ -2095,7 +2093,7 @@ void Con_RunConsole( void )
|
|||||||
}
|
}
|
||||||
else con.showlines = 0; // none visible
|
else con.showlines = 0; // none visible
|
||||||
|
|
||||||
lines_per_frame = fabs( scr_conspeed->value ) * host.realframetime;
|
lines_per_frame = fabs( scr_conspeed.value ) * host.realframetime;
|
||||||
|
|
||||||
if( con.showlines < con.vislines )
|
if( con.showlines < con.vislines )
|
||||||
{
|
{
|
||||||
@ -2110,34 +2108,34 @@ void Con_RunConsole( void )
|
|||||||
con.vislines = con.showlines;
|
con.vislines = con.showlines;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FBitSet( con_charset->flags, FCVAR_CHANGED ) ||
|
if( FBitSet( con_charset.flags, FCVAR_CHANGED ) ||
|
||||||
FBitSet( con_fontscale->flags, FCVAR_CHANGED ) ||
|
FBitSet( con_fontscale.flags, FCVAR_CHANGED ) ||
|
||||||
FBitSet( con_fontnum->flags, FCVAR_CHANGED ) ||
|
FBitSet( con_fontnum.flags, FCVAR_CHANGED ) ||
|
||||||
FBitSet( cl_charset.flags, FCVAR_CHANGED ))
|
FBitSet( cl_charset.flags, FCVAR_CHANGED ))
|
||||||
{
|
{
|
||||||
// update codepage parameters
|
// update codepage parameters
|
||||||
if( !Q_stricmp( con_charset->string, "cp1251" ))
|
if( !Q_stricmp( con_charset.string, "cp1251" ))
|
||||||
{
|
{
|
||||||
g_codepage = 1251;
|
g_codepage = 1251;
|
||||||
}
|
}
|
||||||
else if( !Q_stricmp( con_charset->string, "cp1252" ))
|
else if( !Q_stricmp( con_charset.string, "cp1252" ))
|
||||||
{
|
{
|
||||||
g_codepage = 1252;
|
g_codepage = 1252;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Con_Printf( S_WARN "Unknown charset %s, defaulting to cp1252", con_charset->string );
|
Con_Printf( S_WARN "Unknown charset %s, defaulting to cp1252", con_charset.string );
|
||||||
|
|
||||||
Cvar_DirectSet( con_charset, "cp1252" );
|
Cvar_DirectSet( &con_charset, "cp1252" );
|
||||||
g_codepage = 1252;
|
g_codepage = 1252;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
|
g_utf8 = !Q_stricmp( cl_charset.string, "utf-8" );
|
||||||
Con_InvalidateFonts();
|
Con_InvalidateFonts();
|
||||||
Con_LoadConchars();
|
Con_LoadConchars();
|
||||||
ClearBits( con_charset->flags, FCVAR_CHANGED );
|
ClearBits( con_charset.flags, FCVAR_CHANGED );
|
||||||
ClearBits( con_fontnum->flags, FCVAR_CHANGED );
|
ClearBits( con_fontnum.flags, FCVAR_CHANGED );
|
||||||
ClearBits( con_fontscale->flags, FCVAR_CHANGED );
|
ClearBits( con_fontscale.flags, FCVAR_CHANGED );
|
||||||
ClearBits( cl_charset.flags, FCVAR_CHANGED );
|
ClearBits( cl_charset.flags, FCVAR_CHANGED );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user