From c46dd9156d9fcddb7f5fee66275c4f3a8ad3c6df Mon Sep 17 00:00:00 2001 From: xwidghet Date: Fri, 23 Jun 2017 01:02:51 -0700 Subject: [PATCH] Stop spamming actor commands every frame for hiding and showing sync help. --- src/ScreenSyncOverlay.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/ScreenSyncOverlay.cpp b/src/ScreenSyncOverlay.cpp index c6167be63e..6fe6ea8545 100644 --- a/src/ScreenSyncOverlay.cpp +++ b/src/ScreenSyncOverlay.cpp @@ -11,6 +11,8 @@ #include "AdjustSync.h" #include "ActorUtil.h" +static bool previousGameplayState; + static bool IsGameplay() { return SCREENMAN && SCREENMAN->GetTopScreen() && SCREENMAN->GetTopScreen()->GetScreenType() == gameplay; @@ -21,19 +23,30 @@ REGISTER_SCREEN_CLASS( ScreenSyncOverlay ); void ScreenSyncOverlay::Init() { Screen::Init(); - m_overlay.Load(THEME->GetPathB(m_sName, "overlay")); AddChild(m_overlay); + + // When the screen is initialized we know it will not be gameplay + // but we want Update to start in the correct state to hide help. + previousGameplayState = true; Update( 0 ); } void ScreenSyncOverlay::Update( float fDeltaTime ) { - this->SetVisible( IsGameplay() ); - if( !IsGameplay() ) + bool isGameplay = IsGameplay(); + + this->SetVisible( isGameplay ); + + if( !isGameplay ) { - HideHelp(); + if ( previousGameplayState ) + { + previousGameplayState = isGameplay; + HideHelp(); + } + return; } @@ -125,7 +138,9 @@ static LocalizedString CANT_SYNC_WHILE_PLAYING_A_COURSE ("ScreenSyncOverlay","Ca static LocalizedString SYNC_CHANGES_REVERTED ("ScreenSyncOverlay","Sync changes reverted."); bool ScreenSyncOverlay::Input( const InputEventPlus &input ) { - if( !IsGameplay() ) + bool isGameplay = IsGameplay(); + + if( !isGameplay ) return Screen::Input(input); if( input.DeviceI.device != DEVICE_KEYBOARD ) @@ -283,7 +298,12 @@ bool ScreenSyncOverlay::Input( const InputEventPlus &input ) FAIL_M(ssprintf("Invalid sync action choice: %i", a)); } - ShowHelp(); + if ( !previousGameplayState ) + { + previousGameplayState = isGameplay; + ShowHelp(); + } + UpdateText(); return true; }