Skip to content

Commit c46dd91

Browse files
committed
Stop spamming actor commands every frame for hiding and showing sync help.
1 parent e97ab8b commit c46dd91

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/ScreenSyncOverlay.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "AdjustSync.h"
1212
#include "ActorUtil.h"
1313

14+
static bool previousGameplayState;
15+
1416
static bool IsGameplay()
1517
{
1618
return SCREENMAN && SCREENMAN->GetTopScreen() && SCREENMAN->GetTopScreen()->GetScreenType() == gameplay;
@@ -21,19 +23,30 @@ REGISTER_SCREEN_CLASS( ScreenSyncOverlay );
2123
void ScreenSyncOverlay::Init()
2224
{
2325
Screen::Init();
24-
2526
m_overlay.Load(THEME->GetPathB(m_sName, "overlay"));
2627
AddChild(m_overlay);
28+
29+
// When the screen is initialized we know it will not be gameplay
30+
// but we want Update to start in the correct state to hide help.
31+
previousGameplayState = true;
2732

2833
Update( 0 );
2934
}
3035

3136
void ScreenSyncOverlay::Update( float fDeltaTime )
3237
{
33-
this->SetVisible( IsGameplay() );
34-
if( !IsGameplay() )
38+
bool isGameplay = IsGameplay();
39+
40+
this->SetVisible( isGameplay );
41+
42+
if( !isGameplay )
3543
{
36-
HideHelp();
44+
if ( previousGameplayState )
45+
{
46+
previousGameplayState = isGameplay;
47+
HideHelp();
48+
}
49+
3750
return;
3851
}
3952

@@ -125,7 +138,9 @@ static LocalizedString CANT_SYNC_WHILE_PLAYING_A_COURSE ("ScreenSyncOverlay","Ca
125138
static LocalizedString SYNC_CHANGES_REVERTED ("ScreenSyncOverlay","Sync changes reverted.");
126139
bool ScreenSyncOverlay::Input( const InputEventPlus &input )
127140
{
128-
if( !IsGameplay() )
141+
bool isGameplay = IsGameplay();
142+
143+
if( !isGameplay )
129144
return Screen::Input(input);
130145

131146
if( input.DeviceI.device != DEVICE_KEYBOARD )
@@ -283,7 +298,12 @@ bool ScreenSyncOverlay::Input( const InputEventPlus &input )
283298
FAIL_M(ssprintf("Invalid sync action choice: %i", a));
284299
}
285300

286-
ShowHelp();
301+
if ( !previousGameplayState )
302+
{
303+
previousGameplayState = isGameplay;
304+
ShowHelp();
305+
}
306+
287307
UpdateText();
288308
return true;
289309
}

0 commit comments

Comments
 (0)