engine: client: combine loading or paused icon drawing

This commit is contained in:
Alibek Omarov 2019-11-08 01:28:01 +03:00
parent 3f48bce7da
commit db39f0cc88
1 changed files with 30 additions and 55 deletions

View File

@ -380,7 +380,26 @@ static void SPR_AdjustSize( float *x, float *y, float *w, float *h )
{
float xscale, yscale;
if( !x && !y && !w && !h ) return;
// scale for screen sizes
xscale = refState.width / (float)clgame.scrInfo.iWidth;
yscale = refState.height / (float)clgame.scrInfo.iHeight;
if( x ) *x *= xscale;
if( y ) *y *= yscale;
if( w ) *w *= xscale;
if( h ) *h *= yscale;
}
/*
====================
SPR_AdjustSize
draw hudsprite routine
====================
*/
static void SPR_AdjustSizei( int *x, int *y, int *w, int *h )
{
float xscale, yscale;
// scale for screen sizes
xscale = refState.width / (float)clgame.scrInfo.iWidth;
@ -401,19 +420,9 @@ draw hudsprite routine
*/
void PicAdjustSize( float *x, float *y, float *w, float *h )
{
float xscale, yscale;
if( !clgame.ds.adjust_size ) return;
if( !x && !y && !w && !h ) return;
// scale for screen sizes
xscale = refState.width / (float)clgame.scrInfo.iWidth;
yscale = refState.height / (float)clgame.scrInfo.iHeight;
if( x ) *x *= xscale;
if( y ) *y *= yscale;
if( w ) *w *= xscale;
if( h ) *h *= yscale;
SPR_AdjustSize( x, y, w, h );
}
static qboolean SPR_Scissor( float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 )
@ -947,25 +956,20 @@ CL_DrawLoading
draw loading progress bar
=============
*/
static void CL_DrawLoading( float percent )
static void CL_DrawLoadingOrPaused( qboolean paused, float percent )
{
int x, y, width, height, right;
float xscale, yscale, step, s2;
R_GetTextureParms( &width, &height, cls.loadingBar );
R_GetTextureParms( &width, &height, paused ? cls.pauseIcon : cls.loadingBar );
x = ( clgame.scrInfo.iWidth - width ) >> 1;
y = ( clgame.scrInfo.iHeight - height) >> 1;
xscale = refState.width / (float)clgame.scrInfo.iWidth;
yscale = refState.height / (float)clgame.scrInfo.iHeight;
SPR_AdjustSizei( &x, &y, &width, &height );
x *= xscale;
y *= yscale;
width *= xscale;
height *= yscale;
if( cl_allow_levelshots->value )
if( !paused && cl_allow_levelshots->value )
{
float step, s2;
ref.dllFuncs.Color4ub( 128, 128, 128, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.loadingBar );
@ -988,35 +992,6 @@ static void CL_DrawLoading( float percent )
}
}
/*
=============
CL_DrawPause
draw pause sign
=============
*/
static void CL_DrawPause( void )
{
int x, y, width, height;
float xscale, yscale;
R_GetTextureParms( &width, &height, cls.pauseIcon );
x = ( clgame.scrInfo.iWidth - width ) >> 1;
y = ( clgame.scrInfo.iHeight - height) >> 1;
xscale = refState.width / (float)clgame.scrInfo.iWidth;
yscale = refState.height / (float)clgame.scrInfo.iHeight;
x *= xscale;
y *= yscale;
width *= xscale;
height *= yscale;
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.pauseIcon );
}
void CL_DrawHUD( int state )
{
if( state == CL_ACTIVE && !cl.video_prepped )
@ -1040,15 +1015,15 @@ void CL_DrawHUD( int state )
CL_DrawCrosshair ();
CL_DrawCenterPrint ();
clgame.dllFuncs.pfnRedraw( cl.time, cl.intermission );
CL_DrawPause();
CL_DrawLoadingOrPaused( true, 0.0f );
break;
case CL_LOADING:
CL_DrawLoading( scr_loading->value );
CL_DrawLoadingOrPaused( false, scr_loading->value );
break;
case CL_CHANGELEVEL:
if( cls.draw_changelevel )
{
CL_DrawLoading( 100.0f );
CL_DrawLoadingOrPaused( false, 100.0f );
cls.draw_changelevel = false;
}
break;