Skip to content

Commit a25d3a1

Browse files
committed
perf: optimize HUD animation scoping
1 parent 1faae29 commit a25d3a1

File tree

11 files changed

+37
-30
lines changed

11 files changed

+37
-30
lines changed

src/game/client/game_controls/MapOverview.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ void CMapOverview::SetMode(int mode)
10191019
{
10201020
ShowPanel( false );
10211021

1022-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapOff" );
1022+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "MapOff", true, true );
10231023
}
10241024
else if ( mode == MAP_MODE_INSET )
10251025
{
@@ -1041,7 +1041,7 @@ void CMapOverview::SetMode(int mode)
10411041

10421042
if ( mode != m_nMode && RunHudAnimations() )
10431043
{
1044-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomToSmall" );
1044+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "MapZoomToSmall", true, true );
10451045
}
10461046
}
10471047
else if ( mode == MAP_MODE_FULL )
@@ -1061,7 +1061,7 @@ void CMapOverview::SetMode(int mode)
10611061

10621062
if ( mode != m_nMode && RunHudAnimations() )
10631063
{
1064-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomToLarge" );
1064+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "MapZoomToLarge", true, true );
10651065
}
10661066
}
10671067

src/game/client/hud_base_account.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void CHudBaseAccount::LevelInit( void )
2828
m_pszLastAnimationName = NULL;
2929
m_pszQueuedAnimationName = NULL;
3030

31-
GetAnimationController()->StartAnimationSequence("AccountMoneyInvisible");
31+
GetAnimationController()->StartAnimationSequence(this, "AccountMoneyInvisible", true, true);
3232
}
3333

3434
void CHudBaseAccount::ApplySchemeSettings(vgui::IScheme *pScheme)
@@ -91,14 +91,14 @@ void CHudBaseAccount::Paint()
9191
{
9292
m_pszLastAnimationName = "AccountMoneyAdded";
9393
}
94-
GetAnimationController()->StartAnimationSequence( m_pszLastAnimationName );
94+
GetAnimationController()->StartAnimationSequence( this, m_pszLastAnimationName, true, true );
9595
m_flLastAnimationEnd = gpGlobals->curtime + GetAnimationController()->GetAnimationSequenceLength( m_pszLastAnimationName );
9696

9797
m_iPreviousAccount = account;
9898
}
9999
else if ( m_pszQueuedAnimationName )
100100
{
101-
GetAnimationController()->StartAnimationSequence( m_pszQueuedAnimationName );
101+
GetAnimationController()->StartAnimationSequence( this, m_pszQueuedAnimationName, true, true );
102102
m_pszQueuedAnimationName = NULL;
103103
}
104104

src/game/client/menu.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ void CHudMenu::SelectMenuItem( int menu_item )
256256

257257
m_nSelectedItem = menu_item;
258258
// Pulse the selection
259-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuPulse");
259+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuPulse", true, true);
260260

261261
// remove the menu quickly
262262
m_bMenuTakesInput = false;
263263
m_flShutoffTime = gpGlobals->realtime + m_flOpenCloseTime;
264-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuClose");
264+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuClose", true, true);
265265
}
266266
}
267267

@@ -365,7 +365,7 @@ void CHudMenu::HideMenu( void )
365365
{
366366
m_bMenuTakesInput = false;
367367
m_flShutoffTime = gpGlobals->realtime + m_flOpenCloseTime;
368-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuClose");
368+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuClose", true, true);
369369
}
370370

371371
//-----------------------------------------------------------------------------
@@ -384,7 +384,7 @@ void CHudMenu::ShowMenu( const char * menuName, int validSlots )
384384

385385
Q_strncpy( g_szPrelocalisedMenuString, menuName, sizeof( g_szPrelocalisedMenuString ) );
386386

387-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
387+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuOpen", true, true);
388388
m_nSelectedItem = -1;
389389

390390
// we have the whole string, so we can localise it now
@@ -409,7 +409,7 @@ void CHudMenu::ShowMenu_KeyValueItems( KeyValues *pKV )
409409
m_fWaitingForMore = 0;
410410
m_bitsValidSlots = 0;
411411

412-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
412+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuOpen", true, true);
413413
m_nSelectedItem = -1;
414414

415415
g_szMenuString[0] = '\0';
@@ -489,7 +489,7 @@ void CHudMenu::MsgFunc_ShowMenu( bf_read &msg)
489489

490490
if ( !NeedMore )
491491
{
492-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
492+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence(this, "MenuOpen", true, true);
493493
m_nSelectedItem = -1;
494494

495495
// we have the whole string, so we can localise it now

src/game/client/tf/tf_hud_arena_vs_panel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void CHudArenaVsPanel::FireGameEvent( IGameEvent * event )
121121

122122
if ( m_bVisible )
123123
{
124-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "ArenaVsPanelOnShow" );
124+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "ArenaVsPanelOnShow", true, true );
125125

126126
m_flHideTime = gpGlobals->curtime + 10.0f;
127127

src/game/client/tf/tf_hud_flagstatus.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ void CTFHudFlagObjectives::ApplySchemeSettings( IScheme *pScheme )
507507
//-----------------------------------------------------------------------------
508508
void CTFHudFlagObjectives::Reset()
509509
{
510-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "FlagOutlineHide" );
510+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "FlagOutlineHide", true, true );
511511

512512
UpdateStatus();
513513
}
@@ -834,7 +834,7 @@ void CTFHudFlagObjectives::UpdateStatus( C_BasePlayer *pNewOwner /*= NULL*/, C_B
834834
if ( !m_bFlagAnimationPlayed )
835835
{
836836
m_bFlagAnimationPlayed = true;
837-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "FlagOutline" );
837+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "FlagOutline", true, true );
838838
}
839839

840840
if ( m_pCapturePoint && !m_pCapturePoint->IsVisible() )
@@ -864,7 +864,7 @@ void CTFHudFlagObjectives::UpdateStatus( C_BasePlayer *pNewOwner /*= NULL*/, C_B
864864
if ( m_bCarryingFlag )
865865
{
866866
m_bCarryingFlag = false;
867-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "FlagOutline" );
867+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "FlagOutline", true, true );
868868
}
869869

870870
m_bFlagAnimationPlayed = false;

src/game/client/tf/tf_hud_pve_winpanel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void CTFPVEWinPanel::OnTick()
167167
// Do this only once
168168
if ( bRespecVisible && !m_pRespecBackground->IsVisible() )
169169
{
170-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "RespecEarnedPulseLoss" );
170+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( m_pRespecContainerPanel, "RespecEarnedPulseLoss", true, true );
171171

172172
C_TFPlayer *pLocalTFPlayer = C_TFPlayer::GetLocalTFPlayer();
173173
if ( pLocalTFPlayer )

src/game/client/tf/tf_hud_robot_destruction_status.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "tf_logic_player_destruction.h"
1515
#include "c_tf_objective_resource.h"
1616
#include "c_func_capture_zone.h"
17+
#include "tf_hud_objectivestatus.h"
1718

1819
#define ATTACK_BLINK_TIME 2.f
1920

@@ -516,7 +517,8 @@ void CTFHUDRobotDestruction::PerformRobotLayout( RobotVector_t& vecRobots, int n
516517
//-----------------------------------------------------------------------------
517518
void CTFHUDRobotDestruction::Reset()
518519
{
519-
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "FlagOutlineHide" );
520+
CTFHudObjectiveStatus *pStatus = GET_HUDELEMENT( CTFHudObjectiveStatus );
521+
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( pStatus, "FlagOutlineHide" );
520522
}
521523

522524
//-----------------------------------------------------------------------------

src/game/shared/teamplay_round_timer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,13 @@ static void RecvProxy_TimerPaused( const CRecvProxyData *pData, void *pStruct, v
9797

9898
bool bTimerPaused = ( pData->m_Value.m_Int > 0 );
9999

100+
// UNDONE: Unused HUD animation
101+
#if 0
100102
if ( bTimerPaused == false )
101103
{
102104
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "TimerFlash" );
103105
}
106+
#endif
104107

105108
if ( pTimer )
106109
{

src/game/shared/tf/tf_gamemovement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void CTFGameMovement::ProcessMovement( CBasePlayer *pBasePlayer, CMoveData *pMov
314314
mv = pMove;
315315

316316
// The max speed is currently set to the scout - if this changes we need to change this!
317-
mv->m_flMaxSpeed = TF_MAX_SPEED;
317+
mv->m_flMaxSpeed = tf_movement_maxspeed.GetFloat();
318318

319319
// Handle charging demomens
320320
ChargeMove();

src/public/vgui_controls/AnimationController.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AnimationController : public Panel
5050

5151
// starts an animation sequence script
5252
bool StartAnimationSequence(const char *sequenceName, bool bCanBeCancelled = true );
53-
bool StartAnimationSequence(Panel *pWithinParent, const char *sequenceName, bool bCanBeCancelled = true );
53+
bool StartAnimationSequence(Panel *pWithinParent, const char *sequenceName, bool bCanBeCancelled = true, bool bIncludeParent = false );
5454

5555
bool StopAnimationSequence( Panel *pWithinParent, const char *sequenceName );
5656
void CancelAnimationsForPanel( Panel *pWithinParent );
@@ -241,14 +241,14 @@ class AnimationController : public Panel
241241
CUtlVector<UtlSymId_t> m_ScriptFileNames;
242242

243243
// runs a single line of the script
244-
void ExecAnimationCommand(UtlSymId_t seqName, AnimCommand_t &animCommand, Panel *pWithinParent, bool bCanBeCancelled);
244+
void ExecAnimationCommand(UtlSymId_t seqName, AnimCommand_t &animCommand, Panel *pWithinParent, bool bCanBeCancelled, bool bIncludeParent = false);
245245
// removes all commands belonging to a script
246246
void RemoveQueuedAnimationCommands(UtlSymId_t seqName, vgui::Panel *panel = NULL);
247247
// removes an existing instance of a command
248248
void RemoveQueuedAnimationByType(vgui::Panel *panel, UtlSymId_t variable, UtlSymId_t sequenceToIgnore);
249249

250250
// handlers
251-
void StartCmd_Animate(UtlSymId_t seqName, AnimCmdAnimate_t &cmd, Panel *pWithinParent, bool bCanBeCancelled);
251+
void StartCmd_Animate(UtlSymId_t seqName, AnimCmdAnimate_t &cmd, Panel *pWithinParent, bool bCanBeCancelled, bool bIncludeParent = false);
252252
void StartCmd_Animate(Panel *panel, UtlSymId_t seqName, AnimCmdAnimate_t &cmd, bool bCanBeCancelled);
253253
void RunCmd_RunEvent(PostedMessage_t &msg);
254254
void RunCmd_StopEvent(PostedMessage_t &msg);

0 commit comments

Comments
 (0)