allow overlay screens to accept codes

This commit is contained in:
Devin J. Pohly
2013-01-11 10:08:27 -05:00
parent 4a3e3370d8
commit f58584c939
4 changed files with 21 additions and 14 deletions
+14 -4
View File
@@ -167,12 +167,22 @@ void Screen::Update( float fDeltaTime )
} }
} }
/* ScreenManager sends input here first. Overlay screens can use it to get a first /* ScreenManager sends input here if the screen is an overlay. Overlay screens
* pass at input. Return true if the input was handled and should not be passed * can use it to get a first pass at input. Returns true if the input was
* to lower screens, or false if not handled. If true is returned, Input() will * handled and should not be passed to lower screens, or false if not handled.
* not be called, either. Normal screens should not overload this function. */ * 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 ) bool Screen::OverlayInput( const InputEventPlus &input )
{ {
// Allow overlays to respond to codes
Message msg("");
if( m_Codes.InputMessage(input, msg) )
{
this->HandleMessage( msg );
return true;
}
return false; return false;
} }
+1 -1
View File
@@ -498,7 +498,7 @@ bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input )
} }
} }
return false; return Screen::OverlayInput(input);
} }
+1 -1
View File
@@ -326,7 +326,7 @@ bool ScreenInstallOverlay::OverlayInput( const InputEventPlus &input )
} }
*/ */
return false; return Screen::OverlayInput(input);
} }
void ScreenInstallOverlay::Update( float fDeltaTime ) void ScreenInstallOverlay::Update( float fDeltaTime )
+5 -8
View File
@@ -155,10 +155,10 @@ static LocalizedString SYNC_CHANGES_REVERTED ("ScreenSyncOverlay","Sync changes
bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input ) bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input )
{ {
if( !IsGameplay() ) if( !IsGameplay() )
return false; return Screen::OverlayInput(input);
if( input.DeviceI.device != DEVICE_KEYBOARD ) if( input.DeviceI.device != DEVICE_KEYBOARD )
return false; return Screen::OverlayInput(input);
enum Action enum Action
{ {
@@ -186,7 +186,7 @@ bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input )
break; break;
default: default:
return false; return Screen::OverlayInput(input);
} }
if( GAMESTATE->IsCourseMode() && a != ChangeGlobalOffset ) if( GAMESTATE->IsCourseMode() && a != ChangeGlobalOffset )
@@ -198,11 +198,8 @@ bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input )
switch( a ) switch( a )
{ {
case RevertSyncChanges: case RevertSyncChanges:
switch( input.type ) if( input.type != IET_FIRST_PRESS )
{ return false;
case IET_FIRST_PRESS: break;
default: return false;
}
SCREENMAN->SystemMessage( SYNC_CHANGES_REVERTED ); SCREENMAN->SystemMessage( SYNC_CHANGES_REVERTED );
AdjustSync::RevertSyncChanges(); AdjustSync::RevertSyncChanges();
break; break;