@@ -120,6 +120,7 @@ class CHudCommentary : public CHudElement, public vgui::Panel
120120
121121 // HACKHACK: Needed as a failsafe to prevent desync
122122 int m_iCCDefaultY;
123+ float m_flCCAnimTime;
123124
124125 bool m_bShouldRepositionSubtitles;
125126#endif
@@ -910,6 +911,7 @@ CHudCommentary::CHudCommentary( const char *name ) : vgui::Panel( NULL, "HudComm
910911 m_pFootnoteLabel = new vgui::Label ( this , " HudCommentaryFootnoteLabel" , L" Commentary footnote" );
911912
912913 m_iCCDefaultY = 0 ;
914+ m_flCCAnimTime = 0 .0f ;
913915#endif
914916}
915917
@@ -1415,6 +1417,9 @@ void CHudCommentary::StartCommentary( C_PointCommentaryNode *pNode, char *pszSpe
14151417 {
14161418 m_bShouldPaint = true ;
14171419 m_bShouldRepositionSubtitles = true ;
1420+
1421+ // Ensure we perform layout later
1422+ InvalidateLayout ();
14181423 }
14191424 else
14201425 m_bShouldRepositionSubtitles = false ;
@@ -1634,6 +1639,9 @@ void CHudCommentary::StartSceneCommentary( C_PointCommentaryNode *pNode, char *p
16341639 {
16351640 m_bShouldPaint = true ;
16361641 m_bShouldRepositionSubtitles = true ;
1642+
1643+ // Ensure we perform layout later
1644+ InvalidateLayout ();
16371645 }
16381646 else
16391647 m_bShouldRepositionSubtitles = false ;
@@ -1781,9 +1789,17 @@ void CHudCommentary::RepositionAndFollowCloseCaption( int yOffset )
17811789 // Run this animation command instead of setting the position directly
17821790 g_pClientMode->GetViewportAnimationController ()->RunAnimationCommand ( pHudCloseCaption, " YPos" , ccY - yOffset, 0 .0f , 0 .2f , vgui::AnimationController::INTERPOLATOR_DEACCEL );
17831791 // pHudCloseCaption->SetPos( ccX, ccY );
1792+ m_flCCAnimTime = gpGlobals->curtime + 0 .2f ;
17841793
17851794 pHudCloseCaption->SetUsingCommentaryDimensions ( true );
17861795 }
1796+ else if (gpGlobals->curtime > m_flCCAnimTime && ccY != m_iCCDefaultY - m_iTypeAudioT - yOffset)
1797+ {
1798+ DevMsg ( " CHudCommentary had to correct misaligned CC element offset (%i != %i)\n " , m_iCCDefaultY - ccY, yOffset );
1799+
1800+ g_pClientMode->GetViewportAnimationController ()->RunAnimationCommand ( pHudCloseCaption, " YPos" , m_iCCDefaultY - m_iTypeAudioT - yOffset, 0 .0f , 0 .2f , vgui::AnimationController::INTERPOLATOR_DEACCEL );
1801+ m_flCCAnimTime = gpGlobals->curtime + 0 .2f ;
1802+ }
17871803
17881804 SetPos ( ccX, ccY + pHudCloseCaption->GetTall () + commentary_audio_element_below_cc_margin.GetInt () );
17891805
0 commit comments