コード例 #1
0
ファイル: cl_screen.c プロジェクト: tenght/qfusion
/*
* SCR_RegisterConsoleFont
*/
static void SCR_RegisterConsoleFont( void )
{
	const char *con_fontSystemFamilyName;
	const int con_fontSystemStyle = DEFAULT_SYSTEM_FONT_STYLE;
	int size;
	float pixelRatio = Con_GetPixelRatio();

	// register system fonts
	con_fontSystemFamilyName = con_fontSystemFamily->string;
	if( !con_fontSystemConsoleSize->integer ) {
		Cvar_SetValue( con_fontSystemConsoleSize->name, DEFAULT_SYSTEM_FONT_SMALL_SIZE );
	} else if( con_fontSystemConsoleSize->integer > DEFAULT_SYSTEM_FONT_SMALL_SIZE * 2 ) {
		Cvar_SetValue( con_fontSystemConsoleSize->name, DEFAULT_SYSTEM_FONT_SMALL_SIZE * 2 );
	} else if( con_fontSystemConsoleSize->integer < DEFAULT_SYSTEM_FONT_SMALL_SIZE / 2 ) {
		Cvar_SetValue( con_fontSystemConsoleSize->name, DEFAULT_SYSTEM_FONT_SMALL_SIZE / 2 );
	}

	size = ceil( con_fontSystemConsoleSize->integer * pixelRatio );
	cls.consoleFont = SCR_RegisterFont( con_fontSystemFamilyName, con_fontSystemStyle, size );
	if( !cls.consoleFont )
	{
		Cvar_ForceSet( con_fontSystemFamily->name, con_fontSystemFamily->dvalue );
		con_fontSystemFamilyName = con_fontSystemFamily->dvalue;

		size = DEFAULT_SYSTEM_FONT_SMALL_SIZE;
		cls.consoleFont = SCR_RegisterFont( con_fontSystemFamilyName, con_fontSystemStyle, size );
		if( !cls.consoleFont )
			Com_Error( ERR_FATAL, "Couldn't load default font \"%s\"", con_fontSystemFamily->dvalue );

		Con_CheckResize();
	}
}
コード例 #2
0
ファイル: cl_screen.c プロジェクト: Racenet/racesow
static void SCR_InitFonts( void )
{
	cvar_t *con_fontSystemSmall = Cvar_Get( "con_fontSystemSmall", DEFAULT_FONT_SMALL, CVAR_ARCHIVE|CVAR_LATCH_VIDEO );
	cvar_t *con_fontSystemMedium = Cvar_Get( "con_fontSystemMedium", DEFAULT_FONT_MEDIUM, CVAR_ARCHIVE|CVAR_LATCH_VIDEO );
	cvar_t *con_fontSystemBig = Cvar_Get( "con_fontSystemBig", DEFAULT_FONT_BIG, CVAR_ARCHIVE|CVAR_LATCH_VIDEO );

	fonts_mempool = Mem_AllocPool( NULL, "Fonts" );

	// register system fonts
	cls.fontSystemSmall = SCR_RegisterFont( con_fontSystemSmall->string );
	if( !cls.fontSystemSmall )
	{
		cls.fontSystemSmall = SCR_RegisterFont( DEFAULT_FONT_SMALL );
		if( !cls.fontSystemSmall )
			Com_Error( ERR_FATAL, "Couldn't load default font \"%s\"", DEFAULT_FONT_SMALL );
	}

	cls.fontSystemMedium = SCR_RegisterFont( con_fontSystemMedium->string );
	if( !cls.fontSystemMedium )
		cls.fontSystemMedium = SCR_RegisterFont( DEFAULT_FONT_MEDIUM );

	cls.fontSystemBig = SCR_RegisterFont( con_fontSystemBig->string );
	if( !cls.fontSystemBig )
		cls.fontSystemBig = SCR_RegisterFont( DEFAULT_FONT_BIG );
}
コード例 #3
0
/*
* SCR_RegisterSystemFonts
*/
static void SCR_RegisterSystemFonts( void )
{
	const char *con_fontSystemFamilyName;
	const int con_fontSystemStyle = DEFAULT_SYSTEM_FONT_STYLE;

	// register system fonts
	con_fontSystemFamilyName = con_fontSystemFamily->string;
	if( !con_fontSystemSmallSize->integer ) {
		Cvar_ForceSet( con_fontSystemSmallSize->name, con_fontSystemSmallSize->dvalue );
	}
	if( !con_fontSystemMediumSize->integer ) {
		Cvar_ForceSet( con_fontSystemMediumSize->name, con_fontSystemMediumSize->dvalue );
	}
	if( !con_fontSystemBigSize->integer ) {
		Cvar_ForceSet( con_fontSystemBigSize->name, con_fontSystemBigSize->dvalue );
	}

	cls.fontSystemSmall = SCR_RegisterFont( con_fontSystemFamilyName, con_fontSystemStyle, 
		con_fontSystemSmallSize->integer );
	if( !cls.fontSystemSmall )
	{
		Cvar_ForceSet( con_fontSystemFamily->name, con_fontSystemFamily->dvalue );
		con_fontSystemFamilyName = con_fontSystemFamily->dvalue;

		cls.fontSystemSmall = SCR_RegisterFont( con_fontSystemFamilyName, con_fontSystemStyle, 
			DEFAULT_SYSTEM_FONT_SMALL_SIZE );
		if( !cls.fontSystemSmall )
			Com_Error( ERR_FATAL, "Couldn't load default font \"%s\"", con_fontSystemFamily->dvalue );
	}

	cls.fontSystemMedium = SCR_RegisterFont( con_fontSystemFamilyName, con_fontSystemStyle, 
		con_fontSystemMediumSize->integer );
	if( !cls.fontSystemMedium )
		cls.fontSystemMedium = SCR_RegisterFont( con_fontSystemFamilyName, con_fontSystemStyle, 
			DEFAULT_SYSTEM_FONT_MEDIUM_SIZE );

	cls.fontSystemBig = SCR_RegisterFont( con_fontSystemFamily->string, con_fontSystemStyle, 
		con_fontSystemBigSize->integer );
	if( !cls.fontSystemBig )
		cls.fontSystemBig = SCR_RegisterFont( con_fontSystemFamilyName, con_fontSystemStyle, 
		DEFAULT_SYSTEM_FONT_BIG_SIZE );
}
コード例 #4
0
ファイル: console.c プロジェクト: Turupawn/DogeWarsow
/*
* Con_DrawNotify
*
* Draws the last few lines of output transparently over the game top
*/
void Con_DrawNotify( void )
{
    int v;
    char *text;
    const char *say;
    const char *translated;
    int i;
    int time;
    char *s;

    v = 0;
    if( con_drawNotify->integer )
    {
        for( i = min( NUM_CON_TIMES, con.numlines ) - 1; i >= 0; i-- )
        {
            time = con.times[i];
            if( time == 0 )
                continue;
            time = cls.realtime - time;
            if( time > con_notifytime->value*1000 )
                continue;
            text = con.text[i] ? con.text[i] : "";

            SCR_DrawString( 8, v, ALIGN_LEFT_TOP, text, cls.fontSystemSmall, colorWhite );

            v += SCR_strHeight( cls.fontSystemSmall );
        }
    }

    if( cls.key_dest == key_message )
    {
        int x, y;
        int width, prewidth;
        int promptwidth, cursorwidth;
        struct qfontface_s *font = NULL;

        if( con_chatCGame->integer )
        {
            width = con_chatWidth->integer;

            if( *con_chatFontFamily->string && con_chatFontSize->integer ) {
                font = SCR_RegisterFont( con_chatFontFamily->string, con_chatFontStyle->integer, con_chatFontSize->integer );
            }
            if( !font )
                font = cls.fontSystemSmall;

            x = con_chatX->integer;
            y = con_chatY->integer;
        }
        else
        {
            width = viddef.width;
            x = 8;
            y = v;
            font = cls.fontSystemSmall;
        }

        // 48 is an arbitrary offset for not overlapping the FPS and clock prints
        width -= 48;
        cursorwidth = SCR_strWidth( "_", font, 0 );

        if( chat_team )
        {
            say = "say_team:";
        }
        else
        {
            say = "say:";
        }

        translated = L10n_TranslateString( "common", say );
        if( !translated ) {
            translated = say;
        }
        SCR_DrawString( x, y, ALIGN_LEFT_TOP, translated, font, colorWhite );
        promptwidth = SCR_strWidth( translated, font, 0 ) + SCR_strWidth( " ", font, 0 );

        s = chat_buffer;
        prewidth = chat_linepos ? SCR_strWidth( s, font, chat_linepos ) : 0;

        // don't let the cursor go beyond the left screen edge
        clamp_high( chat_prestep, prewidth );

        // don't let it go beyond the right screen edge
        clamp_low( chat_prestep, prewidth - ( width - promptwidth - cursorwidth ) );

        // FIXME: we double the font height to compensate for alignment issues
        SCR_DrawClampString( x + promptwidth - chat_prestep,
                             y, s, x + promptwidth, y,
                             x + width, y + SCR_strHeight( font ) * 2, font, colorWhite );

        if( (int)( cls.realtime>>8 )&1 )
            SCR_DrawRawChar( x + promptwidth + prewidth - chat_prestep, y, '_',
                             font, colorWhite );
    }