Browse Source

engine: client: add hud_scale_minimal_width to limit scaling factor and potentially avoid unsupported hud sprites resolutions

master
Alibek Omarov 11 months ago
parent
commit
af316bff14
  1. 12
      engine/client/cl_game.c
  2. 2
      engine/client/cl_main.c
  3. 1
      engine/client/client.h

12
engine/client/cl_game.c

@ -1641,6 +1641,7 @@ get actual screen info
*/ */
int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo ) int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
{ {
qboolean apply_scale_factor = false;
float scale_factor = hud_scale.value; float scale_factor = hud_scale.value;
if( FBitSet( hud_fontscale.flags, FCVAR_CHANGED )) if( FBitSet( hud_fontscale.flags, FCVAR_CHANGED ))
@ -1656,16 +1657,23 @@ int GAME_EXPORT CL_GetScreenInfo( SCREENINFO *pscrinfo )
clgame.scrInfo.iFlags = SCRINFO_SCREENFLASH; clgame.scrInfo.iFlags = SCRINFO_SCREENFLASH;
if( scale_factor && scale_factor != 1.0f ) if( scale_factor && scale_factor != 1.0f )
{
float scaled_width = (float)refState.width / scale_factor;
if( scaled_width >= hud_scale_minimal_width.value )
apply_scale_factor = true;
}
if( apply_scale_factor )
{ {
clgame.scrInfo.iWidth = (float)refState.width / scale_factor; clgame.scrInfo.iWidth = (float)refState.width / scale_factor;
clgame.scrInfo.iHeight = (float)refState.height / scale_factor; clgame.scrInfo.iHeight = (float)refState.height / scale_factor;
clgame.scrInfo.iFlags |= SCRINFO_STRETCHED; SetBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED );
} }
else else
{ {
clgame.scrInfo.iWidth = refState.width; clgame.scrInfo.iWidth = refState.width;
clgame.scrInfo.iHeight = refState.height; clgame.scrInfo.iHeight = refState.height;
clgame.scrInfo.iFlags &= ~SCRINFO_STRETCHED; ClearBits( clgame.scrInfo.iFlags, SCRINFO_STRETCHED );
} }
if( !pscrinfo ) return 0; if( !pscrinfo ) return 0;

2
engine/client/cl_main.c

@ -62,6 +62,7 @@ CVAR_DEFINE_AUTO( cl_clockreset, "0.1", FCVAR_ARCHIVE, "frametime delta maximum
CVAR_DEFINE_AUTO( cl_fixtimerate, "7.5", FCVAR_ARCHIVE, "time in msec to client clock adjusting" ); CVAR_DEFINE_AUTO( cl_fixtimerate, "7.5", FCVAR_ARCHIVE, "time in msec to client clock adjusting" );
CVAR_DEFINE_AUTO( hud_fontscale, "1.0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud font texture" ); CVAR_DEFINE_AUTO( hud_fontscale, "1.0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud font texture" );
CVAR_DEFINE_AUTO( hud_scale, "0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud at current resolution" ); CVAR_DEFINE_AUTO( hud_scale, "0", FCVAR_ARCHIVE|FCVAR_LATCH, "scale hud at current resolution" );
CVAR_DEFINE_AUTO( hud_scale_minimal_width, "640", FCVAR_ARCHIVE|FCVAR_LATCH, "if hud_scale results in a HUD virtual screen smaller than this value, it won't be applied" );
CVAR_DEFINE_AUTO( cl_solid_players, "1", 0, "Make all players not solid (can't traceline them)" ); CVAR_DEFINE_AUTO( cl_solid_players, "1", 0, "Make all players not solid (can't traceline them)" );
CVAR_DEFINE_AUTO( cl_updaterate, "20", FCVAR_USERINFO|FCVAR_ARCHIVE, "refresh rate of server messages" ); CVAR_DEFINE_AUTO( cl_updaterate, "20", FCVAR_USERINFO|FCVAR_ARCHIVE, "refresh rate of server messages" );
CVAR_DEFINE_AUTO( cl_showevents, "0", FCVAR_ARCHIVE, "show events playback" ); CVAR_DEFINE_AUTO( cl_showevents, "0", FCVAR_ARCHIVE, "show events playback" );
@ -2926,6 +2927,7 @@ static void CL_InitLocal( void )
Cvar_RegisterVariable( &cl_fixtimerate ); Cvar_RegisterVariable( &cl_fixtimerate );
Cvar_RegisterVariable( &hud_fontscale ); Cvar_RegisterVariable( &hud_fontscale );
Cvar_RegisterVariable( &hud_scale ); Cvar_RegisterVariable( &hud_scale );
Cvar_RegisterVariable( &hud_scale_minimal_width );
Cvar_Get( "cl_background", "0", FCVAR_READ_ONLY, "indicate what background map is running" ); Cvar_Get( "cl_background", "0", FCVAR_READ_ONLY, "indicate what background map is running" );
Cvar_RegisterVariable( &cl_showevents ); Cvar_RegisterVariable( &cl_showevents );
Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" ); Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" );

1
engine/client/client.h

@ -683,6 +683,7 @@ extern convar_t cl_clockreset;
extern convar_t cl_fixtimerate; extern convar_t cl_fixtimerate;
extern convar_t hud_fontscale; extern convar_t hud_fontscale;
extern convar_t hud_scale; extern convar_t hud_scale;
extern convar_t hud_scale_minimal_width;
extern convar_t r_showtextures; extern convar_t r_showtextures;
extern convar_t cl_bmodelinterp; extern convar_t cl_bmodelinterp;
extern convar_t cl_lw; // local weapons extern convar_t cl_lw; // local weapons

Loading…
Cancel
Save