diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index dd89495b..d8e0d10b 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -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]; diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 91615660..0adaa15d 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -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]) diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index f16e30b9..b4d199be 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -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", "0", FCVAR_ARCHIVE ); @@ -481,10 +482,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 ) diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 69c6646f..6bd3d9a3 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -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 ); diff --git a/cl_dll/util.cpp b/cl_dll/util.cpp index 7d6b6669..ff6aa2e0 100644 --- a/cl_dll/util.cpp +++ b/cl_dll/util.cpp @@ -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 );