client: hud: detect the availability of HD spritesheets

This commit is contained in:
Alibek Omarov 2023-12-21 04:15:56 +03:00 committed by Andrey Akhmichin
parent ea229edb2c
commit 5a315a05ea
3 changed files with 18 additions and 2 deletions

View File

@ -171,7 +171,7 @@ inline int GetSpriteRes( int width, int height )
i = 2560; i = 2560;
} }
return i; return Q_min( i, gHUD.m_iMaxRes );
} }
void ScaleColors( int &r, int &g, int &b, int a ); void ScaleColors( int &r, int &g, int &b, int a );

View File

@ -484,13 +484,28 @@ void CHud::VidInit( void )
m_hsprLogo = 0; m_hsprLogo = 0;
m_hsprCursor = 0; m_hsprCursor = 0;
// a1ba: don't break the loading order here and
// don't cause memory leak but check
// maximum HUD sprite resolution we have
m_iMaxRes = 640;
client_sprite_t *pSpriteList = m_pSpriteList ? m_pSpriteList :
SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes );
if( pSpriteList )
{
for( int i = 0; i < m_iSpriteCountAllRes; i++ )
{
if( m_iMaxRes < pSpriteList[i].iRes )
m_iMaxRes = pSpriteList[i].iRes;
}
}
m_iRes = GetSpriteRes( ScreenWidth, ScreenHeight ); m_iRes = GetSpriteRes( ScreenWidth, ScreenHeight );
// Only load this once // Only load this once
if( !m_pSpriteList ) if( !m_pSpriteList )
{ {
// we need to load the hud.txt, and all sprites within // we need to load the hud.txt, and all sprites within
m_pSpriteList = SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes ); m_pSpriteList = pSpriteList;
if( m_pSpriteList ) if( m_pSpriteList )
{ {

View File

@ -555,6 +555,7 @@ public:
int m_iFOV; int m_iFOV;
int m_Teamplay; int m_Teamplay;
int m_iRes; int m_iRes;
int m_iMaxRes;
cvar_t *m_pCvarStealMouse; cvar_t *m_pCvarStealMouse;
cvar_t *m_pCvarDraw; cvar_t *m_pCvarDraw;
cvar_t *m_pAllowHD; cvar_t *m_pAllowHD;