2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-10 20:29:35 +01:00

client: add hud_allow_hd cvar that increases available HUD spritesheet resolutions up to 1280 and 2560

This commit is contained in:
Alibek Omarov 2023-12-21 04:11:52 +03:00 committed by Andrey Akhmichin
parent 58bc7ea53e
commit ea229edb2c
5 changed files with 26 additions and 14 deletions

View File

@ -75,10 +75,7 @@ void WeaponsResource::LoadWeaponSprites( WEAPON *pWeapon )
{
int i, iRes;
if( ScreenWidth < 640 )
iRes = 320;
else
iRes = 640;
iRes = GetSpriteRes( ScreenWidth, ScreenHeight );
char sz[256];

View File

@ -153,6 +153,27 @@ inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex(
#define Q_min(a, b) (((a) < (b)) ? (a) : (b))
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))
inline int GetSpriteRes( int width, int height )
{
int i;
if( width < 640 )
i = 320;
else if( width < 1280 || !gHUD.m_pAllowHD->value )
i = 640;
else
{
if( height <= 720 )
i = 640;
else if( width <= 2560 || height <= 1600 )
i = 1280;
else
i = 2560;
}
return i;
}
void ScaleColors( int &r, int &g, int &b, int a );
#define DotProduct(x, y) ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2])

View File

@ -379,6 +379,7 @@ void CHud::Init( void )
default_fov = CVAR_CREATE( "default_fov", "90", FCVAR_ARCHIVE );
m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE );
m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE );
m_pAllowHD = CVAR_CREATE ( "hud_allow_hd", "1", FCVAR_ARCHIVE );
cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" );
cl_viewbob = CVAR_CREATE( "cl_viewbob", "1", FCVAR_ARCHIVE );
@ -483,10 +484,7 @@ void CHud::VidInit( void )
m_hsprLogo = 0;
m_hsprCursor = 0;
if( ScreenWidth < 640 )
m_iRes = 320;
else
m_iRes = 640;
m_iRes = GetSpriteRes( ScreenWidth, ScreenHeight );
// Only load this once
if( !m_pSpriteList )

View File

@ -557,6 +557,7 @@ public:
int m_iRes;
cvar_t *m_pCvarStealMouse;
cvar_t *m_pCvarDraw;
cvar_t *m_pAllowHD;
int m_iFontHeight;
int DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b );

View File

@ -123,14 +123,9 @@ void VectorMA( const float *veca, float scale, const float *vecb, float *vecc )
HSPRITE LoadSprite( const char *pszName )
{
int i;
int i = GetSpriteRes( ScreenWidth, ScreenHeight );
char sz[256];
if( ScreenWidth < 640 )
i = 320;
else
i = 640;
sprintf( sz, pszName, i );
return SPR_Load( sz );