modify Input() on screens to return boolean

This commit is contained in:
Devin J. Pohly
2013-01-12 22:48:38 -05:00
parent 79583090ac
commit d13ac7e7a2
98 changed files with 861 additions and 697 deletions
+38 -29
View File
@@ -408,19 +408,19 @@ try_again:
return ChangeSelection( pn, dir, iSwitchToIndex );
}
void ScreenSelectMaster::MenuLeft( const InputEventPlus &input )
bool ScreenSelectMaster::MenuLeft( const InputEventPlus &input )
{
PlayerNumber pn = input.pn;
if( m_fLockInputSecs > 0 || m_bChosen[pn] )
return;
return false;
if( input.type == IET_RELEASE )
return;
return false;
if( input.type != IET_FIRST_PRESS )
{
if( !ALLOW_REPEATING_INPUT )
return;
return false;
if( m_TrackingRepeatingInput != input.MenuI )
return;
return false;
}
if( Move(pn, MenuDir_Left) )
{
@@ -434,22 +434,24 @@ void ScreenSelectMaster::MenuLeft( const InputEventPlus &input )
{
m_bDoubleChoice[pn] = false; // player has cancelled their selection
}
return true;
}
return false;
}
void ScreenSelectMaster::MenuRight( const InputEventPlus &input )
bool ScreenSelectMaster::MenuRight( const InputEventPlus &input )
{
PlayerNumber pn = input.pn;
if( m_fLockInputSecs > 0 || m_bChosen[pn] )
return;
return false;
if( input.type == IET_RELEASE )
return;
return false;
if( input.type != IET_FIRST_PRESS )
{
if( !ALLOW_REPEATING_INPUT )
return;
return false;
if( m_TrackingRepeatingInput != input.MenuI )
return;
return false;
}
if( Move(pn, MenuDir_Right) )
{
@@ -463,22 +465,24 @@ void ScreenSelectMaster::MenuRight( const InputEventPlus &input )
{
m_bDoubleChoice[pn] = false; // player has cancelled their selection
}
return true;
}
return false;
}
void ScreenSelectMaster::MenuUp( const InputEventPlus &input )
bool ScreenSelectMaster::MenuUp( const InputEventPlus &input )
{
PlayerNumber pn = input.pn;
if( m_fLockInputSecs > 0 || m_bChosen[pn] )
return;
return false;
if( input.type == IET_RELEASE )
return;
return false;
if( input.type != IET_FIRST_PRESS )
{
if( !ALLOW_REPEATING_INPUT )
return;
return false;
if( m_TrackingRepeatingInput != input.MenuI )
return;
return false;
}
if( Move(pn, MenuDir_Up) )
{
@@ -492,22 +496,24 @@ void ScreenSelectMaster::MenuUp( const InputEventPlus &input )
{
m_bDoubleChoice[pn] = false; // player has cancelled their selection
}
return true;
}
return false;
}
void ScreenSelectMaster::MenuDown( const InputEventPlus &input )
bool ScreenSelectMaster::MenuDown( const InputEventPlus &input )
{
PlayerNumber pn = input.pn;
if( m_fLockInputSecs > 0 || m_bChosen[pn] )
return;
return false;
if( input.type == IET_RELEASE )
return;
return false;
if( input.type != IET_FIRST_PRESS )
{
if( !ALLOW_REPEATING_INPUT )
return;
return false;
if( m_TrackingRepeatingInput != input.MenuI )
return;
return false;
}
if( Move(pn, MenuDir_Down) )
{
@@ -521,7 +527,9 @@ void ScreenSelectMaster::MenuDown( const InputEventPlus &input )
{
m_bDoubleChoice[pn] = false; // player has cancelled their selection
}
return true;
}
return false;
}
bool ScreenSelectMaster::ChangePage( int iNewChoice )
@@ -775,29 +783,29 @@ float ScreenSelectMaster::DoMenuStart( PlayerNumber pn )
return fSecs;
}
void ScreenSelectMaster::MenuStart( const InputEventPlus &input )
bool ScreenSelectMaster::MenuStart( const InputEventPlus &input )
{
if( input.type != IET_FIRST_PRESS )
return;
return false;
PlayerNumber pn = input.pn;
if( m_fLockInputSecs > 0 )
return;
return false;
if( SHARED_SELECTION || GetCurrentPage() == PAGE_2 )
{
// Return if any player has chosen
FOREACH_EnabledPlayer( p )
{
if( m_bChosen[p] )
return;
return false;
}
}
else if( m_bChosen[pn] )
// Return if this player has already chosen
return;
return false;
if( !ProcessMenuStart( pn ) )
return;
return false;
// double press is enabled and the player hasn't made their first press
if(DOUBLE_PRESS_TO_SELECT && !m_bDoubleChoice[pn])
@@ -811,7 +819,7 @@ void ScreenSelectMaster::MenuStart( const InputEventPlus &input )
vScroll[m_iChoice[pn]]->PlayCommand( "InitialSelection" );
}
return;
return true;
}
const GameCommand &mc = m_aGameCommands[m_iChoice[pn]];
@@ -819,7 +827,7 @@ void ScreenSelectMaster::MenuStart( const InputEventPlus &input )
/* If no options are playable, then we're just waiting for one to become available.
* If any options are playable, then the selection must be playable. */
if( !AnyOptionsArePlayable() )
return;
return false;
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(ssprintf("%s comment %s",m_sName.c_str(), mc.m_sName.c_str())) );
@@ -835,7 +843,7 @@ void ScreenSelectMaster::MenuStart( const InputEventPlus &input )
Message msg( MessageIDToString((MessageID)(Message_MenuStartP1+pn)) );
msg.SetParam( "ScreenEmpty", true );
MESSAGEMAN->Broadcast( msg );
return;
return true;
}
float fSecs = 0;
@@ -863,6 +871,7 @@ void ScreenSelectMaster::MenuStart( const InputEventPlus &input )
MESSAGEMAN->Broadcast( (MessageID)(Message_MenuStartP1+pn) );
this->PostScreenMessage( SM_BeginFadingOut, fSecs );// tell our owner it's time to move on
}
return true;
}
/* We want all items to always run OnCommand and either GainFocus or LoseFocus