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

View File

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