Skip to content

Commit

Permalink
Fix crosshairinfo hud_centerid horizontal positioning
Browse files Browse the repository at this point in the history
 * Fixes #252
  • Loading branch information
squeek502 committed May 15, 2016
1 parent 9e3d589 commit 1213b4d
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions cl_dll/ff/ff_hud_crosshairinfo.cpp
Expand Up @@ -585,23 +585,16 @@ void CHudCrosshairInfo::OnTick( void )
int iScreenWide, iScreenTall;
surface()->GetScreenSize( iScreenWide, iScreenTall );

// "map" screen res to 640/480
float iXScale = 640.0f / iScreenWide;
float iYScale = 480.0f / iScreenTall;

int iWide = UTIL_ComputeStringWidth( m_hTextFont, m_pText );
int iTall = surface()->GetFontTall( m_hTextFont );

// Adjust values to get below the crosshair and offset correctly
m_flXOffset = ( float )( iScreenWide / 2 ) - ( iWide / 2 );
m_flYOffset = ( float )( iScreenTall / 2 ) + ( iTall / 2 ) + 75; // 75 to get it below the crosshair and not right on it

// Scale by "map" scale values
m_flXOffset *= iXScale;
// proportionally scale the Y offset so that it is the same distance from the crosshair on any resolution
float iYScale = 480.0f / iScreenTall;
m_flYOffset *= iYScale;

// Scale to screen co-ords
m_flXOffset = scheme()->GetProportionalScaledValue( m_flXOffset );
m_flYOffset = scheme()->GetProportionalScaledValue( m_flYOffset );
}

Expand Down

0 comments on commit 1213b4d

Please sign in to comment.