2007-11-06 22:00:00 +01:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// cl_scrn.c - build client frame
|
|
|
|
|
//=======================================================================
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
|
#include "common.h"
|
2007-06-21 22:00:00 +02:00
|
|
|
|
#include "client.h"
|
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
vrect_t scr_vrect; // position of render window on screen
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-08 22:00:00 +01:00
|
|
|
|
cvar_t *scr_viewsize;
|
|
|
|
|
cvar_t *scr_centertime;
|
|
|
|
|
cvar_t *scr_showpause;
|
|
|
|
|
cvar_t *scr_printspeed;
|
|
|
|
|
cvar_t *scr_loading;
|
2008-08-03 22:00:00 +02:00
|
|
|
|
cvar_t *scr_download;
|
2007-11-18 22:00:00 +01:00
|
|
|
|
cvar_t *scr_width;
|
|
|
|
|
cvar_t *scr_height;
|
2008-08-04 22:00:00 +02:00
|
|
|
|
cvar_t *cl_testentities;
|
|
|
|
|
cvar_t *cl_testlights;
|
2007-11-13 22:00:00 +01:00
|
|
|
|
cvar_t *cl_levelshot_name;
|
2008-01-20 22:00:00 +01:00
|
|
|
|
cvar_t *cl_font;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
void SCR_TimeRefresh_f( void );
|
|
|
|
|
void SCR_Loading_f( void );
|
2007-11-08 22:00:00 +01:00
|
|
|
|
|
2007-11-04 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
================
|
2007-11-06 22:00:00 +01:00
|
|
|
|
SCR_AdjustSize
|
2007-11-04 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
Adjusted for resolution and screen aspect ratio
|
|
|
|
|
================
|
|
|
|
|
*/
|
|
|
|
|
void SCR_AdjustSize( float *x, float *y, float *w, float *h )
|
|
|
|
|
{
|
2007-11-29 22:00:00 +01:00
|
|
|
|
float xscale, yscale;
|
2007-11-04 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// scale for screen sizes
|
2007-11-18 22:00:00 +01:00
|
|
|
|
xscale = scr_width->integer / 640.0f;
|
|
|
|
|
yscale = scr_height->integer / 480.0f;
|
2007-11-04 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
if(x) *x *= xscale;
|
|
|
|
|
if(y) *y *= yscale;
|
|
|
|
|
if(w) *w *= xscale;
|
|
|
|
|
if(h) *h *= yscale;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SCR_FillRect
|
|
|
|
|
|
|
|
|
|
Coordinates are 640*480 virtual values
|
|
|
|
|
=================
|
|
|
|
|
*/
|
|
|
|
|
void SCR_FillRect( float x, float y, float width, float height, const float *color )
|
|
|
|
|
{
|
|
|
|
|
re->SetColor( color );
|
|
|
|
|
SCR_AdjustSize( &x, &y, &width, &height );
|
|
|
|
|
re->DrawFill( x, y, width, height );
|
|
|
|
|
re->SetColor( NULL );
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-04 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SCR_DrawPic
|
|
|
|
|
|
|
|
|
|
Coordinates are 640*480 virtual values
|
|
|
|
|
================
|
|
|
|
|
*/
|
2008-06-29 22:00:00 +02:00
|
|
|
|
void SCR_DrawPic( float x, float y, float width, float height, const char *picname )
|
2007-11-04 22:00:00 +01:00
|
|
|
|
{
|
2007-11-13 22:00:00 +01:00
|
|
|
|
int w, h;
|
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
// to avoid drawing r_notexture image
|
|
|
|
|
if(!picname || !*picname ) return;
|
|
|
|
|
|
2007-11-13 22:00:00 +01:00
|
|
|
|
// get original size
|
|
|
|
|
if(width == -1 || height == -1)
|
|
|
|
|
{
|
|
|
|
|
re->DrawGetPicSize( &w, &h, picname );
|
|
|
|
|
width = w, height = h;
|
|
|
|
|
}
|
2007-11-04 22:00:00 +01:00
|
|
|
|
SCR_AdjustSize( &x, &y, &width, &height );
|
|
|
|
|
re->DrawStretchPic (x, y, width, height, 0, 0, 1, 1, picname );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
================
|
|
|
|
|
SCR_DrawChar
|
|
|
|
|
|
|
|
|
|
chars are drawn at 640*480 virtual screen size
|
|
|
|
|
================
|
|
|
|
|
*/
|
2007-11-23 22:00:00 +01:00
|
|
|
|
void SCR_DrawChar( int x, int y, float w, float h, int ch )
|
2007-11-04 22:00:00 +01:00
|
|
|
|
{
|
2007-11-23 22:00:00 +01:00
|
|
|
|
float size, frow, fcol;
|
2007-11-04 22:00:00 +01:00
|
|
|
|
float ax, ay, aw, ah;
|
|
|
|
|
|
|
|
|
|
ch &= 255;
|
|
|
|
|
|
|
|
|
|
if( ch == ' ' )return;
|
2007-11-23 22:00:00 +01:00
|
|
|
|
if(y < -h) return;
|
2007-11-04 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
ax = x;
|
|
|
|
|
ay = y;
|
2007-11-23 22:00:00 +01:00
|
|
|
|
aw = w;
|
|
|
|
|
ah = h;
|
2007-11-04 22:00:00 +01:00
|
|
|
|
SCR_AdjustSize( &ax, &ay, &aw, &ah );
|
2007-11-23 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
frow = (ch >> 4)*0.0625f + (0.5f / 256.0f);
|
|
|
|
|
fcol = (ch & 15)*0.0625f + (0.5f / 256.0f);
|
|
|
|
|
size = 0.0625f - (1.0f / 256.0f);
|
2007-11-04 22:00:00 +01:00
|
|
|
|
|
2008-01-20 22:00:00 +01:00
|
|
|
|
re->DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size, va( "fonts/%s", cl_font->string ));
|
2007-11-04 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
====================
|
|
|
|
|
SCR_DrawSmallChar
|
|
|
|
|
|
|
|
|
|
small chars are drawn at native screen resolution
|
|
|
|
|
====================
|
|
|
|
|
*/
|
|
|
|
|
void SCR_DrawSmallChar( int x, int y, int ch )
|
|
|
|
|
{
|
|
|
|
|
float frow, fcol;
|
|
|
|
|
float size;
|
|
|
|
|
|
|
|
|
|
ch &= 255;
|
|
|
|
|
|
|
|
|
|
if( ch == ' ' )return;
|
|
|
|
|
if(y < -SMALLCHAR_HEIGHT) return;
|
|
|
|
|
|
2007-11-23 22:00:00 +01:00
|
|
|
|
frow = (ch >> 4)*0.0625f + (0.5f / 256.0f);
|
|
|
|
|
fcol = (ch & 15)*0.0625f + (0.5f / 256.0f);
|
|
|
|
|
size = 0.0625f - (1.0f / 256.0f);
|
2007-11-04 22:00:00 +01:00
|
|
|
|
|
2008-01-20 22:00:00 +01:00
|
|
|
|
re->DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, fcol, frow, fcol + size, frow + size, va( "fonts/%s", cl_font->string ));
|
2007-11-04 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
2007-11-06 22:00:00 +01:00
|
|
|
|
SCR_DrawBigString[Color]
|
2007-11-04 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
Draws a multi-colored string with a drop shadow, optionally forcing
|
|
|
|
|
to a fixed color.
|
|
|
|
|
|
|
|
|
|
Coordinates are at 640 by 480 virtual resolution
|
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-23 22:00:00 +01:00
|
|
|
|
void SCR_DrawStringExt( int x, int y, float w, float h, const char *string, float *setColor, bool forceColor )
|
2007-11-04 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
vec4_t color;
|
|
|
|
|
const char *s;
|
|
|
|
|
int xx;
|
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
// draw the drop shadow
|
|
|
|
|
Vector4Set( color, 0.0f, 0.0f, 0.0f, setColor[3] );
|
|
|
|
|
re->SetColor( color );
|
2007-11-04 22:00:00 +01:00
|
|
|
|
s = string;
|
|
|
|
|
xx = x;
|
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
while ( *s )
|
|
|
|
|
{
|
|
|
|
|
if(IsColorString( s ))
|
|
|
|
|
{
|
|
|
|
|
s += 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2007-11-23 22:00:00 +01:00
|
|
|
|
SCR_DrawChar( xx + 2, y + 2, w, h, *s );
|
|
|
|
|
xx += w;
|
2007-11-06 22:00:00 +01:00
|
|
|
|
s++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// draw the colored text
|
|
|
|
|
s = string;
|
|
|
|
|
xx = x;
|
2007-11-04 22:00:00 +01:00
|
|
|
|
re->SetColor( setColor );
|
|
|
|
|
while ( *s )
|
|
|
|
|
{
|
|
|
|
|
if(IsColorString( s ))
|
|
|
|
|
{
|
2007-11-06 22:00:00 +01:00
|
|
|
|
if ( !forceColor )
|
2007-11-04 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
Mem_Copy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ));
|
|
|
|
|
color[3] = setColor[3];
|
|
|
|
|
re->SetColor( color );
|
|
|
|
|
}
|
|
|
|
|
s += 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2007-11-23 22:00:00 +01:00
|
|
|
|
SCR_DrawChar( xx, y, w, h, *s );
|
|
|
|
|
xx += w;
|
2007-11-04 22:00:00 +01:00
|
|
|
|
s++;
|
|
|
|
|
}
|
|
|
|
|
re->SetColor( NULL );
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
void SCR_DrawBigString( int x, int y, const char *s, float alpha )
|
|
|
|
|
{
|
|
|
|
|
float color[4];
|
2007-11-04 22:00:00 +01:00
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
Vector4Set( color, 1.0f, 1.0f, 1.0f, alpha );
|
2007-11-23 22:00:00 +01:00
|
|
|
|
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, s, color, false );
|
2007-11-06 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color )
|
|
|
|
|
{
|
2007-11-23 22:00:00 +01:00
|
|
|
|
SCR_DrawStringExt( x, y, BIGCHAR_WIDTH, BIGCHAR_HEIGHT, s, color, true );
|
2007-11-06 22:00:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==================
|
|
|
|
|
SCR_DrawSmallString[Color]
|
|
|
|
|
|
|
|
|
|
Draws a multi-colored string with a drop shadow, optionally forcing
|
2007-11-04 22:00:00 +01:00
|
|
|
|
to a fixed color.
|
|
|
|
|
|
|
|
|
|
Coordinates are at 640 by 480 virtual resolution
|
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-06 22:00:00 +01:00
|
|
|
|
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, bool forceColor )
|
2007-11-04 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
vec4_t color;
|
|
|
|
|
const char *s;
|
|
|
|
|
int xx;
|
|
|
|
|
|
|
|
|
|
// draw the colored text
|
|
|
|
|
s = string;
|
|
|
|
|
xx = x;
|
2007-11-06 22:00:00 +01:00
|
|
|
|
|
2007-11-04 22:00:00 +01:00
|
|
|
|
re->SetColor( setColor );
|
|
|
|
|
while ( *s )
|
|
|
|
|
{
|
|
|
|
|
if(IsColorString( s ))
|
|
|
|
|
{
|
2007-11-06 22:00:00 +01:00
|
|
|
|
if( !forceColor )
|
2007-11-04 22:00:00 +01:00
|
|
|
|
{
|
|
|
|
|
Mem_Copy( color, g_color_table[ColorIndex(*(s+1))], sizeof( color ));
|
|
|
|
|
color[3] = setColor[3];
|
|
|
|
|
re->SetColor( color );
|
|
|
|
|
}
|
|
|
|
|
s += 2;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2007-11-06 22:00:00 +01:00
|
|
|
|
SCR_DrawSmallChar( xx, y, *s );
|
|
|
|
|
xx += SMALLCHAR_WIDTH;
|
2007-11-04 22:00:00 +01:00
|
|
|
|
s++;
|
|
|
|
|
}
|
|
|
|
|
re->SetColor( NULL );
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-04 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
|
|
Cinematic user interface
|
|
|
|
|
==============================================================================
|
|
|
|
|
*/
|
|
|
|
|
bool SCR_PlayCinematic( char *name, int bits )
|
|
|
|
|
{
|
|
|
|
|
string path;
|
|
|
|
|
|
|
|
|
|
if( cls.state == ca_cinematic )
|
|
|
|
|
SCR_StopCinematic();
|
|
|
|
|
|
2008-08-10 22:00:00 +02:00
|
|
|
|
com.sprintf( path, "media/%s", name );
|
2008-08-04 22:00:00 +02:00
|
|
|
|
FS_DefaultExtension( path, ".dpv" );
|
|
|
|
|
|
|
|
|
|
S_StopAllSounds();
|
|
|
|
|
//S_StartStreaming();
|
|
|
|
|
|
|
|
|
|
if(CIN_PlayCinematic( path ))
|
|
|
|
|
{
|
|
|
|
|
SCR_RunCinematic(); // load first frame
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCR_DrawCinematic( void )
|
|
|
|
|
{
|
|
|
|
|
CIN_DrawCinematic();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCR_RunCinematic( void )
|
|
|
|
|
{
|
|
|
|
|
CIN_RunCinematic();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCR_StopCinematic( void )
|
|
|
|
|
{
|
|
|
|
|
CIN_StopCinematic();
|
|
|
|
|
S_StopAllSounds();
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==================
|
2007-11-06 22:00:00 +01:00
|
|
|
|
SCR_UpdateScreen
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
This is called every frame, and can also be called explicitly to flush
|
|
|
|
|
text to the screen.
|
2007-06-21 22:00:00 +02:00
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-06 22:00:00 +01:00
|
|
|
|
void SCR_UpdateScreen( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-11-06 22:00:00 +01:00
|
|
|
|
if(!V_PreRender()) return;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-05 22:00:00 +01:00
|
|
|
|
switch( cls.state )
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-11-05 22:00:00 +01:00
|
|
|
|
case ca_disconnected:
|
|
|
|
|
case ca_connecting:
|
|
|
|
|
case ca_connected:
|
2008-06-29 22:00:00 +02:00
|
|
|
|
CL_DrawHUD();
|
2007-11-05 22:00:00 +01:00
|
|
|
|
break;
|
|
|
|
|
case ca_active:
|
2007-11-06 22:00:00 +01:00
|
|
|
|
V_CalcRect();
|
2007-11-05 22:00:00 +01:00
|
|
|
|
V_RenderView();
|
2008-06-29 22:00:00 +02:00
|
|
|
|
CL_DrawHUD();
|
2008-07-12 22:00:00 +02:00
|
|
|
|
CL_DrawDemoRecording();
|
|
|
|
|
break;
|
|
|
|
|
case ca_cinematic:
|
|
|
|
|
SCR_DrawCinematic();
|
2007-11-05 22:00:00 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2007-11-13 22:00:00 +01:00
|
|
|
|
Host_Error("SCR_UpdateScreen: bad cls.state" );
|
2007-11-05 22:00:00 +01:00
|
|
|
|
break;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
}
|
2008-07-01 22:00:00 +02:00
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
V_PostRender();
|
2007-11-05 22:00:00 +01:00
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-05 22:00:00 +01:00
|
|
|
|
/*
|
|
|
|
|
==================
|
2007-11-06 22:00:00 +01:00
|
|
|
|
SCR_Init
|
2007-11-05 22:00:00 +01:00
|
|
|
|
==================
|
|
|
|
|
*/
|
2007-11-06 22:00:00 +01:00
|
|
|
|
void SCR_Init (void)
|
2007-11-05 22:00:00 +01:00
|
|
|
|
{
|
2008-08-04 22:00:00 +02:00
|
|
|
|
cls.mempool = Mem_AllocPool( "Client Static" );
|
|
|
|
|
|
2008-06-29 22:00:00 +02:00
|
|
|
|
scr_showpause = Cvar_Get("scr_showpause", "1", 0, "show pause picture" );
|
|
|
|
|
scr_centertime = Cvar_Get("scr_centertime", "2.5", 0, "centerprint hold time" );
|
|
|
|
|
scr_printspeed = Cvar_Get("scr_printspeed", "8", 0, "centerprint speed of print" );
|
|
|
|
|
cl_levelshot_name = Cvar_Get("cl_levelshot_name", "common/black", 0, "contains path to current levelshot" );
|
|
|
|
|
cl_font = Cvar_Get("cl_font", "conchars", CVAR_ARCHIVE, "contains path to current charset" );
|
2008-08-03 22:00:00 +02:00
|
|
|
|
scr_loading = Cvar_Get("scr_loading", "0", 0, "loading bar progress" );
|
|
|
|
|
scr_download = Cvar_Get("scr_download", "0", 0, "downloading bar progress" );
|
2008-08-04 22:00:00 +02:00
|
|
|
|
cl_testentities = Cvar_Get ("cl_testentities", "0", 0, "test client entities" );
|
|
|
|
|
cl_testlights = Cvar_Get ("cl_testlights", "0", 0, "test dynamic lights" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
|
// register our commands
|
2008-01-20 22:00:00 +01:00
|
|
|
|
Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );
|
|
|
|
|
Cmd_AddCommand( "loading", SCR_Loading_f, "prepare client to a loading new map" );
|
|
|
|
|
Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" );
|
|
|
|
|
Cmd_AddCommand( "setfont", CL_SetFont_f, "set new system font" );
|
2008-08-04 22:00:00 +02:00
|
|
|
|
Cmd_AddCommand( "viewpos", SCR_Viewpos_f, "prints current player origin" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SCR_Shutdown( void )
|
|
|
|
|
{
|
|
|
|
|
Mem_FreePool( &cls.mempool );
|
2007-11-06 22:00:00 +01:00
|
|
|
|
}
|