Added screen height scaling for vgui_text_display

This commit is contained in:
Blixibon 2021-07-24 01:54:04 -05:00
parent 3656ea3082
commit 4ab87250b2
2 changed files with 34 additions and 2 deletions

View File

@ -112,6 +112,15 @@ public:
C_BasePlayer *GetPlayerOwner( void );
bool IsInputOnlyToOwner( void );
#ifdef MAPBASE
void GetSize( float &width, float &height ) const { width = m_flWidth; height = m_flHeight; }
void GetPixelSize( int &width, int &height ) const { width = m_nPixelWidth; height = m_nPixelHeight; }
void SetWidth( float flWidth ) { m_flWidth = flWidth; }
void SetHeight( float flHeight ) { m_flHeight = flHeight; }
void SetPixelWidth( int nWidth ) { m_nPixelWidth = nWidth; }
void SetPixelHeight( int nHeight ) { m_nPixelHeight = nHeight; }
#endif
private:
// Vgui screen management
void CreateVguiScreen( const char *pTypeName );

View File

@ -157,11 +157,34 @@ void C_TextDisplayPanel::UpdateText()
m_pDisplayTextLabel->SetText( m_hScreenEntity->GetDisplayText() );
//SetSize( m_hScreenEntity->GetTextSize(), m_hScreenEntity->GetTextSize() );
SetSize( m_hScreenEntity->GetResolution(), m_hScreenEntity->GetResolution() );
m_pDisplayTextLabel->SetSize( m_hScreenEntity->GetResolution(), m_hScreenEntity->GetResolution() );
//m_pDisplayTextLabel->SetSize( m_hScreenEntity->GetTextSize(), m_hScreenEntity->GetTextSize() );
Label::Alignment iAlignment = m_hScreenEntity->GetContentAlignment();
switch (iAlignment)
{
// Use a special scaling method when using a south alignment
case Label::Alignment::a_southwest:
case Label::Alignment::a_south:
case Label::Alignment::a_southeast:
int lW, lT;
m_pDisplayTextLabel->GetContentSize( lW, lT );
SetSize( m_hScreenEntity->GetResolution(), lT );
m_pDisplayTextLabel->SetSize( m_hScreenEntity->GetResolution(), lT );
float sW, sT;
m_hVGUIScreen->GetSize( sW, sT );
//Msg( "Screen width: %f, new height: %f\n", sW, sW * (lT / m_hScreenEntity->GetResolution()) );
m_hVGUIScreen->SetHeight( sW * ((float)lT / (float)m_hScreenEntity->GetResolution()) );
m_hVGUIScreen->SetPixelHeight( lT );
break;
default:
SetSize( m_hScreenEntity->GetResolution(), m_hScreenEntity->GetResolution() );
m_pDisplayTextLabel->SetSize( m_hScreenEntity->GetResolution(), m_hScreenEntity->GetResolution() );
break;
}
m_pDisplayTextLabel->SetContentAlignment( iAlignment );
bool bWrap = true;