From 2cf9262afcd21b60e2cc5467e4cfa7171bd81df7 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sat, 12 Jan 2013 23:19:44 -0500 Subject: [PATCH] merge OverlayInput into Input. overlay screens can still intercept input if they want. --- src/Screen.cpp | 17 +++-------------- src/Screen.h | 1 - src/ScreenDebugOverlay.cpp | 4 ++-- src/ScreenDebugOverlay.h | 2 +- src/ScreenInstallOverlay.cpp | 4 ++-- src/ScreenInstallOverlay.h | 2 +- src/ScreenManager.cpp | 8 +++----- src/ScreenSyncOverlay.cpp | 8 ++++---- src/ScreenSyncOverlay.h | 2 +- 9 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/Screen.cpp b/src/Screen.cpp index 4eb116f9aa..6e337f98cd 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -167,20 +167,9 @@ void Screen::Update( float fDeltaTime ) } } -/* ScreenManager sends input here if the screen is an overlay. Overlay screens - * can use it to get a first pass at input. Returns true if the input was - * handled and should not be passed to lower screens, or false if not handled. - * If true is returned, neither OverlayInput() nor Input() will not be called - * for any screen lower on the stack. Normal screens should not overload this - * function. */ -bool Screen::OverlayInput( const InputEventPlus &input ) -{ - // XXX Eventually merge this function with Input() once the necessary - // changes are made in ScreenManager. - return this->Input(input); -} - -/* Returns true if the input was handled, or false if not handled. */ +/* Returns true if the input was handled, or false if not handled. For + * overlays, this determines whether the event will be propagated to lower + * screens (i.e. it propagates from an overlay only when this returns false). */ bool Screen::Input( const InputEventPlus &input ) { Message msg(""); diff --git a/src/Screen.h b/src/Screen.h index cfe133b138..31e1939f2d 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -59,7 +59,6 @@ public: virtual void EndScreen(); virtual void Update( float fDeltaTime ); - virtual bool OverlayInput( const InputEventPlus &input ); virtual bool Input( const InputEventPlus &input ); virtual void HandleScreenMessage( const ScreenMessage SM ); void SetLockInputSecs( float f ) { m_fLockInputSecs = f; } diff --git a/src/ScreenDebugOverlay.cpp b/src/ScreenDebugOverlay.cpp index 485d6d1165..e3e26a8c15 100644 --- a/src/ScreenDebugOverlay.cpp +++ b/src/ScreenDebugOverlay.cpp @@ -418,7 +418,7 @@ static bool GetValueFromMap( const map &m, const U &key, V &val ) return true; } -bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input ) +bool ScreenDebugOverlay::Input( const InputEventPlus &input ) { if( input.DeviceI == g_Mappings.holdForDebug1 || input.DeviceI == g_Mappings.holdForDebug2 ) @@ -498,7 +498,7 @@ bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input ) } } - return Screen::OverlayInput(input); + return Screen::Input(input); } diff --git a/src/ScreenDebugOverlay.h b/src/ScreenDebugOverlay.h index 949ecf7a29..992f17b2a2 100644 --- a/src/ScreenDebugOverlay.h +++ b/src/ScreenDebugOverlay.h @@ -16,7 +16,7 @@ public: virtual ~ScreenDebugOverlay(); virtual void Init(); - bool OverlayInput( const InputEventPlus &input ); + bool Input( const InputEventPlus &input ); void Update( float fDeltaTime ); diff --git a/src/ScreenInstallOverlay.cpp b/src/ScreenInstallOverlay.cpp index 0bdac59ee7..191616bd03 100644 --- a/src/ScreenInstallOverlay.cpp +++ b/src/ScreenInstallOverlay.cpp @@ -316,7 +316,7 @@ void ScreenInstallOverlay::Init() this->AddChild( &m_textStatus ); } -bool ScreenInstallOverlay::OverlayInput( const InputEventPlus &input ) +bool ScreenInstallOverlay::Input( const InputEventPlus &input ) { /* if( input.DeviceI.button == g_buttonLogin && input.type == IET_FIRST_PRESS ) @@ -326,7 +326,7 @@ bool ScreenInstallOverlay::OverlayInput( const InputEventPlus &input ) } */ - return Screen::OverlayInput(input); + return Screen::Input(input); } void ScreenInstallOverlay::Update( float fDeltaTime ) diff --git a/src/ScreenInstallOverlay.h b/src/ScreenInstallOverlay.h index 97fcb9c364..fd380b33ac 100644 --- a/src/ScreenInstallOverlay.h +++ b/src/ScreenInstallOverlay.h @@ -13,7 +13,7 @@ public: virtual void Init(); void Update( float fDeltaTime ); - bool OverlayInput( const InputEventPlus &input ); + bool Input( const InputEventPlus &input ); private: void UpdateText(); diff --git a/src/ScreenManager.cpp b/src/ScreenManager.cpp index 2d63d33367..842a29b2f9 100644 --- a/src/ScreenManager.cpp +++ b/src/ScreenManager.cpp @@ -504,14 +504,12 @@ void ScreenManager::Input( const InputEventPlus &input ) // LOG->Trace( "ScreenManager::Input( %d-%d, %d-%d, %d-%d, %d-%d )", // DeviceI.device, DeviceI.button, GameI.controller, GameI.button, MenuI.player, MenuI.button, StyleI.player, StyleI.col ); - // First, give overlay screens a shot at the input. If OverlayInput returns - // true, it handled the input, so don't pass it further. OverlayInput could - // probably be merged with Input, but that would require changing all Input - // overloads, as well as all MenuLeft, etc. overloads. + // First, give overlay screens a shot at the input. If Input returns + // true, it handled the input, so don't pass it further. for( unsigned i = 0; i < g_OverlayScreens.size(); ++i ) { Screen *pScreen = g_OverlayScreens[i]; - if( pScreen->OverlayInput(input) ) + if( pScreen->Input(input) ) return; } diff --git a/src/ScreenSyncOverlay.cpp b/src/ScreenSyncOverlay.cpp index 263f01bd78..bd556266d0 100644 --- a/src/ScreenSyncOverlay.cpp +++ b/src/ScreenSyncOverlay.cpp @@ -152,13 +152,13 @@ void ScreenSyncOverlay::UpdateText() static LocalizedString CANT_SYNC_WHILE_PLAYING_A_COURSE ("ScreenSyncOverlay","Can't sync while playing a course."); static LocalizedString SYNC_CHANGES_REVERTED ("ScreenSyncOverlay","Sync changes reverted."); -bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input ) +bool ScreenSyncOverlay::Input( const InputEventPlus &input ) { if( !IsGameplay() ) - return Screen::OverlayInput(input); + return Screen::Input(input); if( input.DeviceI.device != DEVICE_KEYBOARD ) - return Screen::OverlayInput(input); + return Screen::Input(input); enum Action { @@ -186,7 +186,7 @@ bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input ) break; default: - return Screen::OverlayInput(input); + return Screen::Input(input); } if( GAMESTATE->IsCourseMode() && a != ChangeGlobalOffset ) diff --git a/src/ScreenSyncOverlay.h b/src/ScreenSyncOverlay.h index fd27321609..fb3b109b28 100644 --- a/src/ScreenSyncOverlay.h +++ b/src/ScreenSyncOverlay.h @@ -10,7 +10,7 @@ class ScreenSyncOverlay : public Screen public: virtual void Init(); - bool OverlayInput( const InputEventPlus &input ); + bool Input( const InputEventPlus &input ); void Update( float fDeltaTime );